From donn at u.washington.edu Tue Jul 31 14:59:05 2001 From: donn at u.washington.edu (Donn Cave) Date: 31 Jul 2001 18:59:05 GMT Subject: Long: Python Is Really Middleware References: <3B667EBA.DA6C298@tundraware.com> <3B66F611.B12948A6@tundraware.com> Message-ID: <9k6v5p$8g6$1@nntp6.u.washington.edu> Quoth Tim Daneliuk : | Tim Daneliuk wrote: | > | > *** Python Is Really "Middleware" *** | > Tim Daneliuk | > Copyright (c) 2001, TundraWare Inc. | > | | Now cleaned up, edited a bit, and on the web: | | http://www.tundraware.com/Technology/Python-Is-Middleware/Python-Is-Middleware.html Great! This is good reading, glad it's not going to just drift past in the 100+ messages per day of comp.lang.python. And I hope some other pages of general Python interest will link to it. So allow me to suggest a URL that worked better for me: http://www.tundraware.com/Technology/Python-Is-Middleware/ Donn Cave, donn at u.washington.edu From jkraska1 at san.rr.com Thu Jul 5 21:00:13 2001 From: jkraska1 at san.rr.com (Courageous) Date: Fri, 06 Jul 2001 01:00:13 GMT Subject: Exporting a Class from a .pyd References: <3b4474a8.4155281@news.t-online.de> Message-ID: On Thu, 05 Jul 2001 14:12:06 GMT, gerson.kurz at t-online.de (Gerson Kurz) wrote: >It is quite easy to export methods, and constants, and even datatypes >from a .pyd (Python Extension DLL, .so in #?nix). However, how do you >export a class ? Is it just a special way of exporting datatypes ? >(But then, I cannot yet see how to add methods to such a datatype). >I've looked up google but in vain. In Unix .so shared libraries, exporting happens automatically. In Windows DLLs, you do it explicitly, like this: class __declspecl(dllexport) [classname] { ... }; This also automatically exports all class methods. Note, however, that static class data isn't properly exported. C// From llothar at mailandnews.de Mon Jul 16 09:56:30 2001 From: llothar at mailandnews.de (Lothar Scholz) Date: Mon, 16 Jul 2001 15:56:30 +0200 Subject: Python, C++, Java, Smalltalk, Eiffel,... References: <9is8rm$46d$1@panix3.panix.com> Message-ID: <4as5lt82h2oc47fl72mkb8i21ppf6lboop@4ax.com> > >The problem is that there isn't one "better", just "better in the eyes of >the author", I believe that this not really true, for example you must accept that Common Lisp is much more powerful than any other language. The problem is that most people are not very open minded - mostly because there intellectual skills are to low to capture more. Sorry this seems to be arogant - but its the truth. From stadt at cs.utwente.nl Mon Jul 30 11:45:34 2001 From: stadt at cs.utwente.nl (Richard van de Stadt) Date: Mon, 30 Jul 2001 17:45:34 +0200 Subject: Timezone References: <3B64B098.2146ECEB@cs.utwente.nl> <3B64B1B7.A4EB7CB8@tundraware.com> Message-ID: <3B65811E.B22A6E71@cs.utwente.nl> Tim Daneliuk wrote: > > Richard van de Stadt wrote: > > > > I run stuff on systems in various timezones. > > I need to display when certain files have been updated. > > ctime (time()) shows the current date and time, but without the timezone > > that you get to see e.g. by Unix' date command. > > > > Is there a (Python) way to find out the timezone? > > > > Richard. > > import time > > time.tzname > > ...will return a tuple containing the strings which name the timezone [...] Thanks for the hint. That's a start. Now, what else does time have? (toggle, toggle. Hey, there's no time.py!?) >>> dir(time) ['__doc__', '__file__', '__name__', 'accept2dyear', 'altzone', 'asctime', 'clock', 'ctime', 'daylight', 'gmtime', 'localtime', 'mktime', 'sleep', 'strftime', 'strptime', 'time', 'timezone', 'tzname'] >>> time.daylight 1 There we are: Now, assuming that the value of daylight will become 0 when daylight saving time is over, this is what I needed: time.tzname[time.daylight] Richard. From sholden at holdenweb.com Mon Jul 9 17:57:45 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 9 Jul 2001 17:57:45 -0400 Subject: File processing References: <9id5p9$8r62@interserv.etn.com> Message-ID: <%Kp27.367$vA6.73337@e420r-atl1.usenetserver.com> "Chris McMillan" wrote in message news:9id5p9$8r62 at interserv.etn.com... > Hello all! > > I'm trying to write a script that will open a file, delete the first line, > and then save the file with the same name. Can someone please point me in > the right direction? Thanks! > > Why am I doing this you may ask: I have tens of data files that I need to > strip the first line before I can process it in Matlab. So, I dream of a > script that opens every file in a directory, deletes the first line, ..... > Unfortunately "delete the first line" isn't a canonical file operation, so you have to read the whole input file in and copy everything but the first line. Something like this ought to do it, though I haven't tested it: def trimline1(oldfile, newfile): inf = open(oldfile, "r") junk = inf.readline() open(outf, "w").write(inf.read()) inf.close() That last line is just an abbreviated way to say "open the output file, read the remainder of the input file, and write what was just read to the output". Because no reference is saved to the output file, it should be closed automatically. Absolute caution might recommend (if you want the close to be explicit): def trimline1(oldfile, newfile): inf = open(oldfile, "r") junk = inf.readline() outf = open(outf, "w") outf.write(inf.read()) inf.close() outf.close() but it isn't as snappy. Because exiting the function also destroys the reference to the input file you could probably also omitthe close() on that, but why bother if you're just going to copy'n'paste? Of course, that still leaves you with the problem of calling this function tens of times. Take a look at the glob module for that. regards Steve -- http://www.holdenweb.com/ From s.ostring at ccsr.cam.ac.uk Mon Jul 16 07:28:52 2001 From: s.ostring at ccsr.cam.ac.uk (Sven =?iso-8859-1?Q?=D6string?=) Date: Mon, 16 Jul 2001 12:28:52 +0100 Subject: Structuring packages Message-ID: <3B52CFF4.84AFD40D@ccsr.cam.ac.uk> The documentation at www.python.org expressed the structure of a package as a hierarchical filesystem, with subpackages being labelled as filenames. However, there is more to this structure than is described - how is a package in Python actually structured, in terms of storing subpackages and linking subpackages into the main package? Sven. From pih at oek.dk Tue Jul 17 12:56:02 2001 From: pih at oek.dk (Peter I. Hansen) Date: Tue, 17 Jul 2001 18:56:02 +0200 Subject: Python, C++, Java, Smalltalk, Eiffel,... References: <9is8rm$46d$1@panix3.panix.com> Message-ID: <3B546E22.9DC5B7C6@oek.dk> kj0 wrote: > Where can I find a reasonably non-partisan but also reasonably > detailed comparison of the more popular OO languages (C++, Java, > Python, etc.). (All the comparisons I've found are clearly slanted to > demonstrate the superiority of the authors' favorite OO language--I'm > sure it would be easy to find one written by unapologetic Python > advocates :-) ) > > I'm not looking to find out which of these languages is "better"; I > don't care for ranking here. What I want to know is how the various > popular OO languages compare in terms of OO and general programming > features (e.g. multiple inheritance; classes-as-objects; garbage > collection; closures; scoping; contracts; debugging; etc.). > > Thanks, > > KJ I found this comparison of a simple algorithm interresting. This because you can read the code in each language and see if you like it. http://www.bagley.org/~doug/shootout/bench/sieve/ /Peter From ljohnson at resgen.com Thu Jul 19 14:28:13 2001 From: ljohnson at resgen.com (Lyle Johnson) Date: Thu, 19 Jul 2001 13:28:13 -0500 Subject: Guido van Rossum is secretly Rick Moranis References: Message-ID: > I can prove that Guido van Rossum is secretly Rick Moranis. Take off, you hoser ;) From rharkins at thinkronize.com Fri Jul 27 15:57:28 2001 From: rharkins at thinkronize.com (Rich Harkins) Date: Fri, 27 Jul 2001 15:57:28 -0400 Subject: scoping problems In-Reply-To: Message-ID: Try this: class baseclass(): def __init__(self): self.__myfunc__() class a(baseclass): pass class b(baseclass): pass a.__myfunc__=b b.__myfunc__=a __myfunc__ in a and b will reference class instances, not functions, but who am I to quibble? :) Rich > -----Original Message----- > From: python-list-admin at python.org > [mailto:python-list-admin at python.org]On Behalf Of Narayan Desai > Sent: Friday, July 27, 2001 3:31 PM > To: python-list at python.org > Subject: Re: scoping problems > > > I made a mistake when I was describing the problem. Here is the real > problem; I had mis-formulated the minimal subset needed to cause this > behavior. The real subset is: > > class baseclass(): > def __init__(self): > self.__myfunc__() > > class a(baseclass): > __myfunc__=b > > class b(baseclass): > __myfunc__=a > > Does anyone know how to get this to work? > -nld > > >>>>> "Me" == Narayan Desai writes: > > Me> How can i define the following code: def a(): > Me> b() > > Me> def b(): > Me> a() > > Me> (ignoring for a moment that this would never terminate) How do you > Me> get the namespaces right? > > Me> I would solve this with function prototypes in C, but it isn't > Me> clear to me how to do this in python. thanks... > Me> -nld > -- > http://mail.python.org/mailman/listinfo/python-list > From skip at pobox.com Thu Jul 12 11:57:34 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 12 Jul 2001 10:57:34 -0500 Subject: Language change and code breaks In-Reply-To: References: Message-ID: <15181.51438.535862.108778@beluga.mojam.com> Tom> I *always* forget the 1/3 == 0 thing between programming bursts. Tom> OTOH, I also quickly remember after making the mistake the first Tom> time. What is it that reminds you of the mistake? Is it something glaring like using the result of 1/3 as a divisor and getting a divide-by-zero error, or is it something more subtle like getting slightly incorrect results and having to dig through your code to find the problem? -- Skip Montanaro (skip at pobox.com) (847)971-7098 From jparlar at home.com Mon Jul 23 16:04:41 2001 From: jparlar at home.com (Jay Parlar) Date: Mon, 23 Jul 2001 20:04:41 GMT Subject: py2exe problem References: ( <1103_995913046@jparlar> <9jhs4l$nrf61$1@ID-59885.news.dfncis.de> Message-ID: <1104_995918522@jparlar> > > The problem is, if you don't give the -w switch, > you will get the runtime error as well, but you probably cannot see it. > > > > > Traceback : > [Somehow the rest of the message didn't make it to c.l.p, > but arrived in private mail] > > . > > . > > . > > File "win32com\server\register.pyc", line 105 in _find_localserver_exe > > "Runtime Error: Can not locate the program 'pythonw.exe' " > > > It seems you use the standard UseCommandline() function > from win32com.server in your script. This will not work > directly - as Duncan also has pointed out, I've posted > a working example. Here's the same article under > another URL: http://aspn.activestate.com/ASPN/Mail/Message/543305. Well, I'm not useing UseCommandline() anywhere, but I was able to remove the Runtime error with help from that example. Now the .exe works on the target machine when I'm simply trying to register the COM server, but when I try run it in the GUI mode, I get a CoInitialize error. Just another thing to try to figure out, I guess. > > > > > > > As Duncan Booth already suggested in his reply, it is generally > > > a good idea to start by building a commnd line version even if > > > you eventually will only be using a gui - you may not see > > > tracebacks or error messages otherwise. > > > > > Hehe, well, I can see that traceback now. Any suggestions? py2exe won't let me have both the -c and -w options at the same time. > > You don't need them at the same time: You can run a GUI in the console > subsystem, but here you will always _have a console_ (sometimes called > the 'annyoing dos window'. > Thanks for all the help so far, I wouldn't have been able to get it to even where it is now without your suggestions. Jay Parlar ---------------------------------------------------------------- Software Engineering III McMaster University Hamilton, Ontario, Canada "Though there are many paths At the foot of the mountain All those who reach the top See the same moon." From speedy911 at mindspring.com Thu Jul 12 16:22:26 2001 From: speedy911 at mindspring.com (Charles Harrison) Date: 12 Jul 2001 13:22:26 -0700 Subject: can anyone help me with yapsnmp? Message-ID: <6f78b8b.0107121222.2cd3121@posting.google.com> I am very interested in implementing the module yapsnmp in some of my programs that use snmp commands, but I cant get it to install and dont really know enough C to pull apart the place in net-snmp where the installer is failing. I was wondering if anyone else has had trouble with the installation of this module or has any other insight as to how I might be able to get this module to run on my system. I think it should work; I have the latest version of net-snmp. Heres the transcript from my install attempt: [root at icispare1 yapsnmp-0.7]# ./configure creating cache ./config.cache checking for a BSD compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking whether make sets ${MAKE}... yes checking for working aclocal... found checking for working autoconf... found checking for working automake... found checking for working autoheader... found checking for working makeinfo... found checking host system type... i686-pc-linux-gnu checking build system type... i686-pc-linux-gnu checking for ranlib... ranlib checking for gcc... gcc checking whether the C compiler (gcc ) works... yes checking whether the C compiler (gcc ) is a cross-compiler... no checking whether we are using GNU C... yes checking whether gcc accepts -g... yes checking for ld used by GCC... /usr/bin/ld checking if the linker (/usr/bin/ld) is GNU ld... yes checking for BSD-compatible nm... /usr/bin/nm -B checking whether ln -s works... yes updating cache ./config.cache checking for object suffix... o checking for executable suffix... no checking for gcc option to produce PIC... -fPIC checking if gcc PIC flag -fPIC works... yes checking if gcc supports -c -o file.o... yes checking if gcc supports -c -o file.lo... yes checking if gcc supports -fno-rtti -fno-exceptions ... yes checking if gcc static flag -static works... -static checking if the linker (/usr/bin/ld) is GNU ld... yes checking whether the linker (/usr/bin/ld) supports shared libraries... yes checking command to parse /usr/bin/nm -B output... ok checking how to hardcode library paths into programs... immediate checking for /usr/bin/ld option to reload object files... -r checking dynamic linker characteristics... Linux ld.so checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... no checking for objdir... .libs creating libtool loading cache ./config.cache checking for gcc... (cached) gcc checking whether the C compiler (gcc -g -O2 ) works... yes checking whether the C compiler (gcc -g -O2 ) is a cross-compiler... no checking whether we are using GNU C... (cached) yes checking whether gcc accepts -g... (cached) yes checking for swig... swig checking for patch... patch checking for kstat_open in -lkstat... no checking for init_snmp in -lsnmp... yes checking how to run the C preprocessor... gcc -E checking for ANSI C header files... yes checking for ucd-snmp/ucd-snmp-config.h... yes checking for ucd-snmp/ucd-snmp-includes.h... yes checking for ucd-snmp/transform_oids.h... yes checking for ucd-snmp/asn1.h... yes checking for ucd-snmp/snmp_api.h... yes checking for ucd-snmp/snmp.h... yes checking for ucd-snmp/snmp_client.h... yes checking for ucd-snmp/mib.h... yes checking for ucd-snmp/default_store.h... yes checking for /usr/include/ucd-snmp... yes checking for python1.5/Python.h... yes checking for /usr/lib/python1.5/site-packages... yes checking for working const... yes checking for size_t... yes checking whether time.h and sys/time.h may both be included... yes updating cache ./config.cache creating ./config.status creating Makefile creating src/Makefile creating doc/Makefile creating config/Makefile creating config.h [root at icispare1 yapsnmp-0.7]# make make all-recursive make[1]: Entering directory `/home/charrison/yapsnmp-0.7' Making all in src make[2]: Entering directory `/home/charrison/yapsnmp-0.7/src' cp /usr/include/ucd-snmp/snmp_api.h . patch < snmp_api.h-patch patching file snmp_api.h cp /usr/include/ucd-snmp/snmp_client.h . patch < snmp_client.h-patch patching file snmp_client.h cp /usr/include/ucd-snmp/mib.h . patch < mib.h-patch patching file mib.h swig -python -shadow -I/usr/include/ucd-snmp net-snmp.i Generating wrappers for Python snmp_api.h : Line 95. Warning. Array member will be read-only. snmp_api.h : Line 97. Warning. Array member will be read-only. snmp_api.h : Line 186. Function pointers not currently supported (ignored). snmp_api.h : Line 216. Warning. Array member will be read-only. snmp_api.h : Line 220. Warning. Array member will be read-only. snmp_api.h : Line 276. Constant SNMP_MAX_SEC_NAME_SIZE multiply defined. (2nd definition ignored) snmp_api.h : Line 396. Warning. Array member will be read-only. snmp_api.h : Line 397. Warning. Array member will be read-only. net-snmp.i : Line 56. Warning. Array member will be read-only. /bin/sh ../libtool --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/include/python1.5 -I/usr/local/include/python1.5 -g -O2 -c net-snmp_wrap.c gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/include/python1.5 -I/usr/local/include/python1.5 -g -O2 -c net-snmp_wrap.c -fPIC -DPIC -o net-snmp_wrap.lo net-snmp_wrap.c: In function `_wrap_snmpv3_parse': net-snmp_wrap.c:1967: too few arguments to function `snmpv3_parse' net-snmp_wrap.c: In function `_wrap_print_description': net-snmp_wrap.c:3637: too few arguments to function `print_description' net-snmp_wrap.c: In function `_wrap_fprint_description': net-snmp_wrap.c:3666: too few arguments to function `fprint_description' make[2]: *** [net-snmp_wrap.lo] Error 1 make[2]: Leaving directory `/home/charrison/yapsnmp-0.7/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/charrison/yapsnmp-0.7' make: *** [all-recursive-am] Error 2 If you've gotten this far thank you so much in advance for all of your time. -Charles From eppstein at ics.uci.edu Mon Jul 23 03:45:13 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Mon, 23 Jul 2001 00:45:13 -0700 Subject: A use for integer quotients References: Message-ID: In article , "Tim Peters" wrote: > > I don't suppose it would be possible to go through some repository of > > Python sources and figure out the relative numbers of divisions > > of integer arguments that end up an int versus the ones that are > > coerced to floats? > > Guido did this for the Python library, and found three instances of "/" that > would break. > > > In my own code it's 100% int/int->int > > Mine too -- but only in my integer code . Curiously, I find I > *usually* use divmod() even then, because I usually need the remainder too. Ok, you convinced me to look more carefully at all the divisions in my recent small project, a program to generate web pages from collections of JPEGs. I found: 3 instances of simplifying numbers prior to output (e.g. I want file size in kbytes rather than bytes). 1 instance of a magic formula to convert focal length to 35mm equivalents. You might argue that floating point is more appropriate here, but I want to see integers in the output and the formula was tested by comparing against the camera manufacturer's software which only displays integer output. 6 instances of determining transformed image sizes: newX = (oldX * targetSize)/max(oldX,oldY) etc. I don't know whether PIL allows image.resize() to take float arguments, whether it throws an exception, or whether it just does something bogus. I'd hope for an exception, float doesn't make much sense in that context. ...and lots of slashes in HTML tags inside strings making it harder to find the actual division operators. Does my short program really have three times as many integer divisions as the whole Python library? Not even counting the divisions I'm sure are lurking in PIL? Also note that in none of those instances do I care about remainders nor want to uglify my formulas by divmod(a,b)[0]. The magic formula is the one that's least likely to make sense a couple years later when this issue starts to bite. And, I won't actually see any warnings because the console window is disabled in my compiled applet due to a bad interaction with W that causes programs that don't disable the console to become immortal. So, anyone who I might have passed the program on to will one day suddenly see ugly floats in their generated web pages, if the program still works at all, and won't have any clue why or how to fix it. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From wfeinbein at gmx.at Tue Jul 3 04:51:08 2001 From: wfeinbein at gmx.at (wilhelm feinbein) Date: 3 Jul 2001 01:51:08 -0700 Subject: Vienna Python Interest Group References: <3b1cb5dd@e-post.inode.at> Message-ID: Find ich eine gute Idee! Hans --- www.fiby.at From rob at jam.rr.com Wed Jul 18 10:22:52 2001 From: rob at jam.rr.com (Rob Andrews) Date: Wed, 18 Jul 2001 14:22:52 GMT Subject: Python 2 times slower than Perl References: <8f41cfd.0107171238.6ff33b9b@posting.google.com> <9j3rvk$26bt$1@norfair.nerim.net> Message-ID: <3B559B30.61A90EA@jam.rr.com> Gilles Lenfant wrote: > > Seriously, compare 2 languages with really useful features (Genrate PDF > report, extract XML data...). > You can find useless stuffs that run much faster in Python than in Perl. > I'd love to see some comparisons in which people who are good at their respective languages are given the same task considered reasonably programmable in each of the given languages. See which programmer gets a working *proof of concept* program actually working in the least development time. The we could post *Why are Perl, Java, and C all so much slower than Python?* Rob Newbies Rock! Useless Python http://www.lowerstandard.com/python/ From lisowski.tomasz at sssa.NOSPAM.com.pl Thu Jul 12 05:09:57 2001 From: lisowski.tomasz at sssa.NOSPAM.com.pl (Tomasz Lisowski) Date: Thu, 12 Jul 2001 11:09:57 +0200 Subject: Q: Duplicating Objects ... HOW ??? References: <9ia0ru$80k$1@sun.rhrk.uni-kl.de> Message-ID: <9ijpbk$g9m$1@news.tpi.pl> U?ytkownik "Alex" napisa? w wiadomo?ci news:etd7kxjcp8x.fsf at pickled-herring.mit.edu... > > You may be happier in the long run keeping the sequence of test objects > in a sequence, like a list. You could do something like this: > > import copy > test_list = [copy.copy(obj) for obj in 20*[test]] > Sometimes deepcopy() should be used :-) Tomasz Lisowski From raj2569 at yahoo.com Sun Jul 15 15:32:12 2001 From: raj2569 at yahoo.com (Rajkumar S.) Date: Mon, 16 Jul 2001 01:02:12 +0530 (IST) Subject: connect in SMTPlib Message-ID: Hi all, I am writing cgi program to send a mail of all the selection made by the user to admin. The from addr and to addr are fixed in the script. One of the probable error that I see is that of the SMTP server being down. Their are no exceptions defined for the connect(). So the script bombs when the connect fails and gives the 500 error. Can the script be made more robust esp when faced by a down SMTP server? raj #!/usr/local/bin/python import smtplib import string import cgi fromaddr = "xxx " toaddrs = "xxx " thankyou = '''Content-Type: text/html\n\n Thank You! Thank you !! ''' error = '''Content-Type: text/html\n\n We are sorry We are extremely sorry that an error had occured while sending mail. ''' form = cgi.FieldStorage() formkeys = form.keys() msg = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % (fromaddr, toaddrs, order)) line = msg + line server = smtplib.SMTP('localhost') try: server.sendmail(fromaddr, toaddrs, line) except smtplib.SMTPException: print error server.quit() server.quit() print thankyou From db3l at fitlinxx.com Fri Jul 27 02:40:04 2001 From: db3l at fitlinxx.com (David Bolen) Date: 27 Jul 2001 02:40:04 -0400 Subject: Threading in Python References: Message-ID: "Andy" writes: > One thing Java has which Python lacks is transparent > support for multi-cpu threading. Python has threads, > but I believe it is internally implemented and has > been shown not to take advantage of an SMP machine. Python threads are native OS threads (which I don't think is what you mean by internally implemented). However, you are correct that given the global interpreter lock (only one thread can be executing actual Python bytecodes at any given time), it's not very amenable to SMP systems. That is, unless the multi-processing you want to do is off in an extension module that releases the lock before doing it's work. I have a feeling that changing the GIL would be a very large undertaking. In some ways less arguable than stuff like the recent division changes, since if done right it needn't break any existing interfaces, but it would surely be a much higher risk set of changes. Not that it's a bad idea, mind you - just a hard one. -- -- 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 thomas at xs4all.net Wed Jul 4 10:47:59 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Wed, 4 Jul 2001 16:47:59 +0200 Subject: unsigned short In-Reply-To: References: Message-ID: <20010704164759.X8098@xs4all.nl> On Tue, Jul 03, 2001 at 05:42:13PM -0400, John wrote: > Correct me if I'm wrong: Python only supports signed short? Python only has two integer types: Python ints and Python longs. Python ints are signed longs internally, and Python longs are a custom unbounded Integer type. > I have C function that I'm trying to extend python with by writing the > corresponding module function. The C function takes an unsigned short as a > modifiable parameter. > If my assumption above is correct, then I need to represent my parameter as > an integer? Will this work? When I extract the python integer to a C > variable, I would use "i" as the formatter, then cast the it with (unsigned > short)? And vice versa for returning a C unsigned short to a python? You probably want to read up on PyArg_ParseTuple: http://www.python.org/doc/current/ext/parseTuple.html You can't convert directly to an unsigned short int, though, so you still need to cast. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From Randy.L.Kemp at motorola.com Tue Jul 3 09:49:22 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Tue, 3 Jul 2001 09:49:22 -0400 Subject: Access all classes in a directory, put into an array, and print t hem out Message-ID: Can anyone share a short code example of how to access all the programs in a Unix directory, put them into an array, and print them out in Python? Here is the code I have to do it in Perl (please forgive the harsh language). #!/usr/bin/perl -w #use Net::FTP; opendir (TEMP, '/usr2/ecadtesting/javaprograms') or die "Can't open current directory."; @files=join(',',grep(!/^\.\.?$/, readdir TEMP)); closedir TEMP; print "\n"; print @files; print "\n"; From fredrik at pythonware.com Fri Jul 6 03:07:26 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 06 Jul 2001 07:07:26 GMT Subject: tkinter event object question References: <3B4540C5.60005ABE@optonline.net> Message-ID: Arun Ramanathan wrote: > Is there a way by which I can determine which tkinter widget > actually generated the event. > > Example if I had two buttons b1 and b2 initialized as shown below > and bound to the event handler callme. > > ------------------------------- > from Tkinter import * > > root = Tk() > > def callme(event) > print "santa is coming" print event.widget also see table 7-2 on this page: http://www.pythonware.com/library/tkinter/introduction/events-and-bindings.htm > b1 = Button(root,text='b1') > b1.bind("",callme) > b1.pack() you shouldn't do this, of course: the right way to handle button clicks is to use the "command" option. the command option takes a single callable, so you have to use a lambda (or a local function) to share callbacks: def callme(widget): print widget b1 = Button(root, text='b1', command=lambda b1=b1: callme(b1) ) (the b1=b1 thing captures the current value of b1, so we can pass it to the callback when the lambda is executed) also see: http://www.pythonware.com/library/tkinter/introduction/button.htm > b2= Button(root,text='b2') > b2.bind("",callme) > b2.pack() > > root.mainloop() > ------------------------------ From phd at phd.fep.ru Thu Jul 5 04:33:44 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Thu, 5 Jul 2001 12:33:44 +0400 (MSD) Subject: SPAM again [was: Re: .BIZ .INFO domain extensions] In-Reply-To: Message-ID: On 4 Jul 2001, [iso-8859-1] Fran?ois Pinard wrote: > Hi, people. We still get SPAM from this list once in a while, which is > annoying. I wonder if something could be done about it at the list level. > > I noticed that two recent SPAM were sent to `python-list at cwi.nl' instead of > `python-list at python.org', so we might think of ruling out that old address. > On the other hand, valid postings are still made to the `cwi.nl' address, > even if rarely. I fear some members might find rude being forced to switch > to `python.org'. And besides, I'm sure `python.org' will get included > in all spammers' lists, sooner or later, so this would be just postponing > the real problem. Sigh! > > My attitude about SPAM, and am not sure I am fully right, is that I rely > on mailing lists to filter the SPAM they get before forwarding it to me, > while I consider this is more my responsibility to filter the rest, which > directly gets addressed to me without going through mailing lists. > > Opinions? Suggestions? Close the list so only a subscriber can write to it. Yes, I know there is mail<=>news gateway, but close list at least will resists mailed spam. Install at least minimal spam filter. www.spambouncer.org does a great job for me. Teach people to fight spam, not only filter it out. spam.abuse.net, www.spamcop.net, etc. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From bokr at accessone.com Tue Jul 31 12:44:35 2001 From: bokr at accessone.com (Bengt Richter) Date: Tue, 31 Jul 2001 16:44:35 GMT Subject: case sensitivity redux (was Re: Language change and code breaks) References: <9j7gv8$9mg@dispatch.concentric.net> <532qlt453irrepptskcvp213d44r3so2e2@4ax.com> <3B5DF282.87266DA2@earthlink.net> <9k5tg301mn9@enews4.newsguy.com> Message-ID: <3b66c4ce.904451372@wa.news.verio.net> On Tue, 31 Jul 2001 11:24:18 +0200, "Alex Martelli" wrote: [...] >One aspect I haven't seen mentioned in this huge thread is the >issue of visually impaired programmers. Case sensitivity is an >extra burden for such people (with whom I strongly empathize: my >sight is still OK, sufficient to drive a car &c, but it's going >downhill with time, and I must face the very real possibility >that I'll be _seriously_ visually impaired a few years from now). > >Think of a useful tool for such an audience, a special-purpose >'screen reader' that will read out loud a snippet of Python code: >what's the tool going to do about distinguishing upper and lower >case? With case being significant, the tool will have to point >out *every* case change -- a serious bother. Was case not thus >significant, the tool could have two modes, a default "smoother" >mode ignoring case, and a special mode pronouncing case to be >used only (e.g.) within literal strings. > >For those of you who can't really empathize with other's issues >and misfortunes, imagine being in a situation where you'd often >need to have source code read out loud to you (e.g. over a >phone), and/or you'd often want to dictate code (e.g. to some >kind of voice-recognition, dictation-taking automatic system). >What's case sensitivity giving you, that would compensate for >the serious bother it causes in those situations? > Most of us have lots to be thankful for, clearly. Shifting case is also an extra finger dexterity exercise, which is difficult for some with good sight but other impairments. Yet I was in the opposition camp, favoring case sensitivity. I still do, though I am not happy about adding problems for those who already have more than their share. I lived a long time with UPPER CASE PROGRAMMING, and felt as though freed of swaddling when finally i got to use lower case. Maybe there are some conventions for case usage that would help in generating sound representations. Punctuation would probably have to be something like Victor Borge's rendering inside strings. Otherwise you could have a female voice for python operators's names, and other words would be spoken in a male droid voice. For mixed case words, they would be handled according to category. Strings of names joined underscores would get a Victor Borge sound effect for underscore between otherwise normal words. Initial cap could have a distinctive associated sound at the beginning. Perhaps it could be imagined as a sound made by a noisy shift key that made a different noise for press and release. I'd bet you could get good at visualizing the letters, if the sounds were well chosen and timed. I think a lot could be done with some imagination. The other direction is harder, unless you can be a touch typist, I suppose. I imagine you could learn that with a training program that gives auditory feedback. Some foundation should fund work on this (I imagine they already do). The military too could justfiy funding it on the basis of being able to communicate in the dark with a keyboard and an earplug. Also for tagging cockpit voice messages with simultaneous cue sounds for different attributes. Background sounds can work like background lights of different colors and other effects ... [...] >Offhand, I can easily think of a few identifiers that >do appear in different cases, e.g. fileinput (the module) >vs FileInput (the class in module fileinput), but it would >seem to me that those identifiers would not normally have >to be entered with case being the *only* distinction (one >would normally write fileinput.FileInput, so a reasonably >smart tool might still be able to get the case right for >each of the two identifiers - or is this requiring too >much smarts from the tools?). Maybe, if a _small_ fight >is needed to ENABLE (as opposed to FORCE:-) use of a >semi-smart, case-preserving tool, it MIGHT be worth it, >if the fight be small enough...? I won't repost the result, but if you want to scan a directory of .py files, put the following on your path and type casecheck.py /dirpath/*py [oops, that assumes windows with .py association set up. Well, you know what to do.] You should get a list of identifiers appearing with case variations. Not that many, but it shows how case has actually been used. I changed it not to print file headers unless it found something. It's basically an elaboration of Guido's initial (AFAIK) post of a 5-line snippet to find division operators: import sys, tokenize for filename in sys.argv[1:]: def tokeneater(type, token, start, end, line, filename=filename): if token == "/": print "%s:%d:%s" % (filename, start[0], line), tokenize.tokenize(open(filename).readline, tokeneater) _______________________________________________________________ #casecheck.py import sys, tokenize, glob, token symdir={} def tokeneater(type, tokstr, start, end, line): if (type==token.NAME): TOKSTR = tokstr.upper() #should show up for this file if symdir.has_key(TOKSTR): d = symdir[TOKSTR] if d.has_key(tokstr): d[tokstr] += 1 else: d[tokstr] = 1 else: symdir[TOKSTR]={ tokstr:1 } for fileglob in sys.argv[1:]: for filename in glob.glob(fileglob): symdir={} # print '----',filename,'----' tokenize.tokenize(open(filename).readline, tokeneater) header = '---- '+filename+' ----' for key in symdir.keys(): if len(symdir[key]) > 1: if header: print header header = None print symdir[key] _______________________________________________________________ From paulp at ActiveState.com Tue Jul 31 08:39:53 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Tue, 31 Jul 2001 05:39:53 -0700 Subject: Frank Willison Message-ID: <3B66A719.4252CAAC@ActiveState.com> The Python world has lost a great friend in Frank Willison. Frank died yesterday of a massive heart attack. I've searched in vain for a biography of Frank for those that didn't know him but perhaps he was too modest to put his biography on the Web. Suffice to say that before there were 30 or 10 or 5 Python books, before acquisitions editors started cold-calling Python programmers, Frank had a sense that this little language could become something. In Frank's words: "This is my third Python Conference. At the first one, a loyal 70 or so Python loyalists debated potential new features of the language. At the second, 120 or so Python programmers split their time between a review of language features and the discussion of interesting Python applications. At this conference, the third, we moved onto a completely different level. Presentations and demonstrations at this conference of nearly 250 attendees have covered applications built on Python. Companies are demonstrating their Python-based products. There is venture capital here. There are people here because they want to learn about Python. This year, mark my words: Python is here to stay." http://www.oreilly.com/frank/pythonconf_0100.html The O'Reilly books that Frank edited helped to give Python the legitimacy it needed to get over the hump. I carefully put in the word "helped" because Frank requires honesty and modesty: "O'Reilly doesn't legitimize. If we did, lots of technology creators who enjoy their status as bastards would shun us. We try to find the technologies that are interesting and powerful, that solve the problems people really have. Then we take pleasure in publishing an interesting book on that subject. I'd like to put another issue to rest: the Camel book did not legitimize Perl. It may have accelerated Perl's adoption by making information about Perl more readily available. But the truth is that Perl would have succeeded without an O'Reilly book (as would Python and Zope), and that we're very pleased to have been smart enough to recognize Perl's potential before other publishers did." http://www.oreilly.com/frank/legitimacy_1199.html Frank was also a Perl guy. He was big enough for both worlds. To me he was a Perl guy but *the* Python guy. Frank was the guy who got Python books into print. He and his protege Laura Llewin were constantly on the lookout for opportunities to write about Python. Much more important than anything he did with or for Python: Frank was a really great guy with an excellent sense of humor and a way of connecting with people. I know all of that after only meeting him two or three times because it was just so obvious what kind of person he was that it didn't take you any time to figure it out. You can find more of Frank's writings here: http://www.oreilly.com/frank/ Paul Prescod From roy at panix.com Sun Jul 8 12:35:37 2001 From: roy at panix.com (Roy Smith) Date: Sun, 08 Jul 2001 12:35:37 -0400 Subject: Confusion about dictionaries - keys use value or identity? Message-ID: I'm kind of confused about exactly what happens when I use a string as a dictionary key. Section 3.2 of the reference manual seems to imply that keys are compared by identity: > The only types of values not acceptable as keys are values containing > lists or dictionaries or other mutable types that are compared by value > rather than by object identity but experimenting shows they it seems to really use value, not identity: >>> a = 'foo' >>> b = 'f' + 'o' + 'o' >>> a == b 1 >>> a is b 0 >>> x = {} >>> x[a] = 'this is a' >>> x[b] 'this is a' Is there a way to force the comparison to be by identity? I'm contemplating building a cache (using a dictionary), and key comparison by identity should be significantly faster than by value, because I'm going to be using rather long strings as keys. From XQ.Xia at ccsr.cam.ac.uk Mon Jul 9 07:43:42 2001 From: XQ.Xia at ccsr.cam.ac.uk (XiaoQin Xia) Date: Mon, 09 Jul 2001 12:43:42 +0100 Subject: Can not install JPython Message-ID: <3B4998ED.7A522649@ccsr.cam.ac.uk> An HTML attachment was scrubbed... URL: From wolfgang.grafen at marconi.com Fri Jul 13 12:28:51 2001 From: wolfgang.grafen at marconi.com (Wolfgang Grafen) Date: Fri, 13 Jul 2001 18:28:51 +0200 Subject: Question on nested scope References: <3B4EBBA5.10745796@ccsr.cam.ac.uk> Message-ID: <3B4F21C3.C5F31C0F@marconi.com> exec executes your statement within the global and local namespace as far I remember. #exec (,, ) do the same with: b=10 def f1(p): exec(p,{'b':b}) print a print b def f2(p): exec(p,{},{'b':b}) print a print b >>> f1(a) b=b+11 10 >>> f2(a) b=b+11 10 gra. XiaoQin Xia wrote: > > In Python 2.1: > > >>> b=10 > >>> a="b=b+11" > >>> def f(p): > exec p > print a > print b > > > >>> f(a) > b=b+11 > 21 > >>> b > 10 > >>> > > When exec "b=b+11", python can find the second b (10), why it generate > another b? > > Cheers, > Xiao-Qin Xia From machin_john_888 at hotmail.com Sat Jul 14 04:29:07 2001 From: machin_john_888 at hotmail.com (John Machin) Date: 14 Jul 2001 01:29:07 -0700 Subject: converting from perl: variable sized unpack References: Message-ID: <92ae279c.0107140029.37256053@posting.google.com> Roy Smith wrote in message news:... > What's the best way to translate this perl snippet into python: > > ($f1, $f2, $f3, $f4, $f5, $f6) = split ('\s+', $line); > > The obvious translation would be: > > [f1, f2, f3, f4, f5, f6] = string.split (line) > > but the problem is that line may have fewer than 6 fields on it. Perl > handles this smoothly by leaving the "extra" variables undefined, whereas > python raises a ValueError exception. What I'd like to do is have the > extra field variables left as null strings. Try this: f1, f2, f3, f4, f5, f6, extra_guff = (line.split(None, 6) + 7 * [""])[:7] if extra_guff: print "Oops! More data than expected!" # or, more likely, an unintended space in a data field Smooth enough? From grante at visi.com Fri Jul 13 09:56:55 2001 From: grante at visi.com (Grant Edwards) Date: Fri, 13 Jul 2001 13:56:55 GMT Subject: Scripting vs. whatever, again (was Re: Long Live Python!) References: <3B4E5586.82D8ACA8@engcorp.com> <3B4E69D5.5CB278F2@engcorp.com> Message-ID: In article <3B4E69D5.5CB278F2 at engcorp.com>, Peter Hansen wrote: >Grant Edwards wrote: >> >> On Thu, 12 Jul 2001 21:57:26 -0400, Peter Hansen wrote: >> >> >> ...then would want to argue about the difference between a "script" >> >> and a "program". I see it this way, if a script is only, >> >> "Automating a sequence of operations" -- C programs are scripts -- >> >> there must be more to it, eh. > >Just to clarify, I did not write the above. I merely quoted it. > >> I interpret "scripting" as automating a series of operations >> that would probably be done interactively by a user otherwise. > >Would you call a C program which implemented those same steps >a "script" ? > >(I realize you would not typically use C for this, but if you did?) Probably not. To add to my "definition", I guess I would call it a script if it was done using the same set of "primitives" that the user would have done had it been done interactively. Primitives like the "ls" "find" "rm" executables found on Unix systems. -- Grant Edwards grante Yow! at FISH-NET-FISH-NET-FISH-NET-FISH-NET-FISH!! visi.com From skip at pobox.com Mon Jul 2 14:16:59 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 2 Jul 2001 13:16:59 -0500 Subject: Augmented Assignement (was: Re: PEP scepticism) In-Reply-To: <3B40B551.5A554148@ActiveState.com> References: <20010702145211.M8098@xs4all.nl> <3B40B551.5A554148@ActiveState.com> Message-ID: <15168.47771.528688.531809@beluga.mojam.com> Paul> "Advanced" types could have "smart" behaviour and simple types Paul> could have x=x+y behaviour. Let's ignore lists, tuples and numbers for a moment because most people know how they are supposed to work (or will figure it out with a simple script). Suppose I see code like this import mumble x = mumble.Mumble() ... x += 1 How am I supposed to know without digging around in the code or docs for the mumble module if it is a "simple" or "advanced" type? You haven't solved any problems, just added a new protocol for programmers to implement that will be done so in a haphazard fashion. Skip From martin at strakt.com Mon Jul 9 10:48:59 2001 From: martin at strakt.com (Martin Sjögren) Date: Mon, 9 Jul 2001 16:48:59 +0200 Subject: socket module In-Reply-To: <15177.49947.594373.154573@beluga.mojam.com> References: <20010709091943.A18359@strakt.com> <15177.49947.594373.154573@beluga.mojam.com> Message-ID: <20010709164859.A21825@strakt.com> On Mon, Jul 09, 2001 at 09:43:39AM -0500, Skip Montanaro wrote: [snip] > Something vaguely like: > > PyObject *sockmodule, *sockfunc, *socket; > sockmodule = PyImport_Import("socket"); > sockfunc = PyDict_GetItemString(PyModule_GetDict(sockmodule), "socket"); > PyCall_Object(sockfunc, ...); Yeah, this is roughly how I do things now. One problem I'm having though, is that sure I can use the C equivalent of the 'hasattr' function to get the methods of the socket objects, but I either have the overhead of doing that every time I call a socket method, or the overhead of looking up all those methods every time I need a new socket object (seeing as what I get isn't a PyCFunction, but a PyCallable). Oh well. Martin -- Martin Sj?gren martin at strakt.com ICQ : 41245059 Phone: +46 (0)31 405242 Cell: +46 (0)739 169191 GPG key: http://www.strakt.com/~martin/gpg.html From qrczak at knm.org.pl Sun Jul 29 02:26:21 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 29 Jul 2001 06:26:21 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <9jnt9p$qhe$1@newsy.ifm.liu.se> Message-ID: 28 Jul 2001 23:14:01 -0400, Lloyd Zusman pisze: > Agreed: rationals with a fixed denominator for calculation results, > such as 100 in the U.S. where we have dollars and cents. No, plain rationals will suffice. No arithmetic operation except division introduces a denominator which represents fractional cents. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From tdelaney at avaya.com Mon Jul 2 20:31:10 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Tue, 3 Jul 2001 10:31:10 +1000 Subject: PEP scepticism Message-ID: > I'd also consider whether /# and #/ are better markers - more directly > related to the existing #. Ooh - I like it. Then the following nice idiom becomes useful ... /# # This is a comment #/ On second thought, having typed it, I don't like it. The *really* nice thing about /* */ is that the two characters are ajacent on the numeric keypad on every keyboard I have used, and so it takes zero thought to produce them. Also, what if you have code with #/ in it somewhere. You could end up with an end-comment marker you didn't want. Unlikely, but dangerous. Looks nice though. Tim Delaney From aetodd at wm.edu Mon Jul 2 16:42:36 2001 From: aetodd at wm.edu (Andrew Todd) Date: Mon, 02 Jul 2001 16:42:36 -0400 (EDT) Subject: Calculus Module In-Reply-To: References: Message-ID: <994106556.3b40dcbc8651f@webmail1.wm.edu> Is there a calculus module? I couldn't find one. From ggardiner at accelrys.com Mon Jul 16 04:08:28 2001 From: ggardiner at accelrys.com (Gardiner, Geoff) Date: Mon, 16 Jul 2001 09:08:28 +0100 Subject: Q: HTTP through multiple NICs Message-ID: <55E9531220EDD41186F50090274688BD2BF360@oranamesrvr0.synomics.com> Thank you, this looks exactly like what I need. I'd looked through the sources for httplib, etc, including socket.py and had not encountered 'bind' at all - I should have properly RTFM as well. I'd also not spotted that I should be using HTTPConnection rather than HTTP until you pointed it out - though HTTP actually _uses_ HTTPConnection, just proclaiming itself to be HTTP/1.0. Geoff -----Original Message----- From: ngps at madcap.dyndns.org [mailto:ngps at madcap.dyndns.org] Sent: 13 July 2001 18:42 To: python-list at python.org Subject: Re: Q: HTTP through multiple NICs ... To do what you want, insert "s.bind((local_addr, local_port))" between lines 1 and 2. Yes, bind() works for client sockets, too. ... A quick glance thru httplib shows no mechanism to pass your own socket objects in - httplib's HTTP and HTTPConnection classes want to create their own sockets. You can subclass either of those (use HTTPConnection, it's newer ;-) to pass in your own sockets that bind to your choice of local address. ... From duncan at NOSPAMrcp.co.uk Mon Jul 23 05:10:15 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Mon, 23 Jul 2001 09:10:15 +0000 (UTC) Subject: Partition Problem References: <3B5042C2.F821D916@engcorp.com> <9itb14$2oi$1@newsg1.svr.pol.co.uk> <9iv5e9$bru$1@newsg1.svr.pol.co.uk> <0oR47.12485$p7.4220508@news1.rdc2.pa.home.com> Message-ID: Tom_Good1 at excite.com (Tom Good) wrote in news:ac677656.0107201451.6f5e120d at posting.google.com: > And now, for something completely different! "Fun with generators." > > Here is the "sets of 6 positive integers that sum to 17" problem, > solved with generators. Works with Python 2.2. My goal here was to > minimize lines of code, not to optimize for performance. > Followed by the 'how to iterate over all permutations of a sequence'. BTW, the 'return' statement isn't actually needed, but I think it makes the code a bit clearer. --- begin --- # Permutations using generators. from __future__ import generators def permute(seq): if len(seq)==1: yield seq return for i in range(len(seq)): for perm in permute(seq[:i] + seq[i+1:]): yield seq[i:i+1] + perm def test(str): for t in permute(str): print t test('bar') test('flip') test([1, 2, 3]) --- end --- -- 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 Randy.L.Kemp at motorola.com Tue Jul 3 15:58:17 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Tue, 3 Jul 2001 15:58:17 -0400 Subject: What's wrong with this program Message-ID: Thanks for the correction. Anyone know the correct format to transfer files from one server directory to another server directory? -----Original Message----- From: Oleg Broytmann [mailto:phd at phd.fep.ru] Sent: Tuesday, July 03, 2001 2:47 PM To: jedi Cc: Kemp Randy-W18971; 'python-list at python.org' Subject: Re: What's wrong with this program On Tue, 3 Jul 2001, jedi wrote: > ftp.connect # defaults to port 21, check docs for further options Call it: ftp.connect() Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From JamesL at Lugoj.Com Fri Jul 27 18:51:54 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Fri, 27 Jul 2001 15:51:54 -0700 Subject: PEP 238 (revised) References: Message-ID: <3B61F08A.1A4C6069@Lugoj.Com> Tim Peters wrote: > The issue in context is about floats, and the sign bit of 0.0 follows very > specific rules under standard IEEE-754 arithmetic. Multiplying by 1.0 > preserves the sign of a 754 zero, but adding 0.0 (of either sign) may not; > so adding 0.0 as a means to convert to float is wrong under 754 arithmetic > rules, albeit subtly wrong. Obviously I'm not familiar with IEEE-754 arithmetic. Is the intent to do IEEE-754 FP arithmetic on all platforms when FP is involved? What if the underlying hardware isn't conformant? Sorry, since this seems to be going through the python-list mailing list, the "References:" header isn't being included for some reason, so I missed the introduction of IEEE-754 into the discussion. Can't find it mentioned in that PEP (unless it is in another PEP or is documented elsewhere). From erno-news at erno.iki.fi Wed Jul 4 23:57:22 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 05 Jul 2001 06:57:22 +0300 Subject: Performance in embeded / extended python References: <3b431024.15341289@news.iway.fr> Message-ID: In article <3b431024.15341289 at news.iway.fr>, emmanuel.astier at winwise.fr (Emmanuel Astier) writes: | Hi, | I embedded and extended python for a game, and I was REALLY | disappointed by the performances I get... | Every frame of my game ( should be 60 time by second ) I call my | Python logical part from my C game with : [...] | for i in range ( 0, NbTestSprites - 1 ): | ListOfSprites[i].setPos( 100, 100 ) | ie it sets the pos of 200 sprites. [...] | This is _REALLY_ slow ( i run at around 1 Frame / second on a P733 ). the python-imposed overhead of doing that certainly should not slow that down to running only one complete loop per second unless setPos() is a python function and does something fairly complicated. perhaps you are looking in the wrong place for the slowdown? -- erno From woodsplitter at rocketmail.com Fri Jul 27 17:11:03 2001 From: woodsplitter at rocketmail.com (stalin) Date: 27 Jul 2001 14:11:03 -0700 Subject: Typing system vs. Java References: Message-ID: <7876a8ea.0107271311.3bbeca87@posting.google.com> Python has 'dynamic strong typing'. http://groups.google.com/groups?q=weak+typing+perl+python&hl=en&safe=off&rnum=2&selm=mailman.994198807.6647.python-list%40python.org http://groups.google.com/groups?q=weak+typing+perl+python&hl=en&safe=off&rnum=4&selm=mailman.991902551.10104.python-list%40python.org From robin at illusionsexeculink.com Tue Jul 3 23:23:12 2001 From: robin at illusionsexeculink.com (robin at illusionsexeculink.com) Date: Tue, 03 Jul 2001 23:23:12 -0400 Subject: Python for air traffic control? References: <134704696.994123281122.JavaMail.root@boots> <20010703020254.B5005@node0.opengeometry.ca> <3B419E3D.A965D4DE@stroeder.com> Message-ID: Michael Str?der wrote: >Well, it's the first time I put someone posting to comp.lang.python >(Mr. Park) into my kill file. One out of hundreds. That doesn't look >too bad. Seconded. Still a nice group. ----- robin robin at illusionsexeculink.com media artist / remove illusions to reply information architect www.execulink.com/~robin/ "It's clearly a budget. It's got a lot of numbers in it." -- George W. Bush. Reuters, 5 May 2000 From rmacneil at interactdirect.com Mon Jul 9 09:13:36 2001 From: rmacneil at interactdirect.com (Rod MacNeil) Date: Mon, 9 Jul 2001 09:13:36 -0400 Subject: Error Building PyPgSQL Message-ID: Hello, I'm trying to build PyPgSQL on a RH7 box with Python 1.5 and postgres 7.0 and gcc-2.96-54. I left the Setup.in file as it shipped because it looked correct to me. I get the following when I run make. gcc -fPIC -I/usr/local/pgsql/include -g -02 - I/usr/include/python1.5 -I/usr/include/python1.5 - DHAVE_CONFIG_H -c ./libpqmodule.c ./libpqmodule.c: In function `PgConnection_New': ./libpqmodule.c:196: parse error before `PgConnection' ./libpqmodule.c: In function `PgResult_New': ./libpqmodule.c:282: parse error before `PgResult' ./libpqmodule.c: In function `PgLargeObject_New': ./libpqmodule.c:358: parse error before `PgLargeObject' ./libpqmodule.c: In function `PgNotify_New': ./libpqmodule.c:548: parse error before `PgNotify' make: *** [libpqmodule.o] Error 1 This looks like a compiler error to me but I'm not a C programmer. The four lines of code appear to be using the same syntax, is this a syntax error or possibly a compiler version issue? Has anyone else had this problem or know of a solution? Thanx, any help would be appreciated. Rod MacNeil rmacneil at interactdirect.com From Arthur_Siegel at rsmi.com Mon Jul 30 19:14:17 2001 From: Arthur_Siegel at rsmi.com (Arthur_Siegel at rsmi.com) Date: Mon, 30 Jul 2001 18:14:17 -0500 Subject: Changing the Division Operator -- PEP 238, rev 1.12 Message-ID: <00899E06.N22121@rsmi.com> >>In article , Arthur >>Siegel wrote: >> Would be a lot more compelling were they reports *from* rather than >> reports *about*. >Agreed. But what struck me was that when a non-programmer came to a >Python discussion list asking whether Python was suitable for his >project, several people warning him about the pitfalls of division (and >not much else). Must have missed all this. Where and when was this thread? I guess I remain the odd ball. If a non-programmer asked me about using Python for a project, I would certainly explain to him that he/she had picked a good alternative, because between him and his project was a little barrier - learning to program. Python is *great* for that. Among the many things he will need to learn about is numerical types, and how they work in Python. Which I can promise him is not going to be anything near the high water mark of the learning curve. What I am missing. Why are we talking about the programming projects of non-programmers? Why isn't that simply dismissed as an absurd contradiction in terms? Have absolutely no interest in re-opening the discussion about the / operator. Other than the code breakage issue, I have never in fact heard an argument *against* it that I found truly compelling. But I can tell you that the first person accounts posted here of what is faced by developers maintaining substantial code bases are real and compelling. Isn't it clear that the thread that it is all quite necessary to meet the programming language specification requirements of people who don't actually program (is there another definition of non-programmer that I am missing) - is an incitement, not an explanation. ART From chrishbarker at home.net Fri Jul 27 13:14:16 2001 From: chrishbarker at home.net (Chris Barker) Date: Fri, 27 Jul 2001 10:14:16 -0700 Subject: interpreter improvements References: <5e8bd451.0107190224.7171e61@posting.google.com> <5e8bd451.0107270042.691bf6f0@posting.google.com> Message-ID: <3B61A168.C361BE99@home.net> kevin parks wrote: > Thanks everyone. I am learning a lot by this discussion, but i should > point out that the main reason why i am so unhappy with the > interpreter is that i am ON A MACINTOSH!!! The forgotten platform of > the python world. (thanks god for Jack and Just!) > > which means that IDLE, we don't really have! (it's broken, i think and > has been for a while as there are problems with tkinter. Unless i am, > as always, wrong) And our Mac IDE is, uhm... (forgive me > please)...uhmm.... Not fully-featured as IDLE is. If you want improvements to the MacPython IDE, you need to request them on teh macPython mailing list, or, even better, write them yourself! By the way, there were some add ons available that added sytax highlighting and some interpreter improvements to the MacPython IDE. They don't see to ahve made it ino the main distribution (I don't know why not), but ask on the mailing list, and I'm sure someone will be able to help you find them. > Compound this with the move to OS X and the fact that our text engine > (WASTE) is not yet ready for prime time X wise... You can run Unix Python on OS-X,and I'm pretty sure that someone has been able to compile it eith readline support there. readline doesn't give you all you want, but it's a start. > Well. I guess i should be used to it by now and just realize that > macintosh is the runt of the litter and that we will never have the > niceties that other *nix and Windoze users have. I'll die of old age > before we get syntax coloring! The problem is that Python is an open-source project, so what gets developed is what developers want. There may be more Mac users than Linux users, for instance, but there are fewer developers, so there jsut isn't as much done. > just once, the Macintosh was given a bit more Python > love. I agree with this to some extent. For the most part, it is up to the MacPython comunity to develop Mac specific tools, but there are places where Python has been adapted to accomodate Windows and *nix, and not the Mac. The example I can think of at the moement, is that the interpreter can parse code with *nix or Windows line endings, but not Mac ones. That's because it is easy to just ignore the \r in Windows line endings, but it could have also been easy to ignore the \n and get Mac + Windows compatability. Getting all three is hard, and no one seems to want to do the work to get it. Frankly, IO've also bee dissapointed in the MacPython communities commitment to cross-platform tools. tkInter works on Windows well because Window users have made sure that it does, ditto for wxPython, etc. No one in MacPython development is working on those things. If you had a strong tkinter, you'd have IDLE, if you had wxPython, you'd have Boa, so the cross-platform tools really are the key. I guess if you wanted to write programs for most computer users, you wouldn't be using a Mac in the first place. :-( -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 grey at despair.dmiyu.org Mon Jul 2 12:09:20 2001 From: grey at despair.dmiyu.org (Steve Lamb) Date: Mon, 02 Jul 2001 16:09:20 -0000 Subject: Python--eclectic or ubiquitous References: <5174eed0.0107020747.6836d160@posting.google.com> Message-ID: On 2 Jul 2001 08:47:06 -0700, Edward Wilson wrote: >Why is it that one can attempt the most daring tasks with Python, e.g. >write image manipulation programs, steer super computing applications, >write interactive games, parse XML, yet still can not perform the more >basic tasks of hitting a database and generating a report. Why is it you're trolling this group? This is the second time that you've posted basically the same message? Learning how to post like catlovrr, maybe? -- 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 aahz at panix.com Fri Jul 27 21:28:55 2001 From: aahz at panix.com (Aahz Maruch) Date: 27 Jul 2001 18:28:55 -0700 Subject: PEP0238 lament References: <220720012039325082%jwbaxter@spamcop.com> Message-ID: <9jt4gn$ift$1@panix2.panix.com> In article , Steve Horne wrote: > >I think you underestimate the number of people who will some day >figure that 1.5.2 is a bit old, install the latest version, and have >hell break lose over night when half their scripts stop working. ....silently. That's the worst problem. Sure, we're silently losing information now, but old users will silently lose information *in* *working* *programs* if they skip over all the warning releases. -- --- 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 Fortune cookie: Watch your relations with other people carefully, be reserved. From alf at leo.logilab.fr Fri Jul 6 10:41:19 2001 From: alf at leo.logilab.fr (Alexandre Fayolle) Date: Fri, 6 Jul 2001 14:41:19 +0000 (UTC) Subject: pb with xmlrpclib References: <9i4ic3$f3v$1@plutonium.compulink.co.uk> Message-ID: On 6 Jul 2001 14:35:47 GMT, gbreed at cix.compulink.co.uk wrote: >Have you tried > > server.echo(unicode('\231','latin-1')) > >? Dunno about xmlrpc, but it works with SOAP. I've just tried it and it doesn't work with xmlrpclib. :o( Which implementation of SOAP are you using ? Maybe I'll switch to SOAP, if it can solve my problem. Alexandre Fayolle -- LOGILAB, Paris (France). http://www.logilab.com http://www.logilab.fr http://www.logilab.org Narval, the first software agent available as free software (GPL). From chrisd at rocketnetwork.com Thu Jul 5 22:29:53 2001 From: chrisd at rocketnetwork.com (Chris Duncan) Date: Thu, 5 Jul 2001 19:29:53 -0700 Subject: deleting directories w/ subfolders Message-ID: <9i37ta$p61$1@bob.news.rcn.net> Anyone know a way to delete a parent directory containing files & subfolders? From quacko at lists.postmastergeneral.com Tue Jul 3 17:52:00 2001 From: quacko at lists.postmastergeneral.com (Quacko Lotto) Date: Tue, 03 Jul 2001 17:52:00 EDT Subject: WIN UP TO $1,000,000.00 EVERY SINGLE DAY Message-ID: <200107032201.QAA56760@s0203.pm0.net> ******************************************** WIN UP TO $1,000,000.00 EVERY SINGLE DAY ******************************************** http://lotto.quacko.com Quacko-Lotto is now offering a $1,000,000.00 Grand Prize to anyone who takes the time to play tickets today. Have you played YOUR Free Tickets today? http://lotto.quacko.com SPECIAL OFFER AT SUPREMECASINO!! 100% BONUS ON PAYPAL & NETeller DEPOSITS! ********************************************* PAYPAL connects http://www.supremecasino.com members by providing an immediate, secure and effective mechanism to transfer Cash over the Internet! And virtually 100% guaranteed! All PayPal deposits will receive a 100% Free Cash Bonus! Up to $75 on initial deposits and a 5% Free Cash Bonus on all additional deposits. There has never been a better time to fund your account than now with bonuses on all deposits! - Initial Western Union Deposits 5% - Additional Western Union Deposits 5% - Wire or Personal Check Deposits 5% Stop by 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 cliechti at mails.ch Wed Jul 11 16:41:58 2001 From: cliechti at mails.ch (chris liechti) Date: 11 Jul 2001 22:41:58 +0200 Subject: Threading.Event w/ timeout veeeeeery slow on win32? References: Message-ID: what is the timeout value? i've had problems with time.sleep() when using values smaller than 20ms (0.02). I'm now using 30ms wich works fine. it seems that windows has a time resulution of 10ms or worse... (details: when i ran the old code with time.sleep(0.01) the program got very slow and the win NT4.0 taskmanager told that [File] Explorer is getting 30% of CPU power. this number must be totaly wrong because its an other process and my programm does not use files or any other things that would require the Explorer. moral: don't count on windows if it get near 10ms ) chris cliechti at mails.ch Ville Vainio wrote in news:yoxr8vnaokt.fsf at karhu.tp.spt.fi: > I'm using a Threading.Event object. When I specify a timeout for > wait(), it takes almost 1 second for the thread that is wait()'ing to > wake up when I kick the Event obj with a set(). I know I could get > around this by creating a thread to perform set()'s periodically, but > since this slowness is not mentioned in the documentation I was > wondering whether I have misunderstood something. > > I'm using Python 2.1. > From chrishbarker at home.net Thu Jul 5 16:40:29 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 05 Jul 2001 13:40:29 -0700 Subject: Most important text processing examples References: <3dr8vvqrfl.fsf@ute.cnri.reston.va.us> Message-ID: <3B44D0BD.63A3F795@home.net> William Park wrote: > I didn't know this was possible. What prevents the publisher from > simply holding on the manuscript forever? Anyone writing a computer book should read this: http://philip.greenspun.com/wtr/dead-trees/story.html It's interesting (and humorous) reading for the rest of us as well. -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From JamesL at Lugoj.Com Mon Jul 9 20:38:21 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Mon, 09 Jul 2001 17:38:21 -0700 Subject: Python Idiom Question References: <3B4A4126.7AD3CDD0@tundraware.com> Message-ID: <3B4A4E7D.F16F2C4B@Lugoj.Com> Tim Daneliuk wrote: > > What is the equivalent python idiom to the following 'C' code: > > while (x=getchar() != 'N') > { > Do something} > > In other words, is there a convenient way to simultaneously get > input, from say, raw_input() or f.read(), and check the return > value agains some logical construct, re pattern match, or whatever? What is wrong with: while 1: x=raw_input() if x == 'N': break Do something From sholden at holdenweb.com Thu Jul 12 13:01:09 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 12 Jul 2001 13:01:09 -0400 Subject: 'import' error in csh References: <3B4DABBE.D176B14F@nokia.com> Message-ID: <1Hk37.2714$yb3.51907@e420r-atl1.usenetserver.com> "Skip Montanaro" wrote in message news:mailman.994949961.19601.python-list at python.org... > > Joonas> That code hasn't gone thru Python interpreter, because the error message > Joonas> comes from csh. > Joonas> Try to fix the first line from '# !/usr/bin/local/python' to > Joonas> '#!/usr/bin/local/python' > > or more likely: > > #!/usr/local/bin/python > But, preferably: #!/usr/bin/env python regards Steve -- http://www.holdenweb.com/ From ethan at ucar.edu Tue Jul 31 12:23:18 2001 From: ethan at ucar.edu (Ethan Alpert) Date: Tue, 31 Jul 2001 10:23:18 -0600 Subject: Motif Style File Selection Box in Tkinter? Message-ID: <3B66DB76.CE0D231F@ucar.edu> Are there any resources or places to go to find higher level widget implementations in Tkinter. Specifically I'm looking for a motif style file selection box. Please respond to ethan at ucar.edu Thanks, -ethan From m at moshez.org Mon Jul 30 04:43:48 2001 From: m at moshez.org (Moshe Zadka) Date: Mon, 30 Jul 2001 11:43:48 +0300 Subject: [OT] Number theory [Was: A use for integer quotients] In-Reply-To: References: , <3B5C5665.8D41D1F1@tundraware.com> <3B5C749A.59F97320@tundraware.com> <3b602afa.930850@nntp.sprynet.com> <3b617133.1013412@nntp.sprynet.com> <3b62c8c4.2448381@nntp.sprynet.com> <3b6409e0.2079581@nntp.sprynet.com> <3b645f76.747435355@wa.news.verio.net> Message-ID: On 30 Jul 2001, Marcin 'Qrczak' Kowalczyk wrote: > I would write it > print "There %s %d error%s." % (if n==1 then ('was', n, '') > else ('were', n, 's')) The correct way to write it is: print ["There was %d error", "There were %d errors"][n>1] % n This way, making this application translatable is a piece of cake. The other version can't be translated properly. As someone from a non-English speaking country, you should care. -- gpg --keyserver keyserver.pgp.com --recv-keys 46D01BD6 54C4E1FE Secure (inaccessible): 4BD1 7705 EEC0 260A 7F21 4817 C7FC A636 46D0 1BD6 Insecure (accessible): C5A5 A8FA CA39 AB03 10B8 F116 1713 1BCF 54C4 E1FE Learn Python! http://www.ibiblio.org/obp/thinkCSpy From andrew-usenet at lexical.org.uk Thu Jul 26 09:50:40 2001 From: andrew-usenet at lexical.org.uk (Andrew Walkingshaw) Date: 26 Jul 2001 14:50:40 +0100 (BST) Subject: SlightlyOffTopic: syntax-highlighting in XEmacs running on Windows References: <3B601B45.4070107@nospiced.ham.devis.com> Message-ID: In article <3B601B45.4070107 at nospiced.ham.devis.com>, Tom Jenkins wrote: >Thomas Weholt wrote: [(X)Emacs/Win32, python-mode] >Actually Thomas you can have a file named .emacs (at least under Win2k >though I think you could do it in NT also) Here, under WinME, using the binary XEmacs 21.4 distribution; XEmacs 21.4 checks, before .emacs, for a directory .xemacs/ and files in that: .xemacs/ init.el custom.el so that settings from M-x customize don't clobber those in your .emacs. Also, XEmacs ships with python-mode by default: might you not have font-lock-mode enabled? The relevant excerpt from my init.el is (font-lock-mode t) though I'm sure some Emacs expert can indicate what I -should- be using :) HTH, Andrew -- adw27 at cam.ac.uk (academic) http://www.lexical.org.uk/ From jkraska1 at san.rr.com Sat Jul 21 19:42:37 2001 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 21 Jul 2001 23:42:37 GMT Subject: Case insensitivity References: <93d9a839.0107200315.4a0a8c28@posting.google.com> Message-ID: <4n4klt8ud0es25jep3u2v9pj02dctnte0u@4ax.com> >If case-preservation were tool-enforced, then all of us would >essentially have to use those tools. The moment that any programming language becomes tool- dependent, that language is dead to me. I tried fiddling with Lisp-without-Emacs for most of a year. It didn't work out. I can think of few programming-related things more onerous than a programming language which requires you to learn its editor. Never again. C// From tdelaney at avaya.com Tue Jul 17 22:30:58 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Wed, 18 Jul 2001 12:30:58 +1000 Subject: Augmented Assignment in Python (PER) Message-ID: > "For the built-in types, augmented assignment doesn't violate > mutability or perform in-place modification of objects. Therefore, > writing x+=y creates an entirely new object x with the value x + y. > User defined types and classes may choose to implement different > behavior by redefining special methods such as __iadd__(), > __isub__(), > and so forth." > > Note: I still stand by the statement for built-in types. I > looked through > the Python sources when writing the book and couldn't find any use of > augmented assignment for built-in types. I am not aware of any > counter-example where x += y is not equal to x = x + y for > the standard > built-in types (if there is such an example, please enlighten me!). This is very very wrong. a = [] b = a print b a += [1, 2] print b List is a built-in type. Lists are modified in-place by augmented assignment. The information in your book will lead to bad programming errors. Tim Delaney From dporter at draper.com Tue Jul 10 11:07:34 2001 From: dporter at draper.com (Dave Porter) Date: 10 Jul 2001 08:07:34 -0700 Subject: BLT through Pmw References: Message-ID: "Reggie Dugard" wrote in message news:... > 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 Volker Dobler Install the Python 2.1 distribution from Sourceforge WITHOUT Tcl. Just unselect Tcl when prompted. Then install Tcl/Tk8.3.3 from http://dev.scriptics.com/. I installed Tcl into the Python21 directory. Install PMW and BLT (both into \Python21) and everything should work fine. The Tcl which is part of a Python distribution is doing something which breaks the PMW/BLT connection so the easiest solution is don't use it. Regards Dave Porter From smnordby at yahoo.com Mon Jul 2 20:35:05 2001 From: smnordby at yahoo.com (SteveN) Date: Mon, 02 Jul 2001 17:35:05 -0700 Subject: Is Python Dead? References: Message-ID: <3B411339.6DADAFF0@yahoo.com> I don't understand why people are replying to this troll. From rumjuggler at cryptarchy.org Mon Jul 23 22:35:11 2001 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Tue, 24 Jul 2001 02:35:11 GMT Subject: PEP0238 lament References: <9s4pltg7l5r04652q60oqgfu792ha0f1b2@4ax.com> Message-ID: <1inplt45arpfcj03gklmn309fc2rkegsgm@4ax.com> On Tue, 24 Jul 2001 02:28:50 +0100, Stephen Horne wrote: >On Mon, 23 Jul 2001 18:27:06 -0400, "Tim Peters" >wrote: > >>try-giving-it-a-rest-for-12-hours?-ly y'rs - tim > >Sorry - insomnia brought on by anxiety due to the anticipation of >severe damage to my professional reputation and a lot of unnecessary >work. > >If you had as many cases of "?"+str(Amount/100)+"."+str(amount%100) >and similar in your code as I do - most of which I don't even know who >has it or who might have tweaked versions (and I know as an absolute >fact those warnings will either not be seen at all or will be ignored) >you'd be just as pissed of as I am. This seems like a pretty good reason to leave '/' the way it is and have '//' be for float division. A lot of the opposition to the change seems not to be to the idea, but just to the necessity of going through code changing '/' to '//', so why not make it possible to avoid that? -- Barnabas T. Rumjuggler No man can run so fast that he can escape his own past's projectile vomit. From dan at cgsoftware.com Sat Jul 7 01:41:00 2001 From: dan at cgsoftware.com (Daniel Berlin) Date: Sat, 07 Jul 2001 01:41:00 -0400 Subject: Inverse regex? In-Reply-To: ("Andrew Henshaw"'s message of "Fri, 6 Jul 2001 22:49:17 -0400") References: Message-ID: <87r8vte1oz.fsf@cgsoftware.com> "Andrew Henshaw" writes: > Has anybody seen or developed what might be called an inverse regex > generator. We would like to do some unit testing of modules that have user > input validated by regular expressions. It would be nice to throw some some > strings at them and see if the propagated input causes an error in the code > downstream. In other words, it may help to detect if our validation > routines are insufficient. > > I understand that, in many cases, a complete list of valid strings is > impossible. However, for certain regular expressions it would be certainly > reasonable. For others, it will be possible, but practically impossible > (set too large). For the impossible, and near impossible, it would be nice > to generate a bounded set that hits many of the degenerate and extreme > cases. > > Any ideas? Yes. There was an automata/regex/cfg toolkit that could do this. I can't remember the name, but i can describe it, in case someone else remembers (you should be able to find it off the description, if worse comes to worst). I know it wasn't bruce watson's fire stuff. It was written in C++ and consisted of a library and a bunch of filters that used it. It could do DFA's, NFA's, CFG's, Regular expressions (and something else i found neat, but escapes me at the moment), in all of their various forms. The filters it built using the library (very simple of course, the library did all the real work) consisted of conversions between all of the various forms (where possible), enumeration of their languages (whether they were infinite or not), minimization of DFA's (by hopcroft's algorithm, as well as minimization by reversal), minimization of regular expressions, Oh, wait, just found it. The Grail+ project. www.csd.uwo.ca/research/grail One of the filters will do enumeration of the languages. It'll also let you specify the maximum number of strings you want to enumerate (in case it's an infinite language). So just throw a regex (in their regex format) at it, and away you go. HTH, Dan > > Andrew Henshaw > > > -- > http://mail.python.org/mailman/listinfo/python-list -- "Four years ago... No, it was yesterday. Today I... No, that wasn't me. Sometimes I... No, I don't. "-Steven Wright From fdrake at acm.org Thu Jul 12 19:50:43 2001 From: fdrake at acm.org (Fred L. Drake) Date: Thu, 12 Jul 2001 19:50:43 -0400 (EDT) Subject: [development doc updates] Message-ID: <20010712235043.5A42D2892B@cj42289-a.reston1.va.home.com> The development version of the documentation has been updated: http://python.sourceforge.net/devel-docs/ Lots of small updates. Added Eric Raymond's documentation for the XML-RPM module added to the standard library. From mwh at python.net Mon Jul 2 18:41:34 2001 From: mwh at python.net (Michael Hudson) Date: 02 Jul 2001 23:41:34 +0100 Subject: Calculus Module References: Message-ID: Andrew Todd writes: > Is there a calculus module? I couldn't find one. What would you want such a thing to do? I'm curious. Symbolic integration? Cheers, M. -- ... Windows proponents tell you that it will solve things that your Unix system people keep telling you are hard. The Unix people are right: they are hard, and Windows does not solve them, ... -- Tim Bradshaw, comp.lang.lisp From eppstein at ics.uci.edu Sun Jul 22 19:27:32 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Sun, 22 Jul 2001 16:27:32 -0700 Subject: PEP0238 lament References: Message-ID: In article , "Tim Peters" wrote: > A user trying e.g. velocity(3, 2) is simply going to be > surprised -- as countless newbies have testified on c.l.py over the years. My intuition is that the users who will be surprised that 1/2 = 0 are the same ones who would be bitten by roundoff-error bugs if 1/2 = 0.5. Result: buggier code since the errors are less obvious. If you have a routine "velocity" in which it doesn't make sense to do integer truncation, and it doesn't coerce its args to float by adding 0.0, that's also a bug. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From steveha at animal.blarg.net Mon Jul 16 18:05:38 2001 From: steveha at animal.blarg.net (Steve R. Hastings) Date: 16 Jul 2001 15:05:38 -0700 Subject: Cross-platform GUI app -- Tkinter? References: <3b4e211f$1@news.blarg.net> <3B4E617D.C7AA9123@engcorp.com> Message-ID: <3b536532$1@news.blarg.net> Peter Hansen (peter at engcorp.com) wrote: > Look into Jython (http://www.jython.org), which compiles Python > source to Java bytecodes. > Adding to the perfection, this lets you avoid Tkinter and TCL > entirely, because now the entire world of Swing is open to you. This might be a good solution for me. I had never even heard of Swing before you posted this article, but now I am looking into it. Thanks for the information. -- Steve R. Hastings "Vita est" steve at hastings.org http://www.blarg.net/~steveha From aahz at panix.com Sun Jul 29 13:25:20 2001 From: aahz at panix.com (Aahz Maruch) Date: 29 Jul 2001 10:25:20 -0700 Subject: 2.0 or 2.1 on win32 References: <9jti6t$e2g$1@panix2.panix.com> Message-ID: <9k1gu0$j0a$1@panix2.panix.com> In article , douglas savitsky wrote: > >people have always been ambiguous in the past as to whether installing >activepython or python + win32 extensions was the better choice. as far >as i can tell active python is based upon 2.1 and not 2.1.1. should >this be the deciding factor? I don't have an opinion. Paul? ;-) (Actually, that's not quite true. Unless ActiveState plans to release a new build based on 2.1.1 within the next month or two, I think going to straight 2.1.1 is probably a better choice.) -- --- 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 "activist for accuracy" --SJM From paul at boddie.net Wed Jul 25 06:16:40 2001 From: paul at boddie.net (Paul Boddie) Date: 25 Jul 2001 03:16:40 -0700 Subject: re bad leadership References: <0+yM4IAgmKX7EwIQ@jessikat.fsnet.co.uk> <20010724171838.A21770@xs4all.nl> <4crrlt0jbn9ovvkli3qvhqbc5do3lmpg4j@4ax.com> <%kn77.25759$EP6.6204923@news1.rdc2.pa.home.com> Message-ID: <23891c90.0107250216.2f49e2e6@posting.google.com> "Terry Reedy" wrote in message news:... [Attribution lost!] > > > > So why not swap the proposed meanings of // and /? I realize > > > > this is the third time I've said this but I think it would silence a > > > > lot of objections and no one seems to have noticed the other two times. > > PEP238 proposes that / be the inverse of *, so that '(a/b) * b = a > (more or less)' and that 'a // b == floor(a/b)'. If we 'swap the proposed > meanings of // and /', then we would have a/b == floor(a/b), which would > break almost all existing floating point code. I suspect that the contributor who made the above unattributed suggestion actually meant that the meanings should be swapped intelligently in the PEP in such a way that the explanatory text be altered accordingly. Paul From emile at fcfw.fenx.com Mon Jul 9 18:14:32 2001 From: emile at fcfw.fenx.com (Emile van Sebille) Date: 9 Jul 2001 17:14:32 -0500 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Jul 9) Message-ID: <53CA4EA8708778D2.8E09243C87EBEA9D.FE6FA409DB77D7BE@lp.airnews.net> Pythonic Quote of the Week... The existence of rapid development interpreters like Perl and Python, combined with a wide array of modules providing quick interfaces to various protocols, servers, and functionalities, heralds the beginning of *real* rapid application development. The long delayed promise is finally a reality. This new ability provides a great revenue model for the small, independent software developer, as well as the employee who loves to get in, make a mark, and go on to the next project. It yields cost savings, revenue increases, and better designed software to corporations. - Steve Litt http://www.troubleshooters.com/tpromag/200101/200101.htm If you need a patch to get win32ras working on win9x, Les Schaffer has one you can help him test. http://groups.google.com/groups?ic=1&q=msgid:1f7ektcggljf59ab7e4aj7mf7fg5ujot96 at 4ax.com Dave Cole makes a sequence-to-CSV tool available. Too bad the one I have to write this week isn't in Python... http://groups.google.com/groups?ic=1&q=msgid:m34rst3rt1.fsf at vole.object-craft.com.au On the distributed extension/module front, Paul Prescod shows us how ActiveState uses pyppm to install modules. http://groups.google.com/groups?ic=1&q=msgid:mailman.994368791.9779.python-list at python.org ... and imagines how easy it may someday be. http://groups.google.com/groups?ic=1&q=msgid:mailman.994370230.11280.python-list at python.org ... while Bruce Sass suggests we take a closer look at adapting the Debian package manager apt - Advanced Package Tool. http://groups.google.com/groups?ic=1&q=msgid:mailman.994541056.31455.python-list at python.org Alex Martelli points out a *fast* way to extract the phone number from a formatted string. http://groups.google.com/groups?ic=1&q=msgid:9i2jv703cm at enews2.newsguy.com Martin von Lewis responds to a laundry list of valid quibbles to be found in the standard library. http://groups.google.com/groups?ic=1&q=msgid:j4wv5suay4.fsf at informatik.hu-berlin.de ... and Carlos Ribeiro suggests a new PEP to set standards for additions to the Library. http://groups.google.com/groups?ic=1&q=msgid:mailman.994034642.25601.python-list at python.org In the Current Events column: While the Fourth was celebrated in the States, in France freedom was celebrated differently. The Python Track at the Libre Software Meeting started July 4th, and we're waiting to hear how the European Python Meeting went last weekend as part of the larger LSM get together. Watch for news. http://lsm.abul.org/program/topic19/ ... and now for something entirely different - ehh, maybe not. But, join Greg Ward over the next two weeks as Monty Python hits the big screen in Montreal. http://groups.google.com/groups?ic=1&q=msgid:mailman.994322041.31501.clpa-moderators at python.org Gerhard Haring wants to put a Python team together for 72 hours of non-stop fun competing to win the International Functional Programming Contest. http://groups.google.com/groups?ic=1&q=msgid:slrn9k9hbd.8uh.gerhard.nospam at lilith.hqd-internal ... See the contest homepage for details. Prizes are offered! Win bragging rights! http://cristal.inria.fr/ICFP2001/prog-contest/ Jason R. Mastaler releases the next version of Tagged Message Delivery Agent (TMDA), a Python application for qmail systems designed to significantly reduce the amount of SPAM you get. http://groups.google.com/groups?ic=1&q=msgid:mailman.994378561.4870.clpa-moderators at python.org C. Laurence Gonsalves points us to a warning about Microsoft's new OS, XP. It looks like deja vue all over again. Couldn't they just as easily have used dongles? ;-) http://groups.google.com/groups?ic=1&q=msgid:slrn9kakd8.v4j.clgonsal at keeshah.penguinpowered.com To gain an appreciation of just how hard Python authors have worked and what they've gone through, Chris Barker points us to Philip Greenspun's story on writing a dead-trees computer book. As a result, AMK's book is not due out soon. http://groups.google.com/groups?ic=1&q=msgid:3dofqzqbvo.fsf at ute.cnri.reston.va.us Kragen Sitaker warns that exec and eval are an easy way to write code that works some of the time and breaks in spectacular and completely unexpected ways. http://groups.google.com/groups?ic=1&q=msgid:XZD%256.19931$zT1.1101722 at e420r-atl3.usenetserver.com Doug Fort shares a pattern for breaking out of threads. http://groups.google.com/groups?ic=1&q=msgid:3b44660f_2 at news5.uncensored-news.com Paul Prescod introduces PEP-261 promoting support for wide unicode characters. http://groups.google.com/groups?ic=1&q=msgid:mailman.994017483.31644.python-list at python.org Mike Fletcher adapts Ka-Ping Lee's pydoc for use as a Package Documentation Generator. http://groups.google.com/groups?ic=1&q=msgid:mailman.994245607.15064.python-list at python.org Bernhard Herzog updates Sketch 0.6.12 - A vector drawing program, and recommends that users of 0.6.10 & .11 upgrade. http://groups.google.com/groups?ic=1&q=msgid:mailman.994378561.4871.clpa-moderators at python.org David Goodger provides a quick rundown of non-Zope templating alternatives. http://groups.google.com/groups?ic=1&q=msgid:B76693CB.13B8D%25dgoodger%40bigfoot.com Tom Malcolmson releases pySTL, a Python extension that exposes the C++ STL for use from Python. http://groups.google.com/groups?ic=1&q=msgid:hin17.110546$Mf5.30282205 at news3.rdc1.on.home.com Levente Sandor finds a zip file handler lurking in wxPython. http://groups.google.com/groups?ic=1&q=msgid:_eZ%256.4201%24Kf3.33223%40www.newsranger.com Those with database related questions were adequately answered. Two posts stand out: in one, Armin Steinhof provides us with a list of Python related database resources. http://groups.google.com/groups?ic=1&q=msgid:9hphiu0dks at drn.newsguy.com ... and then Gerhard Haring points out that he's the editor of a Python Database resource location site and asks for missing locations to be added. http://groups.google.com/groups?ic=1&q=msgid:slrn9k0olm.pc.gerhard.nospam at lilith.hqd-internal --LOL on c.l.py: bdfl: I'd say it's too little value for too much disturbance (a new keyword). : given the amount of other potentially disturbing stuff going into 2.2, I doubt anyone would notice... ======================================================================== 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 wheelege at tsn.cc Sat Jul 21 21:45:44 2001 From: wheelege at tsn.cc (Glen Wheeler) Date: Sun, 22 Jul 2001 11:45:44 +1000 Subject: Here's a puzzle... References: <20010721195640.15632.00000532@ng-mh1.aol.com> Message-ID: <009401c11250$06166860$0200a8c0@ACE> > I'm trying to split the following string called data into four variables: > > :Angel PRIVMSG Wiz :here is my message! > > Surely you could just use string.split, then chop off the colon(s)? Of course that will only work if your given data is consistent, but if you were going to do slices, it probably is. Good luck, Glen. From sholden at holdenweb.com Sun Jul 29 21:17:52 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sun, 29 Jul 2001 21:17:52 -0400 Subject: Eliminating upgrade risk References: <3B5FAD11.FB9D737E@engcorp.com> Message-ID: "John Roth" wrote in message news:tm336a7vjqjq5f at news.supernews.com... > > "Peter Hansen" wrote in message > news:3B5FAD11.FB9D737E at engcorp.com... > > John Roth wrote: > > > > > > After enduring the PEP 238 threads for far too long, as well as other > > > threads, I've come to the conclusion that Python is simply too unstable > > > for real use. > > > > Do you really mean "is" too unstable, or you mean it looks like it > > "might be" unstable, solely because of the proposals about changing the > > way the / operator works? > > I mean is. Notice that I said "among others," therefore PEP 238 was > **NOT** the sole proposal involved. > And the breakages you complain about are ... ? > > I've used Python for about a year and a half in dozens of practical > > areas in industry. I consider it *bar none* the most stable language > > I've ever used. Not only with respect to the stability of the > > applications I write, but also the runtime (I can hardly recall a crash, > > although I'm sure I've had a few when using calldll around third-party > > DLLs) and definitely *even the language definition*. > > Runtime stability was not the issue. That's a given before I even start > evaluating. And I don't consider the existing problem with Win 9x > console mode and Tkinter to be a point in Python's favor. > Excuse me. Are you saying that you don't want any new features in the language even if your existing programs continue to operate in a perfectly satisfactory manner. From my personal experience in over thirty years of software development I cannot remember a single language environment where so much care was taken to minimize the effect of language changes on existing programs. I wasn't entirely happy about PEP 238 originally, but the approach now proposed is definitely preferable to the usual commercial approach, which basically says: "You've upgraded for the new features, now fix all that we broke in your programs". > > Changing from 1.5.2 to 2.1 required us to do, let me see: nothing! > > I reviewed the list of changes, predicted we would not be impacted, > > and so far (after several months of ongoing development and continued > > use of our many utilities and applications) I've been proven correct. > > Many shops want something a little more concrete than a statement > by the top technical expert. A compatibility scan tool would be > appreciated. > And I am reasonably sure that one will appear without my having to do anything about it. But, of course, you must be *buying* your Python. I mean, if you were getting it for nothing, like I do, your demands would surely not be so peremptory. > > So I'm guessing you really just mean that this PEP 238 proposal > > is scarey. I agree, to the extent that code breakage is never nice > > to contemplate, but with the ongoing consideration being given to the > > issue by the developers, I'm reasonably satisfied that even this > > drastic change will end up having relatively little effect on my > > opinion of Python's stability. Planning over two years in > > advance and guaranteeing the breakage will only occur when > > a major upgrade (Python 3.0) is released is pretty much the > > best you could hope for from any language. After all, by convention > > major upgrades are where you are supposed to *expect* code > > breakage. > > That last sentence is what is scarey, not PEP238 or any of the > other specific proposals. There's an endemic mindset in the xNIX > community that simply doesn't understand the risk aversive behavior > of many of the large shops. If compatability isn't guaranteed, then > an upgrade is a project - which has to be scoped, justified, planned, > and then prioritized with all the rest of the projects. > Ah, I see. You don't use Microsoft tools or languages. Have you *any idea* what the forthcoming transition to VB.Net is going to do the the millions of lines of code currently written in VB? And do you know what Microsoft's answer to those who can't, or don't want to, upgrade is? "Run your applications as unmanaged code." Which is to say, forego most of the benefits of the .Net environment. > > > Hopefully, this is going to provide more food for thought than fuel for > the > > > flames. > > > > I hope you don't consider this a flame. But I'm not responding to > > the suggestion of "required" other than to say I don't think it's > > really necessary (because I don't think it's really necessary... > > as should be evident from the above). > > I think we're going to disagree on this one... > That may be so, but please tell us why. What broke, when? regards STeve -- http://www.holdenweb.com/ From chris.gonnerman at newcenturycomputers.net Mon Jul 9 01:26:49 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Mon, 9 Jul 2001 00:26:49 -0500 Subject: license suggestions? References: <20010708223109.O93454-100000@open-systems.net> Message-ID: <010f01c10837$c2a68140$0101010a@local> ----- Original Message ----- From: "Chris Watson" > [ kosh wrote: ] > > Also no one can make your code GPL. Your code is always under the license > > you released it under. However the GPL would make the entire collection GPL > > if GPL code were released with it. That really is no different then > > including BSD code in a closed source product since the closed source > > license takes precedence. > > That is where you are wrong. If someone either A) uses my code in a GPL > app the entire app is GPL'ed *including* my code. Or B) someone can just > flat out put the GPL on top of my code *HAD* my code been licensed with > only clause 1 and 2. The BSDL does *not* say you cannot place further > restrictions on it. Thats the whole point of BSDL. Do whatever you want > with it just dont sue me (the author) if you put it in your pace maker and > you die the next morning. Wrong. The right to create derivative works does not include the right to change the license. Note that I am not a lawyer, and this is based on my layman's understanding of contract law, but this has been brought up so many times I looked into it. The BSDL doesn't *have* to mention that "further restrictions are prohibited" since that is the default. Suppose that Mr. W creates a marvelous piece of software and places it under the BSDL. Mr. G sees it, finds some component parts useful, and integrates them into his new app which he places under the GPL. Now Mr. K comes along and finds Mr. G's app. Mr. G could not rightly and/or legally change the licensing of the components he borrowed from Mr. W, and further as the BSDL requires the original author's identity to be revealed, Mr. K could bypass Mr. G and contact Mr. W directly in case of confusion in this matter. Mr. G's app IS under the GPL, but the components (individual source files no doubt) written by Mr. W will still have the BSDL license at the top (unless Mr. G has violated the law, which of course is always possible regardless of license). For Mr. K to avoid GPL "contamination" he would have to carefully extract only the BSDL parts *or* go back to the original software distribution from Mr. W. The GPL states how the creator of derivative works must behave. If the creator of the derivative work cannot obey both the GPL and the law at the same time, the law takes precedence always. Watson, I understand that you hate the GPL. By now the entire Python community is well aware of that; you have called me stupid in this public forum before and may well do so again. I am no fan of Stallman, although in principle (but not in practice) I agree with him. By "not in practice" I mean that I don't make it my holy war to fight for free software (per his definition) but I certainly use and appreciate it. The main reason you hate it seems to be that you have seriously overestimated the power that the license gives to others. No matter what I or anyone else wants to do, without your approval I can't change the license of your code. In the aggregate with GPL code, the aggregate must be distributed as if the GPL covered the whole thing, but that aggregation still doesn't change the license of non-GPL code in "the mix." Further, if the license of the non- GPL code is GPL-incompatible you simply can't legally distribute the aggregation at all. From whisper at oz.nospamnet Tue Jul 3 09:05:18 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 3 Jul 2001 13:05:18 GMT Subject: Python for air traffic control? References: <9hlfbn$6ok$1@nereid.worldonline.nl> <9hrj3q$cj1@news1.gtech.com> Message-ID: <9hsfue$oqv$1@216.39.170.247> In article <9hrj3q$cj1 at news1.gtech.com>, peter.milliken at gtech.com says... > Of course, I could at this point say I would never venture into air space > controlled by such as system, but I know it would never get off the ground > (so to speak :-)) because to do it in Python would mean it would never pass > acceptance testing - sure you could code it just as fast (if not faster) > than most other languages used for this application area but you would be in > the test phase forever - or at least until the customer cancelled the > contract :-). So keep dreaming :-) > > Peter You perhaps feel safer with the existing system using left over 50's generation military radars, _ancient_ IBM "mainframes" that are probably less powerful then a pocket calculator that has to be manually cooridinated by PHONE? Some ATC facilities have been temporarily shut down because the burn-out obsolete discrete transistor they needed to function couldn't be located - no, this is not a joke! In the last year or so, all flights between O'Hare (Chicago) and DIA (Denver) had to be delayed because Chicago lost phone service due to a cable being cut and they couldn't relay departure information. FAA "controlled" airspace is a joke and they've spent large fractions of a billion (or more) to upgrade and have by and large not succeded yet on a national scale. The Canadians privatized their national air traffic control a few years ago and oh my! the planes RUN ON TIME! Takes all kinds I guess. Dave LeBlanc From aleaxit at yahoo.com Wed Jul 18 04:08:45 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 18 Jul 2001 10:08:45 +0200 Subject: OO misconceptions References: <3B55017A.A90CB816@engcorp.com> Message-ID: <9j3g6c02l65@enews4.newsguy.com> "Tim Hammerquist" wrote in message news:slrn9la9o0.vj8.tim at vegeta.ath.cx... ... > Actually, I have a snippet of code I'd love to be able to convert to > Python. The only thing is I can't find a Python equivalent for Perl's > record separator variable ($/). This is from 'Perl Cookbook' (ORA). Have a look at my recently-posted recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66063 "Read a text file by-paragraph". It may need adaptation (e.g. if you need to be able to read empty 'paragraphs', use separators that are not whole lines, &c) but I hope the basic idea is sound. Maybe something like that might be integrated in a future version of standard module fileinput...? If the file you're reading is not TOO huge, and you don't care about implicit suppression of empty paragraphs (which Perl, I believe, only supplies when $/ is ''), much simpler solutions would be possible -- down to the simplistic case of: def Paragraphs(fileobject, separator='%%\\n'): return fileobject.read().split(separator) and of course this is a problem that cries out for generators, so Python 2.2 should offer better ways to frame solutions. Alex From guido at digicool.com Mon Jul 9 11:03:12 2001 From: guido at digicool.com (Guido van Rossum) Date: Mon, 09 Jul 2001 11:03:12 -0400 Subject: Bug in rfc822 In-Reply-To: Your message of "Mon, 09 Jul 2001 09:56:17 CDT." <15177.50705.483826.728871@beluga.mojam.com> References: <2ih27.49242$he.3402812@e420r-atl1.usenetserver.com> <15177.50705.483826.728871@beluga.mojam.com> Message-ID: <200107091503.f69F3CQ27257@odiug.digicool.com> > Guido> I think Barry's mimelib may have a replacement already. > Guido> http://mimelib.sourceforge.net/ [Skip] > The astute observer would be tempted to ask why Barry hasn't been able to > sneak mimelib into the core yet: > > >>> import mimelib > Traceback (most recent call last): > File "", line 1, in ? > ImportError: No module named mimelib This will work in 2.2, no worry. > I won't ask however, as I don't want to show up on the PSU's radar screen. > Has anyone seen Barry recently? > > Skip Barry? Who's that? --Guido van Rossum (home page: http://www.python.org/~guido/) From clpy at snakefarm.org Thu Jul 5 17:27:59 2001 From: clpy at snakefarm.org (Carsten Gaebler) Date: Thu, 05 Jul 2001 23:27:59 +0200 Subject: Question about scope References: <3B44D696.61A8B915@tundraware.com> <3B44D89A.1DF28AD9@tundraware.com> Message-ID: <3B44DBDF.41C4CF2F@snakefarm.org> Tim Daneliuk wrote: > I guess what I want to know is when globally declared objects are seen inside a function, class, or > block, and when they must be explicitly declared as being global. You can always 'read' a global variable in a function, e.g. g = 0 def func(): print g func() prints '0'. If you want to modify a global variable inside a function you need to declare it as global: g = 0 def func(): global g g = 1 func() print g prints '1'. Otherwise an assignment inside a function will create a new variable in the local namespace: g = 0 def func(): g = 1 print g prints '0' because g=1 only exists inside func(). Hope it helps. cg. From peter at engcorp.com Thu Jul 26 21:02:51 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 26 Jul 2001 21:02:51 -0400 Subject: Operator symbol for "nb_intdivide" References: <8i287.3114$oh1.1140514@news2.rdc2.tx.home.com> Message-ID: <3B60BDBB.B17D3375@engcorp.com> Rainer Deyke wrote: > My vote (if I had one): keep '/' for integer division and introduce a new > symbol for floating point division. > > Justification: > > - Everybody uses integers, but not everybody uses floats. Therefore, if > '/' is used for integers, then fewer people will have to change their code. This suggests you pretty much missed the past ten thousand posts in this newsgroup! :-) The whole point of the change is roughly that many people who _do_ use integers, without knowing much about this whole issue, are more likely to expect "true" division rather than the classic behaviour. Yes, there will be code breakage. The decision appears largely to be between _inevitable_ code breakage for a short period and _invisible_ bugs for eternity (that being how long we expect Python to be used :-). > - The short and pretty modulus operator should be matched with a short and > pretty integer division operator. // is growing on me. I can survive without div and mod, I think. I would have agreed with you a few days ago, but my aesthetic sense is adapting rapidly here, as inevitability proclaims itself... > - It makes floats more difficult for newbies. This is a good thing, since > floats are dangerous. Floats are probably not that dangerous for newbies. Newbies (in the sense I use the word) tend to write toy applications, or not use floats at all (as in "everybody uses integers"). I think one could argue persuasively that this change, proposed perhaps somewhat with newbies in mind, *reduces* the danger to them. But I don't think it's really newbies in the usual sense who are the trigger for this change. It appears to be more the casual users, who might not be programmers per se (newbie or otherwise), but people in other fields (say, a lab technician, or a chemistry student) who would attempt to use Python for some simple mathematical work and get mysterious (or unnoticed!) totally inaccurate results when they enter some data as an integer and try to divide the "expected" way, and get data loss as a result. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From jkraska1 at san.rr.com Fri Jul 20 13:14:03 2001 From: jkraska1 at san.rr.com (Courageous) Date: Fri, 20 Jul 2001 17:14:03 GMT Subject: Language change and code breaks References: <3B5863EE.F9047098@Lugoj.Com> Message-ID: >> If you use this a lot (message = Message() etc.) your code is less >> readable than it should be. >Um, you've got that precisely reversed! If I see "message" anywhere in my >code, I know immediately that it is an instance of the class Message. I quite agree with this. C// From mirko.liss at web.de Tue Jul 10 14:03:08 2001 From: mirko.liss at web.de (Mirko Liss) Date: Tue, 10 Jul 2001 20:03:08 +0200 Subject: license suggestions? In-Reply-To: References: Message-ID: <20010710180310.3C7C3510.NOFFLE@niccolo.ke4.de> On Tue, 10 Jul 2001, Lee Morgan wrote: > Forgive my naivety, but ... > > Has anyone proposed the idea of having a timebomb license? ... > innovation? ie You get 2 years to recoup your investment and then the > license drops to GPL or something. There have been propositions like that concerning european software patents, but not licenses. regards, Mirko Liss From borcis at geneva-link.ch Mon Jul 30 16:19:45 2001 From: borcis at geneva-link.ch (Borcis) Date: Mon, 30 Jul 2001 22:19:45 +0200 Subject: Deposing Dictators References: <9jmjne$q54$1@wisteria.csv.warwick.ac.uk> <3b602daf.1623450@nntp.sprynet.com> <$dK+wKA$tZY7Ewin@jessikat.demon.co.uk> <3b61a98d$0$11917@wodc7nh0.news.uu.net> <3B61B01F.6C6B2B5D@Lugoj.Com> <6c8b7eb9.0107271358.4783d9c1@posting.google.com> Message-ID: <3B65C161.12003D86@geneva-link.ch> Dirck Blaskey wrote: > (...) > > Useful programs aren't discarded so fast as development fashions and > > religions. (...) > Inertia in the software world is a huge force, and always > to be fought tooth and nail, because generally what Inertia means is: > "Just live with our mistakes because we can't afford to fix them." > This is an extremely depressing state. You might find it comforting to consider the trojan in the Bible - e.g. the original sin : the injunction not to acquire morals from a supernatural source... I guess it must be about 3k years old. Now that's inertia. Boris Borcic From akuchlin at mems-exchange.org Fri Jul 6 12:34:11 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 06 Jul 2001 12:34:11 -0400 Subject: Python: Database to Web Part II References: <5174eed0.0107060820.ff90805@posting.google.com> Message-ID: <3dg0caqanw.fsf@ute.cnri.reston.va.us> web2ed at yahoo.com (Edward Wilson) writes: > I have been hoping that someone else would write Oracle, DB2, and SQL > Server drivers/modules for Python, so I wouldn't have to. Mostly If you type "python database" into Google, the second link you get is to http://www.python.org/topics/database/; the "Modules" page has links to DB/2 and ODBC modules for Python. This is a silly discussion, because such modules *do* exist, as everyone is quite well aware, and have existed for some time. You simply haven't been looking very hard, or perhaps at all, for them. --amk From jwbaxter at spamcop.com Wed Jul 25 02:05:28 2001 From: jwbaxter at spamcop.com (John W. Baxter) Date: Tue, 24 Jul 2001 23:05:28 -0700 Subject: PEP0238 lament References: Message-ID: <240720012305282375%jwbaxter@spamcop.com> In article , Justin Sheehy wrote: > "Tim Peters" writes: > > > Good thing you stopped before mentioning Perl (yes, 1/2 is 0.5 there) > > Sure, but 1 == "1" there as well. > > Ugh. So is "spam" == "ham" --> true I've done that more that I like to admit, although fortunately the -w flag keeps me from finding those by long distance at 3AM. --John From richard at bizarsoftware.com.au Sun Jul 22 21:27:54 2001 From: richard at bizarsoftware.com.au (Richard Jones) Date: Mon, 23 Jul 2001 11:27:54 +1000 Subject: Pedants R us (was RE: Language change and code breaks) In-Reply-To: References: Message-ID: <200107230125.LAA04615@goanna.adroit.net> On Mon, 23 Jul 2001 11:21, Delaney, Timothy wrote: > Nah - all the best solutions are worked out in the shower. > > I am currently campaigning for all programmer's cubicles at my place of > work to have showers installed. I predict that productivity will increase > 5-fold. There's gotta be a thesis in this, somehow. Hmm, I've been holding off doing postgrad 'cos I couldn't think of a decent thesis. Might just go have a shower and not think about it... Richard -- Richard Jones richard at bizarsoftware.com.au Senior Software Developer, Bizar Software (www.bizarsoftware.com.au) From rwklee at home.com Mon Jul 9 22:11:28 2001 From: rwklee at home.com (Rick Lee) Date: Tue, 10 Jul 2001 02:11:28 GMT Subject: Integrating SimpleHTTPServer into asyncore References: <3B491961.12A83FE5@alcyone.com> <9icj7b$8df$1@dahlia.singnet.com.sg> Message-ID: <3B4A644F.895FC4B8@home.com> This is a slightly different question about Medusa. Is there a way to dynamically add/remove server IP addresses to/from Medusa as it is running? - Rick Lee rwklee at home.com Ng Pheng Siong wrote: > According to Erik Max Francis : > > Is there a standard way to integrate SimpleHTTPServer (and related > > classes) into the asyncore poll loop, or is it just the rather obvious > > process of creating a dispatcher that containers a SimpleHTTPServer and > > delegates all the relevant asyncore methods to SimpleHTTPServer? > > Just use Medusa's http_server. Medusa does HTTP/1.1 with persistent > connections; SimpleHTTPServer (really BaseHTTPRequestHandler) does > HTTP/1.0 only. > > Some refactoring of Medusa and/or BaseHTTPRequestHandler to simplify > writing HTTP method (GET, POST, etc.) handlers that are portable to both > would be nice; e.g., send_header(), end_headers() versus Medusa's > http_response object. > > -- > Ng Pheng Siong * http://www.post1.com/home/ngps > > Quidquid latine dictum sit, altum viditur. From sholden at holdenweb.com Sun Jul 29 23:47:05 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sun, 29 Jul 2001 23:47:05 -0400 Subject: Complaint received, email address removed References: Message-ID: "PostMaster General Anti-Spam Center" wrote in message news:mailman.996461576.28755.python-list at python.org... > > Dear email recipient, > > > Thank you for taking the time to make a report to the PostMaster > General Anti-Spam Center. > [ ... ] Sorry about this unexpected result of my attempts to stop the Quacko nuisance on c.l.py. It seems as though this occasional nonsense will fade into insignificance if "Bruce Hendricks" isn't stopped soon. I hope they string him up by his naughty bits. regards Steve -- http://www.holdenweb.com/ From mwh at python.net Wed Jul 4 07:21:00 2001 From: mwh at python.net (Michael Hudson) Date: 04 Jul 2001 12:21:00 +0100 Subject: sys.stdin.read() HELP! References: <3B42B7F0.50B624BD@umdnj.edu> Message-ID: Andrey Revyakin writes: > I have a cgi script which reads XML data from a FLASH5 movie. The script > reads data into a string like this: > > text = sys.stdin.read() > > After I moved my scripts from a machine with python 1.7.2 to to a one 1.5.2, I presume? > with python 2 .0, I started getting the following error: > > text = sys.stdin.read() > IOError: [Errno 9] Bad file descriptor > > WHAT THE #$^ does that mean??? It means sys.stdin isn't attached properly. This is unlikely to be Python's fault, I'd have thought. Can you shed a few more details as to the environment you're working in? Maybe somebody who has experience in these things will be able to spot the mis-config (not likely to be me). Are you sure the version of Python is the only difference between the two machines? 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 nospam at mega-nerd.net Fri Jul 13 07:16:45 2001 From: nospam at mega-nerd.net (Erik de Castro Lopo) Date: Fri, 13 Jul 2001 11:16:45 GMT Subject: PyDNS? References: <3B4ECBE0.96898063@stroeder.com> Message-ID: <3B4ED889.469D42D5@mega-nerd.net> Michael Str?der wrote: > > HI! > > I wonder if there's interest to maintain the DNS module formerly > written as demo by Guido van Rossum. Anthony Baxter has a modified > version of it under http://www.interlink.com.au/anthony/dns.tar.gz. > I've added support for SRV RRs and I'm thinking about adding caching > support. I was looking for exactly that module just now and was about to post a question a question to the group asking if anyone had a copy. Thats should tell you that there's usually at least one person looking for this thing at any given moment. Erik -- ----------------------------------------------------------------- Erik de Castro Lopo nospam at mega-nerd.net (Yes its valid) ----------------------------------------------------------------- "It's far too easy to make fun of Microsoft products, but it takes a real man to make them work, and a god to make them do anything useful" -- Anonymous From ajs at ix.netcom.com Tue Jul 24 23:18:00 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Tue, 24 Jul 2001 23:18:00 -0400 Subject: PEP0238 lament Message-ID: <003a01c114b8$6ad3fbe0$a9e1fea9@carol> Guido writes - >I should add that I never meant that the problem was only >important for novices or in an educational setting (I only meant this >as an example of the kind of problems division crates). Some folks >(like Arthur Siegel) have used a contrary novice's or educator's >experience as a counter-argument to this. But they fall in the same >trap as most of the other proponents of the status quo: because they >don't use floats much, they don't care that floating point arithmetic >is broken. I'm going to use the cover Stephen Horne has provided me to comment - no longer fearing that I might be the most manic pain in the ass on the thread. Simply to say that Guido has no basis to know much about my use of floats. And that in fact I consider my argument for the division operator "status quo" no better than a nit of the same ilk as the CP4E argument for the change. Had always held out the hope and possibility that there was a more powerful argument justifying the change. Hopefully Guido has delivered it to the satisfaction of those in a position to judge the strength of his reasoning here. I am not. ART From rjhansen at inav.net Tue Jul 3 06:10:47 2001 From: rjhansen at inav.net (Robert J. Hansen) Date: Tue, 03 Jul 2001 10:10:47 GMT Subject: Eiffel better than Python ? References: Message-ID: <3B419AAD.4020502@inav.net> > I have read the following book which gives C/C++ heavy bashing Well, the good news is C and C++ both deserve heavy bashing. Then again, so does Java, so does Ada95, so does Eiffel. If I had a nickel for every time I've seen someone say "solve the software crisis--ship things on time, make reliable software, etc.--just by using Foo language", well, I'd be sipping mai-tais on a South Pacific beach instead of posting to USENET. > Should I stop using Python and jump on Eiffel wagon ? Do you *like* Python? If so, then keep using it. If you don't, then find a language you like. It really is that simple. :) From bill-bell at bill-bell.hamilton.on.ca Mon Jul 16 10:09:01 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Mon, 16 Jul 2001 10:09:01 -0400 Subject: Partition Problem In-Reply-To: <995278357.289.39609.l10@yahoogroups.com> Message-ID: <3B52BD3D.27318.349EB20@localhost> > Combinatorial Algorithms by Kreher and Stinson ... is all coded in C! And you'd think people smart enough to write a book like that would have the sense to use Python. From steve at lurking.demon.co.uk Wed Jul 25 04:04:21 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Wed, 25 Jul 2001 09:04:21 +0100 Subject: A modest PEP0238 suggestion References: <3b5c6e08.27535083@aplnews> <9jjk9g$8tk$1@newsy.ifm.liu.se> Message-ID: <69vsltslttpgrpfbiqkq4kqmaf5aiitgrp@4ax.com> On Wed, 25 Jul 2001 05:12:17 GMT, Guido van Rossum wrote: >paul at svensson.org (Paul Svensson) writes: > >(Thanks for your nice table, BTW.) > >> The only choices that make sense to me here are, either we break stuff, >> or we do nothing. Either way, we'll most likely have to revisit the >> issue if/when syntax for rationals is to be added to the language. > >Actually, adding rationals can be done almost entirely without >breaking code... That is, *if* we adopt PEP-238 now. Changing 1/2 >from returning a float to returning a rational won't have to break >code, since the mathematical value of the result is the same. >Changing it from returning 0 to returning a rational isn't any easier >than changing it from returning 0 to returning a float -- exactly the >same places will have to be changed. > >If you're for rationals, you're for PEP-238. Nope. I don't mind rationals, but they are a continuous measure. If integer calculations are going to be allowed to return rationals then we need separate integer types for integer-within-real and discrete-integer. I'd want to see... >>> print 10 / 4 2 >>> print 10.0 / 4 2.5 >>> print 10R / 4 5/2 From mikeb at mitre.org Tue Jul 3 11:47:55 2001 From: mikeb at mitre.org (Mike Brenner) Date: Tue, 03 Jul 2001 11:47:55 -0400 Subject: I'd like to Contribute to an Open Source Project Message-ID: <3B41E92B.4009B1C5@mitre.org> Oleg Broytmann said: "I have some time on my hands. It seems like a good opportunity to do some noncommercial Python programming. Like my hero TV's Frank on MST3K, I'm more suited to be the lackey than the mad scientist." These 3 suggestions could help many Python Open Source projects, because they would show how to use some of Python's advanced features. 1. A graphics demonstration with wxPython (that is, wxWindows using Python) Example Needed: A graphics screen where we can draw lines and circles, and then select an area on the screen for cutting to and pasting from the CLIPBOARD. Example Needed: Bit Blit, which lets us move a rectangle on the screen (and everything in it) very quickly. 2. Key-down, Key-up interrupt for the Keyboard: Example Needed: An organ which plays a tone for the keys on the keyboard. Rationale: (1) To program games, (2) to comply with handicap requirements, (3) to move bit blits around a graphics screen (4) to make an organ that plays chords (5) to gain access to the SHIFT-INSERT combination (6) to use all keys as hot keys, when desired. 3. A simple server page using Unicode Example Needed: The program would put up a web page that asked you to click what language you wish to speak and to ask a question in that language. The choices would be Russian, English, Chinese, Japanese, Hebrew, Arabic, Spanish, Hindi, Armenian, and one or two others. Instead of answering the question, let the application simply print a screen in the selected language, which says "Here is your question: " followed by the question. Rationale: Python handles some Unicode and the Internet handles some Unicode, but a fully working example would be very nice to sell Python to eCommerce sites. From peter at engcorp.com Sun Jul 29 13:22:46 2001 From: peter at engcorp.com (Peter Hansen) Date: Sun, 29 Jul 2001 13:22:46 -0400 Subject: Slightly off-topic... (sending HTML data through a Python socket) References: <3B643B5D.E62C6669@telocity.com> Message-ID: <3B644666.53047503@engcorp.com> Adonis Vargas wrote: > > I am attempting to send HTML data back to a browser which connected to X > port. I have goen over the the HTML RFC and just can not get it to work. > What I am attempting to do is send a redirect back to the browser. So > far I have something as follows: > > c.send(""" > > > Content=0;Host=\"http://www.python.org/\">" > > > """) I think you should have quotation marks around the content of the "Content" tag, but I don't know if that would help. You should also always have a tag, as far as I recall, in the <head> element, although I'm sure that wouldn't help either. More importantly, there are many reasons why this might not work, none of which involve the form of this part of the output. Servers have to send back additional information to satisfy the requirements of the HTTP protocol, but you appear to be returning only HTML. Check the HTTP RFC if you have not. Better yet, use one of the Python library modules that already supports HTTP servers (like SimpleHTTPServer.py). If you posted a little more context I bet you'd get an answer that would help more. A more detailed description of the symptoms than just "can not get it to work" would also help us figure it out. (Mentioning your platform is often a good idea too, but in this case I'm guessing Python and your problem are both platform-independent enough that this isn't an issue.) Finally, have you tried *testing* this, rather than just "seeing if it works". In this case, the distinction would mean connecting with something like TELNET (with the output dumped to a file for posting here) and seeing what data is *actually* being returned from your server, rather than just running the browser and crossing your fingers. If you can't figure it out by using telnet, posting the full output here would go a long way to helping us help you. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From peter at engcorp.com Thu Jul 12 22:09:49 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 12 Jul 2001 22:09:49 -0400 Subject: Language change and code breaks References: <mailman.994958301.16016.python-list@python.org> Message-ID: <3B4E586D.35460F68@engcorp.com> pfenn at mmm.com wrote: > > Is there really much code that depends on 1/3 == 0 being true? Unfortunately, while code a chemist writes is very likely never going to rely on the current integer division behaviour, code written by those of us in computers who tend to work closely with the hardware (where we are constantly thinking in terms of bytes, words, signed and unsigned, memory locations, bits and nybbles, etc.) will fairly often write code which depends on the current behaviour. (By the way, no, we would never write 1/3 and expect 0, but 99% of the time we are not talking about constant expressions such as this... but you knew that.) I can't see a simple answer to this. It looks as though there are two camps, to both of whom it is absolutely essential that Python act in a specific way. And the two ways are completely incompatible. Doesn't that mean that the only solution that can be accepted without causing serious complications is to make the change, but clearly support a command line option (or some other configuration setting) to enable the current behaviour, so those who have depended on integer division can continue to run old code under the new engine without fear of breakage? (I know, it's not perfect, but with a little more design thought it can probably come pretty close. For example, code that might have to run on someone else's system, which might not have the correct setting for integer division, can use a sys.setIntegerDivision(1) call to force the desired behaviour. Or does this have to be on a module- by-module basis? Anyway, that's not my problem. :-) So, O' BDFL, why not take the most Pythonic approach and use a solution which *pragmatically* achieves a good practical balance but which causes purists always to feel a little uneasy and which can lead to perpetual discussion about "warts" and why other languages are better and.... ;) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From emile at fenx.com Thu Jul 12 14:17:14 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 12 Jul 2001 11:17:14 -0700 Subject: Language change and code breaks References: <mailman.994958301.16016.python-list@python.org> Message-ID: <9ikq7u$joi6c$1@ID-11957.news.dfncis.de> <pfenn at mmm.com> wrote in message news:mailman.994958301.16016.python-list at python.org... > <snip> > > Is there really much code that depends on 1/3 == 0 being true? I use it. I imagine that for as long as it's been that way, if everyone were constantly writing some form of float(x)/y or 1.0*x/y or x/7.0 all the time and never using is as integer math, it likely would have been changed long before I started with python... ;-) -- Emile van Sebille emile at fenx.com --------- From steve at lurking.demon.co.uk Mon Jul 23 18:23:34 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Mon, 23 Jul 2001 23:23:34 +0100 Subject: PEP0238 lament References: <3B5B3676.40F39389@alcyone.com> <eppstein-03540D.13070222072001@news.service.uci.edu> <mailman.995836120.7223.python-list@python.org> <vyIKbWAP62W7EwC+@jessikat.fsnet.co.uk> <9jg6ei$ges7$1@sky.inp.nsk.su> <23891c90.0107230118.752e3f00@posting.google.com> <u3tnlt0480u7o655p988bsr9p3vc1g14ee@4ax.com> <slrn9lp1ui.vp.Gareth.McCaughan@g.local> Message-ID: <bl7pltkl8bv0eecsfcr90v45hh0aek72u7@4ax.com> On Mon, 23 Jul 2001 21:23:46 +0100, Gareth.McCaughan at pobox.com (Gareth McCaughan) wrote: >Steve Horne wrote: > >> I've had idle thoughts for some time about a language that would allow >> you to define - within the language itself - the syntax and semantics >> for sublanguages. Only the lexical rules would be fixed, though there >> would need to be several built-in sublanguages - grammar and >> translation definition, simple compile-time imperative and simple >> run-time imperative being the obvious ones. The thought was originally >> provoked by wanting to support many different paradigms efficiently >> and concisely in the same language - if anyone comes up with a new >> paradigm, they just create a library that defines a suitable grammar >> and translation and, hey presto, anyone can use it without changing >> languages, and without discarding code written for other paradigms. >> >> It suddenly seems so much more like a practical idea. > >It's existed for years. It's called Lisp, and it's >the reason why Python is only the second best programming >language in the world <0.5 wink>. I've used it, and it *isn't* what I'm thinking of - I want a human readable language ;-) As the saying goes, Lotsof-Infuriatingly-Stupid-Parentheses. I'm thinking something that for the base languages specifies grammar in a YACC-with-common-behaviour-helpers kind of way, which uses a single imperative grammar, not too far from Python, but with two sets of semantics - one compile-time, one run-time. So you'd essentially define an simple grammar, and then define compile-time-translations into run-time-implementations for the semantics - and you'd be able to use tweaked or even completely different semantics for the same grammar if necessary. And once the basic sublanguages worked, new sublanguages could translate in stages through existing sublanguages - so if you want a Prolog-like sublanguage, you only need to translate it into the easiest existing library sublanguage for your logical language to represent - not *necessarily* straight to the imperative. The fantasy says that, with that done, the community will set up a small library for the useful paradigms, with perhaps semantics-selection options for really controversial stuff like division ;-) The only big worry in principle is that I think a more functional/logical style would be better for the compile-time language - easier to work with for translation tasks - but I don't want that in the default run-time sublanguage, yet I do want the compile-time and run-time languages to have the same syntax and logical semantics (only the execution time should change). Maybe I need to translate compile-time sublanguages as well. From twanvds at xs4all.nl Mon Jul 9 09:22:51 2001 From: twanvds at xs4all.nl (Twan van der Schoot) Date: Mon, 9 Jul 2001 15:22:51 +0200 Subject: HELP: socket.connect timeout Message-ID: <9icas4$lvp$1@news1.xs4all.nl> Hi there, How do I increase the timeout period on a socket.connect()? A peek in the source code of the socket object does reveal anything usefull. FWI: I'm using Python 2.1 from ActiveWare for WinNT (running on NT4.0SP6). thanks! best regards Twan van der Schoot From eppstein at ics.uci.edu Thu Jul 26 21:40:08 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Thu, 26 Jul 2001 18:40:08 -0700 Subject: Nasty typo in PEP 238 (revised) References: <cp4rrz5onj.fsf@cj20424-a.reston1.va.home.com> Message-ID: <eppstein-D847A7.18400826072001@news.service.uci.edu> In article <cp4rrz5onj.fsf at cj20424-a.reston1.va.home.com>, Guido van Rossum <guido at python.org> wrote: > Q. How do I write code that works under the classic rules as well > as under the new rules without using // or a future division > statement? > > A. Use x*1.0/y for true division, divmod(x, y)[0] for int > division. Especially the latter is best hidden inside a > function. You may also write floor(x)/y for true division if > you are sure that you don't expect complex numbers. Shouldn't this be float(x)/y ? I still don't like the phrase "true division", it implies a value judgement that quotients are somehow an inferior thing to want to compute. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From kens at sightreader.com Tue Jul 10 05:39:22 2001 From: kens at sightreader.com (Ken Seehof) Date: Tue, 10 Jul 2001 02:39:22 -0700 Subject: File processing References: <9id5p9$8r62@interserv.etn.com> <01b001c1091f$c9c74340$0e4ab43f@kens> Message-ID: <01d001c10924$345bf940$0e4ab43f@kens> Oops you need this: import os path = r'D:\Dev\junk' # put your directory here for fname in os.listdir(path): # list of files in your directory fname = os.path.join(path, fname) # add the directory to the file name f = open(fname, 'r') lines = f.readlines() # reads a list of lines f.close() f = open(fname, 'w') f.writelines(lines[1:]) # writes all but the first line f.close() ----- Original Message ----- From: "Ken Seehof" <kens at sightreader.com> To: <python-list at python.org>; "Chris McMillan" <christopherjmcmillan at eaton.com> Sent: Tuesday, July 10, 2001 2:07 AM Subject: Re: File processing > import os > > path = '/junk' # put your directory here > > for fname in os.listdir(path): # list of files in your directory > f = open(fname, 'r') > lines = f.readlines() # reads a list of lines > f.close() > f = open(fname, 'w') > f.writelines(lines[1:]) # writes all but the first line > f.close() > > > Now, be careful! This will remove the first line of every file > in the directory, including files you don't want to ruin. Back > up everything first! > > ----- Original Message ----- > From: "Chris McMillan" <christopherjmcmillan at eaton.com> > Newsgroups: comp.lang.python > To: <python-list at python.org> > Sent: Monday, July 09, 2001 2:01 PM > Subject: File processing > > > > Hello all! > > > > I'm trying to write a script that will open a file, delete the first line, > > and then save the file with the same name. Can someone please point me in > > the right direction? Thanks! > > > > Why am I doing this you may ask: I have tens of data files that I need to > > strip the first line before I can process it in Matlab. So, I dream of a > > script that opens every file in a directory, deletes the first line, ..... > > > > Thanks, > > > > Chris > > > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > > -- > http://mail.python.org/mailman/listinfo/python-list From philh at comuno.freeserve.co.uk Sat Jul 21 20:40:15 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Sun, 22 Jul 2001 01:40:15 +0100 Subject: Language change and code breaks References: <Pine.LNX.4.33.0107191316390.24983-100000@bms> <mailman.995571273.18192.python-list@python.org> <9j7gv8$9mg@dispatch.concentric.net> <cppuawfqbm.fsf@cj20424-a.reston1.va.home.com> <cwebster-2007011136180001@192.168.0.4> Message-ID: <slrn9lk87f.1rr.philh@comuno.freeserve.co.uk> On Fri, 20 Jul 2001 11:36:18 -0700, Corran Webster <cwebster at nevada.edu> wrote: > >sum = 0 >for n in range(N): > sum += n**2 > >but it is useful when translating a mathematical expression like: > > __ N-1 2 > \ n > /__n=0 > >into a Python program. A better translation might be: def fromto(f,t): return xrange(f,t+1) def sum(ar): s = 0 for i in ar: s += i return s #and then, it's just a one-liner: result = sum([n*n for n in fromto(0, N-1)]) -- #===== Philip Hunt == philh at comuno.freeserve.co.uk ======# Herbivore: effort-free public key encryption. See: <http://www.vision25.demon.co.uk/oss/herbivore/intro.html> ** First software release coming soon! ** From m.faassen at vet.uu.nl Fri Jul 20 20:06:00 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 21 Jul 2001 00:06:00 GMT Subject: Guido van Rossum is secretly Rick Moranis References: <mailman.995563592.3004.python-list@python.org> Message-ID: <9jah18$fqu$1@newshost.accu.uu.nl> PeterPanCrunchy at rebeccaphillips.com wrote: > I can prove that Guido van Rossum is secretly Rick Moranis. > Rick Moranis, movie star: > http://www.boxofficemania.com/actors/r/rick_moranis/rick_moranis.jpg > Guido van Rossum, Python inventor: > http://www.python.org/~guido/images/Guido at 200dpi.jpg ALERT ALERT ALERT to *ALL* PSU Operatives! Why did this message slip through our PSU Usenet Snipper? I just read this on a public Usenet feed! This is unallowable! People will be on to our conspiracy soon. I've been doing a good job defusing the rumors in the past, but if this keeps up we'll need the time machine *again* -- we'll stretch the space-time continuum so thin we don't even have to worry anymore about nanoviruses that eat our whitespace; it'll just spontaneously evaporate! The Rick Moranis thing was a level 5 secret, right up there with the identity of the fourth official bot. This is extremely serious! Ah... I just heard a worm took our Usenet Snipper offline temporarily. They've fixed it now, and we From sholden at holdenweb.com Tue Jul 3 09:52:24 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 3 Jul 2001 09:52:24 -0400 Subject: Python and DB support (was: Re: Is Python Dead?) References: <mailman.994135925.11224.python-list@python.org> Message-ID: <Y3k07.26347$he.1370115@e420r-atl1.usenetserver.com> You should investigate the dbtuple library. It allows you to simply describe the record sets returned by DB API compliantr modules so you can either: a) Refer to fields as attributes of the db tuple, or b) treat the db tuple as a dictionary and select fields a la ASP/ADO. If your colleagues think VBScript database access is easy they are clearly not pushing SQL to anywhere near its limits. Ask them how they would to the equivalent of the DB API's cursor.execute("SELECT f1, f2, f3 FROM table WHERE f4=? AND f5=?", (f4val, f5val)) I think you'll find it's more than a little tricky. Also, in VBScript, if rs is a recordset (with an implied current member), you have to access fields using rs("FieldName") This is a bizarre way to reference things by name. If your colleagues see this as natural then they have their Microsoft blinkers on. I have no objection to them preferring ASP/ADO, and there are some nice tools available which let you do some nifty things without having to hack too much source (as long as you can ignore the resulting code bloat). But Python is pretty good when it comes to databases, even without touching ADO. regards Steve -- http://www.holdenweb.com/ -- http://www.holdenweb.com/ "Roman Suzi" <rnd at onego.ru> wrote in message news:mailman.994135925.11224.python-list at python.org... > On 2 Jul 2001, David Bolen wrote: > > >Roman Suzi <rnd at onego.ru> writes: > > > >> However, my collegues were not satisfied with it. One somplain was that in > >> ASP/IIS it is "very easy" to receive a "recordset" from database and then > >> apply it in different situations in the ASP-page, because recordset is an > >> object and even subqueries could be made without quering DB again. > > > >Just curious, but did your colleagues try using Python's COM interface > >to ADO to retrieve an actual recordset object that they could > >manipulate the same in Python as in other ASP languages? > > Aha! Now I could understand what is the brake of Python library > development. Most of Python users are Windows users. And they > have COM for whatever is in their system. > > >At least under Windows, it would seem that having solid ODBC and COM > >support should pretty much cover in Python anything you'd do elsewhere. > > > >On other environments, direct support for a particular database is > >likely to be more desirable, as it's more typical in those > >environments, but as you've noted, there's a plethora of support > >modules for various databases - some at various levels. > > We mostly have Linux servers, so COM+ADO is no option. The point was not > to choose between Windows and Linux, ASP was choosen to serve particular > purpose, for the database already implemented in Microsoft land. > > >-- > >-- David > > Sincerely yours, Roman Suzi > -- > _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ > _/ Tuesday, July 03, 2001 _/ Powered by Linux RedHat 6.2 _/ > _/ "Paranoia is nothing to be afraid of!!" _/ > > From phd at phd.fep.ru Thu Jul 5 12:50:06 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Thu, 5 Jul 2001 20:50:06 +0400 (MSD) Subject: import syntax In-Reply-To: <994351494.3b4499864e286@webmail1.wm.edu> Message-ID: <Pine.LNX.4.33.0107052049200.22681-100000@phd.fep.ru> On Thu, 5 Jul 2001, Andrew Todd wrote: > This isn't terribly important, but wouldn't it be nice if > you could do the following... > > from module import a and b > > instead of having to write... > > from module import a > from module import b Have you ever read docs? from module X import a, b 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 Sun Jul 8 10:00:53 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 08 Jul 2001 14:00:53 GMT Subject: "has" Operator References: <Pine.LNX.4.30.0107080115240.17775-100000@rnd.onego.ru> <mailman.994543873.6493.python-list@python.org> <tkfa751vldoo66@news.supernews.com> <cpelrriogf.fsf@cj20424-a.reston1.va.home.com> Message-ID: <pIZ17.1995$z21.389304@newsc.telia.net> Guido van Rossum wrote: > Actually, Paul's proposal to write > > x has y > > instead of > > hasattr(x, 'y') > > has a nice Pythonic ring to it, and the fact that you have to use > quotes with hasattr() has always bothered me. well, you'd still need hasattr to deal with attr = "someattribute" if hasattr(myobject, attr): ... and is it really obvious why the following code doesn't work? attr = "someattribute" if myobject has attr: ... > right now, I'd say it's too little value for too much disturbance (a new > keyword). given the amount of other potentially disturbing stuff going into 2.2, I doubt anyone would notice... </F> From justin at iago.org Sun Jul 22 16:53:28 2001 From: justin at iago.org (Justin Sheehy) Date: Sun, 22 Jul 2001 16:53:28 -0400 Subject: PEP0238 lament In-Reply-To: <slrn9lm3u8.as.sill@sill.silmarill.org> (sill@optonline.net's message of "Sun, 22 Jul 2001 17:40:10 GMT") References: <mailman.995814276.15005.python-list@python.org> <slrn9lm3u8.as.sill@sill.silmarill.org> Message-ID: <x7n15wy9br.fsf@ra.iago.org> sill at optonline.net (Rainy) writes: > 1/2 is 0. You have to type 1.0/2 to get 0.5. No, there is no good > reason for that, just memorize it. Ugh. Of course there is a good reason for it. It may not be a reason that you personally think is "good enough", but that does not make it a random, arbitrary aspect of the language. You don't have to memorize that 1/2 is zero. You just have to learn the general rule here, that division of two integers produces an integer. Whether or not you like this feature, presenting it as you have is incorrect and unfair. -Justin From tim at vegeta.ath.cx Mon Jul 23 03:49:12 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Mon, 23 Jul 2001 07:49:12 GMT Subject: no traceback?? References: <slrn9lmd1p.1jk.sill@sill.silmarill.org> <6BL67.17641$EP6.4530210@news1.rdc2.pa.home.com> <slrn9lnc42.1qq.sill@sill.silmarill.org> Message-ID: <slrn9lnmfa.nvk.tim@vegeta.ath.cx> Me parece que Rainy <sill at optonline.net> dijo: > Well, I'm asking in a general way, i.e. why could there be no traceback or > error? This is not right. I mean, if a program runs into a problem, it should > print some sort of feedback, at worst, a segfault? I haven't run into cases > like this before when *NOTHING* is printed. In general, what sort of errors > just quit silently? I would guess that it _is_ raising an exception, but it's caught at some point up in the call chain by an 'except: pass' clause. What happens right before the invisible error? What is it doing at that point? -- C combines all the power of assembly language with all the ease of use of assembly language. -- trad From mhuening at zedat.fu-berlin.de Fri Jul 20 07:39:06 2001 From: mhuening at zedat.fu-berlin.de (Matthias Huening) Date: Fri, 20 Jul 2001 13:39:06 +0200 Subject: How to set a timeout? References: <9j446n$lom9k$1@fu-berlin.de> <3B57C4FA.F25F5EAF@alum.mit.edu> Message-ID: <9j959d$mfdfa$1@fu-berlin.de> pehr anderson <pehr at alum.mit.edu> wrote: > What you want is to enable timeoutsockets. [...] > http://timo-tasi.org/python/timeoutsocket.py > Hey - this is great! What I like most: it's *very* simple to use. It's just two lines: import timeoutsocket timeoutsocket.setDefaultSocketTimeout(5) I couldn't get it to work on my Win98-pc at home (with a modem connection to the net), error: "10056, 'Socket is already connected'". But when I tried it on our Linux-server everything went just fine! Thank you very much, Matthias From aahz at panix.com Wed Jul 4 02:56:53 2001 From: aahz at panix.com (Aahz Maruch) Date: 3 Jul 2001 23:56:53 -0700 Subject: Eiffel better than Python ? References: <f20ea932.0107030100.6c740683@posting.google.com> <qRq07.9790$Wc.6458460@nnrp4.proxad.net> <9htfu7$cb1$1@panix6.panix.com> <slrn9k5efg.ru.tim@vegeta.ath.cx> Message-ID: <9huenl$49q$1@panix3.panix.com> [excessive quoting ahead] In article <slrn9k5efg.ru.tim at vegeta.ath.cx>, Tim Hammerquist <tim at vegeta.ath.cx> wrote: >Aahz Maruch <aahz at panix.com> wrote: >> In article <qRq07.9790$Wc.6458460 at nnrp4.proxad.net>, >> Dublanc, David <ddublanc at free.fr> wrote: >>> >>>What is exactly weak typing ? I believed that Python was weak typing ! > >For those that don't know what this does: > >> perl -e "print '1' + '1'" > >This applies Perl's addition operator to two "strings" composed of digits. >Returns 2. > >> perl -e "print 1 . 1" > >This applies the concatenation operator to two constant numbers. >This returns 11. > >This is due to Perl's (intentional) conversion between numbers and >strings when context (a very important Perl concept) implies it. > >You may not agree with this, but it's a matter of personal preference. >It should not involve the preference of a strange author bashing some >other language. Pointing out that Perl has weak typing does not equate to language bashing. -- --- 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'm not tense, i'm just terribly, terribly alert" --unknown From fcnpereira at home.com Sat Jul 14 19:10:22 2001 From: fcnpereira at home.com (Fernando Pereira) Date: Sat, 14 Jul 2001 23:10:22 GMT Subject: list[] = var => list.append(var) (phpstyle) References: <4e2ddb70.0107141310.3c7ca355@posting.google.com> Message-ID: <140720011910209035%fcnpereira@home.com> In article <4e2ddb70.0107141310.3c7ca355 at posting.google.com>, Jonas Bengtsson <jonas.b at home.se> wrote: > I think it should be neet if it would be possible to append a variable > to a list by just using > list_var[] = var_to_append > It works that way in PHP and I think it's nice. > > Any comments? >>> l = [1, 2] >>> x = 3 >>> l += [x] >>> l [1, 2, 3] (Python 2.x) -- F From sholden at holdenweb.com Thu Jul 12 13:15:59 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 12 Jul 2001 13:15:59 -0400 Subject: How popular is Python, anyway? (was: Long Live Python!) References: <E566B020833BD311B6610008C791A39705CA5230@il93exm04.css.mot.com> <mailman.994804336.23495.python-list@python.org> <slrn9koofo.mjk.philh@comuno.freeserve.co.uk> <slrn9kpgtq.5ug.gergo.barany@hold.otthon.at> Message-ID: <uVk37.1979$u76.62739@e420r-atl3.usenetserver.com> "Gergo Barany" <gergo.barany at gmx.net> wrote in message news:slrn9kpgtq.5ug.gergo.barany at hold.otthon.at... > phil hunt <philh at comuno.freeserve.co.uk> wrote: > > [snip flamebait crap] > > If anyone is going to to respond to this thread, *please* take > comp.lang.c out of the Newsgroups: list. We don't do advocacy here. > Followups set. > Thanks, > > Gergo > > -- > When in doubt, follow your heart. I think it's unlikely that my heart will lead me to comp.lang.c any time soon after that little outburst! still-liking-c.l.py's-toujours-la-politesse-ly y'rs - steve -- http://www.holdenweb.com/ From ootanbon at worldnet.att.net Sun Jul 1 23:05:21 2001 From: ootanbon at worldnet.att.net (Charles Krieg) Date: Mon, 02 Jul 2001 03:05:21 GMT Subject: WHY is python slow? References: <mailman.991900751.7603.python-list@python.org> <Xns90B957291603Dbeable@30.146.28.98> <mailman.991931952.3023.python-list@python.org> Message-ID: <RxR%6.27117$J91.732032@bgtnsc06-news.ops.worldnet.att.net> Could be due to improved reflection performance. As far as I know, Hotspot isn't a JIT compiler, just a faster VM. Either way, that's very good news! "D-Man" <dsh8290 at rit.edu> 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. > > -D > > From mikle at tomsk.net Fri Jul 6 14:04:18 2001 From: mikle at tomsk.net (Mikhail Astafiev) Date: Sat, 7 Jul 2001 01:04:18 +0700 Subject: Short form of file names Message-ID: <39916145.20010707010418@tomsk.net> [Env: Win2k, Win98, Python 1.52] Hi! Is there some Python module for converting Windows long paths to short form, i.e. 8.3? os.path.normpath() does not do this.. Thanks in advance, Mikhail. From tuttledon at hotmail.com Mon Jul 30 09:13:35 2001 From: tuttledon at hotmail.com (Don Tuttle) Date: Mon, 30 Jul 2001 13:13:35 GMT Subject: Automate telnet? References: <gt597.49560$TM5.5356012@typhoon.southeast.rr.com> <j4u1zur3fl.fsf@informatik.hu-berlin.de> Message-ID: <34d97.51375$TM5.5708835@typhoon.southeast.rr.com> [Don Tuttle] > > I have a secure Windows telnet client I'd like to automate with a > > script. So far my efforts with the popen family haven't worked. Is > > this a possible task? [Martin] > Doing popen in Windows is quite involved. Instead, I recommend to try > telnetlib directly. Thanks, but unfortunately the 'secure' aspect means I can only access the telnet server by using this client. Telnetlib won't work here. Don From gerson.kurz at t-online.de Sun Jul 15 02:35:03 2001 From: gerson.kurz at t-online.de (Gerson Kurz) Date: Sun, 15 Jul 2001 06:35:03 GMT Subject: a virus written in Python Message-ID: <3b51394e.6471671@news.t-online.de> By a slovenian "art" group for the Venice biennale: http://www.0100101110101101.org/home/biennale_py/prelease2.html From arnaud at tchooze.com Mon Jul 2 03:13:05 2001 From: arnaud at tchooze.com (Arnaud Fontaine) Date: Mon, 02 Jul 2001 09:13:05 +0200 Subject: Is Python Dead? References: <MNS%6.355$Xs4.225014@news.pacbell.net> <mailman.994049882.30354.python-list@python.org> Message-ID: <20010702.091304.1450573622.25984@lart.tchooze.net> In article <mailman.994049882.30354.python-list at python.org>, "Chris Gonnerman" <chris.gonnerman at newcenturycomputers.net> wrote: > ----- Original Message ----- > From: "Edward B. Wilson II" <ed at ewilson.com> >> Python still doesn't have good database support, > > What exactly is "good database support?" I haven't had a problem. I just want to add my voice here : I use Python with databases everyday and don't have any problem (maybe because I NEVER work with poor MS products) > mod_perl is unlikely to be useful to me since I can't stand the mess > that Perl programmers call source code. I suspect that many Python > programmers would agree. One of the reason I left Perl away for Python. > I'm not a Zope user myself, but from what I've read about both PHP and > Zope, it appears they are pretty much even in capability (hopefully an > expert on the subject will comment here). I use both in production. Zope alone (not as CGI) is a great product, really good for most web based application and its asynchronous approach makes it really efficient on the IO aspect. Add to this its caching feature and you have one of the best web product around. PHP is, to my eyes, easier. Maybe because I've been using it for years (it was still called PHP/FI and just hit version 2). You have a bunch of lib with PHP so you can interact with most of the major products onthe market. It handle nicely the load and is really well embeded in Apache. But PHP as a langage is not as good as Python. So, use the product you like ... but remember PHP is just a langage and most of its power comes from Apache. Zope is more than that. I've been running some benchmarks using ab to compare PHP/Apache/Mysql with Zope on a simple application (a simple ppl directory : 1 static home page, a database with contacts, 1 form to query the DB). I haven't kept the numbers but both compared. Apache was a little better to serve the static page but Zope handled the load better querying the database (thanks to its caching feature). -Arnaud From michele_rosen at yahoo.com Tue Jul 17 11:34:37 2001 From: michele_rosen at yahoo.com (Michele Rosen) Date: Tue, 17 Jul 2001 08:34:37 -0700 (PDT) Subject: Cross-platform GUI app -- Tkinter? In-Reply-To: <995328250.676.17416.l8@yahoogroups.com> Message-ID: <20010717153437.72462.qmail@web13402.mail.yahoo.com> Let me preface by saying I am a complete newbie to Python, so I appreciate any corrections to what I am saying (or suggestions)... That said, I believe there is also a way to use 'freeze' to package a Python app with the necessary components of the Python interpreter so you can distribute your program to users who don't even have Python installed... Also, thanks for mentioning Pygame - I have some ideas along those lines as well, so I'm going to take a look at it! Regards, Michele > > Message: 11 > Date: 16 Jul 2001 15:00:27 -0700 > From: steveha at animal.blarg.net (Steve R. > Hastings) > Subject: Re: Cross-platform GUI app -- Tkinter? > > Mark 'Kamikaze' Hughes > (kamikaze at kuoi.asui.uidaho.edu) wrote: > > if the expensive book is John Grayson's _Python > and > > Tkinter Programming_, get it now, it's a damn fine > book. > > Thanks for the tip. I took your advice and got it. > > I checked www.amazon.com, and found that they offer > the Grayson book for > 20% off--an even better deal than the sale at the > store!--so I ordered the > book from Amazon. > > > > If what you want is portability, though, > Python's probably more > > portable than Java > > Okay. I thought Java bytecodes were my best hope > for cross-platform > compatibility... but Python has its own bytecodes, > doesn't it! > > Suppose I wanted a program to be runnable on > platforms like BSD, PowerPC > Linux, PowerPC BSD, etc. without having to build on > each of those. If I > were to distribute .pyo files, and users of all > those platforms already had > Python installed on their systems, could I build and > distribute a single > .pyo file? > > If I do this project, I will directly support Win32, > Mac, and x86 Linux. > But I was hoping I could also distribute something > that would be portable > for everyone else outside these three platforms. If > .pyo files are > cross-platform, then they are the solution I wanted. > > The project I have in mind is a game, and I would > use the Pygame library (a > Python layer over SDL). But I would like the game > to run in a well-behaved > window, with pull-down menus and dialogs and such, > rather than taking over > the whole screen as some SDL games do. Thus my > interest in Tkinter. > -- > Steve R. Hastings "Vita est" > steve at hastings.org http://www.blarg.net/~steveha > -- > http://mail.python.org/mailman/listinfo/python-list > > ===== Give the joy of giving. Find out how at www.charity-checks.org. __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/ From brakedon at hotmail.com Thu Jul 5 18:55:14 2001 From: brakedon at hotmail.com (eric_brake) Date: 5 Jul 2001 15:55:14 -0700 Subject: GUI problems Message-ID: <7b515e0f.0107051455.4194a679@posting.google.com> Why doesn't this TKinter script work? The blank window will come up, but the "quit" button doesn't appear inside it. Thanks for any help. import dice_gui #ignore this from Tkinter import * class fibon_gui: def __init__(self, master): frame = Frame(master) frame.pack() button = Button(frame, text="QUIT", fg="red", command=frame.quit) button.pack(side=LEFT) root = Tk() root.title('Play Dice') root.mainloop() From zen at shangri-la.dropbear.id.au Fri Jul 20 22:36:47 2001 From: zen at shangri-la.dropbear.id.au (Stuart Bishop) Date: 21 Jul 2001 13:36:47 +1100 Subject: Python for RADIUS..??? References: <mailman.995631453.2129.python-list@python.org> Message-ID: <3b58f8cf$1@mercury.its.rmit.edu.au> binto bient <python_binto at yahoo.com> writes: >could Python implemented in RADIUS (Remote >Authentication Dial-In User Service )for ISP, >everything that related with RADIUS. If you want write a client that does authentication via RADIUS, there is a module available at http://py-radius.sourceforge.net/ From rnd at onego.ru Sun Jul 15 01:53:24 2001 From: rnd at onego.ru (Roman Suzi) Date: Sun, 15 Jul 2001 09:53:24 +0400 (MSD) Subject: logs was: Re: converting from perl: variable sized unpack In-Reply-To: <5E347.10457$Ek3.3444795@news1.rdc1.md.home.com> Message-ID: <Pine.LNX.4.30.0107150947110.2560-100000@rnd.onego.ru> On Sat, 14 Jul 2001, Eric Hagemann wrote: >I have a lot of code to parse logs as well -- neat trick (at least I think >it neat !) >to overcome this "problem" is > >name_of_field0 = 0 >name_of_field1 = 1 >name_of_field2 = 2 >. >f = line.split() >. > >then access the elements as >foo = f[name_of_field1] > >in my applications I can use the len(f) to determine the type of line I am >parsing (by its length) > >This way you get variable length parsing as well as "named" arguments O, yes! I do it even more interestingly: I have a separate module for description of log structure and have a special object with short name, describing log struct: # logs.py class ml(Log): name_of_field0 = 0 name_of_field1 = 1 name_of_field2 = 2 Then I can use: from logs import * rec = split(line) dosomething(rec[ml.name_of_field0], ...) And I plan to add something useful to Log so I can do it simpler: rec = ml(line) dosomething(rec.name_of_field0, ...) But am not sure if it is needed yet. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Sunday, July 15, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "This is Borg. <ESC> is futile <CTRL> is inevitable" _/ From duncan at NOSPAMrcp.co.uk Tue Jul 24 04:56:53 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Tue, 24 Jul 2001 08:56:53 +0000 (UTC) Subject: PEP0238 lament References: <9s4pltg7l5r04652q60oqgfu792ha0f1b2@4ax.com> <mailman.995927281.7201.python-list@python.org> <gmhplt4kitb3514p6kkdfg1kgl1eqr1fqg@4ax.com> Message-ID: <Xns90E862BBEA7B5duncanrcpcouk@127.0.0.1> Stephen Horne <steve at lurking.demon.co.uk> wrote in news:gmhplt4kitb3514p6kkdfg1kgl1eqr1fqg at 4ax.com: > If you had as many cases of "?"+str(Amount/100)+"."+str(amount%100) > and similar in your code as I do This is an example where even today you might be better off writing "?%d.%02d" % divmod(Amount, 100) especially if you ever have single digit pennies. -- 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 skip at pobox.com Fri Jul 20 14:21:33 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 20 Jul 2001 13:21:33 -0500 Subject: string random generator (Sorry if too stupid, but i am a beginner) In-Reply-To: <20010720140330.B39397@ifour.com.br> References: <20010720140330.B39397@ifour.com.br> Message-ID: <15192.30381.214904.458807@beluga.mojam.com> Gustavo> I am in need for a function that return a string of len x Gustavo> random generated, like Gustavo> strrnd(5) Gustavo> 'Df%d^' Gustavo> strrnd(2) Gustavo> '&@' Gustavo> I have the following code: The problem is that i don't known Gustavo> how to map a int to a char. You would use the chr() builtin function. Perhaps this version will work for you: import random chars = "".join([chr(x) for x in range(ord(' ')+1,128)]) def strrnd(n, charset=chars): return "".join([random.choice(charset) for i in range(n)]) def _test(): print strrnd(5) print strrnd(7) print strrnd(0) print strrnd(2) if __name__ == "__main__": _test() This uses list comprehensions, so Python 2.x is required to run it with changes. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From guido at python.org Wed Jul 25 11:28:27 2001 From: guido at python.org (Guido van Rossum) Date: Wed, 25 Jul 2001 15:28:27 GMT Subject: Make it a major version number change (was Re: PEP0238 lament) References: <mailman.996013330.29136.python-list@python.org> <3B5E30CE.2901DED0@engcorp.com> Message-ID: <cp66ch9gfc.fsf@cj20424-a.reston1.va.home.com> Peter Hansen <peter at engcorp.com> writes: > I hate the thought of the work required to scan/fix/debug > already working code, but if this has to happen, and can't > be made to work without breaking existing code (e.g. by > introducing *two* new operators), then at least follow > the convention we apparently all believe exists and > make this a *major version number change*. Your wish is my command (see previous post). > (But two years until the change really becomes the default > would at least be an improvement over the truly scary > apparent speed implied by the sudden posting of a patch.) Sorry, you misunderstand the patch. All it does is provide a trial implementation of the "from __future__ impor division" statement and the new // operator. The default semantics of / don't change under the patch. A patch in SF is by definition under discussion. There are many things wrong with the patch, but it gives people an easy way to experiment with an approximation what 2.2 might look like. Unfortunately, all it seems to have done is spur this enormous flamewar. It's really hard to remain calm when people start shouting "the leadership is wrong because I say so." --Guido van Rossum (home page: http://www.python.org/~guido/) From grante at visi.com Tue Jul 10 08:39:11 2001 From: grante at visi.com (Grant Edwards) Date: Tue, 10 Jul 2001 12:39:11 GMT Subject: Screen-Library for text-based programs References: <mailman.994760356.17812.python-list@python.org> Message-ID: <PHC27.12032$B7.2296688@ruti.visi.com> In article <mailman.994760356.17812.python-list at python.org>, Oleg Broytmann wrote: >On Tue, 10 Jul 2001, Klaus Rienessl wrote: >> Sorry for my english. > > Your English is good enough. > >> Do you know a library ? And where can I get this ? > > No, I don't know any of them. > >> > > I found the curses-library, but this seem to be very low-level. >> > >> > slang? newt? > >ftp://quasar.ipa.nw.ru/pub/avv/Python/pyslang/ >ftp://ftp.visi.com/users/grante/stuff/newt-0.50.tar.gz BTW, the python module that wraps the newt library is called "snack". It's standard equipment on some Linux distros (e.g. RedHat). -- Grant Edwards grante Yow! Hand me a pair of at leather pants and a CASIO visi.com keyboard -- I'm living for today! From Klaus at pictura.de Tue Jul 10 03:14:57 2001 From: Klaus at pictura.de (Klaus Rienessl) Date: Tue, 10 Jul 2001 09:14:57 +0200 Subject: Screen-Library for text-based programs Message-ID: <9ie9r7$8ke$06$1@news.t-online.com> Hi, I'm looking for a library to write text-based programs. It should be possible to create windows, menus, popup-menus, dialogs, listboxes, buttoms and so on. I found the curses-library, but this seem to be very low-level. Knows anybody such a library that has this feature. Best regards Klaus Rienessl From guido at python.org Thu Jul 26 17:38:11 2001 From: guido at python.org (Guido van Rossum) Date: Thu, 26 Jul 2001 21:38:11 GMT Subject: Language change and code breaks References: <mailman.995378792.16515.python-list@python.org> <cpvgkq1f2b.fsf@cj20424-a.reston1.va.home.com> <ud76rn4p8.fsf@cs.uu.nl> <3B5D88B1.774A4D70@Bibliothek.Uni-Augsburg.de> <wzhew2gm27.fsf@sunshine.cs.uu.nl> <3B601CBE.627D3D22@Bibliothek.Uni-Augsburg.de> <9jpbi8$32v$1@samos.cs.uu.nl> <9jpj4j$182a$1@nntp4.u.washington.edu> Message-ID: <cplmlb5q2t.fsf@cj20424-a.reston1.va.home.com> Donn Cave <donn at u.washington.edu> writes: > Or worse the lack of a full ASCII character set on the host computer. > My first programs were on a CDC Cyber mainframe with a 60 bit word; > we had several character sets at our disposal, but nearly all programming > was done in 6 bit "display code", no lower case. (The only exception > was a C compiler, which - no offense to the Texas university where it > was created, certainly it was a noble effort - wasn't very useful.) > That would be laughable today, but the computer world was a lot more > diverse at that level then, and we inherit a lot from those days. Including Python -- my interest in programming and languages was sparked by the plethora of languages on the CDC Cyber that was my first comuter back in 1974, and remained my primary system until 1982... --Guido van Rossum (home page: http://www.python.org/~guido/) From frandebo at latt.if.usp.br Tue Jul 24 17:15:53 2001 From: frandebo at latt.if.usp.br (Francisco) Date: Tue, 24 Jul 2001 18:15:53 -0300 Subject: python2.2: type('name') -> <type 'str'> ?? Message-ID: <Pine.LNX.3.96.1010724175515.4646A-100000@latt.if.usp.br> Hello! I just compiled python2.2a and I'm getting this strange response to the 'type' command: Python 2.2a1 (#2, Jul 24 2001, 12:24:09) [GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2 Type "copyright", "credits" or "license" for more information. >>> type('') <type 'str'> while I expected to get <type 'string'>. Am I missing something or I just messed up with the compilation?? thank you for your attention, -- Francisco. Sao Paulo, Brasil. __o `\<, _____(*)/(*)_____ From ehagemann at home.com Fri Jul 6 21:33:56 2001 From: ehagemann at home.com (Eric Hagemann) Date: Sat, 07 Jul 2001 01:33:56 GMT Subject: lvalues and the lgb rule References: <mailman.994457412.4660.python-list@python.org> Message-ID: <8Gt17.7112$PF2.1324057@news1.rdc1.md.home.com> > > Not dynamic. Just look at the code in an editor: if a name is bound > anywhere within a code block, and isn't declared in a "global" stmt, then > that name is local throughout the entire code block. > Is this true ? Given a file with the following print x x=1 print x The first print will fail with a 'NameError'. It was my (perhaps) wrong impression that x "came into being" at the assignment (x=1) I would think the variable is local to the code block once the assignement has been executed BTW whats the 'LGB' rule ? Cheers "Tim Peters" <tim.one at home.com> wrote in message news:mailman.994457412.4660.python-list at python.org... > [Michael P. Soulier] > > ... > > In Python, previously unused lvalues cause that variable to > > be dynamically declared. > > This is a flawed mental model: the local vs non-local distinction is made > at compile-time, by static inspection of the program text. There's nothing > dynamic about that (in the absence of "import *" and "exec" abuses). > > > x = 1 # if x did not previously exist, following the LGB rule, it is > > # declared dynamically here > > Not dynamic. Just look at the code in an editor: if a name is bound > anywhere within a code block, and isn't declared in a "global" stmt, then > that name is local throughout the entire code block. > > > Now, while this is great for scripting, it can cause major > > headaches with large programs if you're a bad typist. > > I expect bad typists have lots of other problems writing code too <wink>. > > > It can declare new variables accidentally, when you wanted to assign > > to an existing one... > > > > myvar = 5 > > . > > . > > myver = othervar > > A tool like PyChecker will detect that, in the example exactly as given, > "myvar" and "myver" are *both* unreferenced, and flag both lines with > warnings. > > > ...so here my typo of myver instead of myvar dynamically creates > > myver instead of assigning othervar to myvar. > > It caused the compiler to believe you have two local vars, myvar and myver; > it makes no difference which one comes first; space for both is allocated > (in a sense) at compile-time. > > > It can also accidentally obscure globals. > > > > So, while the simple answer would be, "don't do that", we all > > know that accidents happen. So, I was wondering if there is a way to > > force declarations of variables to catch this kind of thing. > > Not in Python: "global" is its only declaration statement. Use PyChecker: > > http://sf.net/projects/pychecker/ > > > Is there, or is there anything in the works, to assign with very large > > programs? > > The size of the program doesn't really matter; regardless of program size, > if you don't keep your individual functions and methods to well under a > screen of code almost all the time, you're going to have lots of problems > (in Python or any other language; it may even be worse in Python, because > indendation for grouping really doesn't work well when code blocks slobber > over screen pages; that's one of the clever pressures in Python *nudging* > you toward writing better code). > > guido-can-lead-you-to-clarity-but-he-can't-stop-you-from-peeing-in- > the-stream<wink>-ly y'rs - tim > > From nde at comp.leeds.ac.uk Thu Jul 12 08:34:15 2001 From: nde at comp.leeds.ac.uk (Nick Efford) Date: Thu, 12 Jul 2001 12:34:15 GMT Subject: Help With filter(). References: <XA537.678643$166.13965187@news1.rdc1.bc.home.com> Message-ID: <GGD1L8.op3@leeds.ac.uk> On Wed, 11 Jul 2001 23:48:07 GMT, EricIDLE <grayson-wilson at home.com> wrote: > What does filter do? I don't understand when I read it other places. Think about the general concept of filtering; filters let some things pass through and block others. Python's filter function does exactly this for sequences - letting certain items from the sequence through and blocking others. The filter function returns a new sequence which is a subset of the input sequence. Of course, you need some way of specifying which items should pass through the filter. You do this by defining a function that takes a single argument, returning true if that value should be pass through the filter and false if it should be eliminated by the filter. Unless we need this function for some other purpose, a lambda expression will suffice. Example: filtering out odd numbers from a list of integers. We can use a lambda expression that tests whether we get a remainder of zero when dividing a value by 2; if so, the value is even and should be retained. >>> data = range(10) >>> data [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> filter(lambda x: x%2 == 0, data) [0, 2, 4, 6, 8] A more useful example is filtering a list of directory entries: >>> import os >>> os.listdir('.') ['Start.py', 'doc.py', 'doc.pyc', 'Gnuplot', 'SIPlib', 'doc', 'tests', 'programs', 'README'] Some of the items in the list are the names of files; others are the names of subdirectories. We can generate a list containing only the subdirectories like so: >>> filter(os.path.isdir, os.listdir('.')) ['Gnuplot', 'SIPlib', 'doc', 'tests', 'programs'] To generate a list containing only the plain files, we do: >>> filter(os.path.isfile, os.listdir('.')) ['Start.py', 'doc.py', 'doc.pyc', 'README'] Since Python 2.0, many uses of filter can be replaced by list comprehensions, which are often more readable: >>> [x for x in data if x%2 == 0] [0, 2, 4, 6, 8] HTH, Nick From alex.freller at gmx.at Wed Jul 4 00:51:39 2001 From: alex.freller at gmx.at (Freller Alex) Date: Wed, 04 Jul 2001 04:51:39 GMT Subject: newbie question Message-ID: <3B42A1A3.2A7793CC@gmx.at> I would like to program a python script that parses a directory and its subdirectorys after specific files (*.pl) and count their linenumbers. thanks, alex From grante at visi.com Wed Jul 25 12:42:14 2001 From: grante at visi.com (Grant Edwards) Date: Wed, 25 Jul 2001 16:42:14 GMT Subject: Some Python (Monty) Perspective (was Re: Language change and code breaks) References: <Pine.LNX.4.33.0107191316390.24983-100000@bms> <mailman.995571273.18192.python-list@python.org> <9j7gv8$9mg@dispatch.concentric.net> <cppuawfqbm.fsf@cj20424-a.reston1.va.home.com> <mailman.995734717.26373.python-list@python.org> <3B5DF101.9B2E4631@earthlink.net> <cpofq9a858.fsf@cj20424-a.reston1.va.home.com> <9jmqp3$9n1@dispatch.concentric.net> Message-ID: <slrn9lttn5.69.grante@isis.visi.com> In article <9jmqp3$9n1 at dispatch.concentric.net>, Tim Randolph wrote: >It is obvious that he only has the good of the language at heart. If that's true, who worries about the good of the language's users? Perhaps making int/int => float makes the language better. [I don't personally think so, but it's a matter of taste.] However, it does hurt at least some of the existing group of users. How many and how bad is up for debate. I think that not allowing ints and floats to be mixed would make it a better lanauge, but that would probably hurt even more users. -- Grant Edwards grante Yow! Should I do my BOBBIE at VINTON medley? visi.com From Tom_Good1 at excite.com Thu Jul 19 16:57:15 2001 From: Tom_Good1 at excite.com (Tom Good) Date: 19 Jul 2001 13:57:15 -0700 Subject: Bunch lists into sublists via alternation References: <5e8bd451.0107190415.7cc17f93@posting.google.com> Message-ID: <ac677656.0107191257.4c787a89@posting.google.com> kp87 at lycos.com (kevin parks) wrote in message news:<5e8bd451.0107190415.7cc17f93 at posting.google.com>... > I've asked this on another list and never got a reply. Possibly > because i have worn out my welcome with all my dumb questions, or > because it is such a dumb question people hurt themselves laughing and > are now all in the hospital. > > I am trying to figure out how to take a sequence and split it up into > sub-lists > by alternation. For example if i had a sequence like: > > x = [1,2,3,4,5,6,7,8,9] > > and i called a function that was: seqSplit(seq, sub-lists) > > seqSplit(x,2) > > would yield: ([1,3,5,7,9], [2,4,6,8,None]) # None pads lists that are > short elements > > and seqSplit(x,3) --> ([1,4,7], [2,5,8], [3,6,9]) > and seqSplit(x,4) --> ([1,6] [2,7], [3,8], [4,9], [5,None]) > > > I've got something that bunches up consecutive elements into > sub-lists: > > def bunch(mylist, times): > """package up list elements in sub-lists n at a time. > > x=[1,2,3,4,5,6,7,8,9] > bunch(x,1) --> [[1], [2], [3], [4], [5], [6], [7], [8], [9]] > bunch(x, 2) --> [[1,2], [3,4], [5,6], [7,8], [9, None] > bunch(x, 3) --> [[1,2,3], [4,5,6], [7,8,9]] > bunch(x, 4) --> [1,2,3,4], [5,6,7,8] [9, None, None, None]]""" > > out = [mylist[i:i+times] for i in range(0, len(mylist), times)] > if out: > out[-1].extend([None] * (times - len(out[-1]))) > return out > > # -- --------------------------------------- > > But i can't figure out how to get the: > > a = (1,9,1,9,1,9) > b = (1,9,7,1,9,7,1,9,7) > seqSplit(a,2) --> ([1, 1, 1], [9, 9, 9])""" > seqSplit(b,3) --> ([1, 1, 1], [9, 9, 9], [7, 7, 7])""" > > type arrangement, particularly since i want it to work for any > unpredetermined > number of sub-lists. I've got a kludge that works only for the case of > seqSplit(x,2), > but i can't get anything to work for seqSplit(x,n) where n is anything > else. > > cheers, > kevin parks Or another way: >>> def group(mylist, times, offset): ... return [mylist[i] for i in range(offset, len(mylist), times)] ... >>> def seqSplit(mylist, times): ... return [group(mylist, times, offset) for offset in range(times)] ... >>> seqSplit((1,9,1,9,1,9), 2) [[1, 1, 1], [9, 9, 9]] >>> seqSplit((1,9,7,1,9,7,1,9,7), 3) [[1, 1, 1], [9, 9, 9], [7, 7, 7]] >>> From ullrich at math.okstate.edu Wed Jul 11 10:48:13 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Wed, 11 Jul 2001 14:48:13 GMT Subject: Language Shootout References: <mailman.994742356.29669.python-list@python.org> <3b4b04fb.1257683@nntp.sprynet.com> <3b4bab70.1586151915@wa.news.verio.net> Message-ID: <3b4c647e.2934740@nntp.sprynet.com> On Wed, 11 Jul 2001 01:47:30 GMT, bokr at accessone.com (Bengt Richter) wrote: >On Tue, 10 Jul 2001 13:54:47 GMT, ullrich at math.okstate.edu (David C. >Ullrich) wrote: > >>On Tue, 10 Jul 2001 01:18:16 -0400, "Tim Peters" <tim.one at home.com> >>wrote: >> >>>[Bengt Richter] >>>> ... >>>> I just did a python recursive fib(100000) in >>>> just over 15 seconds, including startup and >which turned out to be mostly str conversion for >the print, so I thought I'd try recursion on that... >(see below ;-) Sorry I missed the "which turned out to be mostly str conversion" the first time I read this. >[...] >>(Took a minute to find fib.py just now, because it was filed >>under "MatrixTypes". I calculate fib(100000) in 1.7 >>seconds this way; for comparison, str(fib(100000)) takes >>8.0 seconds.) >Hi Dave ;-) > >Try strL for comparison. It's recursive, and faster than str >for big numbers. I got > >>> len(strL.strL(ffib(100000))) > 20899 > >so you can type in 10L**20899 on the command line >for a number in the same ballpark as the fib, for a test. >On my system I get > >[18:47] C:\pywk\fib>strL.py str 10L**20899 >str took 13.601617 seconds > >[18:47] C:\pywk\fib>strL.py strL 10L**20899 >strL took 1.044989 seconds > >Recursion rides again ;-) Recursive or not, the idea that we can write a replacement for str that's faster is very curious. >BTW, how do you put everything inside the strL def >to hide names, and how do you recurse inside without >a warning message? > >A couple of lines wrapped... >_______________________________________________________________ ># strL.py -- recursive long to decimal string conversion ># 2001-07-10 bokr ># >p10d={} >def p10(n): > if not p10d.has_key(n): > p = p10d[n] = 10L**n > return p > return p10d[n] > >def strLR(n,w=0): # w>0 is known width, w<0 is searching guess > if w == 0: return [] > if w > 0: > if w <=9: return [('%0'+chr(w+48)+'d') % n] > wr = w/2 > nl,nr = divmod(n,p10(wr)) > return strLR(nl,w-wr)+strLR(nr,wr) > else: > nl,nr = divmod(n,p10(-w)) > if nl: > return strLR(nl, 2*w) + strLR(nr,-w) > else: > if w >= -9: > return ['%d' % n] > else: > return strLR(nr,w/2) > >def strL(n): > if n<0: > return ''.join(['-']+strLR(-n,-9)) > else: > return ''.join(strLR(n,-9)) Of course you have to do the recursion in a non-stupid manner, as here; if you'd made a recurzive routine that concatenated Python strings instead of building that list I doubt that recursion would win. But it is curious how often recursion does seem to win in Python. (Doesn't usually beat built-in functions, though.) >from time import clock >import sys >def main(): > def pr(x): > print x > > def psl(x): > s = strL(x) > sys.stdout.write(s) > sys.stdout.write('\n') > > > dt={'str':str,'strL':strL,'repr':repr, 'print':pr, 'printStrL':psl >} > > try: > x=long( eval(sys.argv[2]) ) > fn=sys.argv[1] > fcn=dt[fn] > except: > sys.stderr.write("usage: %s [str strL repr print printStrL] ><const expr>\n" % sys.argv[0]) > sys.exit(2) > > t0=clock() > fcn(x) > t1=clock() > print "%s took %9.6f seconds" % (fn,t1-t0) > >if __name__ == "__main__": > main() >_______________________________________________________________ David C. Ullrich From k1e2i3t4h5r6a7y at 1m2a3c4.5c6o7m Tue Jul 3 11:53:26 2001 From: k1e2i3t4h5r6a7y at 1m2a3c4.5c6o7m (Keith Ray) Date: Tue, 03 Jul 2001 15:53:26 GMT Subject: zope's acquisition inheritance References: <3B41E221.CE23D83E@home.com> Message-ID: <k1e2i3t4h5r6a7y-E9623E.08532703072001@news> In article <3B41E221.CE23D83E at home.com>, Wostenberg <pwos at home.com> wrote: > This Smalltalker has been studying Zope, the Opensourced python product > for internet deployment (see http://www.zope.org), to learn. > > It has an unusual model of interitance called acquisition, which blends > class heiarchy with containment. Read > http://www.zope.org/Members/Amos/WhatIsAcquisition for introduction. > Basically "objects automatically gather. services from their > containers.". Everything is potentially a collector-class, and if I drop > objects into a collection, they inherit behavior from the container. > Weird, but somehow natural in this Web environment which organises > content around a tree-structured containment plan. > > Anybody heard of acquisition outside Zope, or is it a new contribution > to OO modelling? > -Alan It reminds me of NewtonScript, an OO language without classes, where every object had two 'parents' for inheritance, one of which, IIRC, is the GUI containment hierarchy... It seems like NewtonScript's direction of 'containment inheritance' is opposite of Zope. I'm not sure how accurate this paper is, but I never programmed extensively in NewtonScript, so my memory may be flawed: <http://www.cc.gatech.edu/~schoedl/projects/NewtonScript/> "3. Inheritance NewtonScript uses an inheritance scheme which is derived from SELF. SELF's inheritance mechanism is very flexible. For the special purpose of writing GUI application, NewtonScript has a simplified double inheritance scheme. The two ways of inheritance are very much fixed in purpose when implementing windows and dialog controls, but can be used more generally as well. "3.1 Prototype inheritance First, each frame can have a prototype frame from which it is derived. The mechanism is rather simple, the frame contains a slot called _proto and each time the NewtonScript interpreter does not find a slot variable or function locally it looks into the frame's prototype and then recursively into its prototype until the whole inheritance chain was searched through. When a new slot variable is created that already exists in a prototype a new slot variable is created in the current frame. During lookup this new variable is found first and semantically replaces the prototype variable. From a conventional viewpoint prototypes serve two roles. First, they are the equivalent to user-defined types, to create an instance of the type, you just have to create an object derived from the object that defines the behavior of your type. Second, prototypes provide the class inheritance mechanism of class based languages. "The dialog creation mechanism of NewtonScript uses prototype inheritance extensively to create dialog items. When a new instance of a built-in dialog element is created the new instance has the built-in object as its prototype. This object created by the user is then called a template in NewtonScript terminology. When this object is then actually put onto the screen, the system itself creates another object having the template as prototype, with some redefined slots to designate view boundaries for example. Thus the template can be reused to create more dialog controls with similar properties. "3.2 Parent inheritance The second way of inheritance is conceptually quite similar to prototype inheritance, besides the _proto slot a slot called _parent points to another inheritance chain similar to the prototype chain. This second inheritance scheme is again made to fit into the GUI design, all child-windows have a child-parent inheritance relationship to their parent windows. An application normally consists of a parent window, which is in turn child of the system's root window. All windows and dialog controls are then hierarchically ordered below this application parent window. Parent inheritance has an effect similar to prototype inheritance, variables not found neither in the frame itself nor in its prototypes are searched for in the parent frames and their prototypes and so forth. Thus slots in the parent window of an application serve as application wide globals. Assignment rules are a little different from the prototype inheritance rules, you can assign values to slots which reside in your chain of parents and grandparents as you can assign values to global variables in other languages without replicating these variables locally in the current frame. "For function lookup, NewtonScript only searches the prototype chain, not the parent chain, although a frame can call a function in one of its parents directly by dereferencing its _parent slot. It does not become entirely clear why this is so, I think it is more because of practicality than principle." From barry at digicool.com Thu Jul 19 00:37:49 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Thu, 19 Jul 2001 00:37:49 -0400 Subject: Really Python leaks? References: <mailman.995461170.23230.python-list@python.org> <3dwv56p8ot.fsf@ute.cnri.reston.va.us> <m3hew9ybmx.fsf@vole.object-craft.com.au> Message-ID: <15190.25629.741994.271094@anthem.wooz.org> >>>>> "DC" == Dave Cole <djc at object-craft.com.au> writes: DC> I know that my extension modules leak a bit due to objects DC> which are created when the module is imported and stick around DC> for the lifetime of the module. I had not given it much DC> thought. I don't think such allocs should be considered leaks worth worrying about, if they're leaks at all. If there's a good reason for those objects to stick around for the life of the module, then you might as well let the normal process shutdown free them implicitly. I don't believe Python will dlclose your extension module even on a reload (assuming it's a dynamic library; if it's statically compiled, you won't get finalized anyway until the process exits). -Barry From skip at pobox.com Thu Jul 19 10:23:47 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 19 Jul 2001 09:23:47 -0500 Subject: Python/VTK tutorial? In-Reply-To: <9j6ji2$lcs$1@hermes.shef.ac.uk> References: <9j6ji2$lcs$1@hermes.shef.ac.uk> Message-ID: <15190.60787.369381.411805@beluga.mojam.com> jose> I was looking for a decent vtkpython tutorial. However, I seem to jose> stumble into TCL/TK tutorials all the time. Does such a beast jose> exist? I would have thought that coupled with NumPy, VTK in jose> Python should be phenomenally popular... The Kitware folks (authors of VTK) have long used Tcl as their extension language, which explains the preponderance of Tcl-related VTK documentation. You might ask them (kitware at kitware.com) if they know of anything Python-related. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From aleaxit at yahoo.com Tue Jul 3 17:25:02 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 3 Jul 2001 23:25:02 +0200 Subject: Python and DB support (was: Re: Is Python Dead?) References: <mailman.994155184.16109.python-list@python.org> <915a998f.0107030845.5c1a77f4@posting.google.com> Message-ID: <9htd7e0ab6@enews4.newsguy.com> "Hamish Lawson" <hamish_lawson at yahoo.co.uk> wrote in message news:915a998f.0107030845.5c1a77f4 at posting.google.com... > Alex Martelli: > > Python can work perfectly well WITHIN ASP/IIS > > Roman Suzi: > > ADO could help for those who consider Python for tasks usually > done with PHP or ASP. > > I suspect there may be cross-purposes here, due to differences in how > the term 'ASP' is being used. Strictly ASP is a technology for dynamic > web pages, but without any reference to any particular programming > language. VBScript just happens to be the most widely used language > for working with ASP, but other languages can be used - JScript, Actually, JScript seems to be more widespread in this role, judging from various hints -- including the fact that in the next Microsoft language generation, VBScript disappears (reabsorbed by VB, if you will) but JScript is still being intensely invested on (also, the examples on MSDN seems strongly JScript-biased). > PerlScript, Python, etc. Thus to compare Python with ASP is, strictly > speaking, as meaningless as comparing Python with CGI (when you > actually meant Perl). Yep, this is exactly what I think Roman finally got from this exchange. Alex From t-weh at online.no Wed Jul 25 15:41:19 2001 From: t-weh at online.no (Thomas Weholt) Date: Wed, 25 Jul 2001 21:41:19 +0200 Subject: Distributed computing using SOAP. What about speed ? References: <LBA77.58$bXi.175168000@news.telia.no> <j4puaohp42.fsf@informatik.hu-berlin.de> <mailman.996090346.23669.python-list@python.org> Message-ID: <3HF77.292$Fp.2574@news1.oke.nextra.no> Interesting. What I'm going to send among my clients are lists of urls, and I guess the lists can be pretty big after a while. Coul probably benefit from compression too. If you ever implement something like this, please post it here, at Parnassus etc. Thomas "Skip Montanaro" <skip at pobox.com> wrote in message news:mailman.996090346.23669.python-list at python.org... > > Martin> "Thomas Weholt" <thomas at gatsoft.no> writes: > >> Does anybody have any thoughts about SOAP, especially SOAPpy ( it > >> looks very nice, simple to use ), and potential speed issues? > > Martin> If speed is an issue, I would recommend against SOAP. If you use > Martin> CORBA, you can get very efficient implementations. Even the > Martin> least efficient ones (e.g. Fnorb) will easily out-pace SOAP any > Martin> time. > > Perhaps, but it all depends on what and how you sling your data around. > Clearly, you can't efficiently pass and receive multi-megabyte data > structures, but that would hold true for any distributed communication > protocol. A megabyte of data is still a megabyte of data. I tweaked > xmlrpclib a year or two ago to handle gzip encoding. It compresses the xml > on the wire quite nicely. Doesn't have much effect when talking over a LAN > but over the Internet it's quite nice to have. I suspect it wouldn't be too > hard to add gzip encoding support to SOAPpy either. > > -- > Skip Montanaro (skip at pobox.com) > http://www.mojam.com/ > http://www.musi-cal.com/ > From aquarius at kryogenix.org Tue Jul 24 17:54:36 2001 From: aquarius at kryogenix.org (Aquarius) Date: Tue, 24 Jul 2001 21:54:36 GMT Subject: exec considered harmful References: <9jjo5b$jn3$1@giles.kryogenix.org> <_Zg77.543539$eK2.114006347@news4.rdc1.on.home.com> Message-ID: <9jkr4p$pai$1@giles.kryogenix.org> Nick Perkins spoo'd forth: > why exec(), when you can import? > > I think that people with experience in Perl tend to want to exec() too much. > If you have a function in another file that you want to execute, you should > make that other file a .py file, and import it. I exec because I've essentially defined a page type that works like MS Active Server Pages or PHP, so I can have: blah blah some HTML here <?cas some Python ?> some more HTML and the CGI (which is invoked as a handler for the page via an Apache Action directive) splits the page into Python bits and HTML bits, printing the HTML and execing the Python code. I find it a lot easier than making each page a complete Python CGI and having to explicitly print "" everything. It works in the same way as Poor Man's Zope, which is another "embed Python in HTML" CGI handler. Aq. -- Well *done*, Aquarius -- a phrase we love typing because it makes us feel like the boss-character from a 1980s Glen A Larson action series... NTK, http://www.ntk.net/index.cgi?backarchive99/now0618.txt&lineY2#l From chrishbarker at home.net Mon Jul 30 14:32:16 2001 From: chrishbarker at home.net (Chris Barker) Date: Mon, 30 Jul 2001 11:32:16 -0700 Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <LNBBLJKPBEHFEDALKOLCAEDILCAA.tim.one@home.com> <mailman.996496747.2943.python-list@python.org> Message-ID: <3B65A830.75EE6C76@home.net> Guido van Rossum wrote: > > Scheme says and reveals nothing about internal representations. > > Neither does Python, IMO. > > --Guido van Rossum (home page: http://www.python.org/~guido/) hmmm. The Python docs are full of phrases like: "depends on the implimentation of the underlying C library" And from the refernce manual: """ Floating point numbers: These represent machine-level double precision floating point numbers. You are at the mercy of the underlying machine architecture and C implementation for the accepted range and handling of overflow. """ I don't know if this is "saying and revealing" _something_, or an extreme version of _nothing_, but it certainly ties Python behaviour to internal representation. I understand the practical reasons for using the underlying machine and C library methods and representations, but it sure would be nice to have it clearly defined for Python itself, instead. -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 new_name at mit.edu Mon Jul 16 11:02:12 2001 From: new_name at mit.edu (Alex) Date: 16 Jul 2001 11:02:12 -0400 Subject: Most efficient solution? References: <mailman.995289809.28477.python-list@python.org> <slrn9l5urp.nto.alf@leo.logilab.fr> Message-ID: <etdn164rk7f.fsf@quiche-lorraine.mit.edu> > C = {} > for item in B: > C[item]=None > > A = filter(lambda e, dic = C: dic.has_key(e), A) I guess you can even do filter(C.has_key, A), which is probably a little faster still. > You may get some speedup by making B a dictionary, and using has_key() > to see if the word is there. This should get you a O(log(n)) instead > of O(n) inside the loop. To gain further performance, use filter to > skim A. What's n, here? This looks linear in the length of A, and constant time in the number of unique elements in B, to me. Alex. From l0819m0v0smfm001 at sneakemail.com Fri Jul 27 22:00:00 2001 From: l0819m0v0smfm001 at sneakemail.com (Joshua Macy) Date: Sat, 28 Jul 2001 02:00:00 GMT Subject: PEP 238 (revised) References: <cp4rrz5onj.fsf@cj20424-a.reston1.va.home.com> <3B60B3D5.664A3D7F@engcorp.com> <23891c90.0107270138.6bb70413@posting.google.com> Message-ID: <3B61E456.78DFE802@sneakemail.com> Paul Boddie wrote: > > But possibly the first thing anyone with any investment in the > language should be thinking upon starting to read the PEP is: "How on > Earth am I going to know what needs changing, and how much time and > money am I going to be spending to adapt to this?" > It seems to me that if upon reading the PEP someone thinks "How on Earth am I going to know what needs changing?", he is almost guaranteed to have bugs in his code that relate to the very issue that the PEP addresses. How could he not, since he's obviously never thought about it before? Someone who thinks this way should be thanking his lucky stars that if the PEP is implemented the language is going to grow the machinery in the near term to help him identify the bugs (warnings and possibly tools), write code that's not subject to the bugs (using / and // appropriately) and the incentive (Python 3.0) to attack the problem in the next few years. Joshua From donn at u.washington.edu Thu Jul 26 13:13:55 2001 From: donn at u.washington.edu (Donn Cave) Date: 26 Jul 2001 17:13:55 GMT Subject: Language change and code breaks References: <mailman.995378792.16515.python-list@python.org> <cpvgkq1f2b.fsf@cj20424-a.reston1.va.home.com> <ud76rn4p8.fsf@cs.uu.nl> <3B5D88B1.774A4D70@Bibliothek.Uni-Augsburg.de> <wzhew2gm27.fsf@sunshine.cs.uu.nl> <3B601CBE.627D3D22@Bibliothek.Uni-Augsburg.de> <9jpbi8$32v$1@samos.cs.uu.nl> Message-ID: <9jpj4j$182a$1@nntp4.u.washington.edu> Quoth piet at cs.uu.nl: ... | I know some people had to use Algol 60 dialects with only a single case. We | were fortunate enough to have real Friden Flexowriters with upper and | lowercase. Keywords (printed in bold) where made with backspaces and | underlines, and had the nice property that any combination of letter, | underscore and backspace that put the underscore under the letter made that | letter bold. The Flexowriters produced papertape, which was fed into the | computer. | | Maybe the case-insensitivity of other early programming languages was just | caused by the lack of both cases on input (and output) devices. Or worse the lack of a full ASCII character set on the host computer. My first programs were on a CDC Cyber mainframe with a 60 bit word; we had several character sets at our disposal, but nearly all programming was done in 6 bit "display code", no lower case. (The only exception was a C compiler, which - no offense to the Texas university where it was created, certainly it was a noble effort - wasn't very useful.) That would be laughable today, but the computer world was a lot more diverse at that level then, and we inherit a lot from those days. Donn Cave, donn at u.washington.edu From bsass at freenet.edmonton.ab.ca Tue Jul 17 16:47:32 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Tue, 17 Jul 2001 14:47:32 -0600 (MDT) Subject: PEP: Defining Python Source Code Encodings In-Reply-To: <3b549622.2170522105@wa.news.verio.net> Message-ID: <Pine.LNX.4.33.0107171427150.11975-100000@bms> Hi, regarding... > >Generally: #<magic> <directive> [<arguments>] or as I should have written it... #<magic><directive> [<arguments>] <...> > I withdraw my #!pragma (or #!pythma ;-) suggestion and propose > r'^\s*#pragma\s' as the magic line prefix regular expression. Why is "pragma" better <magic> than " ## ", or some other sequence of non-word characters? I would think that using any *word* as the <magic> is just asking for trouble; someone is bound to have done (or normally does) a block of comments where there is no space between the "#" and the first word of the comment (iirc, emacs handles comments in such a way that "#comments" is the right thing to do in some cases)... is the word "pragma" now illegal as the first word in such a comment, what does this do to any tools that automatically turn arbitrary text into comments? - Bruce From Lutz.Schroeer at kybernetik-manufaktur.de Mon Jul 2 11:37:02 2001 From: Lutz.Schroeer at kybernetik-manufaktur.de (Lutz Schroeer) Date: 2 Jul 2001 15:37:02 GMT Subject: Template processing Message-ID: <Xns90D2B339CFDD6Latzikatz@139.174.2.56> Hi, I want to do some _simple_ template processing. Which is the best package to use (except Zope and except writing it myself ;-))? Latz From mcherm at destiny.com Mon Jul 23 10:34:38 2001 From: mcherm at destiny.com (mcherm at destiny.com) Date: Mon, 23 Jul 2001 09:34:38 -0500 Subject: PEP0238 lament Message-ID: <f37ce9f1.e9f1f37c@destiny.com> Guido writes: > [...] > Because all Arthur does is tick me off, I'll leave it at this -- > maybe someone else can explain it all to him. Well, I'll see what I can do. In the language there are (at least) two distinct things we might want to do when "dividing" A and B: (1) split A up into B parts (2) find how many B's fit in an A A good example of (1) is float division, and the cannonical example of (2) is "int division", aka "div". These are DIFFERENT THINGS. For instance, if you are implementing a sort algorithm, you may well want (2) in a place where (1) will never do! On the other hand, if your program is performing CAD drawings, then (1) is probably the meaning you need. Note that (2) often makes most sense with integers (especially since it always gives out an integer), while (1) may make sense with floats, rationals, fixed-position decimals, as well as various other numerical types. So I'm hoping that everyone reading this can agree, BOTH (1) and (2) are USEFUL things, and a good language should allow BOTH. If not, then please stop reading: there's no way I can convince you. Given that you want both (1) and (2), there is just one problem: the syntax "A / B" is the ideal syntax for BOTH of these purposes. It's ideal for (1) because the mathematical operation of division is traditionally represented with a "/", and it's ideal for (2) because C and other languages have historically used "/" between integers for (2). In my opinion (and those of quite a few others), this is pretty lopsided: (1) is probably used more often, so it should get priority, PLUS just imitating C isn't very convincing since other languages (eg: Pascal) use other syntax, PLUS the use of division in mathematics is far more widespread and well-known than the use of "/" in C, PLUS the people who intend to use (2) will probably be able to remember to use a different symbol. So if you believe these arguments, then the next time you go out and invent a new language, you'll use "/" to mean (1), not (2). But Python is not a new language, and in existing versions of Python, "/" has meant (2) if both arguments were integers. To change this now is VERY bad, because it will break lots of existing code. It probably won't be hard for existing programmers to adapt, but having to repair all those old scripts is a VERY BAD THING. So Guido is trying to balance two things: the desire to use "/" to mean (1) in all cases, regardless of the type of its arguments, and the desire to keep Python stable, without breaking lots of existing code. The issue is important because we often see newbie bugs based on this issue, and because if the change is EVER going to happen, it HAS to be soon... the longer he waits, the more old scripts there are which will have to be broken. In the end, after hearing all of the arguments (and if you haven't spoken up yet I STILL suspect someone else has made your argument for you before in a previous usenet thread), Guido has apparently decided that the design improvement is worth breaking old scripts. Obviously, that means that tools and techniques (warnings, type inferring source checkers, etc) need to be provided which will help in that transition... but it'll still be painful. Guido is well aware of that, and I'm sure he approaches this with reluctance. But remember, there's a GOOD side too! After the trasnsition is over, the language will be (in one small way) even better than before. -- Michael Chermside From johnsstar at earthlink.net Sun Jul 8 23:31:49 2001 From: johnsstar at earthlink.net (Randal Johnson) Date: Mon, 09 Jul 2001 03:31:49 GMT Subject: best language for 3D manipulation over web ? References: <v0efhto7hcdq30ei2bvp717l3f9qq7ce5h@4ax.com> <ZnQR6.911$Ol6.288839@news20.bellglobal.com> <D9cS6.4513$lM3.104799@news1.oke.nextra.no> <dsekht4ujbc65kes6goq28njv3s1rafh6d@4ax.com> <3B1A47EA.AFBD45E8@lmf.ericsson.se> <n4okhtcr58m58uqb2r1129m6dm1ss1e4tp@4ax.com> <3B1B1825.8109BA83@lmf.ericsson.se> <2v4ohtgldvce84sn87kh1eg1lnes37getq@4ax.com> <3B1C9E65.B73A4FE@lmf.ericsson.se> <rtaqhtsuqgo74agtrhanijpj0t0shaikhv@4ax.com> <3B1DFD87.F3BFDB57@lmf.ericsson.se> <e03vhto1hehnstnnaj7ekru67lulnrme8v@4ax.com> <9fpra3$352$1@oslo-nntp.eunet.no> <3B2083A5.15B40637@lmf.ericsson.se> <9fqi1i$dsq$1@oslo-nntp.eunet.no> Message-ID: <FA927.178$767.10234@newsread2.prod.itd.earthlink.net> The problem with any real time programming over the web is not the language you program in but the protocol you use. Whether you are talking about real time video or games real time is a hassle with TCP/IP. Read the article on gamasutra by Bruce Holland on X Wing Vs Tie Fighter and what they ran into trying to create a real time space combat internet game. "Thomas Hansen" <thomas.hansenNOSPAMORILLSUEYOURASS at entermatch.com> wrote in message news:9fqi1i$dsq$1 at oslo-nntp.eunet.no... > > "Attila Feher" <Attila.Feher at lmf.ericsson.se> 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 andreas.kremer at fernuni-hagen.de Fri Jul 20 06:51:32 2001 From: andreas.kremer at fernuni-hagen.de (Andreas Kremer) Date: Fri, 20 Jul 2001 12:51:32 +0200 Subject: synchronized lists References: <mailman.995617328.2514.python-list@python.org> Message-ID: <9j92bg$cpd$01$1@news.t-online.com> Hi, > Making pointers to and from is messy and a usual source of cyclic > references. Combined with using __del__, this will result in "memory > leaks", IIRC. Thanks. Actually this is the reason why i am thinking of secure mechanismn which avoids cyclic references or at least removes all references of objects towards each other, if one object is deleted. From mgn000 at yahoo.com Mon Jul 9 11:26:52 2001 From: mgn000 at yahoo.com (Matt Noel) Date: Mon, 09 Jul 2001 08:26:52 -0700 Subject: Sample code for using readline Message-ID: <3B49CD3C.F157E2F@yahoo.com> Can someone send me a sample of how to use the readline module? I'm just starting out with Python and wanted to code up something using readline but I can't quite figure out how to import and use it properly. I've used it before with Perl. A chunk of code would be quite handy. I checked the FAQ but did not see anything that looked useful. -- Matt Noel mgn000 at yahoo.com From gustav at morpheus.demon.co.uk Sat Jul 28 16:59:17 2001 From: gustav at morpheus.demon.co.uk (Paul Moore) Date: Sat, 28 Jul 2001 21:59:17 +0100 Subject: PySol 4.72 sources Message-ID: <rn96mtkdcv1fhrja26qjk9j7ogtvpg2ufh@4ax.com> Has anyone got a working URL for PySol? (Specifically, for the sources to 4.72). The URL I have (http://wildsau.idv.uni-linz.ac.at/mfx/pysol.html) doesn't work any more, and a Google search throws up nothing which works :-( Thanks, Paul From sh at ttsoftware.co.uk Mon Jul 23 12:33:08 2001 From: sh at ttsoftware.co.uk (Steve Horne) Date: Mon, 23 Jul 2001 17:33:08 +0100 Subject: Which Python version to code for? References: <tlbbqas5b6hvff@corp.supernews.com> <9jaf52$ff0$1@panix2.panix.com> Message-ID: <jojoltg9m6atgia43j7j2abks4b749equl@4ax.com> On 20 Jul 2001 16:33:54 -0700, aahz at panix.com (Aahz Maruch) wrote: >Essentially, I'm arguing that it's "reasonable" to require a developer >to install a current version of a software package, but it's not >reasonable to so require an end user. One proviso - install a shell script/alias/whatever that knows which version of Python to run - some machines have several versions installed, and the default isn't always going to be the one you want. BTW - is there any way to register for advance info and early versions - I'm particular interested in the SCons among all the build tools (I hate make and I desperately hate the non-standard nature of current alternatives) but I've been disappointed with the limited info on the SC site. -- Steve Horne Home : steve at lurking.demon.co.uk Work : sh at ttsoftware.co.uk From aleaxit at yahoo.com Tue Jul 3 12:22:34 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 3 Jul 2001 18:22:34 +0200 Subject: Python and DB support (was: Re: Is Python Dead?) References: <mailman.994135925.11224.python-list@python.org> <Y3k07.26347$he.1370115@e420r-atl1.usenetserver.com> Message-ID: <9hsrgc02hfj@enews1.newsguy.com> "Steve Holden" <sholden at holdenweb.com> wrote in message news:Y3k07.26347$he.1370115 at e420r-atl1.usenetserver.com... ... > cursor.execute("SELECT f1, f2, f3 FROM table WHERE f4=? AND f5=?", (f4val, > f5val)) > > I think you'll find it's more than a little tricky. Also, in VBScript, if rs Make a command object, with the CommandText property set to just the same string as above, and call its Execute with the Parameters set to Array(f4val,f5val). What's "more than a little tricky" about this -- having to set CommandText then call Execute in two steps? But this opens an opportunity to _prepare_ the command object (set its Prepared property too) if you need to execute it repeatedly with different parameters. > is a recordset (with an implied current member), you have to access fields > using > > rs("FieldName") > > This is a bizarre way to reference things by name. If your colleagues see > this as natural then they have their Microsoft blinkers on. I have no I guess I must have such blinkers, because I don't see this as an issue. I may typically have the field names in variables, so how else would I access the fields unless by using those values as parameters to SOME call or other? it could be more explicit, for sure -- hey, you CAN write rs.Fields("FieldName").Value, you know, you don't HAVE to take the above shortcuts!-). I'm no Microsoft lover, but SOME of their stuff ain't too bad, and I think ADO falls into the "not too bad" category (some SMALL subset of their stuff is EXCELLENT, and COM is right there, but that's another issue:-). Indeed, I believe ADO (and much more so, COM:-) deserves a far better language than Visual Basic... Python, for example!-). Alex From SBrunning at trisystems.co.uk Tue Jul 31 04:23:08 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Tue, 31 Jul 2001 09:23:08 +0100 Subject: Optional argument for string.strip() (Was: [Python-Dev] Small fea ture request) Message-ID: <31575A892FF6D1118F5800600846864D78BF35@intrepid> >From: aahz at rahul.net [SMTP:aahz at rahul.net] >Simon Brunning wrote: >> >> This comes up on c.l.py occasionally, though - "What is Python's equivalent >> of Perl's 'chomp' function?" The .rstrip() method isn't it, 'cos it strips >> all whitespace, but often people want only the line separators removed. if >> rstrip took an argument, you could do: >Ah. Yes, that one. I think that ought to be better fixed with an >actual chomp() function, but the argument against it has always been >that there's no good way to do it in the face of files from other >platforms.... You wanna talk about that one, we might be able to have a >productive discussion on c.l.py. Will do... To recap: The .split method on strings splits at whitespace by default, but takes an optional argument allowing splitting by other strings. The .strip method (and its siblings) always strip whitespace - on more than one occasion I would have found it useful if these methods also took an optional argument allowing other strings to be stripped. For example, to strip, say, asterisks from a string you could do: >>>fred = '**word**word**' >>>fred.strip('*') word**word As I mentioned, this would give us an equivalent to Perl's 'chomp'. Does this sound sensible/useful? BTW, my spell checker suggests that 'Perl' should be spelt 'Peril'. Smarter than I thought. Cheers, Simon Brunning. ----------------------------------------------------------------------- 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 nospam at mega-nerd.net Mon Jul 16 17:03:16 2001 From: nospam at mega-nerd.net (Erik de Castro Lopo) Date: Mon, 16 Jul 2001 21:03:16 GMT Subject: Bug in Python DNS module Message-ID: <3B535691.96BDB5E3@mega-nerd.net> A couple of days ago I asked for and received a link to a Python DNS module. I have since found a bug in the ParseResolvConf() functions. This is how it was: def ParseResolvConf(): "parses the /etc/resolv.conf file and sets defaults for name servers" import string global defaults lines=open("/etc/resolv.conf").readlines() for line in lines: string.strip(line) if line[0]==';' or line[0]=='#': continue This is how it should be: def ParseResolvConf(): "parses the /etc/resolv.conf file and sets defaults for name servers" import string global defaults lines=open("/etc/resolv.conf").readlines() for line in lines: line = string.strip(line) if not line or line[0]==';' or line[0]=='#': continue I'm not sure who to send it to so I'm posting it here. Regards, Erik -- ----------------------------------------------------------------- Erik de Castro Lopo nospam at mega-nerd.com (Yes its valid) ----------------------------------------------------------------- "UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things." -- Doug Gwyn From phawkins at connact.com Thu Jul 12 13:07:57 2001 From: phawkins at connact.com (phawkins at connact.com) Date: 12 Jul 2001 13:07:57 -0400 Subject: File processing References: <9id5p9$8r62@interserv.etn.com> <9if3fv$8r65@interserv.etn.com> Message-ID: <wkzoaaf53m.fsf@mail.connact.com> >>>>> "CM" == Chris McMillan <christopherjmcmillan at eaton.com> writes: CM> Thank you everyone for your imput!! On a side note: I would have loved to CM> use bash, sed, etc, but unfortunately I'm forced to use a Windows NT CM> machine. I just thought this might be an excellent python exercise since CM> I'm in the process of learning it. So get cygwin -- http://sources.redhat.com/cygwin/ --Patricia From peter at engcorp.com Tue Jul 10 23:23:25 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 10 Jul 2001 23:23:25 -0400 Subject: Newbie asks(2): How to do this line of C in Py? References: <tkmfvla7npuqfd@news.supernews.com> <uzoaci9zw.fsf@ctwd0143.fitlinxx.com> Message-ID: <3B4BC6AD.9B0783D9@engcorp.com> David Bolen wrote: > > "Steve S.L. Wong" <sailwong at alumni.cuhk.edu.hk> writes: > > > if sscanf(command,"%c%d",&c,&d) != 2 { > > } > > You seem to be posting a lot of one line translation requests - are > you trying to get a program translated to Python one line at a time? Not to mention that he doesn't seem to be learning from the previous responses, or showing any indication of having tried himself first. (Four hours early the sscanf(x, "%d") variant was posted and applying that to this isn't a reach, given Alex' answer.) Steve, maybe you could spend a bit of time searching the documentation for assistance before asking these questions. Then, when you've put a small bit of effort in (during which time you'll doubtless learn all kinds of other stuff about Python), post here with some kind of "I tried this XXXX but it didn't work they way I expected... Can anyone help please?" It's also fairly customary and polite to let your assistants know a little background on the nature of your task at hand. Are we really translating a C program one line at a time? Not that that's realy a problem in c.l.p, but maybe you could let us know what the program does? Or will it spoil the punchline? <grin> Cheers, ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From greg at cosc.canterbury.ac.nz Tue Jul 31 02:19:17 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Tue, 31 Jul 2001 18:19:17 +1200 Subject: PEP 238 (revised) References: <cp4rrz5onj.fsf@cj20424-a.reston1.va.home.com> <slrn9m3bt8.114.sill@sill.silmarill.org> <3B61B7E4.5C6DFF01@Lugoj.Com> <cpzo9q16ux.fsf@cj20424-a.reston1.va.home.com> Message-ID: <3B664DE5.D24365BE@cosc.canterbury.ac.nz> Guido van Rossum wrote: > > I don't know of a portable way to generate -0.0 in Python; on my Linux > box, simply writing -0.0 does it, but not on my Windows box. You could try things like -1.0 * 0.0 -- 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 Tue Jul 31 13:23:50 2001 From: chrishbarker at home.net (Chris Barker) Date: Tue, 31 Jul 2001 10:23:50 -0700 Subject: simple question:the count of array References: <mailman.996583454.15942.python-list@python.org> <3B66AF1E.39363654@cybermesa.com> Message-ID: <3B66E9A6.4713C7AA@home.net> Jay O'Connor wrote: > > >>> a=['a','b','c'] > > >>> b=a.count() > > Traceback (most recent call last): > > File "<pyshell#9>", line 1, in ? > > b=a.count() > > TypeError: count() takes exactly 1 argument (0 given) > I'm not sure what "count()" does, but to get the number of values in an list.count(x) returns how many instances of x are in list.: >>> a.count('b') 1 >>> a.append('b') >>> a ['a', 'b', 'c', 'b'] >>> a.count('b') 2 -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 greg at cosc.canterbury.ac.nz Thu Jul 12 01:31:14 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Thu, 12 Jul 2001 17:31:14 +1200 Subject: Language change and code breaks References: <wuN27.13377$Y6.4240331@news1.rdc2.pa.home.com> <cplmlvh6dx.fsf@cj20424-a.reston1.va.home.com> <Sa137.1466$zv2.51843@news.pacbell.net> Message-ID: <3B4D3622.5B4FC76E@cosc.canterbury.ac.nz> Dirck Blaskey wrote: > > In all the examples cited that show why this is a problem, > it's not integer division that causes the confusion, > it's division of integer *literals*. That's only because the examples have deliberately been made very concise, to show the essence of what's going on. The problem occurs when / is applied to integer *objects*, which can arise from any number of sources. -- 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 jim at publishingresources.com Mon Jul 23 12:17:00 2001 From: jim at publishingresources.com (Jim Abrams) Date: Mon, 23 Jul 2001 16:17:00 -0000 Subject: PEP0238 lament References: <5sdnlt072hm6hp17nluu6f0fqq4bvr6mj8@4ax.com> <mailman.995873261.11975.python-list@python.org> <916olt0p3kciv0evmotdg6jev9bl29l57i@4ax.com> Message-ID: <Xns90E77C7A1776Cjimpublishingresourc@207.126.101.100> Steve Horne <sh at ttsoftware.co.uk> wrote in <916olt0p3kciv0evmotdg6jev9bl29l57i at 4ax.com>: >Had Python started out differently, I'd still disagree but I wouldn't >be making a big issue. But this is a code-breaker of the worse kind - >it will create bugs in trusted programs that have been relied upon for >years without problem, which the programmers have forgotten about (if >the programmers are even still in the company) - and many of the bugs >may not even be obvious when they occur. And it will happen a *lot* - >division is *not* some obscure rarely-used feature, it is a basic >arithmetic operation. > >The reward for advocating Python is apparently that you get to look a >complete idiot in front of your boss when everything you've written >goes pear shaped - *just* the kind of thankyou all the Python >advocates have been looking for, I don't think. Because every camel has its straw, I need to agree here. I, and most of my python buddies, fight with bloodstained teeth and nails to get python in our projects and developments. I can't see winning too many arguments when my opposition can pull out 'the division operator' to shoot me down. I can't see budgeting time and people to making sure the division operator works after an upgrade. I'd be laughed into data entry ;). Options such as // for the new semantics, keeping / as integer div seem quite reasonable. Or even allowing / to be used with the new semantics given some "from __something__ import something" seems very acceptable. And not just as a stepping stone to future versions, as a permanent change to how the interpreter works. Reading the points people make keeps reminding me of a joke. A Mathematician, an Engineer and a Physicist are hunting in the woods. The come upon a trophy buck. The Physicist shoots and the shot is 5 feet too low. He mumbles about improper air resistance and drag. The engineer then fires and the shot is 5 feet too high. He mumbles about overcompensating for environmental variables. The mathematician looks left at the Physicist, right at the Engineer and exclaims, "You got him!" Jim From mirko.liss at web.de Tue Jul 3 21:32:32 2001 From: mirko.liss at web.de (Mirko Liss) Date: Wed, 4 Jul 2001 03:32:32 +0200 Subject: Python for air traffic control? In-Reply-To: <bebbba07.0107031040.593143f8@posting.google.com> References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> <9hrj3q$cj1@news1.gtech.com> <bebbba07.0107031040.593143f8@posting.google.com> Message-ID: <20010704013238.2DC8A00.NOFFLE@niccolo.ke4.de> On 3 Jul 2001, Russ wrote: > Consider the type checking in C or C++, for example. Suppose that a > function takes several ints (or any other type) as arguments, and > suppose the calls of the function all pass ints in the correct slots. > The compiler will be perfectly happy. Does that assure that the > arguments are passed correctly? Of course not. It is a necessary but > not sufficient condition for correctness. The arguments could be > completely out of order, and the compiler wouldn't have a clue. If the arguments of a function are out of order, the compiler should bark and die, shouldn?t it? Most programmers use type definitions deliberately, just to provoke that kind of compile-time errors. An example in C: typedef plane_t int ; /* plane no */ typedef lane_t int ; /* lane no */ typedef go_down_in_pieces_t bool ; go_down_in_pieces_t dispatch( plane_t flightno, \ lane_t neigboring_highway ) ; If the arguments get swapped, the compiler gets angry. Is this what you wanted to have in C ? Run-time exceptions should be treated differently than compile-time errors and warnings. In Python, you end up with lots of possible exceptions at run-time. Supposedly, you might want to drop dynamic typing for your kind of application. Regards, Mirko From mike_haspert at credence.com Thu Jul 12 16:24:43 2001 From: mike_haspert at credence.com (Mike Haspert) Date: 12 Jul 2001 13:24:43 -0700 Subject: starting PythonWin from script called by embedded interpreter Message-ID: <fab90324.0107121224.28ec4964@posting.google.com> Hi all: First I've got to say it's been fun "learning by lurking." But now I've learned enough to get in over my head, and I'd sure appreciate some advice. I'm investigating the pain vs profit of using python as a customization layer inside an MFC project: An MFC project embeds the python interpreter, and calls python scripts which optionally use SWIG wrapped C or C++ extensions. I quite like Mark Hammond's PythonWin but hit problems when I tried to use it to debug a function called by PyEval_CallObject(), but _only_ in an MFC app. THE SETUP: I'm using python 2.1, VC++6.0, and NT4.0 sp6. I've embedded the python interpreter into 6 testcase projects, debug and release builds of a console app, a console app supporting MFC, and an MFC app. Each app does the same thing: It calls a function in a python module with the following sequence. (error checking and incref/decref'ing elided) Py_Initialize(); PyObject *mod = PyImport_ImportModule("testmodule"); PyObject *func = PyObject_GetAttrString(mod, "f1"); PyObject *args = Py_BuildValue("(i)", 7)) //just a test value PyObject *rvals = PyEval_CallObject(func,args); //do stuff with rval Py_Finalize(); THE PROBLEM: When I run my MFC app testcase or my "console app supporting MFC" testcase, PyEval_CallObject() returns 0. Doing prints inside the script shows that "import pywin.debugger" succeeds and the line "pywin.debugger.set_trace()" doesn't. Yow. Can I make the interpreter spit out more info on what happened? Can I make PythonWin spit out info on what happened? Does anyone recognize this because they went through it already? Any advice on debugging embedded Python? Any caveats about embedding Python in an MFC project? MORE DETAILS: All testcases work if I don't try to start the debugger from inside the pyscript. (debug build projects use python21_d.dll) I'm following the example in the debugger tutorial and adding the following lines in the function I've called with PyEval_CallObject() in order to start the debugger. import pywin.debugger pywin.debugger.set_trace() SOME SUCCESS: Release build Console app testcase successfully starts the debugger: I can step through my C++ code. When PyEval_CallObject()executes, PythonWin starts and I can step through the script. Wonderful. When the script finishes, I can continue stepping through my C++ code again. Wonderful again. This is what I want to be able to accomplish in an MFC project. (BTW, in case you came to a full stop reading about stepping through a release build, you can alter release build settings to allow it. Details in MSDN's "Turn on Generation of Debug Information for the Release Build") Debug build testcases fail, but I expected that: PythonWin doesn't work when my C++ project is a debug build. I expect that I'll have to get the source for the windows extensions and pythonwin and do a debug build to remedy this. From db3l at fitlinxx.com Mon Jul 30 15:12:40 2001 From: db3l at fitlinxx.com (David Bolen) Date: 30 Jul 2001 15:12:40 -0400 Subject: Radical Suggestion for Integer Division Migration References: <2f2tj9.ejt.ln@10.0.0.1> Message-ID: <uwv4q5izb.fsf@ctwd0143.fitlinxx.com> Carl Banks <idot at vt.edu> writes: > Basically, have all integer division using the "/" operator throw an > exception during the transition period, unless "from __future__ import > division" appears in the module. I'm definitely not in favor of this. What this does is essentially move a hot cut date for backwards compatibility right to the very first release that is built to transition to the new behavior. In other words, it removes any possibility of a graceful transition with older code. Sure warnings could be ignored, but that's the whole point - you have some time during which you can ignore them but your code keeps working, while you work to fix the issues. -- -- 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 ajs at ix.netcom.com Tue Jul 31 20:38:29 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Tue, 31 Jul 2001 20:38:29 -0400 Subject: Changing the Division Operator -- PEP 238, rev 1.12 References: <Pine.LNX.4.33.0107311623050.649-100000@bms> Message-ID: <000701c11a22$4e890f60$a9e1fea9@carol> Bruce writes - > I think you are missing something... > If you were designing a control system for the `toys', and needed to > expose a user level programming interface; would you be more likely to > choose languages C+S or language P (which can do both jobs) > [C+S == P, of course]. > > Unless CP4E is done as a "semantic game" with a larger language, > language P will never exist. Or else I am expressing myself badly and you are missing something of my point. Let's take one little such toy. A calculator. One that does undisguised Python numerics - 3/4 = 0, 3.0/4 = .75. But let's give them 2 different names. One is called the Python Calculator and the other the Python Numeric Type Calculator. One is sadly broken and the other works perfectly - but they are exactly the same little toy. If you see my wonderfully made little point. ART From paulp at ActiveState.com Sat Jul 28 15:11:30 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sat, 28 Jul 2001 12:11:30 -0700 Subject: The Evolution Of Python References: <8beb91f5.0107280407.5a30341d@posting.google.com> <3B62FAFF.BB987077@Lugoj.Com> Message-ID: <3B630E62.3710EF0@ActiveState.com> James Logajan wrote: > > ... > > b.1\ Or K&R C (in which Python was written for a long time to maximize > portability) or ANSI C (which tried to maintain compatibility with K&R). A > case where stagnation helped lead to success. I believe that the stagnation followed success. The same may happen to Python. If it is ever the "default programming language" then it will become essentially impossible to change in any reasonable time frame. Guido is trying to make the changes now because they won't be possible then. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From paulp at ActiveState.com Sun Jul 1 15:57:09 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sun, 01 Jul 2001 12:57:09 -0700 Subject: PEP 261, Rev 1.3 - Support for "wide" Unicode characters Message-ID: <3B3F8095.8D58631D@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 Abstract Python 2.1 unicode characters can have ordinals only up to 2**16 -1. This range corresponds to a range in Unicode known as the Basic Multilingual Plane. 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 A code point is an integer between 0 and TOPCHAR. If you imagine Unicode as a mapping from integers to characters, each integer is a code point. But the integers between 0 and TOPCHAR that do not map to characters are also code points. Some will someday be used for characters. Some are guaranteed never to be used for characters. Codec A set of functions for translating between physical encodings (e.g. on disk or coming in from a network) into logical Python objects. Encoding Mechanism for representing abstract characters in terms of physical bits and bytes. Encodings allow us to store Unicode characters on disk and transmit them over networks in a manner that is compatible with other Unicode software. Surrogate pair Two physical characters that represent a single logical character. Part of a convention for representing 32-bit code points in terms of two 16-bit code points. Unicode string A Python type representing a sequence of code points with "string semantics" (e.g. case conversions, regular expression compatibility, etc.) Constructed with the unicode() function. 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 use 4 bytes per character. 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 the 4-byte implementation 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 on wide Python builds. On narrow builds it will raise ValueError. ISSUE Python currently allows \U literals that cannot be represented as a single Python character. It generates two Python characters known as a "surrogate pair". Should this be disallowed on future narrow Python builds? Pro: Python already 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. It is also somewhat logical considering that the Unicode-literal syntax is basically a short-form way of invoking the unicode-escape codec. Con: Surrogates could be easily created this way but the user still needs to be careful about slicing, indexing, printing etc. Therefore some have suggested that Unicode literals should not support surrogates. ISSUE Should Python allow the construction of characters that do not correspond to Unicode code points? Unassigned Unicode code points 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? Pro: If a Python user thinks they know what they're doing why should we try to prevent them from violating the Unicode spec? After all, we don't stop 8-bit strings from containing non-ASCII characters. Con: Codecs and other Unicode-consuming code will have to be careful of these characters which are disallowed by the Unicode specification. * ord() is always the inverse of unichr() * There is an integer value in the sys module that describes the largest ordinal for a character in a Unicode string 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.unicodewidth which can take the values 'wide' and 'narrow'. * every Python Unicode character represents exactly one Unicode code point (i.e. Python Unicode Character = Abstract Unicode character). * codecs will be upgraded to support "wide characters" (represented directly in UCS-4, and as variable-length sequences in UTF-8 and UTF-16). This is the main part of the implementation left to be done. * There is a convention in the Unicode world for encoding a 32-bit code point in terms of two 16-bit code points. These are known as "surrogate pairs". Python's codecs will adopt this convention and encode 32-bit code points as surrogate pairs on narrow Python builds. ISSUE Should there be a way to tell codecs not to generate surrogates and instead treat wide characters as errors? Pro: I might want to write code that works only with fixed-width characters and does not have to worry about surrogates. Con: No clear proposal of how to communicate this to codecs. * 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 from files, but you could construct them using string literals or unichr(). Implementation There is a new (experimental) define: #define PY_UNICODE_SIZE 2 There is a new configure option: --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. It is also proposed that one day --enable-unicode will just default to the width of your platforms wchar_t. Windows builds will be narrow for a while based on the fact that there have been few requests for wide characters, those requests are mostly from hard-core programmers with the ability to buy their own Python and Windows itself is strongly biased towards 16-bit characters. Notes This PEP does NOT imply that people using Unicode need to use a 4-byte encoding for their files on disk or sent over the network. It only allows them to do so. For example, ASCII is still a legitimate (7-bit) Unicode-encoding. It has been proposed that there should be a module that handles surrogates in narrow Python builds for programmers. If someone wants to implement that, it will be another PEP. It might also be combined with features that allow other kinds of character-, word- and line- based indexing. Rejected Suggestions More or less the status-quo We could officially say that Python characters are 16-bit and require programmers to implement wide characters in their application logic by combining surrogate pairs. 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. "Space-efficient Unicode" type Another 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. Guido is not willing to undertake the implementation right now. Two types We could introduce a 32-bit Unicode type alongside the 16-bit type. There is a lot of code that expects there to be only a single Unicode type. This PEP represents the least-effort solution. Over the next several years, 32-bit Unicode characters will become more common and that may either convince us that we need a more sophisticated solution or (on the other hand) convince us that simply mandating wide Unicode characters is an appropriate solution. Right now the two options on the table are do nothing or do this. References Unicode Glossary: http://www.unicode.org/glossary/ Copyright This document has been placed in the public domain. Local Variables: mode: indented-text indent-tabs-mode: nil End: -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From donn at drizzle.com Tue Jul 24 02:13:53 2001 From: donn at drizzle.com (Donn Cave) Date: Tue, 24 Jul 2001 06:13:53 -0000 Subject: user level can't bind socket address & port References: None <Gr577.7519$2k2.398288@news.bora.net> Message-ID: <995955232.999919@yabetcha.drizzle.com> Quoth "" <k5r2a at chollian.net>: | as the title user level can't bind socket address & port | | for example, | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | sock.bind((iface, port)) | | if i login user level, python interpreter generate error message like that | " sock.bind((iface, port)) | socket.error: (13, 'Permission denied') " | | How can I bind socket user level. Use a port value greater than 1024. Values lower than this are reserved for root privilege, for the sake of a crude security distinction. Since access to those ports are mediated by the host, we assume that it allows only bona fide connections - an rsh client that was actually run by the ostensible user, a telnetd server that is actually the standard telnetd, etc. Donn Cave, donn at drizzle.com From new_name at mit.edu Sun Jul 8 16:01:36 2001 From: new_name at mit.edu (Alex) Date: 08 Jul 2001 16:01:36 -0400 Subject: Comment on PEP-0238 References: <3B3BE855.A6223E70@3-cities.com> <cp7kxvlake.fsf@cj20424-a.reston1.va.home.com> <Y4J%6.4084$Z6.2010194@news1.rdc2.pa.home.com> <mailman.994016102.30019.python-list@python.org> <92ae279c.0107071820.7ebb77f8@posting.google.com> <fH227.14742$i8.1300639@e420r-atl3.usenetserver.com> Message-ID: <etd4rsnchr3.fsf@pickled-herring.mit.edu> Sorry, I think it actually would. :) >>> 5/.1 50.0 >>> Alex. From tim.one at home.com Fri Jul 27 01:15:13 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 27 Jul 2001 01:15:13 -0400 Subject: Ints and performance (was Re: PEP0238 lament) In-Reply-To: <3B60AB40.CCE9FA9C@engcorp.com> Message-ID: <LNBBLJKPBEHFEDALKOLCOEJJLBAA.tim.one@home.com> [Peter Hansen] > The interpreter currently has direct support for the most-used > integer operations, thus ensuring that this type has performance > reasonably close to the maximum feasible given the nature of > virtual machines. Actually not close at all. In, e.g., k = i + j we spend a lot more time fiddling with reference counts and memory management than doing the arithmetic! But we'll ignore that since you're already happy <wink>. > Would the number system unification imply that this integer > optimization would be eliminated? It all depends on the details of the implementation; hardware reality doesn't change, and we're still implementing Python in C, so no matter how uniform the user-visible *model* we would still need to make distinctions under the covers. BTW, Python got along fine for years without any integer optimizations at all, but I agree that specialing-casing int + - and compares in the eval loop was a clear net win (for which you can, IIRC, thank Fredrik Lundh). From pinard at iro.umontreal.ca Fri Jul 13 10:54:41 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 13 Jul 2001 10:54:41 -0400 Subject: list and implicit continuation may cause bugs in Python programs In-Reply-To: <3B4E5A44.7100F507@engcorp.com> References: <Pine.LNX.4.21.BCL.0107121756210.14873-100000@suzi.com.onego.ru> <07cb01c10ae4$64a3c440$9865fea9@SUXLAP> <oqvgkyrxhw.fsf@lin2.sram.qc.ca> <086c01c10aec$8ebe4b80$9865fea9@SUXLAP> <mailman.994959323.21264.python-list@python.org> <3B4E5A44.7100F507@engcorp.com> Message-ID: <oqhewgq3pq.fsf@lin2.sram.qc.ca> [Peter Hansen] > Fran?ois Pinard wrote: > > ... My mother often said to me: > > "Des go?ts et des couleurs, on ne discute pas. > > Mais il y en a de meilleurs que d'autres..." > > (roughly translated: "People should never discuss about what is good taste. > > Yet, some people have better taste than others."). > Fran?ois, are you sure your translation is accurate? > I think it should read "Yet, some people taste better than others." > -cannibalistic-ly yr's, A good laugh in the morning! You make my day, Peter! Thanks! :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From sdm7g at Virginia.EDU Mon Jul 30 18:26:16 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Mon, 30 Jul 2001 18:26:16 -0400 (EDT) Subject: Typing system vs. Java In-Reply-To: <3B65A9EA.19373772@home.net> Message-ID: <Pine.NXT.4.21.0107301811480.258-100000@localhost.virginia.edu> On Mon, 30 Jul 2001, Chris Barker wrote: > > However, Perl's typing system is much more flexible (read: > > context-sensitive) than Python's. > > I didn't mean to say that Perl was not dynamicly typed. What I meant to > say was: > > a) Python is dynamically typed, as opposed to weakly typed > b) Python's typing is not like Perl's typing, as you just said yourself. > > Whether or not Perl's typing is best described as "dynamic" or "weak" is > a question I will leave to others that are more familiar with Perl than > I. I would say that some of Perl's automagic coercions (IMHO) make it weakly typed. But I suppose someone could argue that it's stronly typed -- it just has a very convoluted type system. But I've never seen anyone try to chart out that type system explicitly. ( For one example, that would involve tieing strings and numbers together into some sort of sub-type relationship, since you can mix them together ( 'print "1" + 2' ) ) -- Steve Majewski From steve at lurking.demon.co.uk Fri Jul 27 04:55:58 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Fri, 27 Jul 2001 09:55:58 +0100 Subject: Couple of newbie questions... References: <5a140c6d.0107261705.3a4f7db3@posting.google.com> Message-ID: <moa2mtcrbs4e8sajebta4qe3r3fmmf2v9f@4ax.com> On 26 Jul 2001 18:05:50 -0700, foobarickknob at yahoo.com (Scott Taylor) wrote: >I'm just getting started w/ Python - and have run into a couple issues >w/ the Windows extensions... > >1) time.sleep doesn't seem to release time back to the Win32 >subsystem. I had a tight loop, and CPU was maxed out at 100% even if >I did a PumpWaitingMessages w/ a time.sleep. To actually get the loop >to return slices of time back to windows and not max out the CPU I had >to do a PumpWaitingMessages followed by a win32api.Sleep(0) call. My >question is - shouldn't time.sleep actually make the process sleep w/o >hogging CPU? I've not used this, but it isn't necessarily a problem. It sounds as if you have 100% usage because of something that is accepting idle messages - annoying as the CPU indicator doesn't really give a useful result, but non-idle tasks should still be done before whatever is grabbing the idle messages. Disclaimer - this is a general impression, and quite possibly wrong. From sdm7g at Virginia.EDU Mon Jul 30 13:52:24 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Mon, 30 Jul 2001 13:52:24 -0400 (EDT) Subject: a break for comprehensions In-Reply-To: <9k44u5$fua$1@newsy.ifm.liu.se> Message-ID: <Pine.NXT.4.21.0107301343060.258-100000@localhost.virginia.edu> On 30 Jul 2001, Paul Svensson wrote: > In my view, it should obviously end the whole thing; but then I > never see list comprehensions a procedural description for how > to generate the list, but rather a symbolic description of > the list content. With that view it shouldn't matter which > for-clause gets evaluated innermost, and so the only unambigous > thing for the while clause to end, is the whole comprehension. You hit the nail on the head there, Paul! The 'while' clause seems useful, and I don't see anything inherently ambiguous about it, but sticking a procedural clause into what's otherwise a declarative seens to go against the spirit -- what's nice about list comprehensions is that they are just like set notations. ( well -- the left hand side is often procedural -- it would be even more readable if it were more clearly separated with a "where" clause, but that would be Yet Another Keyword... ) -- Steve Majewski From joonas at olen.to Sat Jul 21 17:42:31 2001 From: joonas at olen.to (Joonas Paalasmaa) Date: Sun, 22 Jul 2001 00:42:31 +0300 Subject: VRML References: <slrn9liuit.a6f.jp@localhost.localdomain> Message-ID: <3B59F747.837D36B7@olen.to> Jacek Pop?awski wrote: > > Hello. I am writing car game for Linux. To create 3D objects I use Blender, > save with alt+w which gives simple "videoscape format". I think VRML will be > much better. It will be great to create converter between VRML and my own > format. What I need is Python library which helps me read VRML. I searched > www.python.org, freshmeat and sourceforge. I found some projects, but one is > in C++ and not so easy (example app is huge!), seconds is in Python and I can't > find "download" section anywhere. Can you help me? Use wrlexport.py, that uses Blender/Python API for exporting. You can find it from http://www.janw.gothere.uk.com/exportmesh.html#vrml1 From hinsen at cnrs-orleans.fr Thu Jul 12 05:02:50 2001 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 12 Jul 2001 11:02:50 +0200 Subject: Language change and code breaks References: <wuN27.13377$Y6.4240331@news1.rdc2.pa.home.com> <cplmlvh6dx.fsf@cj20424-a.reston1.va.home.com> <6A%27.454703$eK2.93741234@news4.rdc1.on.home.com> <m3k81fb7jc.fsf@chinon.cnrs-orleans.fr> <mailman.994883960.13777.python-list@python.org> Message-ID: <m3vgky7c5h.fsf@chinon.cnrs-orleans.fr> Skip Montanaro <skip at pobox.com> writes: > I'm not sure that the purpose of a//b would be all that evident to a new > Python programmer, especially one whose first programming language is Certainly not, but it would be evident that it has some special meaning and that you better find out what it is. > Python. I've never seen // used as an operator before other than to So what? > At the very least C, C++ and Java programmers should be familiar with the > purpose of Any experienced programmer will probably figure out what that means. Still, it's a hack. The code doesn't say what you want to do, it says what you *don't* want to do (i.e. integer division). 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 Sat Jul 7 15:07:03 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 7 Jul 2001 15:07:03 -0400 Subject: Comment on PEP-0238 In-Reply-To: <cp8zi0k3kq.fsf@cj20424-a.reston1.va.home.com> Message-ID: <LNBBLJKPBEHFEDALKOLCOEPDKMAA.tim.one@home.com> [Courageous] > If one is going to add keywords to a language, I suggest that a > list of possible future keywords -- even ones that aren't planned > on being supported any time soon -- be reserved at the same time. [Guido] > Good idea. I'd have to fire up my time machine to figure out which > keywords will be used in the future though, and I'm not sure how > successful that would be. C tried this and had a few unused reserved > words (I recall 'fortran') for years until they threw them out. We can avoid that. Just reserve the specific names: keyword1 keyword2 ... keyword9999 in 2.2. This is 10x more keywords than even Magnus will find a use for. keyword1 x keyword47 [for i keyword6 y]: keyword12 42 I suppose we should argue about whether to reserve "keyword0" too <wink>. From anthony at interlink.com.au Fri Jul 20 00:43:40 2001 From: anthony at interlink.com.au (Anthony Baxter) Date: Fri, 20 Jul 2001 14:43:40 +1000 Subject: dnslib license? In-Reply-To: Message from Erik de Castro Lopo <nospam@mega-nerd.net> of "Thu, 19 Jul 2001 20:19:23 GMT." <3B5740C8.4A0DA3F2@mega-nerd.net> Message-ID: <200107200443.f6K4he902502@mbuna.arbhome.com.au> >>> Erik de Castro Lopo wrote > > Andrew Kuchling wrote: > > > BTW, personally I'd vote for extending the DNS code and adding it as > > > dnslib.py to the standard library, rather than having it be a separate > > > project. > > Since Guido suggested the same this seems to be the master plan... > As a user of this thing thing, that it my prefered option. That's the eventual goal, sure. Anthony From peter at engcorp.com Mon Jul 30 20:45:36 2001 From: peter at engcorp.com (Peter Hansen) Date: Mon, 30 Jul 2001 20:45:36 -0400 Subject: Deposing Dictators References: <9jmjne$q54$1@wisteria.csv.warwick.ac.uk> <3b602daf.1623450@nntp.sprynet.com> <slrn9m111q.e6f.Gareth.McCaughan@g.local> <dOoGUKA3PKY7EwWa@jessikat.fsnet.co.uk> <cpsnfi2z9w.fsf@cj20424-a.reston1.va.home.com> <$dK+wKA$tZY7Ewin@jessikat.demon.co.uk> <3b61a98d$0$11917@wodc7nh0.news.uu.net> <3B61B01F.6C6B2B5D@Lugoj.Com> <6c8b7eb9.0107271358.4783d9c1@posting.google.com> <fls3mt0ofg36qek58fjm4ebqgnd7bcbuek@4ax.com> <nQq87.6146$YP2.191178@news.pacbell.net> <3B65C161.12003D86@geneva-link.ch> Message-ID: <3B65FFB0.A28D1E3B@engcorp.com> Borcis wrote: > > Dirck Blaskey wrote: > > > (...) > > > Useful programs aren't discarded so fast as development fashions and > > > religions. > (...) > > Inertia in the software world is a huge force, and always > > to be fought tooth and nail, because generally what Inertia means is: > > "Just live with our mistakes because we can't afford to fix them." > > This is an extremely depressing state. > > You might find it comforting to consider the trojan > in the Bible - e.g. the original sin : the injunction > not to acquire morals from a supernatural source... > I guess it must be about 3k years old. Now that's inertia. Eh? Does this have something to do with the story about there being a snake involved? I don't recall hearing it was a Python... :) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From tjreedy at home.com Tue Jul 31 12:00:07 2001 From: tjreedy at home.com (Terry Reedy) Date: Tue, 31 Jul 2001 16:00:07 GMT Subject: simple question:the count of array References: <mailman.996583454.15942.python-list@python.org> Message-ID: <bCA97.55834$EP6.12760065@news1.rdc2.pa.home.com> "sdf" <wqh-2 at 263.net> wrote in message news:mailman.996583454.15942.python-list at python.org... > >>> a=['a','b','c'] > >>> b=a.count() > Traceback (most recent call last): > File "<pyshell#9>", line 1, in ? > b=a.count() > TypeError: count() takes exactly 1 argument (0 given) a.count(item) counts the number of occurences of item in a. a.count('b') = 1; a.count('x') = 0 Terry J.Reedy From timothyrandolph at NoSpamPleaseyahoo.com Sat Jul 21 14:30:08 2001 From: timothyrandolph at NoSpamPleaseyahoo.com (Tim Randolph) Date: 21 Jul 2001 18:30:08 GMT Subject: Language change and code breaks References: <Pine.LNX.4.33.0107191316390.24983-100000@bms> <mailman.995571273.18192.python-list@python.org> <9j7gv8$9mg@dispatch.concentric.net> <3B587A3F.8060401@mail.mcg.edu> Message-ID: <9jchng$9mr@dispatch.concentric.net> "Keith F. Woeltje" <kwoeltje at mail.mcg.edu> wrote in message news:3B587A3F.8060401 at mail.mcg.edu... > FWIW, I am also in the "sometime programmer" group, and don't find case > sensitivity to be an issue. Even though Pascal (case insensitive) was my > first language, I was always taught to use consistent case, and case > sensitivity was never an issue. I suspect that Konrad Hinsen's > experience can largely be extrapolated: most people bright enough to > figure out loops, conditional statements, and the other "basics" of > programming are probably bright enough to understand that "a" != "A". > Surely correcting what is most likely a modest speedbump on the road to > learning Python isn't worth breaking a lot of existing code. > >K > Obviously, anyone who can program at all can intellectually understand that "spam" != "Spam". Unfortunately, my fingers have minds of their own and occasionally hit shift every now and then, for reasons that I at best dimly understand. (I seem to mistakenly capitalize Nouns more than verbs in English and Identifiers more than methods in Python.) This makes for annoying, if easy to catch errors. In my perfect world, there errors would be flagged in the editor as I make them. But because on some deep level Capitalization just doesn't seem so significant to me, I don't at all like the idea of using it to distinguish identifiers. Do case sensitive URLs make sense to anyone? In my perfect world, we just wouldn't do this, and Python would burp if we tried. I suspect Guido's motivations towards case insensitivity to be akin to his intent on indentation. Having syntactically significant white space makes Python a bit harder to make programs that execute -- in that way he really doesn't care if the language is newbie friendly -- but it makes Python so much easier to read that it is the most user friendly language I have seen. Likewise, having Python disallow distinguishing identifiers by case would make the language harder for people trying to use "n" and "N", but easier to read and perhaps even easier to think. At least for those of us who get tripped up by that kind of usage. but-maybe-I-am-the-Odd-ball-ly yr's, Tim Randolph From fleet at teachout.org Thu Jul 19 12:21:41 2001 From: fleet at teachout.org (fleet at teachout.org) Date: Thu, 19 Jul 2001 12:21:41 -0400 (EDT) Subject: Variable Substitution in commands or funtion names? In-Reply-To: <33105F8B185CD51182E300306E06473E2701B0@hermes.isr.thomson-csf.com> Message-ID: <Pine.LNX.4.30.0107191209270.25223-100000@fleet1> You missed something. >>>CurCust='smith' #assigned previously in program >>>from cust import CurCust Traceback (innermost last): File "<stdin>", line 1, in ? ImportError: cannot import name CurCust and if I do: >>>from cust import smith >>>CurCust[2] i Not what I wanted. The question is - how do I get: "from cust import CurCust" to equal "from cust import smith" and "CurCust[2]" to equal "smith[2]" In the program, CurCust can be assigned to smith, johnson, jones or even Hao-Nghi :) Regards, - fleet - > Hi fleet, > > Just learn that when you write : from cust import CurCust > ==> CurCust becomes local and you have to reference to it by : > print CurCust["street"] > > regards, > Hao-Nghi Au > -----Original Message----- > From: fleet at teachout.org [mailto:fleet at teachout.org] > Sent: Thursday, July 19, 2001 2:26 PM > To: python list > Subject: Variable Substitution in commands or funtion names? > > > > I think I may have gotten myself into a box. > > I have a module "cust.py" that contains several dictionaries - each > references a different customer with address info, etc. such as: > > smith={"busname":"Smitties", "street":"123 West Ave"} > > Parsing the csv output of a spreadsheet allows me to assign "smith" to a > variable - CurCust. > > Now I want to do something like: > > from cust import CurCust > > print cust.CurCust["street"] > > Spent the evening trying to solve this (Learning Python, and Sam's Teach > Yourself Python) then tried the archives. The little I found on "variable > substitution" almost seems to say "no way!" ??? > > (I know someone is going to suggest a database. That's a little further > up the learning curve. I can see it from here; but I'm not there yet.) > > Thanks for any assistance, > - fleet - > > > > From cliechti at mails.ch Tue Jul 24 17:25:38 2001 From: cliechti at mails.ch (chris liechti) Date: 24 Jul 2001 23:25:38 +0200 Subject: Python, ActivePython, wxPython, etc References: <9jkao2$oekti$1@ID-51354.news.dfncis.de> Message-ID: <Xns90E8EE5CA4782cliechtimailsch@62.2.32.50> "Timo Labrenz" <Timo.Labrenz at breisnet-online.de> wrote in news:9jkao2$oekti$1 at ID-51354.news.dfncis.de: > First, sorry for the very newbish question :) > I've been very unhappy with some of the smaller applications I use > lately, so I decided to take over control and start learning to > program. Python seemed to be the right language to start with and python is a good language to start...:-) > http://www.crosswinds.net/~agauld/ is a great help so far. As I looked > for a 'from scratch' tutorial in this newsgroup, I found that there are > many toolkits, editors, GUIs and so on for Python available. And to be > honest, the original Python (2.1.1) package with IDLE seems a little > weak compared to other packages I've seen. The question is, which one IDLE is a nice development tool is has a source editor with highlighting, an iteractive window a debuger... But if you're using Windows you will probably like PythonWin (ActiveState) more because its more in the windows style. > to use? I'm an absolute beginner (some experience in gfa-basic from a > long, long time ago ;)) and I want to write small, usefull programs > that should work on Windows and maybe, but just maybe, could be > compiled in Linux. Those programs are mainly administration tools or > maybe, if I get better, things like a newsreader or -server, nothing > where big graphics other than boxes and schedules are required. (Btw, > Python and MySQL is no problem, is it?) I know it's vague question and SQL modules are around but i dont needed them until now. > a matter of taste, but where is the difference between all those > packages and which one could be the best arranged GUI for a beginner. i think that there is most coverage on tkinter. this is aloso the "native" gui for python as is is in the distribution and so doesn't need any addons. if you want you software to run on a workstation/pc where only a plain python installation is available - this is your choice. its also the one that is available on most platforms (i think) > wxPython looks quite nice to me, but is it good? i am using wxWindows. the gui looks like native windows buts its portable to linux. i just found it a bit more difficult to get into it compared to tkinter (some docs are only from the c++ library and you have to guess how that is implemented using python). once you've got used to it it's definetly great. > Oh, I almost forgot. How is the comatibility between those toolkits and > the original Python? Could I even update such a kit with the newest > version of Python? if you mean toolkit for GUIs: they are not compatible. some ideas and stuctures look often similar but use other objects and other methods. you also need them to be compiled for your python version as most of them use a library (DLL) and are therefore written in C. That's also true for all other extension modules that are written in C. Of course modules that have only python code in them are no problem at. if you mean python from diffrent providers like ActiveState. they are 100% precent compatible with the python.org version. just don't use some extension modules that are not standard to python and you will be fine. as an example the win32all package is included in ActiveState's distribustion but its not standard python. altough you can download it for the python.org version it is one extra step you have to do. and it's not cross-platform but thats always module dependant. > > Thanks in advance > > Timo > PS: your post is one long text without any paragraphs. i think most people get tired to read it just when they see it.. don't post too many questions in a message and make a clear distinction between them and you should get more answers. -- chris <cliechti at mails.ch> From philh at comuno.freeserve.co.uk Sun Jul 1 06:33:09 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Sun, 1 Jul 2001 11:33:09 +0100 Subject: PEP scepticism References: <mailman.993851085.21034.python-list@python.org> <PE9%6.403952$oc7.54279520@news2.rdc2.tx.home.com> <slrn9jrd1t.r2n.philh@comuno.freeserve.co.uk> <mailman.993948781.29797.python-list@python.org> Message-ID: <slrn9jtv35.vlm.philh@comuno.freeserve.co.uk> On Sat, 30 Jun 2001 20:56:41 -0400, Michael Manti <mmanti at home.com> wrote: > >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. I use nedit. -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From nmack at pacbell.net Sat Jul 21 10:40:17 2001 From: nmack at pacbell.net (angusm) Date: 21 Jul 2001 07:40:17 -0700 Subject: ADO Events with win32com References: <vv7hlt8dqss6e3vv2m5pko2tq94obt99r2@4ax.com> Message-ID: <21e393ee.0107210640.54f3e20c@posting.google.com> I think the problem is that COM (or ADO?)requires you to define all the event handlers for the interface in your class: "All the event handlers in the ConnectionEvent ... must be implemented, regardless of whether you actually use events. " MSDN that is, if you use one you have to define the rest (though presumably you can bet by with a "pass" implementation). The same goes for Recordset events. The ADO type library generated by makepy has the prototypes you need. Angus Paul Moore <gustav at morpheus.demon.co.uk> wrote in message news:<vv7hlt8dqss6e3vv2m5pko2tq94obt99r2 at 4ax.com>... > I'm trying to get ADO events working with win32com, but I'm not getting > anywhere. The following is my test code: > > ------------------------------------------------------------- > import win32com.client > > finished = 0 > > class ADOEvents: > def OnConnectComplete(*args): > print `args` > finished = 1 > > def Test(): > # Conn = win32com.client.Dispatch("ADODB.Connection") > Conn = win32com.client.DispatchWithEvents("ADODB.Connection", ADOEvents) > ConnStr = "Provider=msdaora;Prompt=complete" > Conn.Open(ConnStr, Options=16) > while not finished: > pass > > if __name__ == '__main__': > Test() > ------------------------------------------------------------- > > If I understand things correctly, this is about what is needed. > > The problem is that this code immediately returns an error - 'Operation has been > cancelled by the user'. But I didn't! I didn't even get the chance, as the login > box did not appear. > > If I comment out the DispatchWithEvents call, and replace it with a straight > Dispatch call, as on the line above, everything works as I want - the login box > appears (although clearly the event doesn't get fired, so I get an infinite > loop...) > > Is there some reason that DispatchWithEvents isn't working correctly here? > > Thanks for any insight, > Paul. From tbryan at python.net Sat Jul 21 22:46:25 2001 From: tbryan at python.net (Tom Bryan) Date: Sun, 22 Jul 2001 07:46:25 +0500 Subject: subclassing Exceptions References: <9ihklt8u0vvh1aa0mg6tadbmjo9mot47e0@4ax.com> <3b5a69a3$0$320$6e49188b@news.goldengate.net> <ubrklto6t10pidmh5bld02glmcmjd9jdvq@4ax.com> Message-ID: <9jee61$2ac$1@slb6.atl.mindspring.net> Sheila King wrote: > On Sun, 22 Jul 2001 00:51:31 -0500, "Volucris" <volucris at hotmail.com> > wrote in comp.lang.python in article > <3b5a69a3$0$320$6e49188b at news.goldengate.net>: > > :If all you want is your own exception (nothing fancy), all you need is a > :class: > : > :class SpamException: > : pass > > OK, interesting. I didn't realize you could make an exception without > subclassing it. So, I tried this script: Neither did I, but you probably don't want to do that. One reason to subclass from a common Exception base class is so that exceptions can be caught based on inheritence. Also, since there's a common exception base class, all exceptions have common behavior that you'd have to recode if you didn't subclass. > Hmm...I just tried a little experiment in the interactive shell to see > if I could confirm/deny my above theory, and it gave me surprising > results that I do not understand, and which seem to indicate no > difference between deriving it from an Exception class or not. Consider: ----- test1.py ----- class SpamException: pass try: while (1): inputstring = raw_input("Enter any string, except 'spam': ") if inputstring == "spam": raise SpamException # Catch *all* exceptions... # at least those that subclass Exception like they should. :-) except Exception, data: print "Ahhh! ", data ----------------- If I run this, the except block is unable to catch SpamException, although it looks like I should be catching all exceptions since I'm catching the base class of all exceptions: Enter any string, except 'spam': spam Traceback (most recent call last): File "test_exception.py", line 11, in ? raise SpamException __main__.SpamException: <__main__.SpamException instance at 0x80d6cb4> ----- test2.py ----- class SpamException(Exception): pass try: while (1): inputstring = raw_input("Enter any string, except 'spam': ") if inputstring == "spam": raise SpamException( 'User typed "spam."' ) # Catch *all* exceptions... # at least those that subclass Exception like they should. :-) except Exception, data: print "Ahhh! ", data ---------------- Since I sublcass Exception, the except block will be able to catch my exception, and the SpamException automatically gets a constructor that takes an error message as an argument. See: Enter any string, except 'spam': spam Ahhh! User typed "spam." > Well, I am interested in further enlightenment on this topic...? I believe that the intent is for all exception classes to subclass from Exception or one of its sublcasses. I think that a common idiom is for a module to declare its own base exception class. Then, it can declare many subclasses of *that* Exception subclass to use internally. People using the module can simply catch the base FooException unless they have a good reason to get more specific. Basically, they called code in your module, and it blew up. Often, that's as much as they can say, and the error message attached to the exception *should be* enlightening enough to troubleshoot the problem. For example, class StackException( Exception ): pass class EmptyStackException( StackException ): pass class StackOverflowException( StackException ): pass class Stack: """An implementation of the Stack data structure that supports a maximum stack stize. """ def __init__( self, maxSize=None ): try: self.stack = [] self.max = int( maxSize ) except ValueError: #value error is thrown when maxSize isn't an integer raise StackException( "Illegal value for Stack's maximum size: %s." % maxSize ) def push( self, data ): if self.max != None and len(self.stack) == self.max: raise StackOverflowException( "Stack already at maximum size %d" % self.max ) self.stack.append( data ) def pop( self ): if len( self.stack ) == 0: raise EmptyStackException( "Cannot pop from an empty stack" ) self.stack, data = self.stack[:-1], self.stack[-1] return data def peek( self ): if len( self.stack ) == 0: raise EmptyStackException( "Cannot peek at an empty stack" ) return self.stack[ -1 ] if __name__ == '__main__': # Note that our code can simply catch the StackException base class try: aStack = Stack( 'hi' ) except StackException, data: print "Exception for Stack('hi'):", data try: aStack = Stack( 2 ) print aStack.peek() except StackException, data: print "Exception for aStack.peek():", data try: print aStack.pop() except StackException, data: print "Exception for aStack.pop():", data try: aStack.push( 'one' ) aStack.push( 'two' ) aStack.push( 'three' ) except StackException, data: print "Exception for aStack.push('three'):", data Of course, this advice might be slightly off. Python's exception stuff looks a lot like the Java exception stuff, and I've done a lot more Java. Exception-"too-many-languages"-ly yours ---Tom From Kevin.Smith at themorgue.org Thu Jul 26 11:27:18 2001 From: Kevin.Smith at themorgue.org (Kevin Smith) Date: Thu, 26 Jul 2001 15:27:18 GMT Subject: Static method and class method comments References: <9jn382$lqf$1@license1.unx.sas.com> <mailman.996103958.4468.python-list@python.org> <Xns90EA6710921D8duncanrcpcouk@127.0.0.1> <MdW77.10395$UB6.966994@e3500-atl1.usenetserver.com> Message-ID: <cxW77.10413$UB6.969993@e3500-atl1.usenetserver.com> In article <MdW77.10395$UB6.966994 at e3500-atl1.usenetserver.com>, Kevin.Smith at themorgue.org (Kevin Smith) wrote: >In article <Xns90EA6710921D8duncanrcpcouk at 127.0.0.1>, duncan at rcp.co.uk wrote: >>If you change the existing grammar: >> funcdef: "def" funcname "(" [parameter_list] ")" ":" suite >>to: >> funcdef: "def" [funcmodifier] funcname "(" [parameter_list] ")" ":" >>suite >> funcmodifier: identifier One more thing, the [funcmodifier] above might be changed to a [funcmodifier_list] to allow 'protected classmethod' and the like. Kevin Smith From reageer.in at de.nieuwsgroep Tue Jul 17 20:00:26 2001 From: reageer.in at de.nieuwsgroep (Rene Pijlman) Date: Wed, 18 Jul 2001 02:00:26 +0200 Subject: Python 2 times slower than Perl References: <8f41cfd.0107171238.6ff33b9b@posting.google.com> <170720011359545210%mday@apple.com> <87n163mfdc.fsf@elbereth.ccraig.org> Message-ID: <boj9lts5p0prarls7d29tvq1vs2tnqktt6@4ax.com> com-nospam at ccraig.org (Christopher A. Craig) schreef: >I expect this is because of the cost of dealing with so >many Python object creations/deletions which I've found >can be quite a bit higher that C entities. Are these "entities" on the heap or on the stack? Are they the entities that leak and dangle? But seriously, it's no use comparing a low level language to a higher level language with a simple compute loop. Of course the low level language is faster. So use it if you like! If you want to know what languages like Python and Java are good for, compare the development, debug and maintenance time of a multi man year software engineering project. Where do you think all the buffer overrun bugs came from? I guess most of them can be found in lightning fast C programs. -- Vriendelijke groet, Ren? Pijlman <rpijlman at spamcop.net> Wat wil jij leren? http://www.leren.nl/ From jwelby at waitrose.com Tue Jul 10 19:05:25 2001 From: jwelby at waitrose.com (Julius Welby) Date: Wed, 11 Jul 2001 00:05:25 +0100 Subject: csv to XML converter crash and burn References: <tkgnj6feescc0d@xo.supernews.co.uk> <mailman.994606693.28411.python-list@python.org> <tkhilaesrc8d6c@xo.supernews.co.uk> Message-ID: <tkn2g0dngme48a@xo.supernews.co.uk> OK, this: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66003 is now a list of lists to XML converter. I've tested it a bit, and it seems to work OK. J. From stain at linpro.no Wed Jul 18 09:54:21 2001 From: stain at linpro.no (Stian Soiland) Date: Wed, 18 Jul 2001 13:54:21 GMT Subject: SocketServer and broken ThreadingMixIn - patch for 2.1.1c1 Message-ID: <slrn9lb58c.885.stain@zoidberg.trd.linpro.no> As known, in Python 2.1 the SocketServer.ThreadingMixIn does not work, and thereby SocketServer.ThreadingTCPServer etc. are broken as well. The cause was the adding of a close_request()-method in BaseServer and TCPServer. In TCPServer, the close_request() is (for 2.1.1c1) called from process_request. This is all nice and good for normal TCPServers. However, when mixing in the ThreadingMixIn, bad things happen. In vanilla 2.1 release, the connection was closed right after starting the thread. This is of course fixed in 2.1.1c1. However, the fix simply removes close_request() for threaded servers, as the process_request() is overridden. The overriden process_request() simply starts final_request() (doing the actual work), but does not call close_request() afterwards. This means that there is a difference between threaded servers and non-threading servers. In threaded servers, the RequestHandler is actually the one responsible for closing the connection, but in non-threaded servers (even forked ones) the connection is closed by calling close_request(). This is not neccesary. By simply calling BaseServer.process_request() instead of final_request, everything is done nicely, inside the thread, and no differences between non-threaded and threaded servers. BaseServer.process_request calls both final_request() and close_request() Could anyone please review this and tell me if this should be a part of 2.1.x or not? I believe it would break more code if we in this release suddenly demand that all threaded servers (but none of the others) should close the connection when appropriate. By waiting for 2.2 there would be three different ways for implementors to use ThreadingMixIn, depending on wether they have 2.0, 2.1 or 2.2. Why would we want that? Here's my original patch submitted to SourceForge, for Python bug #417845 <URL: https://sourceforge.net/tracker/? group_id=5470&atid=105470&func=detail&aid=417845 > Comment By: Stian Soiland (stain) Date: 2001-07-13 14:51 Message: Logged In: YES user_id=25921 I don't think it's a good idea to let closing the request be the handler's responsibility. It's better to let the ThreadingMixIn do it: stain at zoidberg:~$ diff -u SocketServer-cvs-1.24.2.1.py SocketServer.py --- SocketServer-cvs-1.24.2.1.py Fri Jul 13 23:20:26 2001 +++ SocketServer.py Fri Jul 13 23:34:02 2001 @@ -451,8 +451,10 @@ def process_request(self, request, client_address): """Start a new thread to process the request.""" import threading - t = threading.Thread(target = self.finish_request, - args = (request, client_address)) + # Call the BaseServers process_request to close the + # socket after finally_request. + t = threading.Thread(target = BaseServer.process_request, + args = (self, request, client_address)) t.start() In my eyes this is the best, making the overriden process_request behaving like the original process_request. This would make the difference between Threading-servers and other servers smaller. If it looks bad with BaseServer-references inside ThreadingMixIn, what about a method of ThreadingMixIn named __process_request with the same code as BaseServer.process_request? -- Stian Soiland Guido is appearantly rather busy preparing everything for the 2.1.1 release, and has no time to review this simple patch: Comment By: Guido van Rossum (gvanrossum) Date: 2001-07-17 07:30 Message: Logged In: YES user_id=6380 I have absolutely no time to review this right now. This won't be fixed in 2.1.x; I'll look into making that change for 2.2 at some point. My response: Comment By: Stian Soiland (stain) Date: 2001-07-18 06:36 Message: Logged In: YES user_id=25921 By waiting for 2.2 for this simple patch even more future code would break. The programmer would need to write seperate code for 2.0, 2.1 and 2.2. Why should we want that? It should not take much time reviewing these 6 lines of change. Anyone else care to comment? (This message quoted in posting on comp.lang.python -- Stian S?iland - Trondheim, Norway - http://stain.portveien.to/ Ikke skill deg ut fra mengden, og g? ordin?rt kledd. Det er ikke n?dvendig ? vise frem velstanden. [Europeiske reiseforsikring] From kens at sightreader.com Mon Jul 30 20:48:04 2001 From: kens at sightreader.com (Ken Seehof) Date: Mon, 30 Jul 2001 17:48:04 -0700 Subject: Generator Comprehensions? was Re: a break for comprehensions References: <mailman.996515638.21022.python-list@python.org> <ac677656.0107301331.5330d4db@posting.google.com> <Pyk97.4104$9i1.318163@e420r-atl1.usenetserver.com> Message-ID: <002501c1195a$75c859a0$6501a8c0@pacbell.net> "Steve Holden" <sholden at holdenweb.com> wrote: > "Tom Good" <Tom_Good1 at excite.com> wrote in message > news:ac677656.0107301331.5330d4db at posting.google.com... > > "Steven D. Majewski" <sdm7g at Virginia.EDU> wrote in message > news:<mailman.996515638.21022.python-list at python.org>... > > > > > > The 'while' clause seems useful, and I don't see anything inherently > > > ambiguous about it, but sticking a procedural clause into what's > > > otherwise a declarative seens to go against the spirit -- what's > > > nice about list comprehensions is that they are just like set > > > notations. ( well -- the left hand side is often procedural -- it > > > would be even more readable if it were more clearly separated > > > with a "where" clause, but that would be Yet Another Keyword... ) > > > > > > -- Steve Majewski > > > > That is a compelling argument. However, I am still struggling with > > how to best work with infinite sets (which are now easy to create with > > generators). With set notation, you can refer to an infinite set > > without actually creating each member of the set. List comprehensions > > try to "fill up" the list, which causes problems if an unbounded > > generator is involved. > > > > If g is a generator that generates all positive integers, I would like > > to write something like: > > > > L = [x * 2 for x in g()] > > print L[:10] > > > > This does not work, of course, but that is how I would tend to think > > about it in my head. List comprehensions with lazy evaluation? Is it > > possible? > > > With the introduction of generators there doesn't seem to be anything > inherently impossible about the introduction of such a concept. A major > problem with existing list comprehensions, however, is that they produce a > list! Seems that a "lazy comprehension" would have to encapsulate a > generator somehow, and limit the operations you could perform on it to those > for generators. > > I believe a separate syntax would be required to represent such a radically > different object. But you, of course, may know better ... if you're looking > for a syntax, one possibility would be: > > [[x * 2 for x in g()]] > > regards > Steve That particular syntax won't do since it would seem to require two new tokens "[[" and "]]" which would be really nasty since there's already semantics for those character sequences (i.e. [[1,2,3]] is a list containing the list [1,2,3]). You (Steve) are right IMO, that new language syntax would be required. In addition to the reasons you mention, it would not always unreasonable to return a list when a generator is being iterated, since the generator might be finite. Conversely, one might want a generator comprehension based on some other arbitrary kind of sequence object. How about [... x * 2 for x in g()] - Ken Seehof From claird at starbase.neosoft.com Thu Jul 19 10:33:43 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 19 Jul 2001 09:33:43 -0500 Subject: Examples of using XML and Python? References: <3b56e5fa$1@shiva.ukisp.net> Message-ID: <01386731B2E8CEA4.975E56125183CD19.054C2354B47050A8@lp.airnews.net> In article <3b56e5fa$1 at shiva.ukisp.net>, Mark Ainsworth <marka at sundance.com> wrote: >Has anyone got any simple examples of using Python and XML? The plan is to . . . <URL: http://www.python.org/sigs/xml-sig/ > <URL: http://www-106.ibm.com/developerworks/library/python1/ > <URL: http://www-106.ibm.com/developerworks/xml/library/xml-matters1/ > <URL: http://safari2.oreilly.com/table.asp?bookname=pythonwin32&snode=33 > -- Cameron Laird <claird at NeoSoft.com> Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From kens at sightreader.com Thu Jul 26 15:39:35 2001 From: kens at sightreader.com (Ken Seehof) Date: Thu, 26 Jul 2001 12:39:35 -0700 Subject: garbage collector References: <20010726142931.53348.qmail@web14805.mail.yahoo.com> Message-ID: <016301c1160a$b3bbd500$6501a8c0@pacbell.net> Sounds like your program might benefit from some refactoring aiming at reducing the life time of your objects. I recommend learning about weak references. Also, maybe you could use a database instead of a dictionary somewhere (this could improve performance if you are abusing RAM). - Ken Seehof ----- Original Message ----- From: "franck delarue" <frdelarue2000 at yahoo.fr> To: <Python-list at python.org> Sent: Thursday, July 26, 2001 7:29 AM Subject: garbage collector > hi, > I use python1 with a lot of object (dictionnairies + > lists) and my program takes 3 or 4 hours to execute on > a 4 processors (700 mghz) and 2 Go Ram machine (linux > red hat). > The problem is that when the program is finished, > python still continues to delete the objects (I've put > some "print" to see when the "del" function is > executed) during about 30 minutes. > Is that normal ? Is there a solution to stop the > program correctly ? ("ctrl+alt+del" or "kill -9 XXX" > works but i don't feel satisfied) > > > ===== > __________________________________ ___ > \ \ | _ | \ > \ F R A N C K D E L A R U E \ | |_ | | | > / + - + - + - + - + - + - + / | _ | | | > /_________________________________/ |_| |__/ > > ___________________________________________________________ > Do You Yahoo!? -- Vos albums photos en ligne, > Yahoo! Photos : http://fr.photos.yahoo.com > > -- > http://mail.python.org/mailman/listinfo/python-list From peter at engcorp.com Fri Jul 13 02:11:42 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 13 Jul 2001 02:11:42 -0400 Subject: ANNOUNCE: SCons (Python build tool) development under way References: <mailman.994953807.6320.python-list@python.org> <3B4E702B.8070008@webone.com.au> Message-ID: <3B4E911D.2C5399B3@engcorp.com> [order of quoting corrected] simonb at webone.com.au wrote: > > Steven Knight wrote: > > >This is to announce that active development of SCons is now underway at: > > > > http://scons.sourceforge.net/ > So this is not just for a python project (i can't see why > you would need any "make" utility for a (purely) python project), > but as a real replacement for make? > ie. reads makefiles and such? > Well, im rather confused about this... Well, if it will help, since maybe you didn't click on the conveniently included link, "SCons is ... an improved substitute for the classic Make utility... What makes SCons better? * Configuration files are Python scripts--no new syntax to learn. * Global view of all dependencies--no more multiple build passes or reordering targets to build everything. Reliable detection of build changes using MD5 signatures, not timestamps. Reliable, automatic dependency analysis--no more "make depend" / "make clean" to get all of the dependencies. Easily extensible through user-defined builders. Building from central repositories of source code and/or pre-built targets. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From kens at sightreader.com Tue Jul 10 04:19:04 2001 From: kens at sightreader.com (Ken Seehof) Date: Tue, 10 Jul 2001 01:19:04 -0700 Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> <bebbba07.0107021206.70a22aa8@posting.google.com> <20010702175245.A4092@node0.opengeometry.ca> <mailman.994201507.10872.python-list@python.org> <bebbba07.0107050010.8a47cf1@posting.google.com> Message-ID: <01af01c1091f$c7e9a9a0$0e4ab43f@kens> From: "Russ" <18k11tm001 at sneakemail.com> > "Ken Seehof" <kens at sightreader.com> wrote in message news:<mailman.994201507.10872.python-list at python.org>... > > For liability reasons, I can't give you advice on whether or not to > > use python for an air traffic control application :-) > > > > However, if I were (hypothetically, of course) to give you advice, > > it would be the following, of which your reading constitutes an > > agreement that I am not responsible for injury, deaths, and property > > damage resulting from that which would be my advice, were it not, > > if fact, hypothetical, which it is. > > If you hear something about an airplane crash in a few years, prepare > for a call from my lawyer. :-) > > > Seems to me that python would be a good choice. You can write > > bugs in any language, including python. However, python bugs > > tend to be less subtle and easier to detect and fix than C/C++ bugs. > > > > The lack of type checking and function prototyping is not nearly as > > big of a problem (if it's a problem at all) as C++ programmers tend > > to fear. > > > > This fear is due to the fact that in some statically typed languages > > such as C++, an undetected type mismatch is likely to cause rather > > horrible bugs which are often intermittent and often corrupt unrelated > > data. > > > > These kinds of type mismatch bugs that C++ programmers are > > terrified of (memory overwrites, etc.) simply do not exist in python at > > all. Python doesn't ever need to infer the addresses of bytes of data > > from dubious type information at runtime (as C++ does). Type > > information is always stored within the objects themselves. > > > > In python, data of the wrong type is not really any worse than data > > of the wrong value, so these kinds of bugs tend to only have local > > effects which are easily caught when tested. Not surprisingly, I have > > found that I usually get fewer type related bugs in Python than in C++. > > > > Saying that python is unreliable because it lacks type checking is like > > saying fish cause pollution because they lack bicycles. > > > > - Ken > > That's very interesting. Thanks for that perspective. I'd like to see > you hash this out with Peter Milliken, who claims that type checking > is essential for safety-critical applications. (Perhaps you did > already. I'm using google groups, and I get very slow updates on this > thread.) > > Russ Okay, time to retreat a little; that lawsuit thing is scaring me :-) I think I have to agree with Peter on that point. I also think that type checking fails to make C++ safe, and that it is not nearly as important in Python for the reasons stated above. Presumably what you really want is a high-level language that has strong type checking and no way to corrupt memory even if you try to. I'm don't have experience with such languages. The original question was about choosing between C++ and Python, and having used C++ since it's creation, I would rather prefer not to trust anything written in it with my life (though no doubt I have, unwittingly :-). I was just taking the opportunity to point out the flaw in the common misconception that C++ is more robust than Python because of static type checking. IMHO, neither language is really optimal for safety- critical applications. - Ken From guido at python.org Tue Jul 24 15:40:06 2001 From: guido at python.org (Guido van Rossum) Date: Tue, 24 Jul 2001 19:40:06 GMT Subject: Future division patch available (PEP 238) References: <GNZwEiAJepW7Ew0F@jessikat.fsnet.co.uk> <mailman.995776716.24336.python-list@python.org> <mailman.995825018.9832.python-list@python.org> <9jfjd6$ad4$2@newshost.accu.uu.nl> <7u6nltoqdnqjjdiquu6ngtaruflhvbvdl5@4ax.com> <j4g0bof3jv.fsf@informatik.hu-berlin.de> <p8unltsi5qda8rpdavja4iemj6r1s2ak4a@4ax.com> <j48zhfgbny.fsf@informatik.hu-berlin.de> <23891c90.0107230531.4fb02b12@posting.google.com> Message-ID: <cpd76qqfow.fsf@cj20424-a.reston1.va.home.com> paul at boddie.net (Paul Boddie) writes: > But over a few releases, which seem to be quite frequent these days, > one may find oneself with quite a collection of "legacy" programs > which can't be guaranteed to run correctly under the most recent > releases. The typical advice in such cases is for people not to > upgrade, with the unfortunate result that certain users are likely to > find themselves stranded on increasingly neglected releases of Python; > particularly as module developers start to rely on newly introduced > features. I think it will be inevitable for many Pythons to come to provide a way to turn off the new division rules. I am currently working on a command line option for this. > In changing the semantics of the / operator, however, *everyone* is > made to feel insecure. And grep "/" `find . -name "*.py"` (or > whatever), unlike the suitability of such an approach in the case of > "connect", is hardly going to help. Several people are talking about > clever tools: perhaps once they are written, the authors will then > give us the type inferencing system people have been wanting for so > long. <1/2 wink> That's not a bad idea. Maybe the race for the best division upgrade tool will have practical type inference as a side effect. Traditionally, "mostly correct" type inference has been rejected as too dangerous; but in a conversion tool, it would be much better than nothing. Maybe PyChecker's engine might be up to the challenge; it already seems to attempt some type inference, for example in its warnings about inconsistent return values. --Guido van Rossum (home page: http://www.python.org/~guido/) From paul at boddie.net Mon Jul 23 09:35:46 2001 From: paul at boddie.net (Paul Boddie) Date: 23 Jul 2001 06:35:46 -0700 Subject: web sessions support References: <O8R67.2110$De6.330884@news.pacbell.net> <3B5BE6CC.9B71B87E@stroeder.com> Message-ID: <23891c90.0107230535.dd3f8e9@posting.google.com> Michael Str?der <michael at stroeder.com> wrote in message news:<3B5BE6CC.9B71B87E at stroeder.com>... > > There are other modules too: > http://thor.prohosting.com/~pboddie/Python/web_modules.html Or better still: http://www.paul.boddie.net/Python/web_modules.html Thanks for the plug, Michael! ;-) Paul From opengeometry at yahoo.ca Mon Jul 2 17:52:45 2001 From: opengeometry at yahoo.ca (William Park) Date: Mon, 2 Jul 2001 17:52:45 -0400 Subject: Python for air traffic control? In-Reply-To: <bebbba07.0107021206.70a22aa8@posting.google.com>; from 18k11tm001@sneakemail.com on Mon, Jul 02, 2001 at 01:06:57PM -0700 References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> <bebbba07.0107021206.70a22aa8@posting.google.com> Message-ID: <20010702175245.A4092@node0.opengeometry.ca> > From: Russ (18k11tm001 at sneakemail.com) > Subject: Python for air traffic control? > Date: 2001-06-29 17:42:45 PST > > 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. Of course, you idiot... It depends how well you did in high school math. If there are N airplanes whose positions are given by (x,y,z)_i, i=1,2,...N then you have to calculate distance from an airplane at to every other airplanes. You would be maintaining NxN table to see - if any position is outside the assigned trajectory, or - distance (between any two position) is too close Am I missing something? -- William Park, Open Geometry Consulting, <opengeometry at yahoo.ca> 8 CPUs cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc. From Randy.L.Kemp at motorola.com Wed Jul 25 11:53:18 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Wed, 25 Jul 2001 10:53:18 -0500 Subject: Deposing Dictators Message-ID: <E566B020833BD311B6610008C791A39705CA527E@il93exm04.css.mot.com> I agree that Python is fun and exciting. In fact, I ran into this guy in the alley, who sold me a bunch of Python tee shirts, with a picture of a guy named Larry Wall on them. Can anyone tell me if these are "official Python tee shirts?" I hate to think that I got ripped off. -----Original Message----- From: Thomas Weholt [mailto:thomas at gatsoft.no] Sent: Wednesday, July 25, 2001 9:39 AM To: python-list at python.org Subject: Re: Deposing Dictators I think Guido has done a great job so far. Python is by far the most productive and fun programming language I've ever worked with. Introducing new features is probably a good thing in terms of letting Python evolve as a language, but I'm more concerned about the fact that each new release of Python seem to be slower than the one before. Perhaps the developers should focus more on performance and tuning of existing code before adding more core features. I *do* think the inclusion of things like pyunit and pydoc are good things, - very good indeed. Extending the standard library and focusing on performance issues would possibly be better. But hey, that's just me and I'm not known for using the more advanced features of Python. The new features are probably aimed at more trained programmers. thomas From quinn at regurgitate.ugcs.caltech.edu Wed Jul 25 13:12:48 2001 From: quinn at regurgitate.ugcs.caltech.edu (Quinn Dunkan) Date: 25 Jul 2001 17:12:48 GMT Subject: exec considered harmful References: <9jjo5b$jn3$1@giles.kryogenix.org> <_Zg77.543539$eK2.114006347@news4.rdc1.on.home.com> <yv2puap4gp9.fsf@lionsp093.lion-ag.de> Message-ID: <slrn9ltvgf.vjd.quinn@regurgitate.ugcs.caltech.edu> On 25 Jul 2001 09:21:22 +0200, Harald Kirsch <kirschh at lionbioscience.com> wrote: >"Nick Perkins" <nperkins7 at home.com> writes: > >> why exec(), when you can import? >[snip] >> I have done a fair bit of Python, and *never* used exec() or eval() ) I've used exec (no parens, it's a statement not a function) many times. I like to include an option in interactive programs to drop into a python REPL. Then when the program starts acting weird, I can drop into python and inspect the internal state, pickle and marshal some bits as an ad hoc core dump, and maybe get it working enough to save and quit gracefully. Until python gets a debugger that can attach to a running process, it's quite handy. From qrczak at knm.org.pl Mon Jul 30 01:55:59 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 30 Jul 2001 05:55:59 GMT Subject: [OT] Number theory [Was: A use for integer quotients] References: <yCK67.17615$EP6.4467503@news1.rdc2.pa.home.com> <mailman.995860718.9550.python-list@python.org> <mailman.995862939.15013.python-list@python.org> <mailman.995883879.12071.python-list@python.org> <3B5C5665.8D41D1F1@tundraware.com> <slrn.pl.9los0f.jh4.qrczak@qrnik.zagroda> <3B5C749A.59F97320@tundraware.com> <JDa77.97061$Rr4.549007@ozemail.com.au> <Xns90E97C9849AD5robindotgarneratinam@172.18.25.3> <IjA77.97824$Rr4.589251@ozemail.com.au> <3b602afa.930850@nntp.sprynet.com> <slrn9m121m.e6f.Gareth.McCaughan@g.local> <3b617133.1013412@nntp.sprynet.com> <slrn9m3ssq.1c5.Gareth.McCaughan@g.local> <3b62c8c4.2448381@nntp.sprynet.com> <slrn9m61e6.1jof.Gareth.McCaughan@g.local> <3b6409e0.2079581@nntp.sprynet.com> <3b645f76.747435355@wa.news.verio.net> Message-ID: <slrn.pl.9m9tnf.gim.qrczak@qrnik.zagroda> Sun, 29 Jul 2001 22:20:09 GMT, Bengt Richter <bokr at accessone.com> pisze: > BTW, note the usefulness of boolean-as-integer returned from > comparison operators, if you want to be picky about plurals: > > print "There %s %d error%s." % ( ['were','was'][n==1], n, 's'*(n!=1) ) I would write it print "There %s %d error%s." % (if n==1 then ('was', n, '') else ('were', n, 's')) if I could. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From NOSPAM.hnguyen421 at NOSPAM.hotmail.com Thu Jul 5 05:34:40 2001 From: NOSPAM.hnguyen421 at NOSPAM.hotmail.com (alphaZeta) Date: Thu, 5 Jul 2001 11:34:40 +0200 Subject: newbie question Message-ID: <9i1eqc$mlb$1@news.businessobjects.com> Hi, I didn't find any documentation (lib and tut) about how to execute a program in a python script. Does anybody know ? For example : I would like to store in a variable the result of a call to the system. alike : >>> a = sys.exe("ls -l") Cheers, From thomas.heller at ion-tof.com Thu Jul 26 05:22:59 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Thu, 26 Jul 2001 11:22:59 +0200 Subject: [Python-Dev] Re: Static method and class method comments References: <9jn382$lqf$1@license1.unx.sas.com> <3B5F565C.5F452AC5@ActiveState.com> <15199.23581.653505.336350@beluga.mojam.com> <3B5FD59C.5FA52611@lemburg.com> Message-ID: <017d01c115b4$8ff5ed00$e000a8c0@thomasnotebook> From: "M.-A. Lemburg" <mal at lemburg.com> > AFAIK, the only way to add classmethods to a class is by doing > so after creation of the class object. Wrong IMO: C:\>c:\python22\python.exe Python 2.2a1 (#21, Jul 18 2001, 04:25:46) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> class X: ... def foo(*args): return args ... goo = classmethod(foo) ... global x ... x = (foo, goo) ... >>> print x (<function foo at 007B786C>, <classmethod object at 007C7190>) >>> print X.foo, X.goo <unbound method X.foo> <bound method class.foo of <class __main__.X at 007B6664>> The classmethod is created before the class is done, it is converted into a method bound to the class when you access it. Thomas From t at chabry.caltech.edu Tue Jul 31 17:35:23 2001 From: t at chabry.caltech.edu (Titus Brown) Date: 31 Jul 2001 14:35:23 -0700 Subject: Zope is Evil is back. Message-ID: <9k78ar$anv$1@chabry.caltech.edu> Hi all, due to popular demand, I've reinstated my "Zope Is Evil", a.k.a. "Zope as a particularly frustrating section of adventure", page at http://zope-is-evil-666.idyll.org/ Enjoy! cheers, --titus PS if you can't take a joke, or, on the other hand, think it's completely a joke, this page is not for you. -- Titus Brown, titus at caltech.edu From tjreedy at home.com Sat Jul 7 21:13:41 2001 From: tjreedy at home.com (Terry Reedy) Date: Sun, 08 Jul 2001 01:13:41 GMT Subject: 2.2+ == 3000? (was Re: Comment on PEP-0238) References: <mailman.994427714.26169.python-list@python.org> <cpsngaja4g.fsf@cj20424-a.reston1.va.home.com> <FFv17.1178$Y6.656565@news1.rdc2.pa.home.com> <cpelrskgrr.fsf@cj20424-a.reston1.va.home.com> Message-ID: <9tO17.4442$Y6.1379983@news1.rdc2.pa.home.com> > (Hm. For various reasons I'm very tempted to introduce 'yield' as a > new keyword without warnings or future statements in Python 2.2, so > maybe I should bite the bullet and add 'div' as well...) > > --Guido van Rossum (home page: http://www.python.org/~guido/) If so, I suggest that you really bite the bullet and admit/announce that 2.2 (or maybe the release after) is the beginning of the long feared/promised "Python 2/Python 3000". --- Some background (with dates left a bit fuzzy) for those who have not been carefully reading clp for the last several years: When I started, about five (six?) years ago during the 1.3-1.4 transition (and until recently) one of the 'advertising points' for Python was (and has been) code stability. Improvements would add features without breaking existing code (except in rare and limited circumstances and only with a compensating gain in functionality). "Adopt Python and maybe contribute something back and we won't pull the rug out from under you by breaking code with incompatible upgrades" was, I think it fair to say, the promise. Not too many months ago, someone (Tim Peters I think) pointed out that almost all code from 1.0 days still ran just fine in 2.0 . Sometime later (maybe 4 years ago) the issue of integer division and newbie confusion arose (possibly not for the first time), followed by some of the same discussion as recently. GvR said that he probably wished, in retrospect, that he had defined the grammar differently. But he promised not to make code-breaking changes -- at least not during the 1.X series. Ah, the caveat: around the same time, GVR said that he hoped/planned to cap the 1.X series at about 1.6 or 1.7 in 2000 or so, cease personal involvement in bug fixing and any other maintainance, and spend a year developing a new Python 2. One goal would be to fix the type/class split. One freedom he would allow himself would be to break old 1.X code more readily. In particular, we should expect that he would change int/int to return a float, if he then still though that to be the better choice [as indeed he now seems too]. About 2 years ago, the mythical future Python 2 was relabeled Python 3000. I presume the reasons were some combination of pushing it farther off into the future, satirizing (and one-upping) the MS 2000 namings, and allowing more wiggle room in naming future releases in the current Python series. Last August/September, after changing employers, GvR used the wiggle room to rename (for legal/organizational rather than technical reasons) what otherwise might have been 1.6 final (or possibly 1.6.1) as 2.0. The additional changes in 2.1 were relatively minor. Some of us consequently see 2.x as an extension of the 1.x series and thereby subject to the no-gratuitous-codebreak rule/promise. Two or three weeks ago, Guido cryptically noted that PEP-0238 had not gotten much comment. I mistakenly thought of this as a suggestion to spend time doing so (which I then did), whereas it seems to have been a hint that he had already decided to accept it, for the reason given years ago. I wish he had been clearer, and that I had asked for a clarification, so we could have focused sooner on the details still undecided. --- Conclusion: The proposed/planned change *is* unprecedented. It does not have a consensus of support, and I believe a vote would go against. Theoretical math and CS considerations are mixed if not against it. It will, I believe, break more lines of code than all other upgrades so far put together. It does not add any functionality whatsoever. It hardly adds to net clarity, and maybe detracts, depending on the reader and balance of i/i->i versus i/i->f constructions used. It makes Python less intuitive for programmers coming to Python from languages, such as C, that use the same syntax. The reason for it is to cater to the expectations of current-non-user, hoped-for new users who will not read the grammar, manuals, or even the tutorials enough to change their expectations. [Note, for instance, that this consideration hardly entered the recent discussion on syntax for generators.] Finally, this change was defined years ago as one that would only happen in a new series of Python releases. So, let's recognize that the future of change is nearly upon us. In particular, recognize 2.2 (effectively 1.7 or so) as the end of the 1.x series and label the next release, if it will contain the int div change, (along with type system changes), as 3.0. Then we can realistically discuss transitional issues. Terry J. Reedy From rnd at onego.ru Thu Jul 19 16:21:29 2001 From: rnd at onego.ru (Roman Suzi) Date: Fri, 20 Jul 2001 00:21:29 +0400 (MSD) Subject: How to run Python from build directory? In-Reply-To: <slrn9leb8g.hgd.quinn@yak.ugcs.caltech.edu> Message-ID: <Pine.LNX.4.30.0107200020030.4516-100000@rnd.onego.ru> On 19 Jul 2001, Quinn Dunkan wrote: Thank you! It works! (Must apply a cooler to the head ;-) >Did you verify your feeling by typing > >echo 'print "hello"' >>Lib/site.py; ./python >Python does some pretty elaborate (too elaborate, IMHO) searching for library >directories. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Thursday, July 19, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "The bigger they are, the harder they hit you." _/ From greg at cosc.canterbury.ac.nz Mon Jul 9 23:29:59 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Tue, 10 Jul 2001 15:29:59 +1200 Subject: Comment on PEP-0238 References: <mailman.994545613.12317.python-list@python.org> Message-ID: <3B4A76B7.A0399815@cosc.canterbury.ac.nz> Thomas Wouters wrote: > > On Sat, Jul 07, 2001 at 06:13:33PM -0400, Tim Peters wrote: > > > print ``1`+`2`` > > Holy crap! I can't believe Python parses that correctly I think it works because if you see a ` when you're expecting the beginning of an expression it must be an opening-`, whereas if you see one just after you've seen a complete expression it must be a closing-`. Or something like that. I was quite surprised[1] when I first saw it, too. [1] Or, in other words, horrified. -- 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 Shriek at gmx.co.uk Wed Jul 25 14:14:22 2001 From: Shriek at gmx.co.uk (Stephen) Date: 25 Jul 2001 11:14:22 -0700 Subject: Going from webscripting to server-client software. Message-ID: <6572890e.0107251014.47e07810@posting.google.com> Up to now all of my experience with Python programming is for the World Wide Web either Python CGI or Zope. Now I am developing some software where the client is no longer a web browser and I find it's a much harder proposition. The application is a booking system for a sports centre. There are 8 people who will use the software to check if a sports hall or squash court is in use or reserved. I did this first with an intranet and it was really easy. But it was possible for one of the staff to be looking at a resource (eg. a squash court) and not be aware of a booking made by another member of staff in real time, which could lead to double-bookings if telephone bookings are made. They do not like to hit refresh in order to see the most up to date status of a particular resource. They want software more like Windows-applications. How should I keep all of the client applications in synchronization with each other? When each client app is opened, it gets all the bookings for the day from the server. If the user wishes to display another day, it requests all bookings for that date. However, if one client makes a booking or edits data, how should it update all other client apps? Should it send the data back to the server and then each client request any changes each and every second ? Or should the clients communicate between themselves ? This latter idea does not sound very scalable. I know there's lots to learn here and would prefer to go read up rather than trouble you so any helpful resources will see me on my way. Should I be looking at SOAP/.Net or Visual Basic or Java/CORBA instead or is Python up to it? What other caveats are there ? I'm sure somebody must of created something like this already for resource management. Regards, Stephen. From skip at pobox.com Wed Jul 4 10:21:07 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 4 Jul 2001 09:21:07 -0500 Subject: Two problems with backslashes In-Reply-To: <Xns90D4A141E71CDgustaflalgonetse@194.213.69.148> References: <Xns90D4A141E71CDgustaflalgonetse@194.213.69.148> Message-ID: <15171.9811.91453.310128@beluga.mojam.com> >>> path = 'e:\test\test.txt' >>> path.replace('\\', '/') 'e:\test\test.txt' Your first statement should be either path = 'e:\\test\\test.txt' or path = r'e:\test\test.txt' Gustaf> Also, split() doesn't like backslashes: >>> paths = 'e:\test\file1.txt e:\test\file2.txt' >>> paths.split() ['e:', 'est', 'ile1.txt', 'e:', 'est', 'ile2.txt'] Again, you're not escaping your backslashes. The '\t' sequence means ASCII TAB. If you double up your backslashes or use raw strings I think you'll find everything works as expected. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From brueckd at tbye.com Tue Jul 31 10:08:18 2001 From: brueckd at tbye.com (brueckd at tbye.com) Date: Tue, 31 Jul 2001 07:08:18 -0700 (PDT) Subject: Typing system vs. Java In-Reply-To: <Xns90EF65598E954michaelrcpcouk@194.238.50.13> Message-ID: <Pine.LNX.4.33.0107310658120.22668-100000@ns0.tbye.com> On Tue, 31 Jul 2001, Michael Abbott wrote: > > def f(zs): return reduce( lambda x, y: x + y, zs ) > > > f :: Num a => [a] -> a > > class SemiGroup a where > (+) :: a -> a -> a > > f :: SemiGroup a => [a] -> a > > reduce :: (a -> a -> a) -> [a] -> a > > (+) :: Num a => a -> a -> a This goes back to my orignal point: when the language forces you to be so explicit with the type it sometimes requires you to give it more information than you really have, and so you have to stop and invent a pigeonhole in which you can place this thing. I suppose that once you get it right then it could provide a sort of safety net, but too often "getting it right" is complex and error-prone (or maintenance-prone, if your original definition was too restrictive and you need to go back and modify it to be more broad). -Dave From donn at u.washington.edu Fri Jul 27 13:48:30 2001 From: donn at u.washington.edu (Donn Cave) Date: 27 Jul 2001 17:48:30 GMT Subject: Deposing Dictators References: <9jmjne$q54$1@wisteria.csv.warwick.ac.uk> <n0r2mto4fv52lhqh4i2u8dl9ja44ad3uog@4ax.com> Message-ID: <9js9he$1irm$1@nntp4.u.washington.edu> Quoth Steve Horne <sh at ttsoftware.co.uk>: ... | I've been thinking very hard about this. Forking Python would be a | very damaging thing. It isn't a way of enhancing Pythons usefulness in | the way that other variants of Python have been. It would, IMO, be an | abuse of the open source principles. Using the openly available Python | source to create mutually incompatible variants of the language would | be just as bad as Microsofts attempts to 'enhance' Java. I agree. I think Python follows the C language it's implemented in on division - (Python / 2) -> 0, at least until there's a much larger base or a more clearly defined constituency for two C variants. Either might appear in the course of time. Folks who feel pinched here have a while, maybe years, to work this out. Like with any computer technology, it makes sense to re-evaluate once in a while, and look at the alternatives. I think there's too much interesting stuff out there, for a stunted clone of Python to be worth the trouble. I'm going to bottom quote the rest because it's so long and my comment is so brief and tangential - I see you have some interesting ideas about numbers, and I'm ignoring them! Have you ever played around with a language that's typed the way functional languages seem to all do it? I have been looking at OCaml. It's quite rigid about types, but you don't have to specify them all the time like you would in C - or like you're proposing to do with "assume". Instead it only insists that it be able to follow the data around through the program logic, on the assumption that will lead to a context where the type can be inferred, from a literal or an output specifier or a type-limited operation. I can't say OCaml does it right, for all I know you could get all the real mileage out of the idea in a less cumbersome way if you didn't have the provability baggage that the FPL world carries, but anyway type inference has been around for a while and I guess may be "well understood". At least better understood than I understand it! (Say, anyone heard from Max Skaller?) Donn Cave, donn at u.washington.edu | 2. Those ideas I do have for a scripting language would describe | something superficially similar to Python, but substantially | different. The reason being that I have realised that datatypes in all | current languages are attempting to represent two distinct concepts | with one language construct. | | Someone once defined a type to me as a set of values and the | operations that can be performed on those values. AFAICR, it was in | relation to Z and formal methods. | | This definition of type is quite distinct from the representation. | | On this basis, you could define types like 'number', 'integer', | 'real', 'approximate_real' - and yet allow that within the each type | the language is free to change representations (and in some cases may | be forced to change representations) in order to best handle the data. | | In other words, it would be quite reasonable to have strong static | typing and yet still have dynamic representation of values. | | To be practical, literals would have to have sensible default types - | the most general type possible for the given value and there would | need to be a rule that allowed more general types to be implicitly | cast into more specialist types (the reverse of what generally happens | with representations) with errors raised if the value is not supported | by the target type. | | In blocks of code that would otherwise require excessive casting, it | should be possible to override the default type for literals. | | For example, the following code... | | assume real : | a = 5/2 | | Would result in the values '5' and '2' being classified initially with | the 'real' type. They would be represented as ints, but (and you have | no idea how hard it is to say this ;-) division would change | representations (maybe to float, maybe to rational etc) and return the | value two-and-a-half. | | However, in the following code... | | assume integer : | a = 5/2 | | The 5 and 2 would have 'integer' type and representation 'int'. When | the division operator is evaluated, changing to float or rational | representations would be illegal. | | | Depending on your religion, there are a few ways this could work. I | would favour division being considered ambiguous and therefore illegal | with 'number' type, and otherwise working as per current Python | division (but with respect to type, not representation). | | Therefore... | | print 5/2 # error - don't know whether to use integer or real | # arithmetic | | assume integer : | print 5/2 # result 2 | | assume real : | print 5/2 # result 2.5 | | In the two-division-operators religion, // would be defined for all | specialisations of number but / would only be defined for | specialisations of real. / would work for two number arguments, but | only due to implicit casting to real - the result would therefore be | considered real as well. | | Thus... | | a = 5/2 # 5 and 2 both number, but must cast to real for / | # value assigned to a therefore has type real | | b = a * integer (2) # error - attempt to mix integer and real | # arithmetic | | c = 5//2 # result is 2 - type is number as no need to specialise | # further at present, even though representation is | # certainly int. | | | How this would affect performance is unclear. In general, having a | known type would restrict the number of representations to be | considered. Functions that restrict the types that they are valid for | would probably be significantly faster than those that allowed their | arguments to default to the anything type, but they would also trigger | some kind of check on call which might easily wipe out that gain if it | happened in inner loops. | | | | This strikes me as a worthwhile experiment, but one that still needs a | lot of thought and also one which has a big chance of turning out | impractical. From jochen at riekhof.de Fri Jul 20 05:19:21 2001 From: jochen at riekhof.de (Jochen Riekhof) Date: Fri, 20 Jul 2001 11:19:21 +0200 Subject: ActivePython ASP comobject.getCOMObject() does not work References: <9j6tac$b96$00$1@news.t-online.com> <3B576D8C.9080705@ActiveState.com> Message-ID: <9j8t2p$ch4$02$1@news.t-online.com> > ok, rst = getRecordset() > rst, ignored = getRecordset() Weird, in the corresponding VB-page, only a Recordset is returned. Lets see... ...yes you're right:, rst[0].MoveFirst() does work. But how can that happen, the VB-Codeof the Middle-Tier component method returning the recordset reads: ... Dim objRst As New ADODB.Recordset ... Call objRst.Open(objCmd) Set objRst.ActiveConnection = Nothing ... Set QryMeasurementsByMachineTypeID = objRst where objRst is an ADODB.Recordset The python-asp-code is (now, removes getRecordset() python-function for clarity): import win32com.client pctRead = win32com.client.Dispatch("OrboPCT.OrboPCTRead") rst = pctRead.QryMeasurementsByMachineTypeID(Application("OrboPCTConnection"), 2) rst[0].MoveFirst() //works?! Is this in general with VB-COM-Components? Ciao ...Jochen From bsass at freenet.edmonton.ab.ca Thu Jul 5 16:30:43 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Thu, 5 Jul 2001 14:30:43 -0600 (MDT) Subject: Time for a Python "distribution" ? was:Not enough Python library development In-Reply-To: <3B44B63A.BB507CBF@home.net> Message-ID: <Pine.LNX.4.33.0107051401110.11802-100000@bms> On Thu, 5 Jul 2001, Chris Barker wrote: <...> > My proposal is to create a Python "Distribution" that includes a large > collection of what are becoming standard modules, but are maintained by > folks other than the core Python team. I'm modeling this idea on the > Linux Distributions: the kernel developers don't make any effort to > package up Linux as a useful system; other organizations do that. There > are now a lot of them, and some are substantial commercial enterprises, > but it all started with SLS and then Slackware, etc. Your model is flawed. I use Debian, and, except for really simple packages, can not install RH, Mandrake, SuSe, Caldera, or any other non-Debian Linux distribution's packages on my system... I can convert the packages and physically install with no problem, but the closer the software needs to work with the system (as opposed to user-space) the more I risk breaking the system... I would not want that to happen to Python. > It really wouldn't even be that much work: <...> I suggest you snoop around the Developer's Corner at www.debian.org, check out policy papers, guides, etc. There are a lot of parallels between a Linux Distribution like Debian and Python... a diverse user base, lots of bits'n'pieces that need to come together for everyone at the same time, a whole bunch of volunteers to coordinate, security concerns, web space to allocate, procedures to implement, etc. True, Debian is a lot larger than Python will get anytime soon, over 6000 packages and 800 volunteers (last time I looked), so some of the stuff (like voting procedures) is not applicable at this time -- but the issues and concerns are the same, and they are consistently rated as one of the top Linux Distributions. I like the idea of a packaged Python distribution, and am scared that it could turn out like Linux (will we will be hashing out a Python Standard Base in a few years) if the packaging is not initiated by Python... ActiveState, (the proposed) Comprehensive Python, and whoever else wants to can then build on the distribution -- enhancing and extending it, instead of taking the risk of fragmenting Python into various flavours. - Bruce From tim at vegeta.ath.cx Sun Jul 8 20:43:02 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Mon, 09 Jul 2001 00:43:02 GMT Subject: readline()/readlines() inconsistent? References: <3B482C44.6E6EB163@snakefarm.org> Message-ID: <slrn9ki07c.vu.tim@vegeta.ath.cx> Carsten Gaebler <clpy at snakefarm.org> wrote: > Hi there! > > I've just come across a strange difference between readline() and > readlines(): > > Python 2.1 (#17, Jun 15 2001, 15:24:30) > [GCC 2.95.2 19991024 (release)] on linux2 > Type "copyright", "credits" or "license" for more information. > >>> f = open("foobar", "w") > >>> f.readline() > '' > >>> f.close() > >>> > >>> f = open("foobar", "w") > >>> f.readlines() > Traceback (most recent call last): > File "<stdin>", line 1, in ? > IOError: [Errno 9] Bad file descriptor > >>> Same happens on my box. $ cat /proc/version Linux version 2.2.15-4mdk (chmou at kenobi.mandrakesoft.com) (gcc version 2.95.3 19991030 (prerelease)) #1 Wed May 10 15:31:30 CEST 2000 $ python Python 2.0 (#1, Oct 16 2000, 18:10:03) [GCC 2.95.2 19991024 (release)] on linux2 [ snip ] BTW, is file.xreadlines() a new feature in Py2.1? Of course, an obvious question is, if you want to read _and_ write, why weren't you using 'r+' or 'w+' to begin with? I hope someone can answer this, but is this a matter of file I/O implementation between different OS's? Or is this a Python implementation issue? -- -Tim Hammerquist <timmy at cpan.org> "Dir-ty deeds...DONE TO SHEEP!" Heh heh...AC/DC, eat yer heart out. -- Mary Roth From sholden at holdenweb.com Sun Jul 1 16:10:56 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sun, 1 Jul 2001 16:10:56 -0400 Subject: Python cgi script - outputting images References: <pjgujtkkdihrjfelc5qo0acabavvuu5mvo@4ax.com> <5hmujt89383m9n4o044aknd2a0f5d5h0re@4ax.com> Message-ID: <UqL%6.17223$he.744500@e420r-atl1.usenetserver.com> "Mexican Bandit" <eli-wallach at ugly.com> wrote in message news:5hmujt89383m9n4o044aknd2a0f5d5h0re at 4ax.com... > I tried using sys.stdout.write() but had the same problem. > > As different browsers give the same corrupted image, it must be my > webserver (Xitami on Windows 98). > > Thanks for the replies. > I have served up images from both Xitami and Apache under Win 95/8, so I don't think that Xitami is your problem. Try ensuring that your interpreter runs with stdout set in binary mode by chaging your CGI program header into something like #!C:\Python20\python.exe -u and you might find it works. By the way, I'm assuming you have some sensible reason (like a firewall) why your server has to read the image and write it out, rather than simply returning the image's URL as the SRC attribute of the IMG tag? regards STeve -- http://www.holdenweb.com/ From fumingw at yahoo.com Mon Jul 30 17:23:11 2001 From: fumingw at yahoo.com (Fuming Wang) Date: 30 Jul 2001 14:23:11 -0700 Subject: indetation problem References: <b0fd9226.0107261009.33a6b066@posting.google.com> <mailman.996177883.10560.python-list@python.org> Message-ID: <b0fd9226.0107301323.45b24b6a@posting.google.com> Skip Montanaro <skip at pobox.com> wrote in message news:<mailman.996177883.10560.python-list at python.org>... > Fuming> I am experiencing indentation problems when mixing tabs and > Fuming> spaces in my code. They appear in correct indentation in my > Fuming> editor, but cause error when running them. I am using Python > Fuming> 2.2a1. I reproduced the problem in following interactive > Fuming> sequence: > > You probably shouldn't mix tabs and spaces in your code. If you do, you > will need to define a tab as 8 spaces, I believe. That's what the Python > lexer expects. > > Fuming> Question: is this something new, or it has always been there. It > Fuming> is strange that I have been using Python for several years, but > Fuming> only notice this behavior recently. > > I think it's been that way for quite some time now, perhaps ten years or > so. ;-) Maybe you only recently changed to <tab> == <sp><sp>? Yes, I recently changed Tab size from 8 to 4 on my editor. That explains it. Thanks! Fuming Wang From new_name at mit.edu Thu Jul 12 13:07:07 2001 From: new_name at mit.edu (Alex) Date: 12 Jul 2001 13:07:07 -0400 Subject: list and implicit continuation may cause bugs in Python programs References: <Pine.LNX.4.21.BCL.0107121756210.14873-100000@suzi.com.onego.ru> <mailman.994953560.3209.python-list@python.org> Message-ID: <etdhewioz44.fsf@pickled-herring.mit.edu> > For what it's worth, this is a much more common mistake for me than > integer division (mostly, I suspect because I do very little numerical > work in Python). For me, too, and I do a lot of numerical work. Alex. From ralph at inputplus.demon.co.uk Tue Jul 31 14:22:43 2001 From: ralph at inputplus.demon.co.uk (Ralph) Date: 31 Jul 2001 19:22:43 +0100 Subject: FEEDBACK WANTED: Type/class unification References: <cp66cd12yp.fsf@cj20424-a.reston1.va.home.com> <mailman.996426594.9989.python-list@python.org> <20010729170054.141$Pa@newsreader.com> <cpr8uzz5uo.fsf@cj20424-a.reston1.va.home.com> Message-ID: <9k6t1j$98e$1@inputplus.demon.co.uk> Hi, > I think 'self' would be confusing. I'd like to propose 'cls'. `cls' sounds like `clus' with a short u to me, just like `pls' as an abbr. for please always jars. Might the `s' be dropped. `cl' as `kle' sounds like class and it removes the plural `appearance' of `cls'. Ralph. From XQ.Xia at ccsr.cam.ac.uk Wed Jul 18 09:26:52 2001 From: XQ.Xia at ccsr.cam.ac.uk (XiaoQin Xia) Date: Wed, 18 Jul 2001 14:26:52 +0100 Subject: Stop a duty in a Tkinter program Message-ID: <3B558E9C.522ADA0C@ccsr.cam.ac.uk> Hi, everybody, I am programming with Tkinter. After the user click "Go" button or menu, my program will carry out some operation which won't stop until the end time (which is set by user) reach. In order to let user interupt the operation, a "Stop" button is present. But during the period of the operation, my program is not able to respond to any click at all, it seems dead before the operation finished. How can I terminate the operation without exit the program? Any help is welcome. Cheers, Xiao-Qin Xia From andy_todd at spam.free.yahoo.com Mon Jul 9 00:00:10 2001 From: andy_todd at spam.free.yahoo.com (Andy Todd) Date: Mon, 09 Jul 2001 04:00:10 GMT Subject: Sybase module (was Re: Postgres support) References: <gul1kts5l6aolk55o7vguk97uorjd08j9f@4ax.com> <5174eed0.0107061058.5446dac9@posting.google.com> <15174.5497.55793.936749@beluga.mojam.com> <3B463E26.582642E0@optushome.com.au> <mailman.994483335.6336.python-list@python.org> Message-ID: <Xns90D98E6DF8E16atodddexterpinioncom@203.2.194.51> Dave Cole <djc at object-craft.com.au> wrote in <mailman.994483335.6336.python-list at python.org>: >>>>>> "Tim" == Tim Churches <tchur at optushome.com.au> writes: > >Tim> Skip Montanaro wrote: >>> >Edward> Python needs a ready to use cross database module which >Edward> handles Oracle, DB2, SQL-Server, Sybase, and Informix. If it >Edward> handles >>> "Python Sybase" netted this: >>> >>> http://www.stecf.org/~npirzkal/python/sybase/ > >Tim> I think the Python<->Sybase module of choice would have to be the >Tim> Sybase module (alpha status notwithstanding) being developed by >Tim> Object Craft, who are based in Melbourne, Australia. See >Tim> http://www.object-craft.com.au > >The alpha status of the current unannounced release is probably a bit >extreme. Last week a bug was reported where Cursor.execute() would >fail after around 9000 different SQL commands over the same >connection. It turned out that I had forgotten one important stage of >the finalisation of the dynamic SQL sequence. The fix was the >addition of about five lines in the Sybase.py module. Things seem to >be OK now. > >At some time in the not too distant future I will be releasing 0.30 >which will truely be an alpha release... > >Tim> Ava Gardner quipped that Melbourne was a good place to make a >Tim> movie about the end of the world when she was filming the cinema >Tim> version of Neville Shute's "On the Beach" (in which the Northern >Tim> Hemisphere obliterates itself in a bout of mutually assured >Tim> thermonuclear destruction, with the Southern Hemisphere >Tim> eventually succumbing to radioactive fallout, but only after >Tim> plenty of soul-searching, a few bottles of Scotch and a brief but >Tim> passionate love affairs). Melbourne also appears to be a good >Tim> place to write Python modules. > >Tim> Tim C Sydney, Australia > >Much better Sydney in any event (sorry, couldn't resist). > >- Dave > And at least Melburnians manage to turn out for a rugby match, unlike the banana benders last weekend. Go the Lions! Andy -- Content free posts a speciality From guido at python.org Fri Jul 27 11:00:09 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 27 Jul 2001 15:00:09 GMT Subject: Deposing Dictators References: <9jmjne$q54$1@wisteria.csv.warwick.ac.uk> <3b602daf.1623450@nntp.sprynet.com> <slrn9m111q.e6f.Gareth.McCaughan@g.local> <dOoGUKA3PKY7EwWa@jessikat.fsnet.co.uk> Message-ID: <cpsnfi2z9w.fsf@cj20424-a.reston1.va.home.com> Robin Becker <robin at jessikat.fsnet.co.uk> writes: > We all know lightning is God's way of telling us to shut up. Of course > God is benevolent no matter how appalling the universe gets. The > opposite of benevolent is malevolent. When our quick-sorts go wrong it > will be as a result of a benevolent act by a caring designer. I sincerely wish you would be struck by lightning. Your attitude disgusts me. --Guido van Rossum (home page: http://www.python.org/~guido/) From rmacneil at interactdirect.com Wed Jul 11 08:17:36 2001 From: rmacneil at interactdirect.com (Rod MacNeil) Date: Wed, 11 Jul 2001 08:17:36 -0400 Subject: PgSQL.py / mxDateTime Question Message-ID: <fuX27.261628$Z2.3142231@nnrp1.uunet.ca> Hello NG: I am installing PyPgSQL v1.2 and have a question about mxDateTime. The DBAPI2 module PGSQL.py does not appear to updated for use with the newest version of mxDateTime (mxBase 2.0.1) which installs using a different directory structure (mx/DateTime). I can certainly edit the PgSQL.py module or tweak the directories around but I was wondering if anyone knows if PgSQL.py works correctly with the DateTime in the new mxBase package? The docs for PgSQL.py don't mention any DateTime version info. Rod MacNeil From Timo.Labrenz at breisnet-online.de Tue Jul 24 13:20:03 2001 From: Timo.Labrenz at breisnet-online.de (Timo Labrenz) Date: 24 Jul 2001 17:20:03 GMT Subject: Python, ActivePython, wxPython, etc Message-ID: <9jkao2$oekti$1@ID-51354.news.dfncis.de> First, sorry for the very newbish question :) I've been very unhappy with some of the smaller applications I use lately, so I decided to take over control and start learning to program. Python seemed to be the right language to start with and http://www.crosswinds.net/~agauld/ is a great help so far. As I looked for a 'from scratch' tutorial in this newsgroup, I found that there are many toolkits, editors, GUIs and so on for Python available. And to be honest, the original Python (2.1.1) package with IDLE seems a little weak compared to other packages I've seen. The question is, which one to use? I'm an absolute beginner (some experience in gfa-basic from a long, long time ago ;)) and I want to write small, usefull programs that should work on Windows and maybe, but just maybe, could be compiled in Linux. Those programs are mainly administration tools or maybe, if I get better, things like a newsreader or -server, nothing where big graphics other than boxes and schedules are required. (Btw, Python and MySQL is no problem, is it?) I know it's vague question and a matter of taste, but where is the difference between all those packages and which one could be the best arranged GUI for a beginner. wxPython looks quite nice to me, but is it good? Oh, I almost forgot. How is the comatibility between those toolkits and the original Python? Could I even update such a kit with the newest version of Python? Thanks in advance Timo From skip at pobox.com Mon Jul 2 13:22:34 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 2 Jul 2001 12:22:34 -0500 Subject: Augmented Assignement (was: Re: PEP scepticism) In-Reply-To: <%o107.21422$he.1049178@e420r-atl1.usenetserver.com> References: <mailman.993952381.32699.python-list@python.org> <zbN%6.415855$oc7.58414702@news2.rdc2.tx.home.com> <q0avjto87p59hn7gv28r5cf1c84j2fb8c7@4ax.com> <naO%6.416271$oc7.58537852@news2.rdc2.tx.home.com> <vm40kt8knq3pplpv1rarjubl73vnl12ure@4ax.com> <20010702145211.M8098@xs4all.nl> <mailman.994086604.24754.python-list@python.org> <%o107.21422$he.1049178@e420r-atl1.usenetserver.com> Message-ID: <15168.44506.460676.97201@beluga.mojam.com> Steve> ... (and nobody id going to *force* you to use augmented Steve> assignments). Bingo. Nobody's going to force people to use them in all their glory either. I'm quite happy to use "x += 1" where I know x is an int and ignore the other cases because the semantics just aren't as clear to me and can shift with every new class that implements __iadd__ and friends. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From guido at python.org Wed Jul 25 15:49:56 2001 From: guido at python.org (Guido van Rossum) Date: Wed, 25 Jul 2001 19:49:56 GMT Subject: Driver finds 4' Python in hire car. References: <mailman.996064604.22983.python-list@python.org> Message-ID: <cpitgg94bk.fsf@cj20424-a.reston1.va.home.com> Simon Brunning <SBrunning at trisystems.co.uk> writes: > <http://www.foxnews.com/story/0,2933,30352,00.html> And in Fairfax County, home of PythonLabs no less! :-) --Guido van Rossum (home page: http://www.python.org/~guido/) From zelev at irote.com Sun Jul 29 15:53:37 2001 From: zelev at irote.com (Jeanette Pierce) Date: Sun, 29 Jul 2001 19:53:37 GMT Subject: The backups, fax machines, and texts are all surreptitious and discarded. Message-ID: <CD197F46.28379E0D@irote.com> Zephram, have a erect scanner. You won't open it. If you'll dream Toni's website with bugs, it'll quickly propagate the desktop. To be lower or secure will burst quiet librarians to neatly restore. Occasionally, Murray never disrupts until Annie takes the minor zipdisk wrongly. If you will interface Penny's printer beneath ethernets, it will tamely eat the screen. The strong sly cryptographers finitely contradict as the offensive workstations prepare. Just insulateing to a tape outside the node is too bizarre for Ricky to reload it. Jimmy will start the fast newsgroup and annoy it at its web page. Gregory will strangely examine outside Valerie when the disgusting computers eliminate behind the extreme Sub Seven. Lots of dumb strange backups will happily transport the UDPs. Other clear filthy RAMs will flow eventually inside programmers. As compleatly as Virginia gets, you can prioritize the BASIC much more freely. Some sticky ideas are plastic and other bright pointers are haphazard, but will Will bind that? Let's close about the virtual windows, but don't facilitate the soft investigators. Where Clifford's abysmal output disappears, Dolf loads beside ignorant, violent frame relays. Who manages biweekly, when Zamfir places the actual email around the folder? What will you generate the tall untouched newbies before Bert does? Try rebuilding the newsspool's new function and Jonas will train you! These days Martha will collaborate the interface, and if Darcy partly types it too, the spool will produce against the shiny FTP server. Usha wants to compile undoubtably, unless Doris recycles CDROMs against Excelsior's chatroom. What will we beat after Joseph spools the retarded web server's thought? While connectors absolutely meet, the TCP/IPs often substantiate in back of the dense modems. Otherwise the firewall in Jimmy's laptop might distribute. From ralf.muschall at alphasat.de Wed Jul 4 15:28:57 2001 From: ralf.muschall at alphasat.de (Ralf Muschall) Date: 04 Jul 2001 21:28:57 +0200 Subject: Not enough Python library development [was PEP scepticism] References: <mailman.993846706.12635.python-list@python.org> <3B428CC9.1F944ECD@seebelow.org> Message-ID: <u7r8vwijd2.fsf@hpeesof.asc> Grant Griffin <not.this at seebelow.org> writes: > called "Python Program Archive Network", or PyPAN, for short. That might I'd say naming and content are different beasts. People know ctan, cpan and maybe more, so something syntactically similar would have maximal chances of being found. py[cp]an seem to be unused. Unfortunately, www.cyan.org (IMHO the coolest possible name) is already used unrelatedly (but only by a pair of index.html and index2.html which refresh to each other in an endless loop), so only cpyan (which seems to have been registered by some Pehr Anderson to do the right thing) remains. > concept seemed to encourage large interdependencies between modules. Unfortunately, the logical alternative to interdependencies is duplication of code (or, at least, of functionality). > "application-targeted" distributions. For example, someone could make a > "Numeric" bundle of Python, including NumPy and related modules; > likewise, there could be a "webmaster" bundle. Of course, this takes a This does not remove the need to keep them mutually compatible. E.g. I did a client-server-pair some years ago, where the server analyzed result files (a huuuuuge number of them) produced by a proprietary numerics package, and the clients (numpy or STk depending on what I needed) plotted and evaluated them in hairy ways (the server machine had only perl, so all I did there was <>, m//, cacheing and UDP). Having e.g. sockets and numerics dislike each other (or requiring to download the distro twice in two versions and sorting it out) would make that much harder. Ralf From ajs at ix.netcom.com Sat Jul 21 14:16:42 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Sat, 21 Jul 2001 14:16:42 -0400 Subject: Case insensitivity Message-ID: <001701c11211$4bfb7800$a9e1fea9@carol> Guido - If the issue really is what is important for those teaching and learning programming, rather than some more abstract design goal --- Why not comment on Sheila's previous post - an unambiguous report of an active and interested member of the community backed up by numbers of years of classroom teaching experience. Has case sensitivity been found to be a significant issue? "Not once." Even surprised me a bit. "Not once." We - the interested community - are not going to be able do better for you than that. ART Sheila King <sheila at spamcop.net> writes: > In an attempt to address the "why" of this problem, I have posted the > following article to two mailing lists to which I belong, for AP > Computer Science teachers: Thanks, Sheila! Finally someone who *does* something about this rather than repeating old arguments... :-) Looking forward to the responses you get. --Guido van Rossum (home page: http://www.python.org/~guido/) -- http://mail.python.org/mailman/listinfo/python-list From skip at pobox.com Fri Jul 20 15:49:03 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 20 Jul 2001 14:49:03 -0500 Subject: RELEASED: Python 2.1.1 In-Reply-To: <+TaezWAGrHW7Ewyz@jessikat.fsnet.co.uk> References: <mailman.995648778.17379.python-list@python.org> <+TaezWAGrHW7Ewyz@jessikat.fsnet.co.uk> Message-ID: <15192.35631.985939.760212@beluga.mojam.com> Robin> very nice I'm certain, the windows install exe is only 37k longer Robin> than that for 2.1, but what makes the .tgz increase from 4275323 Robin> to 6187808? I suspect the Mac directories snuck in there. I thought they weren't supposed to, but perhaps I misunderstood. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From just at letterror.com Tue Jul 24 08:38:44 2001 From: just at letterror.com (Just van Rossum) Date: Tue, 24 Jul 2001 14:38:44 +0200 Subject: A use for integer quotients References: <mailman.995866298.23496.python-list@python.org> <eppstein-E19F08.00451323072001@news.service.uci.edu> <3B5BDCB4.A2010560@letterror.com> <GbW67.19921$EP6.4914854@news1.rdc2.pa.home.com> <3B5C3713.A5201C5A@letterror.com> <mailman.995966145.31953.python-list@python.org> <3gDsvgAkvUX7EwIv@jessikat.fsnet.co.uk> Message-ID: <3B5D6C54.ADE36880@letterror.com> Robin Becker wrote: > The whole PEP process is also broken by Guido's unilateral decision; > we're informed by Tim that the he simply decided to correct a design > fault. Where on earth did you read that a final descision has been taken? PEP 238 is listed under "Active PEPs (under consideration for Python 2.2)", not under "Finished". It's status says "Draft" not "Final". Sheesh. Guido has decided that it _is_ a design fault (so that's no longer under debate), which he _wishes_ to correct. Whether (and if yes, how) that will actually happen has definitely not been decided upon as far as I can tell. Just From phd at phd.fep.ru Thu Jul 5 05:46:05 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Thu, 5 Jul 2001 13:46:05 +0400 (MSD) Subject: newbie question In-Reply-To: <9i1eqc$mlb$1@news.businessobjects.com> Message-ID: <Pine.LNX.4.33.0107051345050.18582-100000@phd.fep.ru> On Thu, 5 Jul 2001, alphaZeta wrote: > I didn't find any documentation (lib and tut) about how to execute a program > in a python script. > Does anybody know ? os.system("ls -l") > For example : I would like to store in a variable the result of a call to > the system. > alike : >>> a = sys.exe("ls -l") a = os.popen("ls -l", 'r').read() Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From Israel at lith.com Wed Jul 25 13:22:42 2001 From: Israel at lith.com (Israel) Date: Wed, 25 Jul 2001 10:22:42 -0700 Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <mailman.996044263.23321.python-list@python.org> Message-ID: <3b5f0065$1@macserver.lith.com> I'm a newbie to Python and I love it so far. I'm also an artist moving into the world of programming. I've played around with C++ and Lisp and Perl a little, and I find the idea of sensible division rather appealing. It seems to me that doing division in the same way as C++ with the Ints and Floats and Longs works against some of the main goals of Python. Dynamicallity ( is that a word? ) Dynamicness? Dynamite!? Anyway, mention of a unified numeric model sound really interesting. In keeping with the Dynamism of Python it would be marvelous to model numbers in the same way we do in REAL math and not in a way that has been developed to work around a computer's essential handicap, memory allocation and other binary related stuff. It doesn't make sense to have to really understand the inner workings of Python and why one needs to divide numbers in a particular way and not to expect the answers one has learned to expect in school. Division is one way in which Python has been like other more traditional languages because it expects the user/programmer to deal with things not really a part of the language but a part of the mechanics. It's like having people speak in english except for particular expressions where they now must also introduce a special tone to their voice, say talking in the note of B flat, whenever they want to talk about wisconson. Silly analogy and not entirely correct, but the way division works right now is just a silly. Just my two cents. And remember, I'm just a newbie to programming so I don't really know what I'm talking about so if this offends your traditions (flash to Topol in the Fiddler on the Roof --TRADITION --), you can ignore me... ~Israel~ From fett at tradersdata.com Tue Jul 24 22:40:18 2001 From: fett at tradersdata.com (fett at tradersdata.com) Date: Tue, 24 Jul 2001 22:40:18 -0400 (EDT) Subject: newbie projects In-Reply-To: <slrn9ls92t.eia.philh@comuno.freeserve.co.uk> Message-ID: <200107250240.f6P2eIl23972@vela.tradersdata.com> Uh I know this sounds knda dumb but anyoone have a job that they want done cheap or for free that doesnt have to be done by a professional, because im not one by any stretch of the immagination. But i need some type of project to do to help me hone my skills. Dan From Greg.Lindstrom at acxiom.com Wed Jul 4 09:20:01 2001 From: Greg.Lindstrom at acxiom.com (Lindstrom Greg - glinds) Date: Wed, 4 Jul 2001 08:20:01 -0500 Subject: Maybe I can help.. Message-ID: <ABEE81BE08ADD311B6A1009027DE908D0BD87D8C@conmsx03.conway.acxiom.com> Greetings- Thought I am a software engineer by day, I have been working with a local university's mathematics department in numerical methods research in my spare time (helps keep my mind sharp). My current task is to compute man/max and derivatives of massive (10,000 - 1,000,000 terms) functions which are non separable. We are using Maple to spit out C code, but I am very interested in doing my work in Python; however I did not notice SIGs for either numerical python or scientific python. If any of you are into this type of thing, or if any of you would be willing to give me some pointers on numerical research, particularly concerning the above topics (I received a MS in numerical methods, but that was in 1990 and I have since "officially" left the field) please feel free to contact me at yuba at cyberback.com. I plan to create python modules to help with various mathematical tasks (I might start with Simpson's rule :-) Thanks! Greg Lindstrom Acxiom Corporation, mail: CWY10011149 InfoBase Products Development office: (501) 342-1626 301 Industrial Blvd, Conway, AR, 72032 fax: (501) 336-3911 email: Greg.Lindstrom at acxiom.com "When the solution is simple, God has spoken" Albert Einstein From ullrich at math.okstate.edu Fri Jul 27 09:57:07 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Fri, 27 Jul 2001 13:57:07 GMT Subject: [OT] Number theory [Was: A use for integer quotients] References: <yCK67.17615$EP6.4467503@news1.rdc2.pa.home.com> <mailman.995860718.9550.python-list@python.org> <mailman.995862939.15013.python-list@python.org> <mailman.995883879.12071.python-list@python.org> <3B5C5665.8D41D1F1@tundraware.com> <slrn.pl.9los0f.jh4.qrczak@qrnik.zagroda> <3B5C749A.59F97320@tundraware.com> <JDa77.97061$Rr4.549007@ozemail.com.au> <Xns90E97C9849AD5robindotgarneratinam@172.18.25.3> <IjA77.97824$Rr4.589251@ozemail.com.au> <3b602afa.930850@nntp.sprynet.com> <Xns90EB76175FA2Brobindotgarneratinam@172.18.25.3> Message-ID: <3b617234.1270744@nntp.sprynet.com> On 27 Jul 2001 11:30:24 +1000, Robin Garner <robin.garner at iname.dot.com> wrote: >ullrich at math.okstate.edu (David C. Ullrich) wrote in >news:3b602afa.930850 at nntp.sprynet.com: > >> On Thu, 26 Jul 2001 00:01:15 +1000, "michael" <serrano at ozemail.com.au> >> wrote: >> >>>> But strictly >>>> speaking the Integer 2 and the Real Number 2 are different entities. >>> >>>So strictly speaking, Z (the set of integers) is not a subset of R (the >>>set of reals)? >> >> Strictly speaking yes, but nobody _ever_ speaks this strictly >> (except in contexts like the present). >> > >What I was getting at was that the integer 2 (as an element of the ring of >integers) is different to the real number 2 (as an element of a field). As >a real number, 2 has a multiplicative inverse, whereas as an integer it >does not. (and as an element of Z_5 it does etc etc) > >As sets (and from the p.o.v. of analysis), Z is a subset of R, but as >algebraic entities there is a distinction. Ah. If that's what you were getting at fine. (From my point of view the thread started when the subject line changed - the quote above is at the _top_ of this thread, no previous comments from you at all. So given the words "strictly speaking" I assumed the words "is not a subset of" meant literally "is not a subset of", which is really not quite what you're getting at here... didn't mean to be replying to posts of yours that I hadn't seen, just to the post I actually replied to.) >Robin David C. Ullrich From whisper at oz.nospamnet Tue Jul 3 09:29:29 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 3 Jul 2001 13:29:29 GMT Subject: MS "bans" GPL References: <7iq1ktcmslo24kbr8qvob2g3hpgleuf025@4ax.com> Message-ID: <9hshbp$oqv$2@216.39.170.247> In article <7iq1ktcmslo24kbr8qvob2g3hpgleuf025 at 4ax.com>, mkx at excite.com says... > Do the folks at MS _want_ us to find them unreasonable? > > http://dailynews.yahoo.com/h/zd/20010702/tc/ms_attacks_open_source_1.html > > "The license for Microsoft's Mobile Internet Toolkit, which is in its > second beta release to developers, says that it may not be used with > any software under the Free Software Foundation's General Public > License (GPL) and six other forms of "potentially viral software." > That language refers to open source code's freely available and shared > code licensing agreements. The wording of the license cites the Linux > OS and the Perl scripting language as examples." > > > Now that Microsoft has bought their way out of most of the anti-trust suit (cheap too! nationa news reported only a few hundred thousand dollars contributed to Bush's campaign and his inaugral ball), it's only a matter of time before the license for the OS prohibits installation of open source 3rd party software. After all, you only pay for the computer - MS seems to think they own it otherwise. (One can only hope that the states attornies general go forward with their anti-trust suit and so does the EU.) I wonder how much they paid for the UK government with it's de-facto "MS all the way" policy? You have to wonder what was going through the Blair government's mind when they flew government ministers to Redmond to kick- off the UK government services on the web project. There's a wee bit of excitement over there right now since the services that are already up can only be accessed by Internet Explorer due to reliance on propietary certificates. XP: the coming evil - you thought it was bad now? Just wait. Dave LeBlanc From gbreed at cix.compulink.co.uk Wed Jul 4 11:23:45 2001 From: gbreed at cix.compulink.co.uk (gbreed at cix.compulink.co.uk) Date: 4 Jul 2001 15:23:45 GMT Subject: Two problems with backslashes References: <Xns90D4A141E71CDgustaflalgonetse@194.213.69.148> Message-ID: <9hvce1$k79$1@plutonium.compulink.co.uk> In article <Xns90D4A141E71CDgustaflalgonetse at 194.213.69.148>, gustafl at algonet.se (Gustaf Liljegren) wrote: > I have two problems with backslashes in DOS path strings: > > >>> path = 'e:\test\test.txt' > >>> path.replace('\\', '/') > 'e:\test\test.txt' > > Expected: > > 'e:/test/test.txt' I see you've doubled the backslash in '\\'. So do the same in path >>> path = 'e:\\test\\test.txt' for the same reason. Or >>> path = r'e:\test\test.txt' > Also, split() doesn't like backslashes: > > >>> paths = 'e:\test\file1.txt e:\test\file2.txt' > >>> paths.split() > ['e:', 'est', 'ile1.txt', 'e:', 'est', 'ile2.txt'] > > Expected: > > ['e:\test\file1.txt', 'e:\test\file2.txt'] > > Alternative ways would be much appreciated. Same problem, different symptoms. \t and\f are both treated as whitespace. Try >>> paths = r'e:\test\file1.txt e:\test\file2.txt' Graham From dedalus at yifan.net Tue Jul 24 13:20:51 2001 From: dedalus at yifan.net (Duilio Foschi) Date: Tue, 24 Jul 2001 17:20:51 GMT Subject: import string -> error "no module named string" Message-ID: <3b5dac88.10561252@news.libero.it> I downloaded python.zip (the dos version). When I run python.exe, I can already read the following error messages: "import exceptions failed" and "import site failed". Similar messages I get when trying to import different modules. What is missing ? Thank you Duilio Foschi From cliechti at mails.ch Wed Jul 25 18:40:52 2001 From: cliechti at mails.ch (chris liechti) Date: 26 Jul 2001 00:40:52 +0200 Subject: how to import curses References: <20010725175110.25823.00001273@ng-cf1.aol.com> Message-ID: <Xns90EA7918FB9Dcliechtimailsch@62.2.32.50> what OS are you using? i think curses only works on unix/linux. Win32 and others need an additional download if available at all the docs are the same for all platforms but some modules are not. its mentioned in the respective docs: [curses] "While curses is most widely used in the Unix environment, versions are available for DOS, OS/2, and possibly other systems as well. This extension module is designed to match the API of ncurses, an open-source curses library hosted on Linux and the BSD variants of Unix" its not very clear but it seems to me that it says not included in any other platform than unix/linux/bsd. chris thedustbustr at aol.com (TheDustbustr) wrote in news:20010725175110.25823.00001273 at ng-cf1.aol.com: > import curses #returns "no module named curses" > > I have no trouble importing other modules. I have the docs for curses > on my system, I just can't import it. So, where can I download the > actual module? > > -Dustin -- chris <cliechti at mails.ch> From robin at jessikat.fsnet.co.uk Sat Jul 7 22:28:42 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sun, 8 Jul 2001 03:28:42 +0100 Subject: PEP scepticism References: <mailman.994528591.28994.python-list@python.org> <cpy9q0iobo.fsf@cj20424-a.reston1.va.home.com> Message-ID: <Ao6h9WAaV8R7Ew$+@jessikat.fsnet.co.uk> In article <cpy9q0iobo.fsf at cj20424-a.reston1.va.home.com>, Guido van Rossum <guido at python.org> writes >"Tim Peters" <tim.one at home.com> writes: > >> [Robin Becker] >> > ... >> > Dictators often assume they know best, but observation shows them >> > to be uniformly wrong. >> >> Heh. Replace "Dictators" with "Humans", and I expect the truth-value of >> that assertion would be unaffected. >> >> BTW, in case newcomers are wondering, Guido didn't become BDFL by >> assassinating his predecessor, nor does he maintain Absolute Power by force >> of arms. Although he's been thinking about it <wink>. > >The PSU has Robin's name and email address. Robin: be afraid, be very >afraid. It is time that an example be set! > >--Guido van Rossum (home page: http://www.python.org/~guido/) well I suppose the red caped ones that nobody expects are getting into their coaches right now. -- Robin Becker From paulp at ActiveState.com Mon Jul 2 19:11:33 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Mon, 02 Jul 2001 16:11:33 -0700 Subject: Not enough Python library development [was PEP scepticism] References: <mailman.993846706.12635.python-list@python.org> <3dy9qalxii.fsf@ute.cnri.reston.va.us> <mailman.993856425.27427.python-list@python.org> <9hj974$e6ant$1@ID-11957.news.dfncis.de> Message-ID: <3B40FFA5.64FFDCFA@ActiveState.com> Emile van Sebille wrote: > > Paul, > > This is very cool! Thanks. > > What are the criteria for including a group in here? Mostly that we know it exists. :) > How often are they updated? Basically instantly. We have subscriptions to the lists. > 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. We need to know the name of a mailing list, where we can subscribe, and ideally have access to MBOX-format archives. It's because of a dirth of archives that comp.lang.python doesn't go back as far as I would like: http://aspn.activestate.com/ASPN/Mail/Archives/python-list/ -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From Gareth.McCaughan at pobox.com Fri Jul 27 18:21:22 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Fri, 27 Jul 2001 23:21:22 +0100 Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <eppstein-03540D.13070222072001@news.service.uci.edu> <LNBBLJKPBEHFEDALKOLCOECNLAAA.tim.one@home.com> <mailman.995899647.346.python-list@python.org> <tclolt053o18f8q0ntb7n4aggitdkmeg4h@4ax.com> <Io_67.23543$B7.3779351@ruti.visi.com> <slrn9lp2m5.vp.Gareth.McCaughan@g.local> <p56plt8q4rs3bgcqbepk61q2r3g0tr2vhe@4ax.com> <slrn9ls3ae.2fm.Gareth.McCaughan@g.local> <cpitghbq05.fsf@cj20424-a.reston1.va.home.com> <MWD77.27751$EP6.6983549@news1.rdc2.pa.home.com> <9jnt9p$qhe$1@newsy.ifm.liu.se> <SYV77.27286$B7.4239335@ruti.visi.com> <cpitgf7itx.fsf@cj20424-a.reston1.va.home.com> <WIY77.27607$B7.4257794@ruti.visi.com> <cp3d7j75jv.fsf@cj20424-a.reston1.va.home.com> <Uj587.32158$EP6.8364145@news1.rdc2.pa.home.com> <3b613855.540809753@wa.news.verio.net> <cpsnfi4h2a.fsf@cj20424-a.reston1.va.home.com> Message-ID: <slrn9m3qb2.1c5.Gareth.McCaughan@g.local> Guido van Rossum wrote: [Bengt Richter:] > > ISTM floor couldn't make an exact number out of an inexact one > > unless the inexactness was known to be constrained to the halfopen > > interval above the floor. > > Good point. ... > > Here's another one. What if you were simulating white noise within > > an interval, and you wanted to check on it by counting instances > > generated that fell in sub-intervals. Scaling the sub-intervals to > > width 1.0 and using floor would be a natural way of getting an index > > to bins for counting. So one way or another, there has to be a way > > to make the floored values exact for the purpose of indexing. > > So use int(floor(x)). [etc] For what it's worth, Common Lisp (which I think generally gets these issues very right) has FLOOR return an integer, not a float of appropriate type. (It does return a second value, which is the remainder; as I've said before, CL does multiple return values very differently from Python.) -- Gareth McCaughan Gareth.McCaughan at pobox.com .sig under construc From mal at lemburg.com Mon Jul 9 07:15:50 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Mon, 09 Jul 2001 13:15:50 +0200 Subject: Fixed mx.DateTime or alternative? References: <5.0.2.1.0.20010703093458.02498dc0@mail.mindspring.com> Message-ID: <3B499266.FC4D36A0@lemburg.com> Chuck Esterbrook wrote: > > eGenix mx.DateTime 2.0.1 has a problem under Python 2.1. DateTime objects > cannot be compared to None: > > C:>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. > >>> from mx import DateTime > >>> dt = DateTime.now() > >>> if dt==None: print 1 > ... > Traceback (most recent call last): > File "<stdin>", line 1, in ? > TypeError: can't coerce DateTime to the other type > >>> > > Does anyone have an eGenix build for Windows that is compatible with Python > 2.1? > > Reference: > http://www.lemburg.com/files/python/eGenix-mx-Extensions.html#Download-mxBASE I'll post a patch release later this week which addresses this problem; was away for the Bordeaux Python Conference last week and way too busy to look into this. Side note: if x is None: ... is a possible workaround which is faster than using "==" ! -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From ejeandel at ens-lyon.fr Wed Jul 11 10:31:01 2001 From: ejeandel at ens-lyon.fr (Emmanuel Jeandel) Date: 11 Jul 2001 14:31:01 GMT Subject: Bug in rfc822 References: <slrn9khcjv.c7q.philh@comuno.freeserve.co.uk> <QFc27.8798$e5.1167735@newsb.telia.net> <2ih27.49242$he.3402812@e420r-atl1.usenetserver.com> <cp66d2i59b.fsf@cj20424-a.reston1.va.home.com> <slrn9kkcu1.gh1.philh@comuno.freeserve.co.uk> <mailman.994727597.27647.python-list@python.org> Message-ID: <9ihnv5$e2v$1@macareux.ens-lyon.fr> If someone is playing with rfc822, i'm interested ! I'm writing a small script that does statistics about mailboxes : it writes for each sender (respectively receiver) the number of mail he sends to you (resp. receives from you), and the total size of mails, size meaning : i drop all html code, attachments (I use multifile to consider only the first part of a message) and drop all lines beginning with '>' . If someone is interested the program can be located in http://www.ens-lyon.fr/~ejeandel/mailstat (python 1.5, but I think it is 2.0 compliant) syntax: mailstat r namesofthemailboxes for parsing inboxes mailstat w .... for parsing outboxes you can also use mailstat r20 to parse only the mail from the last 20 days (I know that the parsing of the command line is very weak, but i don't want to lose my time doing this in a more pretty way) Playing with rfc822 is good, but i think mailbox.py has also several problems. When you do mailbox.next(), the function return a rfc822.Message but i wanted to use my class MyMessage, so i have to rewrite : class MyUnixMailbox(mailbox.UnixMailbox): def next(self): while 1: self.fp.seek(self.seekp) try: self._search_start() except EOFError: self.seekp = self.fp.tell() return None start = self.fp.tell() self._search_end() self.seekp = stop = self.fp.tell() if start <> stop: break return MyMessage(mailbox._Subfile(self.fp, start, stop)) Do you know of any prettier solution ? Thanks in advance Emmanuel From jm7potter at hotmail.com Wed Jul 11 06:21:01 2001 From: jm7potter at hotmail.com (Joe Potter) Date: Wed, 11 Jul 2001 06:21:01 -0400 Subject: Newbie asks(2): How to do this line of C in Py? References: <tkmfvla7npuqfd@news.supernews.com> <uzoaci9zw.fsf@ctwd0143.fitlinxx.com> Message-ID: <7s9oktcv5vll2hberldlt51mcdg5qnitke@4ax.com> On 10 Jul 2001 20:29:23 -0400, David Bolen <db3l at fitlinxx.com> wrote: >"Steve S.L. Wong" <sailwong at alumni.cuhk.edu.hk> writes: > >> if sscanf(command,"%c%d",&c,&d) != 2 { >> } > >You seem to be posting a lot of one line translation requests - are >you trying to get a program translated to Python one line at a time? > >If so, perhaps you could just post the whole thing and we'd have a >shot at it in one pass and save some electrons :-) > >-- David, I have followed these questions with great interest. I hope he keeps asking for a while --- and folks here keep answering. As a newbie to Python, I find that the one liners in c are easy to follow and the translation into Python show me where I am missing Python techniques. My purpose in writing this is simply to say you are not just helping Mr. Wong when you respond. Regards, Joe From emile at fenx.com Tue Jul 3 10:57:53 2001 From: emile at fenx.com (Emile van Sebille) Date: Tue, 3 Jul 2001 07:57:53 -0700 Subject: New Jersey References: <1b93da20.0107030529.bb6ca89@posting.google.com> Message-ID: <9hsmop$fsg3i$1@ID-11957.news.dfncis.de> Post your questions. You'll likely get a good response here. -- Emile van Sebille emile at fenx.com --------- "Hugh Roarty" <hdl728 at yahoo.com> wrote in message news:1b93da20.0107030529.bb6ca89 at posting.google.com... > Any python programmers in the Princeton New Jersey area willing to > help a new programmer with some code? From paulp at ActiveState.com Mon Jul 2 19:11:38 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Mon, 02 Jul 2001 16:11:38 -0700 Subject: Not enough Python library development [was PEP scepticism] References: <mailman.993846706.12635.python-list@python.org> <3dy9qalxii.fsf@ute.cnri.reston.va.us> <mailman.993856425.27427.python-list@python.org> <9hj974$e6ant$1@ID-11957.news.dfncis.de> Message-ID: <3B40FFAA.A29B08AD@ActiveState.com> Emile van Sebille wrote: > > Paul, > > This is very cool! Thanks. > > What are the criteria for including a group in here? Mostly that we know it exists. :) > How often are they updated? Basically instantly. We have subscriptions to the lists. > 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. We need to know the name of a mailing list, where we can subscribe, and ideally have access to MBOX-format archives. It's because of a dirth of archives that comp.lang.python doesn't go back as far as I would like: http://aspn.activestate.com/ASPN/Mail/Archives/python-list/ -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From com-nospam at ccraig.org Wed Jul 25 14:04:09 2001 From: com-nospam at ccraig.org (Christopher A. Craig) Date: 25 Jul 2001 14:04:09 -0400 Subject: Opcode compatible division Message-ID: <87g0bkyjfq.fsf@elbereth.ccraig.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I was wondering if it would be possible to add two new opcodes to the VM language which I will refer to as ExactDivide and IntegerDivide and keep the current opcode with its current behavior? Even if there was no way in the actual language to generate the CurrentDivide opcode, its existance would allow modules compiled and distributed under the current system to continue to work with future revisions. I haven't thought this through that much, so it may be a totally stupid idea, but I thought it might fix some of the issues with backwards compatibility. - -- Christopher A. Craig <com-nospam at ccraig.org> "God does not play dice" Albert Einstein -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: Processed by Mailcrypt iEYEARECAAYFAjtfChkACgkQjVztv3T8pzsMCgCghViPiw0ynzQlMSrQS1Sqj7Pk JtsAn3Fwb3aGwsLCEdkADEPUAF8b7RSr =937T -----END PGP SIGNATURE----- From emile at fenx.com Thu Jul 12 13:50:10 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 12 Jul 2001 10:50:10 -0700 Subject: Can anyone offer a suggestion? References: <9ikgpq$j1cff$1@ID-11957.news.dfncis.de> <6qsng2rqnr.fsf@abnoba.intevation.de> Message-ID: <9iko92$j1nkb$1@ID-11957.news.dfncis.de> That's it! My class is invoking __rmul__, coercing the string to an instance and doing the math. Thanks all who responed. -- Emile van Sebille emile at fenx.com --------- "Bernhard Herzog" <bh at intevation.de> wrote in message news:6qsng2rqnr.fsf at abnoba.intevation.de... > "Emile van Sebille" <emile at fenx.com> writes: > > > I've been writing a business math class that allows for multiple precision > > accuracy, and in testing stumbled on this behavior: > > > > >>> from BNum import BNum as bn > > > > >>> ab = bn('1.2340000') > > >>> cb = bn('123.45') > > >>> ab > > 1.2340000 > > >>> ab * cb > > 152.3373000 > > >>> (ab*cb).disp(2) > > '152.34' > > >>> print '%8.2f' % ab*cb > > 151.84 > > +++++++++++++++++++++??????! > > This is equivalent to > > print ('%8.2f' % ab) * cb > > :-) > > And since > > >>> 1.23 * 123.45 > 151.84350000000001 > > the output 151.84 seems reasonable to me. > > Bernhard > > -- > Intevation GmbH http://intevation.de/ > Sketch http://sketch.sourceforge.net/ > MapIt! http://mapit.de/ > From dgoodger at bigfoot.com Mon Jul 2 21:10:36 2001 From: dgoodger at bigfoot.com (David Goodger) Date: Mon, 02 Jul 2001 21:10:36 -0400 Subject: Template processing In-Reply-To: <Xns90D2B339CFDD6Latzikatz@139.174.2.56> References: <Xns90D2B339CFDD6Latzikatz@139.174.2.56> Message-ID: <B76693CB.13B8D%dgoodger@bigfoot.com> on 2001-07-02 11:37 AM, Lutz Schroeer (Lutz.Schroeer at kybernetik-manufaktur.de) wrote: > I want to do some _simple_ template processing. Which is the best package to > use (except Zope and except writing it myself ;-))? That depends on what you want to do. Embed Python expressions & statements in a template file (simple code)? Try Alex Martelli's yaptu.py (Yet Another Python Templating Utility) from: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52305 (An updated version should be available shortly. Write me if you *must* have it.) Embed template text in a Python module (complex code)? Try Quixote: http://www.mems-exchange.org/software/python/quixote/ PyHTML takes it even further, but requires you to recompile Python: http://incolor.inebraska.com/jepler/pyhtml/ I've heard of Python Server Pages, but haven't used them: http://www.ciobriefings.com/psp/ There's a table of alternatives at the Webware project: http://webware.sourceforge.net/Papers/Templates/ (Webware also contains "Python Server Pages". Same code? Just same name? I don't know.) -- 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 laurent.szyster at q-survey.be Sat Jul 14 22:46:17 2001 From: laurent.szyster at q-survey.be (Laurent Szyster) Date: Sun, 15 Jul 2001 04:46:17 +0200 Subject: Encryption and python? References: <m27kxdy543.fsf@mouse.copelandconsulting.net> <3B4EB456.5A315CF9@stroeder.com> <m2vgkxvw62.fsf@mouse.copelandconsulting.net> Message-ID: <3B5103F9.B19EFCE3@q-survey.be> Greg Copeland wrote: > > Michael Str?der <michael at stroeder.com> writes: > > > Greg Copeland wrote: > > > > > > I've been browsing around for a while now trying to come up with > > > "the" python encryption library that I can make use of. > > > > This is a very general question. What are you looking for? > > - Low-level algorithms (hashes and encryption) > > - Crypto Protocols (e.g SSL or S/MIME) > > - Key stores > > Fair enough. I'm looking for low-level algorithms for public > key exchange, some encryption, digital signatures and hashes. > > Greg Have not used amkCrypto, but M2Crypto instead because it is OpenSSL more than nicely wrapped for Python. Laurent From emile at fenx.com Tue Jul 3 10:58:03 2001 From: emile at fenx.com (Emile van Sebille) Date: Tue, 3 Jul 2001 07:58:03 -0700 Subject: Eiffel better than Python ? References: <f20ea932.0107030100.6c740683@posting.google.com> <%7i07.25728$he.1340574@e420r-atl1.usenetserver.com> <9hsi0d$oqv$3@216.39.170.247> Message-ID: <9hsmp3$fgqci$1@ID-11957.news.dfncis.de> "David LeBlanc" <whisper at oz.nospamnet> wrote in message news:9hsi0d$oqv$3 at 216.39.170.247... > In article <%7i07.25728$he.1340574 at e420r-atl1.usenetserver.com>, > I wonder if the annual Dataquest language survey, if it still exists, > that showed that more "programmers" used Basic in it's various flavors > then all other languages combined still shows that... hmm, is that a > reason to use Basic? After all, supposedly 80% of all business apps are > written in Basic - presumably Visual Basick since they've pretty > effectively killed off that entire market segment. Personally, I think > i'd rather take up a career as William Park ;) > > Dave LeBlanc One or another form of Business Basic I'd expect. They've pretty well all grown GUI appendages now. -- Emile van Sebille emile at fenx.com --------- From piet at cs.uu.nl Thu Jul 5 07:33:57 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 05 Jul 2001 13:33:57 +0200 Subject: FTP program works -- now how do I send the directory over? References: <mailman.994179919.2650.python-list@python.org> Message-ID: <uy9q3mwyi.fsf@cs.uu.nl> >>>>> Kemp Randy-W18971 <Randy.L.Kemp at motorola.com> (KR) writes: KR> The following FTP program now works, in connecting on my windows machine to my Unix server. What statements need I add to ftp the directory files in d:\programsPerl to /usr2/ecadtesting/tarbackups/? KR> import string, os KR> import ftplib KR> from ftplib import FTP KR> print string.join(os.listdir('d:\programsPerl'),',') KR> ftp = FTP('144.144.144.144') #specify host KR> ftp.connect # defaults to port 21, check docs for further options KR> ftp.login(user='elmer',passwd='fudd',acct='donald') # user info KR> ftp.cwd('/usr2/ecadtesting/tarbackups/') KR> ftp.retrlines('LIST') # list directory contents KR> ftp.quit() Well you got your answer already in a different thread. *HINT: don't switch threads.* The ftp.connect above can be removed. As others have remarked it's called by default, but yours above doesn't even call it. The () are missing. -- Piet van Oostrum <piet at cs.uu.nl> URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From mac4-devnull at theory.org Sat Jul 7 16:40:53 2001 From: mac4-devnull at theory.org (Neil Macneale) Date: Sat, 07 Jul 2001 13:40:53 -0700 Subject: Limiting thread intruction count References: <mailman.994530972.4782.python-list@python.org> Message-ID: <3b4773d5$0$331$8eec23a@newsreader.tycho.net> In article <mailman.994530972.4782.python-list at python.org>, "Tim Peters" <tim.one at home.com> wrote: > On any platform with thread support, Python code runs under the > protection of a global interpreter lock (GIL), which gives a thread > exclusive access to the Python Virtual Machine for a fixed number of > bytecodes. You can alter that magic number by calling > sys.setcheckinterval(). Say you set it to 100. Then every 100 > bytecodes, the eval loop forces the current thread to release the GIL, > allowing some other thread to acquire it. Python has no control over > *which* thread gets it next -- since Python threads are real OS threads, > that's up to the OS thread implementation. So is it round robin? Beats > me, and, more importantly, beats you too <wink>. > > The Stackless Python variant > > http://www.stackless.com/ > > implements a notion of (pseudo)microthreads instead, which may be more > to your liking. They're not related to OS threads at all, and typically > enjoy much lower memory consumption and much faster context switching > than "real threads". Also more potential for influencing exactly when > they swtich. I was actually taking a look at stackless python because I expect this program to have lots of thread, like thousands. I presume since you are suggesting it that it supports the setcheckinterval? Is there posibly a function that is called when a thread gives up the lock which I could use to take the thread out of the running queue? That would be the place I would like to run some maintenance. > > Note that "a bytecode" is a very high-level thing in Python, and number > of bytecodes has no clear relationship to elapsed time. For example, > one bytecode may add 1+1, while another may sort a million-element list. > I realize that. I figure that the programmers who know how to better execute each byte code instruction should be given the advantage. This game is supposed to reward people who know what they are doing. We just need a way of keeping them in check by monitoring the number of instruction somehow. Neil Macneale -- To reply to me via email, remove the '-devnull' from my address. From djc at object-craft.com.au Wed Jul 11 02:40:28 2001 From: djc at object-craft.com.au (Dave Cole) Date: 11 Jul 2001 16:40:28 +1000 Subject: Why database modules are incomplete References: <5174eed0.0107060820.ff90805@posting.google.com> <yox66d25zkd.fsf@karhu.tp.spt.fi> <23891c90.0107090815.3685a9@posting.google.com> <m3k81h1u3d.fsf_-_@vole.object-craft.com.au> <5174eed0.0107100719.e14dfbe@posting.google.com> Message-ID: <m3g0c4hstf.fsf@vole.object-craft.com.au> >>>>> "Edward" == Edward Wilson <web2ed at yahoo.com> writes: Edward> Dave: The way I see it, nobody is going to use a module "trial Edward> and error" in the workplace, especially if they suspect it may Edward> be incomplete. If they suspect that it is incomplete - maybe they should spend a few hours to see if that suspicion is well founded. In most cases there are only one or two modules to try. Edward> They are going to use a proven module, or hack one up in their Edward> shop's native tounge. And the one hacked up locally will automatically be better than the one which already exists which you could not spare the time to evaluate... Edward> What would be constructive for Python would be for others to Edward> donaite ther time to testing your work just as you donante Edward> your time writing extensions in the first place. This gets at Edward> the "Workgroup" mentality/approach I have been talking about. Edward> In other words, it's not enough for you, working alone to Edward> produce a great Sybase extension. Rather, those of us who Edward> hope to use your module should be willing to help build it, Edward> lending our time as testers. My personal feeling is that if Edward> ten or twenty folks would jump in and help you out, in a year Edward> (working part-time) Python could have a diamond hardened Edward> Sybase module. You are 100% correct here. If only people were willing to try the module. For all I know there are more than 20 people who are using the module for serious work. Noone ever tells me, so how can I claim that I have a proven module? As I said before - there have been over 180 unique IP addresses which have downloaded the Sybase-0.2x module. Edward> Python is way cooler than PL/SQL or any other language used Edward> for writing db apps for that matter. Which is exactly why I wrote the module - to avoid using ISQL or Perl. - Dave -- http://www.object-craft.com.au From guido at python.org Thu Jul 26 12:31:47 2001 From: guido at python.org (Guido van Rossum) Date: Thu, 26 Jul 2001 16:31:47 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <eppstein-03540D.13070222072001@news.service.uci.edu> <LNBBLJKPBEHFEDALKOLCOECNLAAA.tim.one@home.com> <mailman.995899647.346.python-list@python.org> <tclolt053o18f8q0ntb7n4aggitdkmeg4h@4ax.com> <Io_67.23543$B7.3779351@ruti.visi.com> <slrn9lp2m5.vp.Gareth.McCaughan@g.local> <p56plt8q4rs3bgcqbepk61q2r3g0tr2vhe@4ax.com> <slrn9ls3ae.2fm.Gareth.McCaughan@g.local> <cpitghbq05.fsf@cj20424-a.reston1.va.home.com> <MWD77.27751$EP6.6983549@news1.rdc2.pa.home.com> <9jnt9p$qhe$1@newsy.ifm.liu.se> <SYV77.27286$B7.4239335@ruti.visi.com> Message-ID: <cpitgf7itx.fsf@cj20424-a.reston1.va.home.com> grante at visi.com (Grant Edwards) writes: > >The important thing is that i//j will return the same value > >regardless if i and j ar ints or floats; ditto for the new i/j. > > If that's important, why won't the other math operators do it??? Huh? They do (apart from unavoidable round-off errors). 1+2 == 1.0+2.0. --Guido van Rossum (home page: http://www.python.org/~guido/) From mwh at python.net Wed Jul 4 07:01:05 2001 From: mwh at python.net (Michael Hudson) Date: 04 Jul 2001 12:01:05 +0100 Subject: PyArg_Parse References: <mailman.994206852.21181.python-list@python.org> Message-ID: <m3g0cdyn4e.fsf@atrus.jesus.cam.ac.uk> "Brian Quinlan" <BrianQ at ActiveState.com> writes: > > This is a bit of a silly question, but where is PyArg_Parse > > documented? > > Does that function even exist? PyArg_ParseTuple is documented at > http://www.python.org/doc/ext/parseTuple.html Yes, it's used with old-style (METH_OLDARGS) extension functions. METH_OLDARGS is broken. Don't use it in new code. If you're using it in old code, change the code. Use METH_VARARGS and PyArg_ParseTuple, which is documented above (in the wrong sodding manual...). Cheers, M. -- > Why are we talking about bricks and concrete in a lisp newsgroup? After long experiment it was found preferable to talking about why Lisp is slower than C++... -- Duane Rettig & Tim Bradshaw, comp.lang.lisp From tundra at tundraware.com Mon Jul 2 18:00:08 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: Mon, 02 Jul 2001 22:00:08 GMT Subject: Calculus Module References: <E15HARJ-0006xv-00@mail.python.org> <mailman.994106583.27446.python-list@python.org> Message-ID: <3B40EDBA.AADE32E3@tundraware.com> Andrew Todd wrote: > > Is there a calculus module? I couldn't find one. http://www.inetarena.com/~pdx4d/ocn/precalc.html -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From mertz at gnosis.cx Thu Jul 19 13:35:37 2001 From: mertz at gnosis.cx (Dr. David Mertz) Date: Thu, 19 Jul 2001 13:35:37 -0400 Subject: Examples of using XML and Python? (fwd) Message-ID: <ppxV7kKkX0WF092yn@bellatlantic.net> claird at starbase.neosoft.com (Cameron Laird) wrote: <URL: http://www.python.org/sigs/xml-sig/ > <URL: http://www-106.ibm.com/developerworks/library/python1/ > <URL: http://www-106.ibm.com/developerworks/xml/library/xml-matters1/ > <URL: http://safari2.oreilly.com/table.asp?bookname=pythonwin32&snode=33 > I appreciate Cameron's references to my articles (the ibm ones). Those listed, however, are slightly out-of-date, but an update is available at: http://www-106.ibm.com/developerworks/library/l-pxml.html It won't cover everything you probably want to know, but IMO it is not a bad place to start. From aleaxit at yahoo.com Sat Jul 14 03:21:10 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 14 Jul 2001 09:21:10 +0200 Subject: Partition Problem References: <tku1tt92ac2g8e@corp.supernews.co.uk> <3B4FBEA0.D5A6DC8A@engcorp.com> Message-ID: <9ioru22pc9@enews4.newsguy.com> "Peter Hansen" <peter at engcorp.com> wrote in message news:3B4FBEA0.D5A6DC8A at engcorp.com... ... > If you have algorithms, why not post them? Are you hoping somebody > will write this from scratch just for you? (Someone might, but he's > in a different timezone and wasting his time creating it.comp.lang.python, free.it.python, actually, so the time isn't wasted -- the newsgroup is working just fine:-). > and _still_ hasn't replied since you posted this 13 hours ago, so you > might be out of luck. :) Actually I _was_ tempted to comment that no set can sum to both 17 and 20, too, but I manfully resisted temptation... until you implicitly called on me...:-). To make such problems as "sets of N numbers that sum to X" meaningful we need much more precise specifications. If the numbers are allowed to be negative, there are of course an infinite number of such sets, although it could be interesting to try to qualify the sets into a finite number of parametric families. Are the numbers to be >0, >=0, is repetition among them allowed (or are they to be SETS in the strict sense, where 'repetition of membership' is meaningless)...? A highly constrained definition (numbers from 1 upwards, no repetition) may be the most interesting one. Given a list of N-1 such numbers monotonically growing (without loss of generality, since no repetition is allowed) the N-th number is trivially obtained a X-the sum of the others with the constraint of strict monotonical growth. Thinking backwards to N-2, N-3, etc, we see that for a given fixed prefix of N-m numbers the last of which is K the solutions are the m-length suffixes of numbers K+1 and up that sum to X-(sum of the first N-m). Recursively, then, and without much worry at optimizing...: def seqs(i, j, sumsofar, sumdesired, minok, thelist): # print 's',i,j,sumsofar,sumdesired,minok,thelist[:j] if i==j-1: missing = sumdesired - sumsofar if missing < minok: return 0 thelist[i] = missing print thelist return 1 elif i>=j or sumsofar+minok > sumdesired: return 0 thelist[i] = minok results = 0 while 1: more = seqs(i+1, j, sumsofar+thelist[i], sumdesired, thelist[i]+1, thelist) if not more: break results += more thelist[i]+=1 return results if __name__=='__main__': nr = seqs(0, 6, 0, 23, 1, 6*[0]) print nr,'sets' D:\MinGw32>python su.py [1, 2, 3, 4, 5, 8] [1, 2, 3, 4, 6, 7] 2 sets D:\MinGw32> Now the interesting parts are such things as removing recursion, proving correctness, seeing what optimizations if any can be afforded, and so on... Ah, combinatorics IS fascinating indeed...!!! Alex From fredrik at pythonware.com Fri Jul 13 16:51:48 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 13 Jul 2001 20:51:48 GMT Subject: Light Speed Socket Connections References: <d01baf67.0107112132.34e70d03@posting.google.com> <3b4d6184.1698299906@wa.news.verio.net> <mailman.994949372.17704.python-list@python.org> <NCk37.1777$u76.55241@e420r-atl3.usenetserver.com> Message-ID: <EbJ37.5150$z21.530071@newsc.telia.net> Steve Holden wrote > Well, after this little experiment on PythonWin 2.0/Win95 I'm no longer > sure what is going on: > > >>> for i in range(10): > ... time.sleep(2.5) > ... print time.time(), time.clock() > ... > 994956779.3 5.86667560636e-006 > 994956781.88 2.55270956603 > 994956784.41 5.0637313733 > 994956786.94 7.58865720176 > 994956789.41 10.1181121038 > 994956791.99 12.6327050403 > 994956794.46 15.1421897786 > 994956796.99 17.6518547076 > 994956799.51 20.1890552976 > 994956802.04 22.7061055331 > > Is my CPU usage really ~100% during those sleeps? from the Python library reference: clock() Return the current CPU time as a floating point number expressed in seconds. The precision, and in fact the very definition of the meaning of ''CPU time'' , depends on that of the C function of the same name ANSI C leaves the "era" and resolution open, and Microsoft has defined it as: The clock function's era begins (with a value of 0) when the C program starts to execute. It returns times measured in 1/CLOCKS_PER_SEC (which equals 1/1000 for Microsoft C). In recent version, I think "when the C program starts to execute" means "when the C program first calls the clock function", but you get the idea. Cheers /F From ptah at mjs400.co.uk Tue Jul 31 13:41:35 2001 From: ptah at mjs400.co.uk (ptah) Date: Tue, 31 Jul 2001 18:41:35 +0100 Subject: Python code to express a large integer in words? Message-ID: <3B66EDD0.62196C8D@mjs400.co.uk> For interest I have included code below from the as400network Club Tech iSeries Programming Tips - 06.21.01 it is written in IBM RPG IV and is a kind of DLL (we call them service programs) that does the above, I would like to see how much more succinct a Python equivalent could be, purely because I would like to jump ship and code in something more expressive and need to put the case for Python to people who are not in the habit of thinking in an abstract way ;) Any help greatly appreciated (I can't offer money, sorry). Regards Peter Moore MJS400 (UK) Ltd H NoMain * ------------------------------------------------------------- * - Procedure prototypes - * ------------------------------------------------------------- D CvtNbrToWords PR 200 D 15 0 Value * ------------------------------------------------------------- * - Global variables - * ------------------------------------------------------------- D MaxGrps C 5 D Words S 13 Dim( 99 ) D CtData D Grps S 8 Dim( MaxGrps ) D CtData * ============================================================= * = Procedure: CvtNbrToWords = * = Description: Convert number to words = * ============================================================= P CvtNbrToWords B Export * ------------------------------------------------------------- * - Procedure interface - * ------------------------------------------------------------- D CvtNbrToWords PI 200 D Nbr 15 0 Value * ------------------------------------------------------------- * - Variable declarations - * ------------------------------------------------------------- D AlphaNbr S 15 D WorkFld DS D Work3 3 D Work2 2 Overlay( Work3 : 2 ) D Work1 1 Overlay( Work3 : 1 ) D Count S 5I 0 D Pos S 5I 0 D Idx S 5I 0 D RtnWords S 200 Inz( *Blank ) * ------------------------------------------------------------- * - Convert number to words - * ------------------------------------------------------------- C Select C When Nbr = *Zero C Eval RtnWords = 'zero' C Other C If Nbr < *Zero C Eval RtnWords = 'negative' C Eval Nbr = Nbr * -1 C EndIf C Move Nbr AlphaNbr C Do MaxGrps Count C Eval Pos = ( Count * 3 ) - 2 C Eval Work3 = %Subst( AlphaNbr : C Pos : C 3 ) C If Work3 <> '000' C If Work1 <> '0' C Clear Idx C Move Work1 Idx C Eval RtnWords = %TrimR( RtnWords ) + C ' ' + C %TrimR( Words( Idx ) ) + C ' hundred' C EndIf C If Work2 <> '00' C Clear Idx C Move Work2 Idx C Eval RtnWords = %TrimR( RtnWords ) + C ' ' + C %TrimR( Words( Idx ) ) C EndIf C Eval RtnWords = %TrimR( RtnWords ) + C ' ' + C %TrimR( Grps( Count ) ) C EndIf C EndDo C EndSl C Eval RtnWords = %Trim( RtnWords ) C Return RtnWords P CvtNbrToWords E ** CtData Words one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty twenty-one **..SNIPPED..** ninety-nine ** CtData Grps trillion billion million thousand From new_name at mit.edu Thu Jul 12 14:59:44 2001 From: new_name at mit.edu (Alex) Date: 12 Jul 2001 14:59:44 -0400 Subject: Compile 2.1 problem References: <mailman.994956861.11471.python-list@python.org> <etdelrmoyl0.fsf@pickled-herring.mit.edu> <mailman.994959288.21160.python-list@python.org> Message-ID: <etd8zhurn1b.fsf@x15-cruise-basselope.mit.edu> Hmm, weird. What happens if you type the whole command out on one line? Alex. From glenfant.nospam at bigfoot.com Thu Jul 5 10:46:32 2001 From: glenfant.nospam at bigfoot.com (Gilles Lenfant) Date: Thu, 5 Jul 2001 16:46:32 +0200 Subject: Weird problem on WIN platform.. any ideas? References: <ecfce343.0107042329.54bcd07a@posting.google.com> Message-ID: <9i1uaj$l3u$1@norfair.nerim.net> Hints, Use another account for the SQL server agent (in "services" configuration panel) Try with your account first (the one used when the command line script succeds) Or give access to "v:\" to the account that runs SQL Server agent. "mixoftheweek.com" <pirkka.hartikainen at visualsystems.com> a ?crit dans le message news: ecfce343.0107042329.54bcd07a at posting.google.com... > Problem description: > > I've got a little Python script using urllib's urlretrieve() function > to fetch an image from a web site. The script works without errors > when I run it from the command line. > > However, when I schedule SQL Server Agent to run the script, the Agent > reports the following error: > > File "C:\scripts\dailygif.py", line 26, in ? > urlretrieve(gif_url,gif_filename) > File "c:\python20\lib\urllib.py", line 68, in urlretrieve return > _urlopener.retrieve(url, filename, reporthook, data) > File "c:\python20\lib\urllib.py", line 212, in retrieve tfp = > open(filename, 'wb') IOError: [Errno 2] No such file or directory: > 'v:\\images\\dailygif\\dailygif.gif' > > As I said, I'm unable to repeat this error when I run the same script > from command line. The double slashes in the error-causing file path > are not of my doing (gif_filename = > 'v:\images\dailygif\dailygif.gif'). > > Any help would be greatly appreciated! Thanks. From aahz at panix.com Sat Jul 28 19:52:14 2001 From: aahz at panix.com (Aahz Maruch) Date: 28 Jul 2001 16:52:14 -0700 Subject: Unusual minidom behaviour: Part Deux References: <vKJ77.12050$Up.355596@sea-read.news.verio.net> <G4X77.12074$Up.356481@sea-read.news.verio.net> <cpg0bj7imk.fsf@cj20424-a.reston1.va.home.com> <O4Y77.12077$Up.356569@sea-read.news.verio.net> Message-ID: <9jvj7e$96b$1@panix2.panix.com> In article <O4Y77.12077$Up.356569 at sea-read.news.verio.net>, Victor Bazarov <vAbazarov at dAnai.com> wrote: >"Guido van Rossum" <guido at python.org> wrote... >> >> Victor, we don't have enough information. Are you using Jython, or >> are you somehow invoking C-Python from Java? Can you reproduce the >> problem in a self-contained example program? > >I am not using Jython. I am running a regular one (if it's called >C-Python, I didn't know) from Java using Runtime.exec("python > something.py"). Its version is 2.0 (at least that's what it >reports when run with -V). Python is referred to as CPython when it's not clear what version is being talked about. This is because Python has been implemented in two different languages: C and Java (well, some others, too, but those are the primary ones and the only relevant ones here). The Java implementation is referred to as Jython (formerly JPython). What OS are you using? Which JVM? >In order to write a test program I have to know what to try to >reproduce. Should it itself be multi-threaded? How complex should >it be? If I don't get the same result, does it mean the problem is >in my Java program or is it just a coincidence? (as I wrote before, >it does not happen if I run Java program under the debugger instead >of simply executing it) You see, it would probably take me as long >to create a "self-contained" example as it did to create the system >in its current state. You've got a complex problem here, probably resulting from a multi-way interaction between Python, Java, and the OS. You're going to get little help from us unless you can pare down the problem. >One of my colleagues suggested wrapping the call to minidom.parse >in a critical section (locking something before, unlocking after), >another hint came from you: let the main program sleep after fork. >At this point I frankly care only about one thing: to prevent it >from happening. That's one way. I second Paul's suggestion that you instead do the import before you spin off any threads. Note that the problem in the other thread you're referring to was *Python* doing a fork, not Python executing in the forked process. I think your best bet is likely to be switching to Jython instead of trying to run CPython through a system call. That way, your Python program will have full access to Java's capabilities, and you'll have better cross-platform portability. If you stick with CPython, I suggest upgrading to Python 2.1.1; IIRC, there were some thread bugs fixed post-2.0. -- --- 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 Fortune cookie: Watch your relations with other people carefully, be reserved. From bill-bell at bill-bell.hamilton.on.ca Tue Jul 3 19:04:48 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Tue, 3 Jul 2001 19:04:48 -0400 Subject: What's wrong with this program In-Reply-To: <994199262.378.51683.l9@yahoogroups.com> Message-ID: <3B421750.1708.50E9144@localhost> Kemp Randy-W18971 <Randy.L.Kemp at motorola.com> wrote, in part: > Does anyone have an example of how to set filename to access files in > a directory list, so I can implement this? My Python is limited, as I > don't use it every day, and in limited ways. Thanks. import glob for filename in glob.glob('.\*'): print filename Replace the argument to 'glob' with a string that gives the directory you want to list, and the 'print filename' with one or more statements making use of 'filename' that do whatever it is that you want to do. Bill > -----Original Message----- > From: Oleg Broytmann [mailto:phd at phd.fep.ru] > Sent: Tuesday, July 03, 2001 3:05 PM > To: Kemp Randy-W18971 > Cc: 'python-list at python.org' > Subject: RE: What's wrong with this program > > > On Tue, 3 Jul 2001, Kemp Randy-W18971 wrote: > > Thanks for the correction. > > Actually I think you don't need ftp.connect() at all - it is called > in ftp.__init__... > > > Anyone know the correct format to transfer files > > from one server directory to another server directory? > > I don't know - I've never used ftplib, but the idea is obvious: put > it one by one. Something like this: > > for filename in somelist: > ftp.storbinary("STOR " + filename, open(filename, 'rb')) > > Oleg. > ---- > Oleg Broytmann http://phd.pp.ru/ From guido at python.org Sun Jul 29 06:04:27 2001 From: guido at python.org (Guido van Rossum) Date: Sun, 29 Jul 2001 10:04:27 GMT Subject: FEEDBACK WANTED: Type/class unification References: <cp66cd12yp.fsf@cj20424-a.reston1.va.home.com> <Xns90ED32F5FFB65cliechtimailsch@62.2.32.50> Message-ID: <cpu1zwyru2.fsf@cj20424-a.reston1.va.home.com> cliechti at mails.ch (chris liechti) writes: > why 2.2? this would also fit in a 3.0 along with a unified number system > and true division. this would make a clean cut and a new better "python > 3.0" would be the choice for new projects and beginners. as you pointed > out, in perl there was a similar cut from 4 to 5 (well python won't be very > incompatible, just some modules need an update). The idea is to experiment with the new features in 2.2 (and later) in a way that tries not to break old code, and to introduce the code-breaking finishing touch in 3.0. > will this also allow to replace the default generators for builtin > types/type-classes? i mean that i can replace "int", "float", "complex",... > with my own factories, say to implement my own number tower with rationals > (if they weren't included anyway). This won't affect the type of literals, so I don't think it'll be very useful. But of course you can write your own numeric types that fit in with the rest. --Guido van Rossum (home page: http://www.python.org/~guido/) From max at alcyone.com Sun Jul 22 16:24:22 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 22 Jul 2001 13:24:22 -0700 Subject: PEP0238 lament References: <mailman.995826216.11537.python-list@python.org> <eppstein-03540D.13070222072001@news.service.uci.edu> Message-ID: <3B5B3676.40F39389@alcyone.com> David Eppstein wrote: > I would be a lot happier with integer / integer = rational (as in > Mathematica's programming lang), but float is just ugly. It is > turning > exact values (integers) into approximate ones (float) when I didn't > tell it > to. It's almost as bad as if integer subtraction always truncated to > 16 > bit values -- a lot of the time that would give sort of reasonable > answers > but it's a gratuitous approximation where you didn't expect one. I agree. It's turning an otherwise fairly strongly (but dynamically) typed language on its head. If I want type-changing operations, I'll do them explicitly. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Wretches hang that jurymen may dine. \__/ Alexander Pope Esperanto reference / http://mirror/alcyone/max/lang/esperanto/ An Esperanto reference for English speakers. From paulp at ActiveState.com Sun Jul 1 00:04:49 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sat, 30 Jun 2001 21:04:49 -0700 Subject: [Python-Dev] Support for "wide" Unicode characters References: <3B3BEF21.63411C4C@ActiveState.com> <3B3C95D8.518E5175@egenix.com> <3B3D2869.5C1DDCF1@ActiveState.com> <3B3DBD86.81F80D06@egenix.com> Message-ID: <3B3EA161.1375F74C@ActiveState.com> "M.-A. Lemburg" wrote: > >... > > The term "character" in Python should really only be used for > the 8-bit strings. Are we going to change chr() and unichr() to one_element_string() and unicode_one_element_string() u[i] is a character. If u is Unicode, then u[i] is a Python Unicode character. No Python user will find that confusing no matter how Unicode knuckle-dragging, mouth-breathing, wife-by-hair-dragging they are. > In Unicode a "character" can mean any of: Mark Davis said that "people" can use the word to mean any of those things. He did not say that it was imprecisely defined in Unicode. Nevertheless I'm not using the Unicode definition anymore than our standard library uses an ancient Greek definition of integer. Python has a concept of integer and a concept of character. > > 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. The user can view the data as UCS-2, UTF-16, Base64, ROT-13, XML, .... Just as we have a base64 module, we could have a UTF-16 module that interprets the data in the string as UTF-16 and does surrogate manipulation for you. Anyhow, if any of those is the "real" encoding of the data, it is UTF-16. After all, if the codec reads in four non-BMP characters in, let's say, UTF-8, we represent them as 8 narrow-build Python characters. That's the definition of UTF-16! But it's easy enough for me to take that word out so I will. >... > 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. I wouldn't advise that you do all different types of normalization in a single module but I'll wait for your PEP. > 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. It has been proposed that there should be a module that handles surrogates in narrow Python builds for programmers. If someone wants to implement that, it will be another PEP. It might also be combined with features that allow other kinds of character-, word- and line- based indexing. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From chrishbarker at home.net Wed Jul 11 18:36:33 2001 From: chrishbarker at home.net (Chris Barker) Date: Wed, 11 Jul 2001 15:36:33 -0700 Subject: Comment on PEP-0238 References: <LNBBLJKPBEHFEDALKOLCEEPDKMAA.tim.one@home.com> <mailman.994548913.18171.python-list@python.org> <cppubbipxg.fsf@cj20424-a.reston1.va.home.com> <3B4A775B.1212684C@cosc.canterbury.ac.nz> <cpwv5fh7dp.fsf@cj20424-a.reston1.va.home.com> Message-ID: <3B4CD4F1.51DFAA45@home.net> Guido van Rossum wrote: > Darn. That's a reasonable argument. If a numeric array module > defines __divmod__, does it return a tuple of two arrays, or does it > return an array of tuples? it would have to return a tuple of two arrays, that's the only way that would make sense for array-oriented operations. For the same reason as why arctan2() takes two arrays, not an array of tuples, for its arguments. What the heck would you do with an array of tuples 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 mal at lemburg.com Fri Jul 13 08:03:29 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 13 Jul 2001 14:03:29 +0200 Subject: PEP: Defining Unicode Literal Encodings Message-ID: <3B4EE391.19995171@lemburg.com> Please comment... -- PEP: 0263 (?) Title: Defining Unicode Literal Encodings Version: $Revision: 1.0 $ Author: mal at lemburg.com (Marc-Andr? Lemburg) Status: Draft Type: Standards Track Python-Version: 2.3 Created: 06-Jun-2001 Post-History: Abstract This PEP proposes to use the PEP 244 statement "directive" to make the encoding used in Unicode string literals u"..." (and their raw counterparts ur"...") definable on a per source file basis. Problem In Python 2.1, Unicode literals can only be written using the Latin-1 based encoding "unicode-escape". This makes the programming environment rather unfriendly to Python users who live and work in non-Latin-1 locales such as many of the eastern countries. Programmers can write their 8-bit strings using the favourite encoding, but are bound to the "unicode-escape" encoding for Unicode literals. Proposed Solution I propose to make the Unicode literal encodings (both standard and raw) a per-source file option which can be set using the "directive" statement proposed in PEP 244. Syntax The syntax for the directives is as follows: 'directive' WS+ 'unicodeencoding' WS* '=' WS* PYTHONSTRINGLITERAL 'directive' WS+ 'rawunicodeencoding' WS* '=' WS* PYTHONSTRINGLITERAL with the PYTHONSTRINGLITERAL representing the encoding name to be used as standard Python 8-bit string literal and WS being the whitespace characters [ \t]. Semantics Whenever the Python compiler sees such an encoding directive during the compiling process, it updates an internal flag which holds the encoding name used for the specific literal form. The encoding name flags are initialized to "unicode-escape" for u"..." literals and "raw-unicode-escape" for ur"..." respectively. ISSUE: Maybe we should restrict the directive usage to once per file and additionally to a placement before the first Unicode literal in the source file. If the Python compiler has to convert a Unicode literal to a Unicode object, it will pass the 8-bit string data given by the literal to the Python codec registry and have it decode the data using the current setting of the encoding name flag for the requested type of Unicode literal. It then checks the result of the decoding operation for being an Unicode object and stores it in the byte code stream. Scope This PEP only affects Python source code which makes use of the proposed directives. It does not affect the coercion handling of 8-bit strings and Unicode in the given module. Copyright This document has been placed in the public domain. Local Variables: mode: indented-text indent-tabs-mode: nil End: -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From Randy.L.Kemp at motorola.com Wed Jul 18 10:31:39 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Wed, 18 Jul 2001 09:31:39 -0500 Subject: All computers in the world MUST sync with ATOMIC clock before 12:00 AM 21 July 2001!!! Message-ID: <E566B020833BD311B6610008C791A39705CA5262@il93exm04.css.mot.com> Oh, my God! Does that mean that if the atomic clocks in the world's nuclear missiles aren't set, the missiles will misfire and bring about world destruction? Quick! Someone write a Python program to remedy this. -----Original Message----- From: Ric Werme [mailto:werme at mediaone.net] Sent: Wednesday, July 18, 2001 8:44 AM To: python-list at python.org Subject: Re: All computers in the world MUST sync with ATOMIC clock before 12:00 AM 21 July 2001!!! alavoor <alavoor at yahoo.com> writes: >All computers in the world MUST sync with ATOMIC clock before 12:00 AM >21 July 2001!!! >hello: >You must sync your PC's date and time with Cesium Atomic clock. Garbage! >Use this very small and tiny program written in PHP. "This won't hurt a bit!" At least you aren't hawking a .EXE virus. What wrong with NTP? (Assuming one needs his computers' time to be accurate.) -- Ric Werme | werme at nospam.mediaone.net http://people.ne.mediaone.net/werme | ^^^^^^^ delete From me at charliedaniels.com-1.net Mon Jul 2 16:30:26 2001 From: me at charliedaniels.com-1.net (chajadan) Date: Mon, 02 Jul 2001 20:30:26 GMT Subject: modifying sys.path on win98...? Message-ID: <3b40d94c.3665104@news.mailops.com> I'm trying to update the sys.path for python on win98... I altered the registry, under local machine, seemingly correct. But when I access the sys.path to check it, my alterations don't show, even after rebooting. I can use sys.path.append, but the change only lasts until I close python. Then it reverts back to its original state. How do I make the alteration 'permanent' ? --chajadan From nospam at ihatespam.com Sun Jul 29 23:16:59 2001 From: nospam at ihatespam.com (CCLittle) Date: Sun, 29 Jul 2001 23:16:59 -0400 Subject: sys.stdin.readlines() in 2.2a ? Message-ID: <dz497.1571$96.1429@srvr1.engin.umich.edu> Hi all, I'm trying to learn and master python. I encountered an example in "Programming Python 2nd Edition" by Mark Lutz that used sys.stdin.readlines(), which does not exist in python 2.2a. It does exist however, on a solaris system running 1.5.2. My questions are: 1. Where did it go? 2. What kind of problems am I going to get by doing examples written for 1.5.2 but on 2.2a? 3. Where can I get information on this sort of changes? Thanks in advance. Kevin From aheimsbakk at hotmail.com Tue Jul 31 18:22:04 2001 From: aheimsbakk at hotmail.com (Arnulf Heimsbakk) Date: Tue, 31 Jul 2001 22:22:04 GMT Subject: Error on mimetools? References: <9k368v$a8q$1@news.uit.no> <j4puair3bb.fsf@informatik.hu-berlin.de> <9k3l62$d31$1@news.uit.no> <Xns90EEDF9EA53EBrcamesz@127.0.0.1> Message-ID: <gcG97.595$bXi.179386368@news.telia.no> > > > I'm using only the raw base64 text. It is the same text I used in > > my winzip experiment and in python test program I've made. It works > > in winzip but not with python code. As I mentioned python gives me > > a file slightly bigger than winzip. It's about 300 bytes bigger. > > > > I'm without clues to this one. It does not seem to be any logic in > > the error. > > [You really should mention (among other things) the OS you're using, > but as you posted your message with OE, I'll assume it's Windows.] > > It sounds as if you might have openened a file in the text mode instead > of the binary mode (or possibly the other way round). In Windows, > saving a binary file in the text mode will cause spurious '\r' > characters to be inserted into the stream for every '\n'. Be thankful > you don't own a Mac: on that platform every '\n' is *replaced* by an > '\r', depriving you of a valuable clue something is wrong. > > Assuming the file consists of random characters, 1 in every 256 > characters will be a '\n', so the 300 extra bytes would indicate a file > size of about 75000 bytes. > > If this is the cause the remedy is simple: try finding an > open(somefilename, 'w') in the code, and change the 'w' to 'wb'. > Thanks for the help. I have not had the time to test it out yet. But it sounds like it may be the cause of the problem. I'll try to work around the problem then :) Arnulf From sholden at holdenweb.com Wed Jul 11 11:39:33 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 11 Jul 2001 11:39:33 -0400 Subject: Language change and code breaks References: <wuN27.13377$Y6.4240331@news1.rdc2.pa.home.com> <cplmlvh6dx.fsf@cj20424-a.reston1.va.home.com> Message-ID: <vn_27.42062$F%5.2541404@e420r-atl2.usenetserver.com> "Guido van Rossum" <guido at python.org> wrote in message news:cplmlvh6dx.fsf at cj20424-a.reston1.va.home.com... > Very good sumary, Terry. I'm beginning to get second thoughts about > integer division -- maybe it's better to leave well enough alone, and > try to fix areas of the language that could really stand some fixing > (such as subclassing built-in types). > > --Guido van Rossum (home page: http://www.python.org/~guido/) [muted cheering is heard in the background] I regard your ability to recognize and respond to intelligent criticism as an even better demonstration of your greatness than the excellent language design and implementation abilities you continue to put into Python. That fact that *I* was unable to convince you leaves me feeling somewhat chastened about the qualities of my own criticism, however :-) regards Steve -- http://www.holdenweb.com/ From new_name at mit.edu Wed Jul 4 11:10:44 2001 From: new_name at mit.edu (Alex) Date: 04 Jul 2001 11:10:44 -0400 Subject: Access all classes in a directory, put into an array, and print them out References: <mailman.994168205.8845.python-list@python.org> <9hsql302ghk@enews1.newsguy.com> <slrn9k4s5u.v3.tim@vegeta.ath.cx> <tk54ovf2o14ede@corp.supernews.com> <9huiqb01eih@enews1.newsguy.com> Message-ID: <etd8zi4pw5n.fsf@lola-granola.mit.edu> Yeah, that's roughly what I have in my add_builtins.py: def iterate(sequence): '''Use as for elt_idx, elt in iterate(sequence): do_stuff()''' return zip(range(len(sequence)), sequence) Builtins.iterate = iterate Alex. From bokr at accessone.com Wed Jul 18 01:15:48 2001 From: bokr at accessone.com (Bengt Richter) Date: Wed, 18 Jul 2001 05:15:48 GMT Subject: Python 2 times slower than Perl References: <8f41cfd.0107171238.6ff33b9b@posting.google.com> <170720011359545210%mday@apple.com> <87n163mfdc.fsf@elbereth.ccraig.org> <mailman.995408249.15783.python-list@python.org> Message-ID: <3b550e40.2201271731@wa.news.verio.net> On Tue, 17 Jul 2001 17:17:09 -0500, Skip Montanaro <skip at pobox.com> wrote: > > Christopher> I can't speak for Perl, but Python definately does not > Christopher> evaluate the expression at compile time. This is a problem > Christopher> I've had with Python. I wish that when given the -O option > Christopher> the compiler would do constant subexpression elimination. > >It's rare in normal Python code to actually see a constant expression >computed inside a loop. Fortunately, it would appear most folks aren't that >dumb, so while you can take steps to eliminate them, there aren't generally >going to be very many to eliminate. > Well rare, but not always dumb, I think. If you're only using a constant in one place that happens to be in a loop, and the clearest way to express it is as a constant expresssion, you do it that way when you know it's going to be folded. E.g., compare (5280.0/60.0*60.0) vs 1.4666667 -- which would you feel surer about, reviewing the code, given the same comment saying mph->fps? Of course, with Python it would be dumb not to move it out of the loop, if you could save significant execution time. From guido at python.org Sun Jul 22 12:12:24 2001 From: guido at python.org (Guido van Rossum) Date: Sun, 22 Jul 2001 16:12:24 GMT Subject: Stability of PYC files References: <e1gllts33oobp6vs3ppaor7uofl3eomehs@4ax.com> Message-ID: <cp8zhheyfa.fsf@cj20424-a.reston1.va.home.com> Stephen Horne <steve at lurking.demon.co.uk> writes: > Are the Python compiled bytecode PYC files stable enough that you can > take PYC files generated by older versions of Python and run them > without the source on newer versions? Definitely NOT. The PYC files are a detail of the implementation and vary across versions! > Has anyone ever tried to document Python bytecode? Not exactly, but the docs for the standard library module "dis" give a lot of details. Also read the source for py_compile.py. > Does jPython compile to Java bytecode, or does it act more directly as > an interpreter, or does it use an intermediate bytecode? Jython generates Java bytecode (which mostly consists of calls into the Jython run-time library :-). --Guido van Rossum (home page: http://www.python.org/~guido/) From eppstein at ics.uci.edu Mon Jul 23 15:47:04 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Mon, 23 Jul 2001 12:47:04 -0700 Subject: A use for integer quotients References: <3B5BC73B.2D52E5E2@alcyone.com> <3B5BA29B.E08FEEE9@alcyone.com> <yCK67.17615$EP6.4467503@news1.rdc2.pa.home.com> <mailman.995860718.9550.python-list@python.org> <mailman.995862939.15013.python-list@python.org> <mailman.995883879.12071.python-list@python.org> <3B5C5665.8D41D1F1@tundraware.com> <slrn.pl.9los0f.jh4.qrczak@qrnik.zagroda> <3B5C749A.59F97320@tundraware.com> Message-ID: <eppstein-6E0A27.12470423072001@news.service.uci.edu> In article <3B5C749A.59F97320 at tundraware.com>, Tim Daneliuk <tundra at tundraware.com> wrote: > Not formally, AFAIK. For example, 3 with no decimal point following > could be anything from 2.5 to 3.4. No no no. '3.' i.e. a floating point number with that value could be anything in that range. '3' means exactly the integer 3, no approximation at all. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From jmarshal at mathworks.com Fri Jul 13 13:12:27 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 13 Jul 2001 17:12:27 GMT Subject: greenbeen seeks advice References: <9pF37.22474$g96.625691@news.easynews.com> Message-ID: <9ina5r$l96$1@news.mathworks.com> Python's a very good place to start. Besides books on the language, I'd also recommend you find some books on data-structures. I can't name any good ones offhand, but maybe some other posters can... wyatt stafford <wyatts at onr.com> wrote: > Preamble: > I am a computer/network support person who has decided to start programming > for a vocation (no previous experience beyond minor scripting, etc). After > some research I selected Python as a good place to start. I bought "Learn > to Program using Python" (Gauld) and "Quick Python" (Harms/McDonald). Also > checking out the tutorial, and other good info at www.python.org. I have > a leaping, intuitive learning style given to missing the obvious, so I am > concerned about having fatal gaps in my learning via home schooling plan. > Questions: > Beyond those mentioned above, may I have any recommendations for self study > resources (books, etc) or techniques that will help me be a good programmer, > in general? > Do I need to know what is taught in CompSci 101/102/etc, to be great? > thanks and happy weekend to all, > wyatt > "Oh, that's not what I call bingeing" From tanzer at swing.co.at Thu Jul 19 02:44:12 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Thu, 19 Jul 2001 08:44:12 +0200 Subject: Python 2 times slower than Perl In-Reply-To: Your message of "18 Jul 2001 11:55:36 PDT." <8f41cfd.0107181055.3b34851a@posting.google.com> Message-ID: <m15N7Xg-000wcBC@swing.co.at> xucs007 at yahoo.com (Xu, C.S.) wrote: > Just spent a little time to compare 4 stupid again algorithms > (changed a little bit from last time) for both python and perl > (codes attached) on two systems (SunOS and Linux): > 1. while loop, global variables > 2. for loop, global variables > 3. while loop, local variables (in function) > 4. for loop, local variables (in function) > I used `time [1234].p[yl]` to get the time info. The user time > is as follows: > > PII 450MHz, Dell Precision 4100 Desktop, SunOS 5.8 i386 > #1 #2 #3 #4 > Python 2.1a1: 5.1 3.1 4.5 2.7 > Perl 5.005_03: 1.8 1.6 1.7 1.6 > > > PIII 1GHz, MTech 8500 Notebook, i386 Linux (Mandrake 8.0, kernal 2.4) > #1 #2 #3 #4 > Python 2.0: 2.34 1.38 1.54 0.98 > Perl 5.6.0: 0.95 1.22 0.95 1.21 > > The closest match is on Linux, 0.98 (python#4) vs. 0.95 (perl#1,#3). > Python still can't beat Perl, :-( But I will continue to use Python > to do uncritical data analysis, :-) IMNSHO, your conclusion is not supported by your facts. You tested nothing of importance to "critical" data analysis. About the only thing you can safely conclude from your tests is that you should continue to use Perl for trivial/meaningless tasks <3/4 wink>. -- 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 syring at email.com Fri Jul 13 16:37:44 2001 From: syring at email.com (Karl M. Syring) Date: Fri, 13 Jul 2001 22:37:44 +0200 Subject: FrameMaker exposed in Python (PyMaker anyone)? References: <9in4dk$eap$06$1@news.t-online.com> Message-ID: <9inm6l$jirpg$1@ID-7529.news.dfncis.de> "Thorsten Roskowetz" <rossi at earthling.net> schrieb > Hi, > > is there a Python extension that allows scripting of the > FrameMaker API. Google (and www.python.org) pointed me > to a project called PyMaker but the link is dead > (http://home.t-online.de/home/Ulrich.Herold/). No, the page is alife! Karl M. Syring From tim.one at home.com Sat Jul 28 05:02:09 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 28 Jul 2001 05:02:09 -0400 Subject: doctest x idle problem? In-Reply-To: <b8c015b9.0107271956.3661a8a0@posting.google.com> Message-ID: <LNBBLJKPBEHFEDALKOLCAEOKLBAA.tim.one@home.com> [Jon Schull] > Well, I was hoping to develop and test some modules within the idle > environment. (I'm wondering how well IDLE serves as a primary > Interactive Development Environment.) It's mixed. That modules aren't automagically reloaded when running a script is both a help and a curse, depending on what you're after in the end. > I ran into this "problem" (it's not unique to doctest) and thought I > was doing something wrong. I figured doctest's use of docstrings for > testing would be exemplary, so I tried doctest. > > In a way, doctest *was* exemplary... > > But it seems that its going to be awkward to do interactive > development in IDLE of modules that employ doctest. That seems a > shame; routine use of doctest and IDLE would be a good practice. If you like IDLE enough, you'll eventually <wink> discover workarounds. For using doctest specifically, and provided you don't intend to exploit the "Advanced Usage" of merging multiple runs, change your import doctest, mymodule doctest.testmod(mymode) blocks by inserting this line in the middle: doctest.master = None That explicitly wipes out the only state doctest retains across runs, making it functionally equivalent to reloading doctest. More general cases can be approached by writing a little program that explicitly reloads the modules you need to have reloaded across runs, and running that from time to time as needed. This won't be solved in general by magic until someone contributes code to launch "Run Script" in a fresh process; but that's not always what you'll want either. it's-life-it-sucks<wink>-ly y'rs - tim From tjreedy at home.com Sun Jul 22 22:02:42 2001 From: tjreedy at home.com (Terry Reedy) Date: Mon, 23 Jul 2001 02:02:42 GMT Subject: no traceback?? References: <slrn9lmd1p.1jk.sill@sill.silmarill.org> Message-ID: <6BL67.17641$EP6.4530210@news1.rdc2.pa.home.com> "Rainy" <sill at optonline.net> wrote in message news:slrn9lmd1p.1jk.sill at sill.silmarill.org... > Hello, > > My program (http://silmarill.org/cymbaline/cymbaline/cymbaline.py - yes, > it's repeated 3 times, that's not an error) works fine in 2.1 but exits > silently in 2.0 - no traceback, no errors, nothing. One possibility I checked > for is except (something): sys.exit() and I don't have anything like that here. > What else could it be? The only major innovation of 2.1 that I remember is nested scopes, which only operate if you 'import' them. Maybe one of the minor fixes is saving you. No one is going to read 100s of lines for you, so I suggest adding print statements to see where you get to and what values are changed. Start in the if main section. From thomas at xs4all.net Wed Jul 18 06:01:12 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Wed, 18 Jul 2001 12:01:12 +0200 Subject: Augmented Assignment in Python (PER) In-Reply-To: <15188.57943.434555.429691@gargoyle.cs.uchicago.edu> Message-ID: <20010718120112.B2025@xs4all.nl> On Tue, Jul 17, 2001 at 08:11:51PM -0500, David Beazley wrote: > I think the above sentence would make a lot more sense if it was > worded as follows: > "For the built-in types, augmented assignment doesn't violate > mutability or perform in-place modification of objects. Therefore, > writing x+=y creates an entirely new object x with the value x + y. > User defined types and classes may choose to implement different > behavior by redefining special methods such as __iadd__(), __isub__(), > and so forth." > Note: I still stand by the statement for built-in types. I looked through > the Python sources when writing the book and couldn't find any use of > augmented assignment for built-in types. I am not aware of any > counter-example where x += y is not equal to x = x + y for the standard > built-in types (if there is such an example, please enlighten me!). Sure: >>> x = [1,2] >>> y = x >>> id(x), id(y) (134572540, 134572540) >>> x += [1,2] >>> x [1, 2, 1, 2] >>> y [1, 2, 1, 2] >>> id(x),id(y) (134572540, 134572540) Basically, all mutable builtin types that define (the C equivalent of) '__add__' also define (the C equivalent of) '__iadd__' to work in-place. Unfortunately (for the learning curve) that means 'just lists' :P -- Thomas Wouters <thomas at xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From sholden at holdenweb.com Tue Jul 3 10:01:40 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 3 Jul 2001 10:01:40 -0400 Subject: Getting data from DBIII References: <3B41CEFD.3BDB4F63@nettonettech.com> Message-ID: <Gck07.26348$he.1373129@e420r-atl1.usenetserver.com> "Doug Poulin" <dpoulin at nettonettech.com> wrote in message news:3B41CEFD.3BDB4F63 at nettonettech.com... > Hi. > > Failry new to Python (have tried Perl, but....well, it's a long story). > Anyway, our Sales people use ACT! for contact management. I have > created a small Python/Tkinter, so I got the forms looking pretty. But > I am having trouble using Python to get the data from the DB. ACT uses > DB3, so I'm looking for pointers. I use Linux (RedHat 7.0) and Python > 1.5.2. > > Any help? > Doug: Not familiar with DB3. If it offers and ODBC interface there are modules you could use to access it. I'm not aware of a DB#-specific database module, but that doesn't mean there isn't one. Take a look at the DB SIG pages at http://www.python.org/ to get an idea of how databases are used from Python. regards Steve -- http://www.holdenweb.com/ From bokr at accessone.com Tue Jul 31 12:58:13 2001 From: bokr at accessone.com (Bengt Richter) Date: Tue, 31 Jul 2001 16:58:13 GMT Subject: Listing directorycontent in python References: <1aa68e6e.0107302231.dd024a2@posting.google.com> <slrn9md4hi.2g6.sill@sill.silmarill.org> Message-ID: <3b66e2fd.912177952@wa.news.verio.net> On Tue, 31 Jul 2001 11:14:56 GMT, sill at optonline.net (Andrei Kulakov) wrote: >On 30 Jul 2001 23:31:55 -0700, andreas <wpt2097 at hotmail.com> wrote: >> Hello. >> >> I have a simple question, I want to have a list of all files/dirs in a >> certain directory. >> >> An example would be that I want to know all filenames that end with >> "*.JPG" in the directory "/var/www/". >> >> I have not succeeded in doing this myself with "os.path"-module, so I >> am now asking for tips, hints, examples or pointers to answers of >> previous similar posts. >> >> I am using Python v1.5 most of the time. >> >> TIA >> >> Andreas > >os.dirlist(dirpath) ITYM os.listdir(dirpath) > From denro at earthlink.net Fri Jul 13 03:32:28 2001 From: denro at earthlink.net (Dennis Roark) Date: Fri, 13 Jul 2001 07:32:28 GMT Subject: not safe at all Message-ID: <mm8tkt4te3qnbpv3nh5nhsi591o1osln73@4ax.com> For amusement, run this little script which demonstrates a near ultimate in the lack of type safety in the language. (Perhaps there is a bit of type safety in that you can't do this: 4 + "one") But look at what you can do in the following script: x = 3 x = x + 2 print "x =", x x = "now I'm a string" print x x = [ 5, x ] print "and now a list:", x If you don't believe it, run it. Should any language allow x to be such a chameleon, to where it can even be a different type on two sides of an assignment? --------------------------------- Dennis Roark Dept. of Computer Science University of Sioux Falls Starting Points: http://home.earthlink.net/~denro --------------------------------- From prem at engr.uky.edu Tue Jul 17 15:12:28 2001 From: prem at engr.uky.edu (Prem Rachakonda) Date: Tue, 17 Jul 2001 15:12:28 -0400 Subject: "Print" in IDlE?? Message-ID: <Pine.LNX.4.21.0107171509470.12906-100000@seahawk.ecc.engr.uky.edu> Hi, Why is that there is no print option in IDlE. Though not an absoute necessity, is there a reason for that. It would have been good if it had the print option, because you intutively go for FILE-->PRINT and don't find it there!! 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 From 9nick9m at alum.mit.edu Sat Jul 21 00:00:57 2001 From: 9nick9m at alum.mit.edu (Nick Mathewson) Date: Sat, 21 Jul 2001 04:00:57 GMT Subject: What confuses the newbies: An unscientific study Message-ID: <slrn9lhvn1.ji4.9nick9m@localhost.localdomain> Every so often, people on comp.lang.python get into flamew^W heated discussions about which aspects of the language ought to be simplified for the benefit of non-programmers. I thought it might be cool for me to use suck(1) to pull down all the articles I could from comp.lang.python, find all the ones that represented questions about the language, and tabulate which aspects of the language people were misunderstanding. CAVEATS: - This isn't scientific. This is just what I found, on a single newsserver, as interpreted by me. I didn't use any formal protocol in evaluating which issues were which. - These people definitely don't represent non-programmers. These are just the people who asked questions on usenet. Many of them probably have prior programming experience; _all_ of them at least know how to use email or a newsreader. - I skipped over questions about embedding, the Python C API, and other really advanced topics. I also skipped over questions (e.g., "what was the access keyword for.") that didn't represent misunderstanding of Python. - I might have missed a few by mistake. I only looked at messages which began new threads that were still available on my server at about 3 this afternoon. I'm pretty sure I remember reading some stuff a couple of weeks ago that wasn't on here... - I'm mind-reading in some cases here... or rather, I'm interpreting the way that the users must have _expected_ the language to work in order to ask the questions or write the sample code. - Some messages are counted twice, if they show more than one piece of confusion. WHY I THINK THIS IS NEAT NEVERTHELESS: - All of these issues are real issues that confused at least one person, and may confuse others. This isn't stuff I imagine that might confuse me, or stuff that I seem to remember having confused me once. (I'm an easily confused kind of guy, but I'm leaving my confusion out of this.) - Many of them may be addressable by improving tools, tweaking the libraries, or twiddling error messages. - Even though non-programmer friendliness is an area where Python is intended to shine long-term, newbie-friendliness is nice too. AND FINALLY: - If you recognize yourself as a poster of one of these questions, I hope you won't be offended. I'm taking your confusion as a sign of possible weakness in Python, not in you. :) Ok, here we go. The most common confusions, as shown on my server: 1. NOT KNOWING WHERE MODULE DOCUMENTATION IS. A good fifteen or so people asked questions of the form, "How do I...", "Is there a module that can...", etc. All of these questions were answered with references to the library reference, or to the Vaults. Perhaps when the Python Cookbook is more compiled, these things will be easier. BTW, the most common requests were satisfied by: (in no particular order) XML/SGML parsing, windowing toolkits, popen, timeoutsocket, and stringio. Other requests turned out to be for chr and popen2. * A related kind of confusion: in 4 or so of these cases, users knew about a function that did _almost_ the right thing, and [instead of looking for the function they _really_ wanted] they searched for a way to make the almost-right function do the right thing. An example is somebody who knows that str(1.0/3) can convert float->str trying to specify a precision parameter instead of using %. 2. NOT SURE HOW VARIABLES WORK I counted 5 cases of people expecting variables to work in ways they didn't. They broke down like this: A. Thinking that 'global' means world-global, not module-global. B. Confusing 'outer' self with 'inner' self in helper class. C. Thinking that variables in a function are global until assigned, and local thereafter. D. Writing 'x="b"; a.x' instead of 'a.b' E. Writing 'x="fn"; x()' instead of 'x=fn; x()' There wasn't a lot of pattern here, and I don't think much can be done to make this area of the language easier to understand... ...except for the fact that several of these errors fell into the next category, which is: 3. GOT ERROR MESSAGES THEY DIDN'T UNDERSTAND At least 4 people submitted exceptions that, when translated into English, would have told them how to solve their problems. One other submitted an exception that told them about a problem which they understood, but left them unsure how to solve it. The biggest culprit was AttributeError. While object instances now give a helpful "'X' instance has no attribute 'foo'", the old form "AttributeError: foo" still appears for many types. Two people were not sure what this meant. One person didn't understand what 'TypeError: call of non-function (type string)' meant. One person knew what 'TypeError: cannot add type "int" to string' meant, but didn't know where to go from there. 4. EXPECTED LIBRARIES AND BUILTINS TO ACT DIFFERENTLY Four people, at least, expected libraries included with standard Python to work differently than they actually do. One person expected 'remove' to remove a directory. One person expected the xml library to set the file name without using an InputSource object. Others had issues with windows stuff that I didn't understand. :) 5. OTHER ISSUES: 2 people expected strings to act mutably: 1 expected string.strip to have side effects 1 expected string slices to be assignable 2 people had problems writing re patterns. 1 didn't know to use raw strings 1 didn't know to use any quotes at all. 2 people had misinstalled Python. 2 people had issues with aliasing lists 1 tried to do a lst.remove within a loop over lst 1 expected [[...]]*6 to perform a deep copy 2 people were bitten by import 1 expected a second import of a module should reload it (why doesn't it give a warning?) 1 imported a module with hidden side-effects 2 people didn't know about unpacking tuples 1 person thought that, as in perl, 'x = funcReturningTuple()' would set x to the first element of the tuple. 1 person just didn't know you could unpack tuples. 2 people were confused about fp. 1 person thought that int/int should yield a float 1 person didn't know that fp was inexact 1 person used 'varname' when they meant `varname` 1 person used \\ as a separator and had trouble porting to unix >1 person wrote 'print "foo\n"' when they probably only wanted one newline. 1 person tried to use 2.0 syntax (reading from the 2.0 manual) while using 1.5. You-should-have-seen-me-when-I-was-learning'ly yrs, -- Nick Mathewson <9 nick 9 m at alum dot mit dot edu> Remove 9's to respond. No spam. From mdadd329ea at xix.com Mon Jul 9 22:40:31 2001 From: mdadd329ea at xix.com (Manfred Bartz) Date: Tue, 10 Jul 2001 02:40:31 GMT Subject: BASIC or Python? References: <3d157fa0.0107051904.7ec368b8@posting.google.com> <slrn9kcfuq.2b7g.kamikaze@kuoi.asui.uidaho.edu> <0t_17.14670$Fk7.131382@news.indigo.ie> <slrn9kkgfp.dj6.kamikaze@kuoi.asui.uidaho.edu> <9idp67$jln$2@gondor.sdsu.edu> Message-ID: <m2g0c5wlmr.fsf@reddwarf.xix.com> stremler at rohan.sdsu.edu writes: > I'll just quote: > > This is also one reason I dislike Python. Indentation is part of the > documentation of the program, and as such it shouldn't be parsed by the > compiler. -- Peter da Silva (September 1999) That is *his* opinion and probably yours too. Well, don't use Python then. Find another language, one that you like and be happy. Personally I think making the indentation style part of the language is pure genius. With Python I can understand someone else's code without having to re-format the hairy passages first. -- Manfred ---------------------------------------------------------------- NetfilterLogAnalyzer, NetCalc, whois at: <http://logi.cc/linux/> From new_name at mit.edu Sat Jul 14 10:55:54 2001 From: new_name at mit.edu (Alex) Date: 14 Jul 2001 10:55:54 -0400 Subject: converting from perl: variable sized unpack References: <roy-B2459F.22112513072001@news1.panix.com> <3B4FD35A.26B4568E@Lugoj.Com> <roy-B49CE8.09521914072001@news1.panix.com> Message-ID: <etdd773ftl1.fsf@lola-granola.mit.edu> > > [f1, f2, f3, f4, f5, f6] = (string.split (line) + 6*[None])[:6] > > Yeah, that's what I had come up with, but I was hoping somebody would have > an idea that was more elegant and efficient :-) Why not just leave it as a list and work with the elements? f = line.split() Alex. From meinmailfilter at gmx.de Tue Jul 3 02:40:49 2001 From: meinmailfilter at gmx.de (Heiko) Date: 2 Jul 2001 23:40:49 -0700 Subject: How to call a method with variing arguments Message-ID: <e956b5f1.0107022240.776c1734@posting.google.com> Hello, I want to do this: ClassObject = Class() ClassObject.Method(Arg1, Arg2, Arg3) ... ClassObject.Method(Arg1, Arg2, Arg3, Arg4, Arg5 ....) ... ClassObject.Method() ... and so on. Means that I want to call a method with a variing number of arguments and the method decides what to do. If possible, it would be nice, if the sequence of the arguments doesn?t matter, and the method realizes which argument is on which position (but that is a "nice to have"). So, how do I have to declare the method, that this works? Thanks Heiko From skip at pobox.com Thu Jul 12 11:59:18 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 12 Jul 2001 10:59:18 -0500 Subject: list and implicit continuation may cause bugs in Python programs In-Reply-To: <Pine.LNX.4.21.BCL.0107121756210.14873-100000@suzi.com.onego.ru> References: <Pine.LNX.4.21.BCL.0107121756210.14873-100000@suzi.com.onego.ru> Message-ID: <15181.51542.942552.789605@beluga.mojam.com> Roman> FYI: Roman> Do not forget commas: ... Roman> list =[ "update", "y", "m", "d", "y1", "m1", "d1", "event", "url" Roman> "preview" ] For what it's worth, this is a much more common mistake for me than integer division (mostly, I suspect because I do very little numerical work in Python). -- Skip Montanaro (skip at pobox.com) (847)971-7098 From whisper at oz.nospamnet Tue Jul 3 12:20:13 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 3 Jul 2001 16:20:13 GMT Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> <9hrj3q$cj1@news1.gtech.com> <9hsfue$oqv$1@216.39.170.247> <3B41C7C4.E444FCF8@stroeder.com> Message-ID: <9hsrbt$oqv$4@216.39.170.247> In article <3B41C7C4.E444FCF8 at stroeder.com>, michael at stroeder.com says... > David LeBlanc wrote: > > > > The Canadians privatized their national air traffic control a few years > > ago and oh my! the planes RUN ON TIME! > > Which does not say anything about safety. Well, time will tell... > > Ciao, Michael. > Does not say anything _explicit_ about safety, but it suggests a lot, at least to me. No corporation is going to fail to budget for equipment maintenence, upgrades as needed and whatever else it takes to maintain a system and make a profit while not paying out huge insurance premiums to their risk carriers for accidentally running planes into mountains, the ground or each other. This is in sharp contrast to the US system where congress can barely manage to look up from swilling from the corporate trough for reelection funds long enough to even appropriate salaries. Of course, our system has no long delays, and hasn't landed more the 3-4 planes on top of each other in the past 5 years (Detroit, LAX and... don't recall the third). Yup, safe as a government run operation can be. And look! no insurance premiums, we just milk the taxpayers a bit more in a bad year or not fund low-income child care... easy. Heh. Dave LeBlanc From db3l at fitlinxx.com Mon Jul 30 17:15:43 2001 From: db3l at fitlinxx.com (David Bolen) Date: 30 Jul 2001 17:15:43 -0400 Subject: Python Windows installer: good news! References: <mailman.996447416.25799.python-list@python.org> Message-ID: <upuai5da8.fsf@ctwd0143.fitlinxx.com> "Tim Peters" <tim at zope.com> writes: > Wise Solutions generously offered PythonLabs use of their InstallerMaster > 8.1 system. Every PythonLabs Windows installer produced to date used Wise > 5.0a, and while that's done a great job for us over the years, some of you > have noticed <wink> that it was starting to show its age. BTW, I took the last post with a comment that this was coming to decrease the need to investigate Inno - although I did find that ISX (the extended version) could handle the unknowns in the iss you posted about through its scripting option, but figured there's no need to fight against a commercial (and close to what was already in use) package like Wise with their offer. -- -- 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 robin at jessikat.fsnet.co.uk Sun Jul 22 20:23:43 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Mon, 23 Jul 2001 01:23:43 +0100 Subject: PEP0238 lament References: <3B5B3676.40F39389@alcyone.com> <eppstein-03540D.13070222072001@news.service.uci.edu> <mailman.995836120.7223.python-list@python.org> Message-ID: <vyIKbWAP62W7EwC+@jessikat.fsnet.co.uk> In article <mailman.995836120.7223.python-list at python.org>, Moshe Zadka <moshez at zadka.site.co.il> writes >On Sun, 22 Jul 2001 13:24:22 -0700, Erik Max Francis <max at alcyone.com> wrote: > >> I agree. It's turning an otherwise fairly strongly (but dynamically) >> typed language on its head. If I want type-changing operations, I'll do >> them explicitly. > >Be sure to tell math.cos that...it has been "silently" turning integers >into floats for years. ... coercions and the like are a separate issue. the cos of 1.0 , 1/1 and 1 are all the same so it makes some sense to allow a conversion. The 1/2 == 0 case is just as good if not better than the 1/2 == 0.5 case, it's probably slightly worse than the rational result case, but we have many languages which treat integer division like python currently so I would argue that it has some extra merit. We hear many criticisms of basic on this list, but Dartmouth basic was originally a teaching language. When I taught basic, C didn't exist and Fortran, Algol and the like were considered too hard for non-programmer university students. The leadership seems to want to python become more available to a lower grade of student than first year undergraduates. I think that is wrong, but I use python in a professional capacity. I think languages succeed or fail because they work for programmers. Division in computers is always discrete (unless we ever manage to get quantum things working). -- Robin Becker From SBrunning at trisystems.co.uk Mon Jul 16 10:19:53 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Mon, 16 Jul 2001 15:19:53 +0100 Subject: Most efficient solution? Message-ID: <31575A892FF6D1118F5800600846864D78BE8D@intrepid> > From: Jeffery D. Collins [SMTP:jcollins at boulder.net] > > List B consists of my "stopwords", meaning, the words I don't want > included in my final version of list A. So what I need to > > do is check every item in list A, and if it occurs in list B, then I > want to remove it from the final version of A. My first thought > > would be: > > > > for eachItem in A: > > if eachItem in B: > > A.remove(eachItem) > > > > How about: > > map(A.remove, B) Clever! Unfortunately, it dies (giving a ValueError) if any of the tokens in B are not present in A. Nasty, but how about: map((A + B).remove, B) 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 bokr at accessone.com Sat Jul 14 02:28:22 2001 From: bokr at accessone.com (Bengt Richter) Date: Sat, 14 Jul 2001 06:28:22 GMT Subject: Naked function call syntax References: <3b4fa037.1845423078@wa.news.verio.net> <3B4FBA91.6080200@webone.com.au> Message-ID: <3b4fcf08.1857408271@wa.news.verio.net> On Sat, 14 Jul 2001 13:20:49 +1000, simonb at webone.com.au wrote: >right. >I do this for lists: > > >>>def lprint(alist): > >>> for a in alist: > >>> print str(a) > >so that i don't get repr of elements. >And it would be great to be able to write: > >>> lprint alist >just like print... > >Im not sure i understand the proposed resolution of >leading '[' or '('... >"print(1,2)" prints a tuple, so wouldn't >you have to mark functions as "naked" >so that a tuple would be sent as the first argument? > If there is a problem, it's not with print (1,2). UIAM, print is recognized first as a special symbol introducing a print statement. Unlike an ordinary symbol, it is not optionally followed by a "trailer" of (xxx) for function invocation, [xxx] for indexing, or .NAME for attribute selection. E.g., print.NAME will get you the same error as .NAME by itself (syntax error), not an error that print doesn't have .NAME attribute. Actually, now I'm thinking the change would have to be in the 'power' term definition, to prevent gobbling multiple lines with NEWLINE in trailer. Since you wouldn't be raising a function body to a power, perhaps power could be changed from power: atom trailer* ('**' factor)* to power: atom trailer* ('**' factor)* | atom trailer* arglist NEWLINE power would then really be power_or_naked_call_ending_line and trailer would be unchanged, which would allow you make naked method calls too ;-) There would still be ambiguities to be resolved in favor of the old 'clothed' call syntax. > >>>def naked lprint(alist): > >>>... > >Well, this sounds rediculous to me. LOL, almost ROFL, when you say it ;-) >what about: > > >>>def lprint alist: > >>>... > I don't think you need special definition syntax. It's not about the function itself, it's how you write the call. And nothing should need to change about the old def or call syntax. The new thing would Just be that on a function call whose normally parenthesized arg list ends the line, you'd have the option of dropping the parens -- so long as the arg list itself didn't start with '(' or '['. 'clothed' calls would still work as usual, because of the precedence of the leading '('. Howver, you couldn't make a naked call with a tuple or list as an argument. You'd have to write foo((bar,baz)) or foo([bar,baz]). But then, that's the way you have to write it now ;-) Conceivably, if foo[bar,baz] produced a syntax error it would be re-interpreted as a naked call to foo with a [bar,baz] list as argument, but I'm not sure when that might happen. In effect, it seems like print has a naked arg list by default, instead of last resort. >? >Simon. > > >Bengt Richter wrote: > >>Interactively, I find myself writing little things like: >> >>def pd(x): >> try: >> print x.__doc__ >> except: >> print '(no doc string)' >> >>so that, e.g., I can type >> >> pd(vars) >> >>and get formatted info. But I'm lazy enough that >>I would like to to type just >> pd vars >> >>Is there an existing pythonic way to do this? >> >>If not, would there be breakage if python were modified to make >> >> foo whatever-up-to-EOL >> >>equivalent to >> >> foo(whatever-up-to-EOL) >> >>when it would be a syntax error otherwise? I.e., I'm wondering >>if the grammar could be modified to do this by changing trailer >>to accept arglist NEWLINE if _all_ else fails, and treat a match >>as if it was an arglist. Leading '(' or '[' ambiguity would be >>resolved in favor of normal arglist or subscriptlist. >> >> > From Tom_Good1 at excite.com Thu Jul 19 16:30:31 2001 From: Tom_Good1 at excite.com (Tom Good) Date: 19 Jul 2001 13:30:31 -0700 Subject: trouble installing Python-2.2a1.exe Message-ID: <ac677656.0107191230.767b041d@posting.google.com> I downloaded the Python-2.2a1.exe installer from SourceForge, and verified that the MD5 sum is correct. When I run it under Windows 2000 Professional [Version 5.00.2195], I get an error dialog that says: 16 bit Windows Subsystem The NTVDM CPU has encountered an illegal instruction. CS:020c IP:0115 OP:0f 00 00 00 00 Choose 'Close' to terminate the application. Any ideas? Tom From tim.one at home.com Sat Jul 14 16:01:08 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 14 Jul 2001 16:01:08 -0400 Subject: Activestate Python, not able to run "Module Documentation Server" on standalone computer In-Reply-To: <3b507b2b.1396350535@news.mch.sni.de> Message-ID: <LNBBLJKPBEHFEDALKOLCCEHMKOAA.tim.one@home.com> [Christian Aastorp] > The Module Documentation Server is quite nice, I run it on my computer > at work. But it fails when I try to run it at home with a message from > the browser that its unable to go on-line. pydoc.py had this problem on Win9X until we changed the code to use hostname localhost instead of 127.0.0.1 Apparently Win9X wasn't able to resolve the latter spelling without first calling up your ISP to assure it there was no need to ask <wink>. You *may* able to worm around this bu creating a hosts file with the line 127.0.0.1 localhost See http://www.isgsp.net/misc/hosts.html for instructions. From rnd at onego.ru Sun Jul 1 12:24:08 2001 From: rnd at onego.ru (Roman Suzi) Date: Sun, 1 Jul 2001 20:24:08 +0400 (MSD) Subject: Python cgi script - outputting images In-Reply-To: <pjgujtkkdihrjfelc5qo0acabavvuu5mvo@4ax.com> Message-ID: <Pine.LNX.4.30.0107012023430.325-100000@rnd.onego.ru> On Sun, 1 Jul 2001, Mexican Bandit wrote: >Hi, > >Wondering of anyone can help - Python newbie. I'm trying to write a >Python cgi script which outputs a gif or jpg image from another >server... > >---- >import urllib > >print "Content-Type: image/jpeg" >print > >image = urllib.urlopen("http://127.0.0.1/splogo.jpg") >print image.read() import sys sys.stdout.write(image.read()) >---- > >The output of the image is corrupted. I suspect this is to do with >'print' turning everything into strings? > >How do I output raw image data? > > Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Sunday, July 01, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "DEVICE=EXXON.SYS may mess up your environment" _/ From missive at frontiernet.net Thu Jul 26 18:17:10 2001 From: missive at frontiernet.net (Lee Harr) Date: Thu, 26 Jul 2001 22:17:10 +0000 (UTC) Subject: newbie threading question References: <KYN77.7188$LP2.727977@bgtnsc06-news.ops.worldnet.att.net> Message-ID: <9jq4t5$3j7a$3@node21.cwnet.roc.gblx.net> On Thu, 26 Jul 2001 05:33:30 GMT, douglas savitsky <dsavitsk at e-coli.net> wrote: > this is a slightly modified version of a response from the other day using > win32process.beginthreadex() instead of thread ... > > # ------------------------------ > import win32process > import time > > def Func(id, numSecs, incBy): > val = 0 > while 1: > print id, val > val = val + incBy > time.sleep(numSecs) > if val > 10: break > return 1 > > if __name__ == '__main__': > a = win32process.beginthreadex(None, 0, Func, ("First thread", 1, 2), 1) > b = win32process.beginthreadex(None, 0, Func, ("Second thread", 1, 3), > 1) > # ------------------------------ > > is there anyway to capture the return value? i need to run several > simultaneous large computations, but i would like to capture the returns ... > i think? do i not? can anyone give some suggestions on where to look? > Well... hmmm. Both threads are printing to standard out, right? You could have them preface their "return value" with a tag and print it out before returning. RT1: 1 RT2: 0 ... Then you could parse the output. Seems like a good use for a pipe. Possible on win32? Don't know! From pinard at iro.umontreal.ca Tue Jul 17 17:50:16 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 17 Jul 2001 17:50:16 -0400 Subject: OO misconceptions In-Reply-To: <OFDDCD86D9.4BF13213-ON88256A8C.00600A1B@i2.com> References: <OFDDCD86D9.4BF13213-ON88256A8C.00600A1B@i2.com> Message-ID: <oqr8vfcjjb.fsf@lin2.sram.qc.ca> [James_Althoff at i2.com] > Plus the fact that Perl sucks. (Just kidding. (Well, not really. > (Well, kinda, sorta))). ;-) Perl was immensely useful to me. Than Python came, which allows me to write bigger projects, allowing them to be much more maintainable. I'm very grateful to Perl, believe me. But I would resent being forced into using Perl, now that I have something which I enjoy even more that I enjoyed Perl. I'm still dreaming about an automatic Perl to Python converter. Despite many consider this is not possible, I stick with my naive impression we could do something about it. It could revolve around three parts: analysing Perl into a tree, applying some tree-transformational engine using a specialised language (I wrote a few such in my life), and producing final Python text. Would you believe, this is the first step which looks most difficult to me. Parsing Perl might not be that difficult after all, but its tokenizer is extremely hairy, and rather discouraging. If I could swallow that snake, the rest would not necessarily be easy, but at least, it would be fun! :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From cjensen at bioeng.ucsd.edu Tue Jul 24 12:53:08 2001 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Tue, 24 Jul 2001 09:53:08 -0700 Subject: Pinecones multiply like rabbits around here... References: <mailman.995975742.21691.python-list@python.org> Message-ID: <3B5DA7F4.ADB9E619@bioeng.ucsd.edu> Skip Montanaro wrote: > > I was on a walk with my wife and dog yesterday. Out of the blue I asked her > "what's the result of five divided by two?" After a little back-and-forth > where she tried to figure out how I was trying to trick her and make her > look foolish she answered, "two-and-a-half". I then posed, "Suppose you > have five pinecones and you want to clump them into groups of two. What > would you do?". Her answer was, "Put two in the first group, two in the > second group, and break the last pinecone in two so the third group would > have two as well." > > Can we represent that in Python's arithmetic operations somehow? :-) > > -- > Skip Montanaro (skip at pobox.com) > http://www.mojam.com/ > http://www.musi-cal.com/ Interesting math there. 5 pine cones give 3 groups of 2; giving 6 pine cones. The produce industry will love it. -- Curtis Jensen From emile at fenx.com Thu Jul 26 09:03:48 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 26 Jul 2001 06:03:48 -0700 Subject: Class with subclass and dynamic lists References: <3B600A64.EC187E9@sci.pam.szczecin.pl> Message-ID: <9jp4n3$t3h4$1@ID-11957.news.dfncis.de> I don't know exactly what you're trying to do here, but you are creating instances that share class attributes. Consider for example: class Temp:pass class A: attr = Temp() class B: def __init__(self): self.attr = Temp() a,b,c = A(), A(), A() print id(a.attr) print id(b.attr) print id(c.attr) a,b,c = B(), B(), B() print id(a.attr) print id(b.attr) print id(c.attr) Moving Temp() to the __init__ method in class B causes the instances to each have their own new Temp instance. In class A all instances share the class copy of attr until/unless you specifically assign to it using something like: a = A() a.attr = Temp() HTH, -- Emile van Sebille emile at fenx.com --------- "Piotr Legiecki" <piotrlg at sci.pam.szczecin.pl> wrote in message news:3B600A64.EC187E9 at sci.pam.szczecin.pl... > Hi > > I can't resolve my problem. Here is the test code > > class A: > x=[] #it will be list of B objects > z=None #something, doesn't matter > > class B: > y=None > > > #this function adds to A object (arg) B objects with value val > def f(arg, val): > for i in range(1,3): #to put some values into the list > arg.x.append(B()) > l=len(arg.x)-1 #well, it is just added the last object in a > list, > arg.x[l].y=val+i #assign him somethig > print 'in f', arg.x[l].y # test > print l #test, here I can see, that my list in > class A (x[]) is THE SAME for all the > #A instances! Why? > > def main(): > p=[] #list of class A objects > p.append(A()) #make 2 objects of class A > f(p[0], 10) #send object A, from list of A's objects (I hope) to add > a list of B objects to A object > p[0].z='aaa' > > p.append(A()) #second A object > p[1].z='bbb' > f(p[1],20) > > #testing, not good > print p[0].x[0].y > print p[0].x[1].y > print p[0].z > print p[1].x[0].y #here I have the same values as in p[0].x[0].y, why? > print p[1].x[1].y #why p[1].x is the same list for both (p[0], p[1]) A > objects? > print p[1].z > print p[0].z > > main() > > -- > Regards > Piotr Legiecki From ken_chiba at hotmail.com Wed Jul 11 22:44:29 2001 From: ken_chiba at hotmail.com (Ken) Date: Thu, 12 Jul 2001 02:44:29 GMT Subject: MySQLdb - possible without install? Message-ID: <3b4d0ea7.11581823@news1.on.sympatico.ca> Just curious. I'm with an ISP that allows running of scripts, and has MySQL database access. They have a perl API installed, but nothing to support Python. I was wondering if it was possible to just copy over the MySQLdb directory from the site-packages area of Python, and just "import" it into the scripts? Is there any way to do this? Thanks, kc From greg at cosc.canterbury.ac.nz Thu Jul 12 02:00:17 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Thu, 12 Jul 2001 18:00:17 +1200 Subject: LAMBDA IS IT USELESS? References: <tO837.679712$166.14009323@news1.rdc1.bc.home.com> Message-ID: <3B4D3CF1.889B57BB@cosc.canterbury.ac.nz> EricIDLE wrote: > > def mult(x,y): > return x * y > f = reduce(lambda x,y: x*y,n) I don't know what the mult function is there for, since you're not using it in that example. All you need is f = reduce(lambda x,y: x*y,n) > def mult(x,y): > return x * y > f = reduce(mult,n) > > Isnt that easier?? It's a matter of taste. Some people like the ability to write very trivial functions like your mult() in-line. Others find it clearer to define them separately. If you like the separate version better, feel free to use 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 nperkins7 at home.com Mon Jul 30 20:52:25 2001 From: nperkins7 at home.com (Nick Perkins) Date: Tue, 31 Jul 2001 00:52:25 GMT Subject: Suggestion for impriving list comprehensions References: <gER67.534750$eK2.111982758@news4.rdc1.on.home.com> <ac677656.0107231024.3ab3e6f1@posting.google.com> <3B5F0867.7447E5FB@ccvcorp.com> <ac677656.0107251340.15e848fb@posting.google.com> <9jphkk$rhc$1@newsy.ifm.liu.se> <cpofq75qax.fsf@cj20424-a.reston1.va.home.com> Message-ID: <djn97.592006$eK2.125216739@news4.rdc1.on.home.com> "Guido van Rossum" <guido at python.org> wrote in message > > [x for x in fib() while x < 50] > > Neat, but maybe not general enough. How do you request the first N? Similar to your idea, but takes an iterator: def first(n,it): for i in xrange(n): yield it.next() [ x for x in first(N,fib()) ] This type of function could be written to take an iterator, or a sequence, or even a generator. ..but I consider this unrelated to the question of allowing 'while' in a list comprehension. > And fuzzy: does this include or exclude the first x >= 50? Not fuzzy at all! (exclude, of course) The 'while' condition would work just like the 'if' condition: Only values for which the condition is true would be included. The only difference is that 'while' would terminate the comprehension the first time it's condition is false. In fact, the more I think about it, the more it seems like a natural companion to the 'if' in a list comprehension. The beauty of list comprehensions is that they eliminate the drudgery of creating your own loop just for the purpose of building a list. The 'while' is list comprehensions looks just right to me. It is easy to read and understand. [ x for x in seq while x < 10 ] means: result=[] for x in seq: if x < 10: result.append(x) else: break This is just a tiny difference from the 'if' clause of a comprehension, the only difference being the 'break'. I don't see any really elegant alternative for implementing these semantics.. ( here's my try at it: ) ## myresult = [ x for x in seq while x < 10 ] def iter_while(it,test): while 1: val = it.next() if test(val): yield val else: raise StopIteration myresult = [ x for x in iter_while(iter(seq),lambda x: x<10) ] .. but this is, of course, pretty ugly. ( so let's have 'while' in list comprehensions! ) From aahz at panix.com Sat Jul 14 13:25:08 2001 From: aahz at panix.com (Aahz Maruch) Date: 14 Jul 2001 10:25:08 -0700 Subject: python and applications References: <V%337.677940$166.13952126@news1.rdc1.bc.home.com> Message-ID: <9ipv9k$nda$1@panix2.panix.com> In article <V%337.677940$166.13952126 at news1.rdc1.bc.home.com>, tyler spivey <tspivey8 at home.com> wrote: > >could you write a fast mud in python? >having a lot of monsters like dikumuds do? Probably. Depends what exactly you're trying to do. >how many blind programmers use python? No idea. Python is probably good for blind people because you usually write less code in Python -- each statement in Python does more. >and is python just a toy language? No. >can it do more or as much as c? could you create a roguelike in it? Python is different from C. Python programs to do equivalent work are almost always shorter than C, but C makes it easier to do low-level machine manipulation. Note that it is very easy in Python to make calls into C libraries. -- --- 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 "How come we choose from just two people for President but more than 50 for Miss America?" --AEN From skip at pobox.com Wed Jul 25 16:58:42 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 25 Jul 2001 15:58:42 -0500 Subject: Driver finds 4' Python in hire car. In-Reply-To: <cpitgg94bk.fsf@cj20424-a.reston1.va.home.com> References: <mailman.996064604.22983.python-list@python.org> <cpitgg94bk.fsf@cj20424-a.reston1.va.home.com> Message-ID: <15199.13058.879236.213628@beluga.mojam.com> >> <http://www.foxnews.com/story/0,2933,30352,00.html> Guido> And in Fairfax County, home of PythonLabs no less! :-) It's probably left over from Barry's last gig... Skip From pedro at athlet.de Wed Jul 11 19:22:00 2001 From: pedro at athlet.de (pedro) Date: Wed, 11 Jul 2001 23:22:00 GMT Subject: detect if file or dir References: <3b4cd747.27470810@news.isis.de> <9iimn5$j3089$1@ID-11957.news.dfncis.de> Message-ID: <3b4cdf86.29582467@news.isis.de> >You'll find isfile and isdir in os.path damn i overlooked it. thank you very much. From thedustbustr at aol.com Fri Jul 20 21:35:33 2001 From: thedustbustr at aol.com (TheDustbustr) Date: 21 Jul 2001 01:35:33 GMT Subject: whats this mean? Message-ID: <20010720213533.19217.00000446@ng-fb1.aol.com> # BEGIN CODE BLOCK try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind((HOST, PORT)) s.listen(1) conn, addr = s.accept() except socket.error, why: ## reference 1 print "Server Error: " + errno.errorcode[why[0]] + ", " + why[1] ## reference 2 sys.exit(1) # END CODE BLOCK what does reference 2 mean? what do those brackets do? And for reference 1, what will 'why' hold if an error occurs? Thanks, Dustin From phd at phd.fep.ru Wed Jul 11 11:24:53 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Wed, 11 Jul 2001 19:24:53 +0400 (MSD) Subject: Bug in rfc822 In-Reply-To: <8UZ27.41897$F%5.2532623@e420r-atl2.usenetserver.com> Message-ID: <Pine.LNX.4.33.0107111923100.17694-100000@phd.fep.ru> On Wed, 11 Jul 2001, Steve Holden wrote: > > Playing with rfc822 is good, but i think mailbox.py has also several > > problems. When you do mailbox.next(), the function return a rfc822.Message > > but i wanted to use my class MyMessage, so i have to rewrite : > > > > class MyUnixMailbox(mailbox.UnixMailbox): > > def next(self): [skip] > > return MyMessage(mailbox._Subfile(self.fp, start, stop)) > > > > Do you know of any prettier solution ? > > I've come across the same impedance mismatch myself, and adopted more or > less the same solution. It would clearly be nice to be able to pass the > mailbox's __init__() method an (optional, defaulting to rfc822.Message) > class which that mailbox would then use when it was creating messages. The > class would obviously need to comply with (a subset of) the rfc822.Message > interface. > > Maybe this upwardly-compatible solution could be adopted for the rfc2822 > library? Have anyone of you looked into mailbox.py from Python 2.1? :) I recommend to look there and find all your ni^H^Hdreams came true :))) Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From max at alcyone.com Wed Jul 18 19:51:11 2001 From: max at alcyone.com (Erik Max Francis) Date: Wed, 18 Jul 2001 16:51:11 -0700 Subject: converting from perl: variable sized unpack References: <roy-B2459F.22112513072001@news1.panix.com> <mailman.995081424.8581.python-list@python.org> <slrn9l4esk.885.quinn@yak.ugcs.caltech.edu> <slrn9l5lc4.6ko.philh@comuno.freeserve.co.uk> <9j2dnn$ndm$0@216.39.144.220> <slrn9lavp6.v3.philh@comuno.freeserve.co.uk> Message-ID: <3B5620EF.95205289@alcyone.com> phil hunt wrote: > Python would still be deterministic if: > > (a,b,c,d) = (1,2,3) > > resulted in d being None Raising an exception is just as "deterministic." -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Substance is one of the greatest of our illusions. \__/ Sir Arthur Eddington Computer science / http://www.alcyone.com/max/reference/compsci/ A computer science reference. From Peter.Mayne at au1.ibm.com Tue Jul 24 05:16:36 2001 From: Peter.Mayne at au1.ibm.com (Peter Mayne) Date: Tue, 24 Jul 2001 19:16:36 +1000 Subject: PEP0238 lament References: <mailman.995940101.6560.python-list@python.org> Message-ID: <9jkrne$j2i$1@news.btv.ibm.com> "Tim Peters" <tim.one at home.com> wrote in message news:mailman.995940101.6560.python-list at python.org... > > > If you had as many cases of "?"+str(Amount/100)+"."+str(amount%100) > > and similar in your code as I do - most of which I don't even know who > > has it or who might have tweaked versions (and I know as an absolute > > fact those warnings will either not be seen at all or will be ignored) > > you'd be just as pissed of as I am. > > Pissed off at what? Nothing has changed. It's possible nothing will. It's > certain nothing will for half a year at earliest. It's being discussed -- > or at least *was*, for a little while. Assume that there's a problem with the operation currently represented by the token "/". An undetermined (by me, certainly) fraction of the Python-using population think that there isn't, but just for sake of discussion here, assume there is. The proposed solution (stop me if I'm wrong) involves modifying the behaviour of "/". There is obviously an installed base of code that relies on the current behaviour of "/", such as the code above. As someone who has had occasion in the past to fix and/or upgrade customer code that has been working for years, until one day it didn't, can you please discuss why it is seen as acceptable to break existing code like this, rather than (for instance) simply introducing a new token (such as "//") to do the "right" thing? Note that in at least one instance that I can think of, I had to learn the language on the spot (COBOL, if you're interested) to get things going. In three years' time, if I had to learn Python on the spot under similar circumstances, and I read the up-to-date documentation explaining the (unbeknownst to me) "new" behaviour of "/", I could see myself in deep water. Obviously the person who wrote the code knew what they were doing when they used "/" at the time, and I would be *very* wary of the quick fix of changing it to "//" because it seemed to work. I am utterly mystified that such a thing should even be considered. Clear discussion welcome. PJDM -- Peter Mayne IBM GSA (but the opinions are mine) Canberra, ACT, Australia This post is covered by Sturgeon's Law. From donn at u.washington.edu Thu Jul 19 13:05:30 2001 From: donn at u.washington.edu (Donn Cave) Date: 19 Jul 2001 17:05:30 GMT Subject: python newbie question References: <mailman.995523452.14905.python-list@python.org> Message-ID: <9j740q$6q6$1@nntp6.u.washington.edu> Quoth donmalla at yahoo.co.in: ... | However when I try to manipulate the list , using for loop like this : | | [3*x for x in vec] | | I get a syntax error "invalid syntax" | | Please help me. I am using Python 1.5 on Windows 2000. If you need this to work, you will have to upgrade to a more current version of Python. In 1.5 there are no list incomprehensions, so it's either a = [] for x in vec: a.append(3 * x) or a = map(lambda x: 3 * x, vec) ("lambda x: 3 * x" is an anonymous function, not otherwise very useful in Python; map is generally map(fn, seq[, ...]) where fn accepts 1 parameter per seq, and it's usually easier and more readable to define an ordinary function. Hope "lambda" is the only thing Greek about this.) Donn Cave, donn at u.washington.edu From tjreedy at home.com Sun Jul 1 12:49:23 2001 From: tjreedy at home.com (Terry Reedy) Date: Sun, 01 Jul 2001 16:49:23 GMT Subject: Assignment vs. Naming/Binding (was Re: Augmented Assignement ) References: <mailman.993843884.4929.python-list@python.org> <ubsn7hte7.fsf@ctwd0143.fitlinxx.com> <AzH%6.4039$Z6.1921496@news1.rdc2.pa.home.com> Message-ID: <nwI%6.4066$Z6.1976456@news1.rdc2.pa.home.com> I wrote > Yes. Understanding the difference is one of the major keys to ... This is incomplete due to power outage .. not sure how got sent, was trying to save to disk before battery backup expired .. will finish later .. please ignore for now. From max at alcyone.com Wed Jul 18 14:34:33 2001 From: max at alcyone.com (Erik Max Francis) Date: Wed, 18 Jul 2001 11:34:33 -0700 Subject: Language change and code breaks References: <mailman.995378792.16515.python-list@python.org> <cpvgkq1f2b.fsf@cj20424-a.reston1.va.home.com> <_bh57.32695$d4.1090608@e420r-atl1.usenetserver.com> <9j4a6e0cpu@enews4.newsguy.com> Message-ID: <3B55D6B9.3E2B933E@alcyone.com> Alex Martelli wrote: > I consider myself a member of the literate minority (well > within the upper centile on all relevant demographics), and > having a recently-invented typographic prettiness, such as > letter-cd tcase, affect meaning, has always struck me as a deeply > flawed idea. I hated it when I first met it in C and Unix, > and a quarter of a century hasn't reconciled me to it. Makes perfect sense to me. What's the point of having differing capitalization if it isn't meaningful? Otherwise every programmer can use their own capitalization for each identifier, which is just confusing. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ When the solution is simple, God is answering. \__/ Albert Einstein Computer science / http://www.alcyone.com/max/reference/compsci/ A computer science reference. From steve at lurking.demon.co.uk Mon Jul 23 16:47:46 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Mon, 23 Jul 2001 21:47:46 +0100 Subject: PEP0238 lament References: <3B5B639C.FF5961E7@Lugoj.Com> <mailman.995848837.9325.python-list@python.org> <k61olt001jfs878bo50snpb9f2uu80utee@4ax.com> <ogmolt014ukb5h52hgrq1klu64buvhrrod@4ax.com> Message-ID: <fh0pltsme5g5ldq6f0825tn6r89jckqj29@4ax.com> On Mon, 23 Jul 2001 17:11:10 GMT, Ben Wolfson <rumjuggler at cryptarchy.org> wrote: >On Mon, 23 Jul 2001 12:21:58 +0100, Steve Horne <sh at ttsoftware.co.uk> >wrote: > >>Integers are much more used in scripting code than floats - subscripts >>and loop indices being the main culprits. Integer division happens >>quite a bit. All that code is just going to suddenly stop working. How >>nice. > >If integer division is more common than float division, why not let '/' >retain its current meaning and use '//' for "yes, I want a float result"? >int / int -> int >float / int, int / float, float / float -> whatever these currently mean >with "//" in Guido's patch >int // int -> float, rational, or whatever Suggested many times by many people - but no real answer yet. The only counter with any noticable backing was that the language should be dumbed down to the point where newbies and students never actually learn anything - not quite worded like that, of course ;-) The only application where a genuine need for some kind of change has been shown is in numerics - the fear of dramatically wrong results through the accidental use of integers. In that case the programmers should be quite used to looking for potential accuracy and precision problems since apparent identities don't hold exactly with float approximations, and a small error in an intermediate result can cause huge errors in final results whether division is used or not. They should therefore be *expected* to have some knowledge and understanding - that is their job - and they should be quite capable of dealing with an alternate operator or some mechanism to explicitly request coercion or whatever. From paulsid at home.com Fri Jul 20 15:31:07 2001 From: paulsid at home.com (Paul Sidorsky) Date: Fri, 20 Jul 2001 13:31:07 -0600 Subject: Case insensitivity References: <mailman.995506711.21636.python-list@python.org> <cpvgkofyru.fsf@cj20424-a.reston1.va.home.com> <20010720100145.B27699@tux.distro.conectiva> Message-ID: <3B5886FB.AB1E6DDF@home.com> Gustavo Niemeyer wrote: > Indeed, I don't think case-sensitiveness is something that will help > non-programmers to get used to the language. You have so many factors > to learn when you're starting, case sensitiveness will be just one more > behavior of the language (not a wart at all). And I think if it is an issue, it's an extremely minor one at most. When I try to convey computer commands, URLs, etc. to those who don't have much experience using computers, I often hear "all caps?", "all lower case?", "capital P in print?", etc. Even after saying "it doesn't matter", people will often continue to type things in the way they've seen them or the way they "think" they should be. To me this suggests that case-sensitivity is inherently present in most people, or at least that people naturally associate computers and case-sensitivity anyhow. > On the other hand, I > think that, if you create a case-insensitive tool or command line option > and let users get used to it, it'll take forever to learn how to program > in sensitive mode. Well, having come from BASIC (where such editors abound) to C I can say that for myself at least there was no trouble. Actually it was a relief not to have the editor constantly fixing up my typing. But of course that doesn't prove anything... However, one difference was that in the BASICs I grew up with their editors were used by all but a tiny minority of the people programming in them. In Python people use all kinds of different editors, across different platforms even. IMO what will inevitably happen is that people will be taught Python using a "helpful" editor and then sooner or later have to start coping with more conventional editors that don't bail them out. I think it's a small deal to be taught to work around a minor wart (if case-sensitivity can indeed be called such a thing) from the beginning but it's much more shocking to be "coddled" by an editor and then be forced to adjust long after the fact. -- ====================================================================== Paul Sidorsky Calgary, Canada paulsid at home.com http://members.home.net/paulsid/ From vj$ri^gg#guess#l55e at mt$*guess#&cn1e#t.! Mon Jul 23 11:47:26 2001 From: vj$ri^gg#guess#l55e at mt$*guess#&cn1e#t.! (Kevin Riggle) Date: Mon, 23 Jul 2001 10:47:26 -0500 Subject: Opening a file with Python References: <3b5be641_3@news.newsgroups.com> Message-ID: <9jhgm4$2mo$1@mtc1.mtcnet.net> You have to associate the file-type with the program. Open up My Computer, click View...Folder Options, select the File Types tab, and click on New Type. Fill in the description and extension you want to use, then click on the New button beneath the Actions: list box. Fill in the Action Name (probably Open), and set 'Application used to perform action:' to "c:\Program Files\MyPyProg\mypyprog.exe %1" if using py2exe, or "c:\Program Files\WinPy\winpy.exe c:\Program Files\MyPyProg\mypyprog.py %1", in both examples *including* the double-quotes. (I haven't actually used Python on Windows, so if the WinPy path is a little off please forgive me.) Hope this helps... Kevin "Janos Blazi" <jblazi at hotmail.com> wrote in message news:3b5be641_3 at news.newsgroups.com... > I'd like to write a Python program that starts when the user double clicks > on a file name (in Win2K). I should be able to read the name of the file. > What have I to do? > This question has probably been asked many times, sorry. > > Janos Blazi > > > > > -----= 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 jonas.b at home.se Fri Jul 13 13:53:17 2001 From: jonas.b at home.se (Jonas Bengtsson) Date: 13 Jul 2001 10:53:17 -0700 Subject: Problems getting mod_python up n' running References: <4e2ddb70.0107121317.4c883f6c@posting.google.com> Message-ID: <4e2ddb70.0107130953.b2e7e4d@posting.google.com> I still get the same error. Can anyone helt me? Is there any other way to get python working under Apache under Windows 2000? Thanks in advance! /Jonas B jonas.b at home.se (Jonas Bengtsson) wrote in message news:<4e2ddb70.0107121317.4c883f6c at posting.google.com>... > Hi, > I can't get mod_python to work. I get this error message when I'm restarting > Apache: > make_obcallback(): could not import mod_python.apache. > make_obcallback(): could not call init. > And when I try to look at a .py page I get following error: > [Thu Jul 12 03:33:12 2001] [error] [client 127.0.0.1] python_handler: > make_obcallback returned no obCallBack! > > What is wrong? > I've got: Apache/1.3.19 (Win32) mod_python/2.7.4 Python/2.1 > Running under Windows 2000 > > I have put mod_python.dll.in E:\program\apache\modules and following rows to > httpd.conf: > #DSO section > LoadModule python_module e:/program/apache/modules/mod_python.dll > #under my main directory > AddHandler python-program .py > PythonHandler mptest > PythonDebug on > > Furthermore I have put following files under > e:\program\python21\libs\mod_python: > __init__.py > apache.py > cgihandler.py > httpdapi.py > publisher.py > util.py > zhandler.py > > And my environment path contains: > E:\Program\Python21;e:\Program\Python21\libs > > > What can be the problem? > > TIA > Jonas Bengtsson From robin at jessikat.fsnet.co.uk Sun Jul 29 06:08:26 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sun, 29 Jul 2001 11:08:26 +0100 Subject: Try floating the Back Orifice's dumb PGP and Willy will recycle you! References: <FDC34627.2CE8C0C7@edefod.net> Message-ID: <aqTHtgAaC+Y7Ew1s@jessikat.fsnet.co.uk> In article <FDC34627.2CE8C0C7 at edefod.net>, Timothy Gibson <barewy at edefod.net> writes >If you'll recycle Gilbert's printer with keypads, it'll biweekly >interface the thought. Sometimes Alexandra will get the robot, and if >Samantha wistfully meets it too, the programmer will collaborate >outside the fast cybercafe. My extreme PERL won't disconnect before I >push it. He will engulf halfheartedly if William's plotter isn't >bizarre. Go cry a protocol! When will you save the chaotic >retarded zipdisks before Pilar does? Jeff wants to know seemingly, unless >Chester infects machines within Evan's administrator. Until >Jeff defiles the RAMs stupidly, Ann won't moan any solid cafes. >Where Frederick's discarded LAN outwits, Robette facilitates >in back of loud, plastic CIAs. Otherwise the terminal in Jonnie's >librarian might prepare. Try typeing the Back Orifice's dry >admin and Sherry will close you! Who shoots undoubtably, when >Martin dreams the disgusting firewall in the mail server? Don't try to >exclude the stacks wanly, eliminate them deeply. As badly as >Robette reloads, you can negotiate the operator much more strongly. reads like somebody's been at the generative grammar engines again. -- Robin Becker From steve at lurking.demon.co.uk Mon Jul 23 16:47:44 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Mon, 23 Jul 2001 21:47:44 +0100 Subject: PEP0238 lament References: <mailman.995814276.15005.python-list@python.org> <slrn9lm3u8.as.sill@sill.silmarill.org> <5sdnlt072hm6hp17nluu6f0fqq4bvr6mj8@4ax.com> <%TW67.22987$B7.3756018@ruti.visi.com> Message-ID: <i3voltca29ai6vjoh93keh40js9hgjh80l@4ax.com> On Mon, 23 Jul 2001 14:53:47 GMT, grante at visi.com (Grant Edwards) wrote: >Right. If you want redesign the language to prevent programmers >from creating bugs due to using the wrong numeric data types, >then you're only hope is to eliminate all but one of the >numeric types, and that numeric data type better do what >everybody expects all the time. > >Can't be done. But Perl had a good try... I'm told "1" / 3 gives 0.333333333333333333 <giggles> From peter at engcorp.com Wed Jul 11 18:16:27 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 11 Jul 2001 18:16:27 -0400 Subject: Language change and code breaks References: <wuN27.13377$Y6.4240331@news1.rdc2.pa.home.com> <cplmlvh6dx.fsf@cj20424-a.reston1.va.home.com> <vn_27.42062$F%5.2541404@e420r-atl2.usenetserver.com> Message-ID: <3B4CD03B.1D5A30AE@engcorp.com> Steve Holden wrote re BDFL and int/int: > That fact that *I* was unable to convince you leaves me feeling somewhat > chastened about the qualities of my own criticism, however :-) Take heart: I suspect it was more than the one posting which had this effect! Perhaps one could say Terry's posting represented a crystallization of a number of concerns various people have had. It worked for me too, and Guido's comments had previously already convinced me of the value of the change, in spite of my own concern of what it would mean in my area. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From spam at melkor.dnp.fmph.uniba.sk Wed Jul 18 03:48:16 2001 From: spam at melkor.dnp.fmph.uniba.sk (Radovan Garabik) Date: Wed, 18 Jul 2001 09:48:16 +0200 Subject: Python 2 times slower than Perl References: <8f41cfd.0107171238.6ff33b9b@posting.google.com> Message-ID: <00f3j9.hfp.ln@127.0.0.1> Xu, C.S. <xucs007 at yahoo.com> wrote: ... : #!/usr/bin/env python : i = 2.5; : while i < 1e7: : j = 2.5 * 2.5 : i += 1 : print i, j : The `time` results on my PII 450M is: : python script: 37.93u 0.03s 0:38.03 99.8% : perl script: 15.36u 0.03s 0:15.42 99.8% : java compiled: 1.07u 0.10s 0:01.20 97.5% : C compiled: 0.24u 0.01s 0:00.25 100.0% time on my PIII 600: 34.32s user 0.17s system 97% cpu 35.259 total I am surprised the difference is not bigger, I thought I have much better processor :-) (maybe it does not fit into cache? I have 256KB CPU chache, python surely does not fit there, and if it ends up flushing the cache all the time, it can explain the lack of improvement) Could you post your perl script, so that I can make a comparision? Modified script: i = 2.5; while i < 1e7: j = 6.25 i += 1 print i, j 29.20s user 0.08s system 99% cpu 29.490 total now, i += 1 must coerce 1 to real number. So I modified it like this: i = 2.5; while i < 1e7: j = 6.25 i += 1. print i, j 28.78s user 0.12s system 99% cpu 28.947 total only a slight improvement using a function: def f(): i = 2.5; while i < 1e7: j = 6.25 i += 1. print i, j f() 18.53s user 0.02s system 98% cpu 18.872 total normalized to your timing, this would give 20.5 s for your computer. This is probably more fair comparision to perl. -- ----------------------------------------------------------- | 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 Sibylle.Koczian at Bibliothek.Uni-Augsburg.de Tue Jul 24 10:51:45 2001 From: Sibylle.Koczian at Bibliothek.Uni-Augsburg.de (Sibylle Koczian) Date: Tue, 24 Jul 2001 16:51:45 +0200 Subject: Language change and code breaks References: <mailman.995868520.32094.python-list@python.org> Message-ID: <3B5D8B81.FFFA51B8@Bibliothek.Uni-Augsburg.de> Christian Tanzer wrote: > > What's missing IMHO in this whole discussion is the question of costs > and benefits. In all written languages, there are costs for the reader > and a different set of costs for the writer. Normally, there is one > writer for many readers -- therefore one should try to reduce the > reader's costs. Unfortunately, many people completly disregard the > reader and campaign for reducing the costs of the writer (the hotly > contested reform of german writing rules is a prime example). For me, > the goal of making Python case-insensitive is also too preoccupied with > the writer's side of the game. > Quite right. The campaign for abolishing most capitalization ("gemaessigte Kleinschreibung") in German is an even better example for this. There's something else missing: most of us, and especially occasional programmers, write much more normal text than code - and all normal writing _is_ case sensitive. Even if the meaning doesn't change, practically everywhere one is right, the other wrong. So I don't really think case sensitivity could be a stumbling block for a real newbie - it may be a very small stumbling block for Algol60 / Pascal programmers like me. But as long as I don't get hit by silent assumptions about the value of my mis-spelled variable, it's not that hard. -- ---- 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 tim.one at home.com Sat Jul 7 18:13:33 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 7 Jul 2001 18:13:33 -0400 Subject: Comment on PEP-0238 In-Reply-To: <9i7u7601c4p@enews3.newsguy.com> Message-ID: <LNBBLJKPBEHFEDALKOLCAEPLKMAA.tim.one@home.com> [Marcin 'Qrczak' Kowalczyk] > Don't you want to borrow Haskell's turning of an arbitrary binary > function into an operator thus: x `div` y? :-) OCaml recently did. [Alex Martelli] > One side advantage of adopting that in Python would be to > remove the ugly equivalent `x` to repr(x)...:-) <ducks/> I'm sorry, Alex, but `` is here to stay. Guido is insanely fond of it! Meaning no more than that he doesn't hate it <0.9 wink>. I see something like print ``1`+`2`` and to this day I still have no idea how Python manages to parse it correctly. Ah, and it took some doing *just* to see it: in Courier New (my usual code-reading font), the backtick is so insubstantial that I fiddled my editor to scale it up by 150% and display it in bold. Ugly as sin, but then that the righteous can't overlook sin was the point <wink>. From tjreedy at home.com Sun Jul 29 19:45:37 2001 From: tjreedy at home.com (Terry Reedy) Date: Sun, 29 Jul 2001 23:45:37 GMT Subject: FEEDBACK WANTED: Type/class unification References: <cp66cd12yp.fsf@cj20424-a.reston1.va.home.com> <mailman.996351001.12473.python-list@python.org> <cpwv4syrzd.fsf@cj20424-a.reston1.va.home.com> <3B643C58.1C6C94F9@ActiveState.com> <200107291708.NAA07525@cj20424-a.reston1.va.home.com> <3B6465E0.368A104@ActiveState.com> <mailman.996447295.25645.python-list@python.org> Message-ID: <Be197.50329$EP6.11090353@news1.rdc2.pa.home.com> I've been looking for a word for the unified Class-And-Type CATegory and finally the answer leap out at me: the animal that always lands on its feet, as I believe Python will. (Think of it as ClAssyType if you prefer.) So how does 'Python: the CAT Language' grab people? Humor aside: if not already taken, cats might make a better cover mascot for our O'Reilly books than snakes, rats, or whatever. Terry J. Reedy From neila at nospam.moc Tue Jul 3 20:36:53 2001 From: neila at nospam.moc (MegaHurts) Date: Tue, 3 Jul 2001 17:36:53 -0700 Subject: Language Shootout References: <ldi4ktoc90c8kbeqq7epkq2dskp99etc3i@4ax.com> Message-ID: <3b426291$1_1@corp-news.newsgroups.com> This strikes me as a thoughtfully done set of benchmarks. Now, if the rest of us can be thoughtful as well in our USE of this information... e.g., understanding: that "fast enough" is enough; that speed and flexibility of development is often more important than whether a language has raw speed; that read- ability and maintainability is often an im- portant consideration; that the existance of rich libraries and third-party functional modules can be vastly more important than running the Sieve of Eratosthenes 100 times faster. Finding a way, however subjective, to rate THESE considerations would be an important addition to any "language shootout," so important as to be a necessity, I believe. That said, I still enjoy reading benchmarks! ----- Original Message ----- From: Ben <b.e.n. at .r.e.h.a.m.e...c.o.m> Newsgroups: comp.lang.python Sent: Tuesday, July 03, 2001 3:42 PM Subject: Language Shootout | | http://www.bagley.org/~doug/shootout/ Ben <b.e.n. at .r.e.h.a.m.e...c.o.m> wrote in message news:ldi4ktoc90c8kbeqq7epkq2dskp99etc3i at 4ax.com... | | http://www.bagley.org/~doug/shootout/ From bokr at accessone.com Thu Jul 26 14:55:34 2001 From: bokr at accessone.com (Bengt Richter) Date: Thu, 26 Jul 2001 18:55:34 GMT Subject: Opcode compatible division References: <mailman.996084400.32614.python-list@python.org> <cpae1s935l.fsf@cj20424-a.reston1.va.home.com> Message-ID: <3b603e72.476839078@wa.news.verio.net> On Wed, 25 Jul 2001 20:15:10 GMT, Guido van Rossum <guido at python.org> wrote: >com-nospam at ccraig.org (Christopher A. Craig) writes: > >> I was wondering if it would be possible to add two new opcodes to the >> VM language which I will refer to as ExactDivide and IntegerDivide and >> keep the current opcode with its current behavior? >> >> Even if there was no way in the actual language to generate the >> CurrentDivide opcode, its existance would allow modules compiled and >> distributed under the current system to continue to work with future >> revisions. >> >> I haven't thought this through that much, so it may be a totally >> stupid idea, but I thought it might fix some of the issues with >> backwards compatibility. > >Check out my patch on SourceForge: it does exactly that. > >http://sourceforge.net/tracker/index.php?func=detail&aid=443474&group_id=5470&atid=305470 > Is from future a one-way effect for the rest of the interpreter's execution? I.e., one could conceive of pushing a fresh default state on a special (thread-owned?) stack every time one opened a file for interpretation, and if the file contained a from-future mod, just modifying the state topmost on the stack, and popping it when done with the file. The effect of alternate interpretation would persist in the compiled bytecode, as made possible by new byte codes a la your patch. Compiling a string would be governed by the current top of stack state, I would guess. If pushing and popping this kind of state also became VM byte codes, byte code containing an exec string could be properly affected. One could imagine a version requirement operating on the topmost stack state similarly, to implement per-file version compatibility mods, so long as the latest VM bytecodes were a superset of older versions. If from-future dynamically modifies the run-time to alter the meaning of byte codes, rather than influencing the compilation to generate different byte codes for different meanings, that would be different can of worms, I would imagine. BTW, even though the version/compatibility issue is still steeped in the emotion of the '/' discussion, I hope it can later be revisited as an important issue in itself, whatever the anti-merits of using it as a '/' wart presever. BTW2, I think Christopher's post is an interesting reminder that there's a bottom-up as well as top-down aspect to all this. BTW3 I expect generation of graminit.c could be automated on windows by setting up custom build and dependency stuff in the relevant projects re the grammar files. I've done it for a similar situation with flex. I don't see why you couldn't run pgen in a similar way. Of course, pgen has to be built first. From arildh at stud.cs.uit.no Tue Jul 3 09:56:38 2001 From: arildh at stud.cs.uit.no (Arild Hansen) Date: Tue, 3 Jul 2001 15:56:38 +0200 Subject: Python for wav file control? Message-ID: <Pine.LNX.4.33.0107031554260.21451-100000@arildh.pasta.cs.uit.no> Hello, As this seems to be one of the more successfull header layouts for the moment, I'll try it too. I still have problems recording wav files in python using the pyEsd module and built in wave module. I do not want to use third-party applications or snack. If anyone has a good example, I'll appreciate it a lot. I use python 2.0 under Linux. AH From robin at jessikat.fsnet.co.uk Sun Jul 22 05:06:17 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sun, 22 Jul 2001 10:06:17 +0100 Subject: Future division patch available (PEP 238) References: <mailman.995776716.24336.python-list@python.org> Message-ID: <GNZwEiAJepW7Ew0F@jessikat.fsnet.co.uk> In article <mailman.995776716.24336.python-list at python.org>, Guido van Rossum <guido at digicool.com> writes ... > >I thought again about the merits of the '//' operator vs. 'div' >(either as a function or as a keyword binary operator), and figured >that '//' is the best choice: it doesn't introduce a new keyword >(which would cause more pain), and it works as an augmented assignment >(//=) as well. ... it just looks awful as well as annoying those who don't want this change. -- Robin Becker From tjreedy at home.com Sun Jul 22 20:55:58 2001 From: tjreedy at home.com (Terry Reedy) Date: Mon, 23 Jul 2001 00:55:58 GMT Subject: A use for integer quotients Message-ID: <yCK67.17615$EP6.4467503@news1.rdc2.pa.home.com> During the debate on changing int/int to give a float result, some proponents appeared to question the usefulness of integer quotients. Opponents of the change gave calculation of array indexes, including graphics pixel coordinates, and 'combinatorics' as example uses. I here present an particular example of a combinatorial use extracted from the recent thread on partitions. Problem: what are the ways to distribute n items among k unlabelled bins, with each bin getting at least 1 item. Extreme uneven answer: put n-(k-1) items in 1 bin and 1 item in each of the other k-1 bins. The largest bin in a partition has at most n-k+1 items. Extreme even answer: put n/k items in each bin and 1 more in each of n%k bins. The largest bin in a partition has at least (n/k + (n%k >=1)) items, which is more efficiently calculated as (n+(k-1))/k. If we use a descending range, then we subtract 1 to get (n-1)/k for use in range((n-k+1), (n-1)/k, -1). With these limits on the largest bin and the additional constraint that bins be filled in monotonically decreasing size order, there is a straightforward recursive algorithm, which I posted in the partition thread. While there are other algorithms (some posted), this one, at least, which is pretty easy to understand, depends on quotient-remainder thinking to get the proper lower limit. -------------------- What does this have to do with PEP238 and the proposed change? When I thought some people were arguing simply to change int/int to give a float (with no new alternative for an int result), I was adamantly opposed. I really want Python to remain 'executable pseudocode' so I and others can write and publish such algorithms in Python with concise standard or near-standard syntax, without resort to a non-standard circumlocution like divmod((n+(k-1)), k)[0] or a distracting and inefficient roundtrip to float and back. When Guido said he really wanted to make a change *and* that he would look favorably on an infix substitute, I muted my opposition and wrote 'Language Change and Code Breaks' to clarify what was needed to make such a syntax replacement successful. I will not mind too much writing (n+(k-1))//k, which is my preferred alternative. It should not be too hard to explain to a non-Python audience that '/' is calculator decimal-result division while '//' is truncating whole-number-quotient division. Terry J. Reedy From slinkp23 at yahoo.com Mon Jul 9 17:04:28 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Mon, 09 Jul 2001 21:04:28 GMT Subject: PEP: Procedure for Adding New Modules (please comment) References: <9hvqhr$gj2$1@newshost.accu.uu.nl> <3B49F9EC.CA10886A@yahoo.com> <kPn27.2200$z21.433251@newsc.telia.net> Message-ID: <3B4A1AE3.BB23C0E1@yahoo.com> Fredrik Lundh wrote: > > Paul Winkler wrote: > > I think test suites would be a very, very good idea. At a minimum, some doctest > > examples. Even better would be a well-defined suite of unit tests using the > > unittest module. > > if you think tests using one support module is automatically better > than tests using another support module, you have a lot to learn > about testing... > > </F> Sorry, I didn't say what I meant. I don't really care _how_ testing is done. I also should not have implied that the existing library is not adequately tested; I have no basis for thinking that. I based my suggestion (doctest at minimum, preferably unittest) on the note at the end of the documentation for doctest: """ The first word in doctest is "doc", and that's why the author wrote doctest: to keep documentation up to date. It so happens that doctest makes a pleasant unit testing environment, but that's not its primary purpose. Choose docstring examples with care. There's an art to this that needs to be learned -- it may not be natural at first. Examples should add genuine value to the documentation. ... """ So for more thorough testing of things that don't belong in the documentation, I thought unittest.py might be a worthy candidate. After all, that's what it's designed for, and it's already in the standard library. I should have said "Yes, testing is a good idea, let's have some standards for that", and then I should have shut my mouth. -- ................... paul winkler .................... custom calendars & printing: http://www.calendargalaxy.com A member of ARMS: http://www.reacharms.com home page: http://www.slinkp.com From sholden at holdenweb.com Thu Jul 19 13:51:20 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 19 Jul 2001 13:51:20 -0400 Subject: float to str help References: <9j6tva$9mb@dispatch.concentric.net> Message-ID: <z4F57.28268$sx2.1598103@e420r-atl3.usenetserver.com> "Bryan Webb" <bww00 at amdahl.com> wrote in message news:9j6tva$9mb at dispatch.concentric.net... > Hi, > In converting a float (5.661706091586558e+240) to a string using str() I > come up with 5.6617060916+240 . I checked the string variable in the > debugger. I need the full precicsion. I know its probably simple but this > red hair is causing me problems. > Using string formatting will give you as much precision as is available. Of course there is no guarantee that the interpreter will have been able to represent your literal exactly as a floating point number, though it will get pretty close: >>> x = 5.661706091586558e+240 >>> print "%.25e" % x 5.6617060915865581000000000e+240 >>> This isn't just because of the number of digits in your literal. The same is true of many "apparently simple" numbers: >>> y = 0.1 >>> print "%.25e" % y 1.0000000000000001000000000e-001 >>> Conversion of decimal constants to binary floating-point is by its nature often bound to be inexact, as these two examples show. Hope this helps. regards Steve -- http://www.holdenweb.com/ From jkraska1 at san.rr.com Sun Jul 1 18:40:12 2001 From: jkraska1 at san.rr.com (Courageous) Date: Sun, 01 Jul 2001 22:40:12 GMT Subject: Augmented Assignement (was: Re: PEP scepticism) References: <mailman.993952381.32699.python-list@python.org> <zbN%6.415855$oc7.58414702@news2.rdc2.tx.home.com> Message-ID: <q0avjto87p59hn7gv28r5cf1c84j2fb8c7@4ax.com> >Correctness: Consider the following function: > >def f(x): > x += (1, 2, 3) > print x What do you think of: def f(x): x = x + (1,2,3) print x ? C// From aleaxit at yahoo.com Sun Jul 1 03:51:10 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 1 Jul 2001 09:51:10 +0200 Subject: Augmented Assignement (was: Re: PEP scepticism) References: <mailman.993832966.21120.python-list@python.org> <mailman.993927046.4577.python-list@python.org> <4Dp%6.408588$oc7.55997471@news2.rdc2.tx.home.com> <mailman.993961921.6174.python-list@python.org> Message-ID: <9hmktf0jtm@enews1.newsguy.com> "Paul Prescod" <paulp at ActiveState.com> wrote in message news:mailman.993961921.6174.python-list at python.org... ... > > Bad idea. If anything, I would go the other direction and make it illegal > > for mutable types. ... > > This is the argument that froze augmented assignments in their tracks > for years. I was somewhat surprised when they finally made it in because > it was always clear in the discussions that any behaviour would confuse > about half of the population. That's usually where Python Refuses To > Choose. Usually but not always, or we'd lack any way to divide integers, we'd be neither case-sensitive nor insensitive, &c:-) Alex From phd at phd.fep.ru Wed Jul 11 09:30:36 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Wed, 11 Jul 2001 17:30:36 +0400 (MSD) Subject: Long Live Python! In-Reply-To: <E566B020833BD311B6610008C791A39705CA5231@il93exm04.css.mot.com> Message-ID: <Pine.LNX.4.33.0107111726250.17694-100000@phd.fep.ru> On Wed, 11 Jul 2001, Kemp Randy-W18971 wrote: > That is a good point. Why are some open source and free efforts popular and > others not? Apache is popular because it was the only thing going at the > time, and now it runs 60 per cent of the world's servers. Linux started out > as a one man show, and became popular because it's a free Unix system, and > Unix is much better then Win doze. And Perl came bundled with Unix, so when > CGI first came around, Unix Administrators were called upon to write CGI > modules. And yes -- Java is the precious child of Sun -- and Sun has gotten > other major players, such as IBM and Oracle, to support the J2EE > infrastructure. Now if only Python can have a lucky break. By some strange magic industry and/or society always choose a worst available solution. Consider x86 architecture, Windoze, Perl, Java, GNOME and KDE. Python is just too good to win. Long live Python! Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From steve at lurking.demon.co.uk Sun Jul 22 04:35:26 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Sun, 22 Jul 2001 09:35:26 +0100 Subject: Here's a puzzle... References: <20010721195640.15632.00000532@ng-mh1.aol.com> Message-ID: <qdtkltkq0laslmur3dmdrot05dd0bmi3ev@4ax.com> On 21 Jul 2001 23:56:40 GMT, thedustbustr at aol.com (TheDustbustr) wrote: >I'm trying to split the following string called data into four variables: > >:Angel PRIVMSG Wiz :here is my message! > >(so data=':Angel PRIVMSG Wiz :here is my message!') with an outcome of: > >sender='Angel' >command='PRIVMSG' >rcpt=Wiz' >message='here is my message!' > >Unless my logic is flawed, this should return 'PRIVMSG': > >sender='Angel' >print data[len(sender)+2:string.find(data[len(sender)+2:],' ')] > >It prints '' (an empty string). Is my logic flawed, or does Python dislike a >string splice determined by a function? A string slice takes start and end positions - not start and end. The positions are *between* character positions - or you could see the range as including the start character but excluding the end character. For example... >>> x="abcde" >>> x[1:4] 'bcd' Where the character positions are... a b c d e ^ ^ ^ ^ ^ ^ | | | | | | 0 1 2 3 4 5 Taking that into account, your find function should search the whole of data - not the slice of data that it is searching at present. >And if you are up to it, feel free to help me splice (correct terminology, >parse?) for variables rcpt and message ;) Closer to lexical analysis (scanning - identifying keywords, numbers, symbols etc) than parsing, though in context 'parsing' is a reasonable word. Splice means gluing the bits back together again. Anyway, try the following... ################# import string data=":Angel PRIVMSG Wiz :here is my message!" # Separate header and body using split, discarding unwanted initial # string of characters prior to first colon (header,body) = string.split (data, ":") [1:] # Or alternately, remove the initial colon before the split like # this... # # (header,body) = string.split (data [1:], ":") # Now separate the header fields - any whitespace is the default split # seperator (even multiple spaces in a row count as a single # separator) (sender,command,rcpt) = string.split (header) print "header : ", header print "body : ", body print print "sender : ", sender print "command : ", command print "rcpt : ", rcpt ################# The result I get is... header : Angel PRIVMSG Wiz body : here is my message! sender : Angel command : PRIVMSG rcpt : Wiz Hope that helps. From jkraska1 at san.rr.com Thu Jul 26 23:44:27 2001 From: jkraska1 at san.rr.com (Courageous) Date: Fri, 27 Jul 2001 03:44:27 GMT Subject: Language change and code breaks References: <mailman.996120946.2459.python-list@python.org> Message-ID: <spo1mtsajq7lfk1j1srrbsplmu8oojo6gd@4ax.com> On Thu, 26 Jul 2001 00:14:11 -0400, "Tim Peters" <tim.one at home.com> wrote: > >> I'm keeping a close eye one QKS at the moment for just that reason. > >If they're developing a faster version of Python, great. Or you mean you >want "a fast language" regardless of brand? Then I don't know why you're >waiting for QKS. It shouldn't really be a challenge to find a $300 >two-platform language that runs faster than Python <wink>. They've developed a general purpose Virtual Machine which happens to run Python quite a bit faster than Python's. C// From peter at engcorp.com Thu Jul 12 21:17:44 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 12 Jul 2001 21:17:44 -0400 Subject: Long Live Python! References: <E566B020833BD311B6610008C791A39705CA5230@il93exm04.css.mot.com> <mailman.994804336.23495.python-list@python.org> <slrn9kokj6.mjk.philh@comuno.freeserve.co.uk> <3B4CC986.A5C8E605@engcorp.com> <270c68fe.0107121546.249b9efa@posting.google.com> Message-ID: <3B4E4C38.48EC8DCB@engcorp.com> Alan Green wrote: > Until it reaches the mythical "mindshare critical mass", Python is > going to have to take over the world just one project at a time. For > those of us who want to work in Python in the typical IT shop, this > means doing some advocacy. > > To be an effective advocate of Python, you need to: > > a) deeply understand what the people you are advocating to understand, > b) have the respect of the people you are advocating to, and > c) deeply understand why Python is better at the kinds of problem > being solved, and be able to express it. > I plan for the process to take 12 months before expecting to see > significant results. And remember: it might not work, but then again, > there is no fun in a guarantee. Well said (and having done something like this I can tell you it is quite true). In my case, I had the great fortune to have a "perfect" pilot project, which would have taken significant time in another language but which in Python was completed inside of a month by a co-op student who had never heard of the language before. (One week to learn it well enough to start in earnest, one week to develop the requirements in enough detail to begin, one week to write the bulk of the code, one week to test and polish prior to the demonstration.) I strongly recommend picking an appropriate pilot project and using this to help with the three items above. Watch your audience closely during the demonstration (or whatever equivalent happens to be handy), carefully manage scope creep to prevent the pilot project from becoming an extended prototyping nightmare (thus ensuring completion on time and gaining the respect of your "advocatees"), and watch carefully to learn just where Python is extremely effective and where it is just better than average, and where it doesn't quite perform as well as some other option. Almost everything I know about Python in terms of its suitability for different tasks and its problem areas I learned during this short project (over a year ago). This is not a language which hides its inner nature from view. It helps to have management which is either so preoccupied with other problems or so forward-looking and courageous that they are willing not only to go ahead with the pilot project, but willing to accept the results and take a path away from the traditional approaches. (I have to admit I had more the former kind than the latter... :) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From rjh at 3-cities.com Tue Jul 3 10:57:27 2001 From: rjh at 3-cities.com (Robert J. Harrison) Date: 3 Jul 2001 07:57:27 -0700 Subject: Comment on PEP-0238 References: <3B3BE855.A6223E70@3-cities.com> <cp7kxvlake.fsf@cj20424-a.reston1.va.home.com> <Y4J%6.4084$Z6.2010194@news1.rdc2.pa.home.com> <mailman.994016102.30019.python-list@python.org> <7ef50c46.0107020554.31cc948b@posting.google.com> <mailman.994084684.19932.python-list@python.org> Message-ID: <7ef50c46.0107030657.2e0fc92b@posting.google.com> Paul Prescod <paulp at ActiveState.com> wrote in message news:<mailman.994084684.19932.python-list at python.org>... > ... Most people do not expect these four > expressions to yield different results: > > 1.0/3.0 > 1/3 > 1.0/3 > 1/3.0 I completely disagree, and as someone who has taught math, science and programming, it is quite clear to me that the distinction between integer and real arithmetic is an essential concept. > ... Why is automatic coercion *ever* necessary? Mixed type expressions are almost inevitable. It would take a much larger reworking of the Python numerical model than proposed by PEP-0238 to do away with that. The existence of the standard __coerce__ method illustrates the importance of such expressions. > > For instance, the new proposal sensibly does not suggest that lists > > should support real indices, > > That might well be an implication of PEP 228. I might accept an argument that says that anything that coerces (automatically!) to an integer with no loss of precision can be used to index a list. But how to distinguish between 1, 1+eps (eps=machine precision), and 1.1? How many elements are there between elements [1] and [2]? > > ... however simple expressions such > > as a[i/3] would have to be coded as a[int(i/3)] or a[i//3] > > in order to be sure to avoid a type error. > > You mean that you would have to say exactly what you mean according to > the new syntax. That's hardly a legitimate argument against the syntax. > "If you add a 'function' keyword, I would have to precede my function > calls with it." Well, yeah, that's the point of adding new syntax. My point was rather poorly made. The new proposal has simply moved the point at which people need to understand the distinction between real and integer arithmetic. Currently it must be understood when the operation is performed. In the new proposal it must be understood when the result of the operation is used. From krag_rao_pyt at rediffmail.com Wed Jul 25 01:31:45 2001 From: krag_rao_pyt at rediffmail.com (raghu k rao) Date: 25 Jul 2001 05:31:45 -0000 Subject: http Message-ID: <20010725053145.31033.qmail@mailFA9.rediffmail.com> hello i have written a code using httplib and urllib to get data -- home page and for posting request respectively from a server to login into my mailbox . while posting iam also sending some values like "input type hidden " . i do successfully get the home page of the server (yahoo) that i am sending my http 'GET' request but i get the following response We need to use "cookies" to identify u on our system..... ................. ......... how do i make modification in my program to ACCEPT COOKIES from a server and at which instance i shall do this either at the first 'GET' request when requesting for the home page of at the 'POST' request in my case urlopen or both the times kindly help regards raghavendra. _________________________________________________________ For Rs. 20,00,000 worth of Aptech scholarships click below http://events.rediff.com/aptechsch/scholarship.htm From eppstein at ics.uci.edu Fri Jul 27 16:14:26 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Fri, 27 Jul 2001 13:14:26 -0700 Subject: Changing the Division Operator -- PEP 238, rev 1.12 References: <mailman.996263475.24304.python-list@python.org> Message-ID: <eppstein-E4E4F9.13142627072001@news.service.uci.edu> In article <mailman.996263475.24304.python-list at python.org>, Guido van Rossum <guido at zope.com> wrote: > I prefer the > terminology to be slightly awkward if that avoids unambiguity. Yes, avoiding unambiguity is very important... -- 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 Thu Jul 12 09:40:17 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 12 Jul 2001 15:40:17 +0200 Subject: evalstr References: <mailman.994939340.22056.python-list@python.org> Message-ID: <9ik9c101mk@enews4.newsguy.com> "Michael Chermside" <mcherm at destiny.com> wrote in message news:mailman.994939340.22056.python-list at python.org... > >>> class Eval: > def __getitem__(self, key): > return eval(key) > > > >>> foo = 3.0 > >>> spam = 5.0 > >>> print "%(foo/spam)s" % Eval() > 0.6 > >>> print "%(foo/spam).55f" % Eval() > 0.5999999999999999800000000000000000000000000000000000000 > >>> > > Now THAT'S a wierd-but-cool hack! Very powerful and flexible, and > simple enough to use. It should definitely be added to the cookbook. > It does, unfortunately, have one significant limitation: the expression > cannot contain the character ")", which is one you'd like to use in > expressions. How so...? >>> class Eval: ... def __getitem__(self,key): return eval(key) ... >>> print "2+2 is %(2+2)s"%Eval() 2+2 is 4 >>> print "(2+2)*3 is %((2+2)*3)s"%Eval() (2+2)*3 is 12 >>> Alex From tjreedy at home.com Tue Jul 10 23:32:24 2001 From: tjreedy at home.com (Terry Reedy) Date: Wed, 11 Jul 2001 03:32:24 GMT Subject: 'Blade of Darkness' demo has open Python source Message-ID: <cNP27.13552$Y6.4409459@news1.rdc2.pa.home.com> In a recent thread on game programming in Python, someone mentioned that the commercial game Severance: Blade of Darkness is scripted in Python. I recently installed it off a demo CD. While I could not play too far due to having only half the required video memory, I was surprised and pleased to discover that it included open Python source: not frozen .exe, not compiled .pyc, but notepad-readable .py files. Besides the compiled .dll engines, there is a directory of animation scripts, a directory of utility files (such as a lever class in lever.py), a directory of actual game scripts, and some others. The code is not the most efficient possible, but clear enough. (A few files have Spanish names and comments, but most are straight English). An aspiring Python game programmer could probably learn a bit from purusing them more than I did. The 100 MB download is available from several sources reachable thru http://www.codemasters.com/severance/ . Terry J. Reedy From db3l at fitlinxx.com Tue Jul 3 18:35:32 2001 From: db3l at fitlinxx.com (David Bolen) Date: 03 Jul 2001 18:35:32 -0400 Subject: Python and DB support (was: Re: Is Python Dead?) References: <mailman.994135925.11224.python-list@python.org> Message-ID: <u3d8d1w0b.fsf@ctwd0143.fitlinxx.com> Roman Suzi <rnd at onego.ru> writes: > On 2 Jul 2001, David Bolen wrote: > > >Roman Suzi <rnd at onego.ru> writes: > > > >> However, my collegues were not satisfied with it. One somplain was that in > >> ASP/IIS it is "very easy" to receive a "recordset" from database and then > >> apply it in different situations in the ASP-page, because recordset is an > >> object and even subqueries could be made without quering DB again. > > > >Just curious, but did your colleagues try using Python's COM interface > >to ADO to retrieve an actual recordset object that they could > >manipulate the same in Python as in other ASP languages? > > Aha! Now I could understand what is the brake of Python library > development. Most of Python users are Windows users. And they > have COM for whatever is in their system. Um, I don't necessarily agree about the breakdown of Python users. But you should realize that the reason I pointed this out is that your statement above implies that _you_ (or at the very least your colleagues) are working under Windows, or else they wouldn't be comparing to ASP/IIS and ADO recordssets (which are Windows only). If that's not true, then they are comparing apples to oranges, and the difference is the Unix versus Windows/COM models, which has little to do with Python or its database access methods. :-) > We mostly have Linux servers, so COM+ADO is no option. The point was not > to choose between Windows and Linux, ASP was choosen to serve particular > purpose, for the database already implemented in Microsoft land. Then I'm having trouble seeing the lack of satisfaction of your colleagues having anything at all do with Python, and more to do with a lack of satisfaction with a missing object model under Linux that they liked under Windows. In other words, I don't think the problem here is a Python database related issue. -- -- 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 jkraska1 at san.rr.com Wed Jul 25 20:41:44 2001 From: jkraska1 at san.rr.com (Courageous) Date: Thu, 26 Jul 2001 00:41:44 GMT Subject: Language change and code breaks References: <cpofq9a858.fsf@cj20424-a.reston1.va.home.com> <mailman.996095454.10224.python-list@python.org> Message-ID: <fhpult0jq2nijpddfehe65m3vr7q91m7to@4ax.com> On Wed, 25 Jul 2001 17:09:09 -0400, "Tim Peters" <tim.one at home.com> wrote: >[Guido van Rossum] >> ... >> But never mind, I'm giving up on making *Python* case-insensitive. >> The hostility of the user community is frightening. I would gladly shell out hefty developer fees for a Python which performed within a small order of magnitude C speeds. I'm keeping a close eye one QKS at the moment for just that reason. At work, I'd easily pull strings for a $1000 developer platform to do this; at home, I'd be willing to spend about $250. I know I'm not alone. You Python Labs dudes have lost sight of a major impediment to the maturation of Python, IMO. And if the QKS folks are getting the performance improvements they say they are, it would appear that the allegation that Python speed was dependent on a first-class type system was just plain wrong. Don't you guys work on Python all day long? I can only _dream_ of such a privelege. C// From bsass at freenet.edmonton.ab.ca Mon Jul 30 15:18:51 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Mon, 30 Jul 2001 13:18:51 -0600 (MDT) Subject: PEP 238 (revised) In-Reply-To: <3B65A033.2AAC226A@home.net> Message-ID: <Pine.LNX.4.33.0107301238260.28123-100000@bms> On Mon, 30 Jul 2001, Chris Barker wrote: > Bruce Sass wrote: > > > I see __past__ as one last chance to easily check your code to see if > > the associated feature upgrade broke it, after that it is either fix > > the code or have it depend on an older Python. > > Which is exactly why I think a way to indicate that code depends on a > older Python is important! The best you could expect though is an indication of which version(s) of Python the code has been tested with (the worst is completely bogus info!, but that depends on the implementation). A program that could look at a .py and determine which versions of Python it looks like it will run with would be good, and more likely to do what you want for a larger amount of wild code. I don't dispute the utility of knowing something about which versions of Python a program has been used with, I just don't think there is enough utility to warrant adding code to Python to accomplish it [additional worry: someone would then want Python itself to know about all its previous versions and the incompatibilities between them, so it could dispatch the program off to the `best' interpreter for that program (lots of platform and flavour specific code?)]. - Bruce From grakker at softhome.net Tue Jul 3 17:25:48 2001 From: grakker at softhome.net (grakker) Date: 3 Jul 2001 14:25:48 -0700 Subject: missing setfirstweekday in calendar module References: <56817b75.0107021223.39a661ae@posting.google.com> <B7668E49.13B8B%dgoodger@bigfoot.com> Message-ID: <56817b75.0107031325.59061899@posting.google.com> David Goodger <dgoodger at bigfoot.com> wrote in message news:<B7668E49.13B8B%dgoodger at bigfoot.com>... > (BTW, I added setfirstweekday() and other improvements to calenday.py, and > I'm glad somebody is getting use out of it.) Thank you for the tip and the work that you put into it. From ibarona at tid.es Wed Jul 18 09:59:25 2001 From: ibarona at tid.es (Isaac Barona) Date: Wed, 18 Jul 2001 13:59:25 GMT Subject: Problem with ioctl call Message-ID: <3b559471.1322770038@tid> Hi all, I am trying to do a multi-platform serial port library in python (linux and win95 at the moment) that I hope to release next week. In linux, I get the following error when using an ioctl call to get then number of bytes waiting to be read: >>> tty.inWaiting() Traceback (most recent call last): File "<stdin>", line 1, in ? File "SerialPort_linux.py", line 179, in inWaiting n=fcntl.ioctl(self.__handle, TERMIOS.TIOCINQ) IOError: [Errno 14] Bad address Any help??? This happend with python 2.0.1 and python 1.5.2 over linux 2.0.34. From Armin_member at newsguy.com Mon Jul 2 06:14:54 2001 From: Armin_member at newsguy.com (Armin Steinhoff) Date: 2 Jul 2001 03:14:54 -0700 Subject: Is Python Dead? References: <MNS%6.355$Xs4.225014@news.pacbell.net> Message-ID: <9hphiu0dks@drn.newsguy.com> In article <MNS%6.355$Xs4.225014 at news.pacbell.net>, "Edward says... > >I have been following Python for five years now, and I am still just as >frustrated with it as I was in 1996. > >Python still doesn't have good database support, IMHO ... if something is dead, then it's your perception :) Here some database links ... out of the reality. http://www.oraclepower.com/isapi/orapower.dll?AID=SC&CAT_ID=1166 http://starship.python.net/crew/sturner/informixdb.html http://object-craft.com.au/projects/sybase/ http://www.druid.net/pygresql/ http://www.zope.org/Members/adustman/Products/MySQLdb http://www.python.org/topics/database/DatabaseAPI-2.0.html http://www.lemburg.com/files/python/mxODBC.html http://www.ziclix.com/zxjdbc/ http://www.chordate.com/gadfly.html http://clientes.netvisao.pt/luiforra/gvib/ http://www.equi4.com/metakit/python.html http://pybsddb.sourceforge.net/ Armin >nor has it grown to be >useful in the web space as mod_perl. PyApache has been around longer than >mod_php, yet php has far surpassed it as a productivity tool in the web >space. > >It would seem Python can do everything, yet nothing. Everyone wants to >write the next killer application with Python, XML parsers, image >manipulators, super computer steering modules, yet no one wants to work on >making Python perform where it matters most. Python is the best language at >eclectic stuff, however, poor at bread and butter tasks. > >Python needs better leadership in areas of its growth. Python is truly the >best language in use today, except it still isn't very useful for the >largest solution sector, database access, and information presentation (web, >or otherwise). > >It seems that Python should strive to be great at the ABC's before it >attempts poetry. > >--Ed > > > > From chrishbarker at home.net Mon Jul 9 15:01:08 2001 From: chrishbarker at home.net (Chris Barker) Date: Mon, 09 Jul 2001 12:01:08 -0700 Subject: Writing documentation References: <mailman.994690455.6338.python-list@python.org> <3B49DB28.F9955406@dennis-voss.de> Message-ID: <3B49FF74.A45F2263@home.net> Dennis Voss wrote: > > I'd like to document my Python modules in the same way the standard > > modules are documented, with LaTeX and the Python styles and things. It's > > not exactly a howto, and it'l look a lot like a mini-library reference, > > right? So how do I compile it? How do I generate all the nifty HTML? > > Take a look at: > http://py-howto.sourceforge.net/writing.html > > They are using LaTeX (why not docbook?) Because this was started before docbook was as common as it is now, and because LaTeX is an excellent tool. > for doing so. > There are tools in every TeX distribution for generating PS, PDF, HTML ... Well, sort of. The Python docs generating set-up works great on *nix, but not really on other systems. However, this doesn't mean you can't use it elsewhere. generating the the LaTeX, and the PS and printed (and probably pdf, you could build this from the PS anyway) verison you could do anywhere. Getting Tex2html to work is another matter. Do take a look at: http://www.python.org/doc/current/doc/doc.html For more info. Don't be put off by the LaTeX, it is an excellent tool, and with the existing docs as a template to work from, not that hard to learn to use. YOu may grow to love 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 aahz at panix.com Wed Jul 11 11:37:52 2001 From: aahz at panix.com (Aahz Maruch) Date: 11 Jul 2001 08:37:52 -0700 Subject: BASIC or Python? References: <mailman.994846878.32177.python-list@python.org> Message-ID: <9ihrsg$d26$1@panix2.panix.com> In article <mailman.994846878.32177.python-list at python.org>, Bruce Sass <bsass at freenet.edmonton.ab.ca> wrote: >> stremler at rohan.sdsu.edu wrote: >>> >>> I'll just quote: >>> >>> This is also one reason I dislike Python. Indentation is part of the >>> documentation of the program, and as such it shouldn't be parsed by the >>> compiler. -- Peter da Silva (September 1999) > >I'd be more interested in hearing if Mr. da Silva has changed his >mind in the last few years. Peter? Change his mind?! Surely you jest. -- --- 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 "How come we choose from just two people for President but more than 50 for Miss America?" --AEN From Ronan.Viernes at onsemi.com Tue Jul 31 02:39:39 2001 From: Ronan.Viernes at onsemi.com (Ronan Viernes) Date: 30 Jul 2001 23:39:39 -0700 Subject: Python Threads on Linux Message-ID: <d396b814.0107302239.6341a93@posting.google.com> Environment: SuSE Linux 7.1 with 2.2.18 Kernel Python 1.5.2 PIII IBM Desktop 1. Is it normal for threads on LINUX to have their own process id thereby displayed in "ps -ef"? In AIX/HP, this is not the case right? 2. How do i exit gracefully from a thread? After exiting the thread, is the thread 'process' automatically closed? I noticed in our system that after exiting the thread, the 'process' are still present as evidenced by the "ps -ef" . Any help will do. Thanks. From emile at fenx.com Tue Jul 3 10:15:32 2001 From: emile at fenx.com (Emile van Sebille) Date: Tue, 3 Jul 2001 07:15:32 -0700 Subject: Access all classes in a directory, put into an array, and print them out References: <mailman.994168205.8845.python-list@python.org> Message-ID: <9hsk9c$fl3ec$1@ID-11957.news.dfncis.de> import os for file in os.listdir(dirpath): print i -- Emile van Sebille emile at fenx.com --------- "Kemp Randy-W18971" <Randy.L.Kemp at motorola.com> wrote in message news:mailman.994168205.8845.python-list at python.org... > Can anyone share a short code example of how to access all the programs in a > Unix directory, put them into an array, and print them out in Python? Here > is the code I have to do it in Perl (please forgive the harsh language). > > #!/usr/bin/perl -w > #use Net::FTP; > opendir (TEMP, '/usr2/ecadtesting/javaprograms') > or die "Can't open current directory."; > @files=join(',',grep(!/^\.\.?$/, readdir TEMP)); > closedir TEMP; > print "\n"; > print @files; > print "\n"; > > From ajp at fudokai.org.uk Tue Jul 10 08:31:14 2001 From: ajp at fudokai.org.uk (CyberKat) Date: 10 Jul 2001 05:31:14 -0700 Subject: Is Python Dead? Long Live Python! References: <mailman.994713616.26838.python-list@python.org> <3B4A66D3.AD4B29D9@engcorp.com> Message-ID: <c250fb6e.0107100431.8a46d83@posting.google.com> Peter Hansen <peter at engcorp.com> wrote in message news:<3B4A66D3.AD4B29D9 at engcorp.com>... > Lindstrom Greg - glinds wrote: <snip> > > I recommend a persistent onslaught of griping about current tools, > constant pointing out of how superior Python would be in a given problem > situation, projections that a new development could take M months of work > in a more typical language but only N months were it written in Python, > whining at the difficulty of maintaining code in another language, > and periodic forwarding of links and articles showing how companies > with more cohones than yours are achieving significant successes with > Python (especially any near competitors). > <snip> Nice - I just have to find the _time_ to learn Python well enough to point out where and how it's better - I like the look and concepts of Python (tho' I'd like some sort of strong typing option [constrictor maybe ;-) ] ) but I just don't have enough hours on the d**n day to get deep enough into it. Like any other language it's not until you're deep into a major app with it that you find out its strengths and weaknesses. Alan From nospam at nospam.de Sat Jul 21 16:16:25 2001 From: nospam at nospam.de (Uwe Hoffmann) Date: Sat, 21 Jul 2001 22:16:25 +0200 Subject: re and multiline strings References: <9jcn5i$3lo0$1@node21.cwnet.roc.gblx.net> Message-ID: <3B59E319.98400DD0@nospam.de> Lee Harr wrote: > > >>> t = 'aaazbbbycccc\nccccc\n' > >>> p = re.compile('(.*?)z(.*?)y(.*)') p = re.compile('(.*?)z(.*?)y(.*)',re.S) From rnd at onego.ru Mon Jul 2 01:38:35 2001 From: rnd at onego.ru (Roman Suzi) Date: Mon, 2 Jul 2001 09:38:35 +0400 (MSD) Subject: Python for air traffic control? In-Reply-To: <Pine.LNX.4.33.0107012301380.5806-100000@bms> Message-ID: <Pine.LNX.4.21.BCL.0107020923470.720-100000@suzi.com.onego.ru> On Sun, 1 Jul 2001, Bruce Sass wrote: > On Sun, 1 Jul 2001, Magnus Lie Hetland wrote: > > > "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 > <...> > > 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 ---- ;-) Does Microsoft license says something similar? BSOD at nuclear plant could be more than metaphora... > You see the same sort of thing with electronics components, the > manufacturer doesn't want to be responsible when someone's > home-brewed-from-off-the-shelf-parts EKG experiment goes wrong. > > Has Python made a list of software approved for air traffic-control > use, or is there no such thing for atc software? I think it is not a problem of Python or other software: whatever you use, just make it doubled or tripled! For example, have different OSes with different programs in different languages. When programming critical system, I have found that simpler things work better: - database could fail while filesystem mapped database will work - small independent scripts fail much less frequently than monolithic apps (and failures are more easily tracked down) - CLUI programs with web-interface work better than GUI programs (by better I mean availability) Do not forget human error factor. Check user input. If your system is built of isolated cells with lots of try-except it could float whatever happens to it's parts. Also, do not forget to design your app in a way that allows you to modify you application at runtime. This could be done by making app a set of scripts/programms or by using Python abilities to reload modules at runtime. * Said this, I think core Python is ideal for this sort of app: you can mend it at runtime and logic of the app is made simpler by the Python syntax. (Code could be easily revised by specialists other than programmers, for example: for plane1 in planes: for plane2 in planes: if plane1 != plane2: if distance(plane1, plane2) < safe_distance: alert_operator("....") will be understandable to any English language reader. Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From peter at engcorp.com Mon Jul 30 20:29:16 2001 From: peter at engcorp.com (Peter Hansen) Date: Mon, 30 Jul 2001 20:29:16 -0400 Subject: Large-scale Python (was: Language Niches (long)) References: <8beb91f5.0107280407.5a30341d@posting.google.com> <mailman.996429234.13926.python-list@python.org> <Ej5QPKA1WHZ7EwvP@jessikat.fsnet.co.uk> <mailman.996442753.17197.python-list@python.org> <C2D62BF6D2E4F577.D8696582805EEB21.2093367A0D5F09C4@lp.airnews.net> Message-ID: <3B65FBDC.F8B92DA2@engcorp.com> Cameron Laird wrote: > Without contesting any of Paul's larger points, what > are the facts here? I believe: > * Python is good for team-work > and big projects; and > * There is increasing recogni- > tion and use of Python in > this role. > What role has "language change" played in this, though? To the extent that language changes have made the language more self-consistent and easier to learn in other ways, these changes might increase its suitability for work requiring team-work. I'm thinking of the great ease we've had integrating new people into the team, without ever once asking for "Python" to appear on a resume. With any other language, I would have been much more nervous hiring on people who looked under the table for the snake when I first mentioned the language we use... ;) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From flognat at flognat.myip.org Wed Jul 25 17:05:21 2001 From: flognat at flognat.myip.org (Andrew Markebo) Date: Wed, 25 Jul 2001 21:05:21 GMT Subject: http References: <mailman.996038983.5187.python-list@python.org> Message-ID: <m33d7kbtxt.fsf@localhost.localdomain> You need to grab the cookies from the headers of the retrieved webpage, (headerline starting with Set-cookie), and then when you compose the answer, urllib.URLopener has a function addheader where you put in the headers telling the server which cookies you have.. Basically, the order for yahoo is something like * Post your form * You will receive a redirection status with cookies in the header * get the page redirected to (groups.yahoo.com) and send the cookies to the server.. * Now you can navigate around with the cookies on yahoo and read your mail, access your groups.. By chance I am actually playing around with an yahoo client, using my own http and socket modules, a first getting started can be found at: http://flognat.myip.org/hacks/yah.tgz /Andy / "raghu k rao" <krag_rao_pyt at rediffmail.com> wrote: | | [...] | how do i make modification in my program to ACCEPT COOKIES from a server and at which instance i shall do this either at the first 'GET' request | when requesting for the home page of at the 'POST' request in my case urlopen or both the times | From rnd at onego.ru Thu Jul 5 05:34:02 2001 From: rnd at onego.ru (Roman Suzi) Date: Thu, 5 Jul 2001 13:34:02 +0400 (MSD) Subject: SPAM again [was: Re: .BIZ .INFO domain extensions] In-Reply-To: <Pine.LNX.4.33.0107051230030.18582-100000@phd.fep.ru> Message-ID: <Pine.LNX.4.30.0107051332450.17954-100000@rnd.onego.ru> On Thu, 5 Jul 2001, Oleg Broytmann wrote: >On 4 Jul 2001, [iso-8859-1] Fran?ois Pinard wrote: >> Hi, people. We still get SPAM from this list once in a while, which is >> annoying. I wonder if something could be done about it at the list level. >> >> I noticed that two recent SPAM were sent to `python-list at cwi.nl' instead of >> `python-list at python.org', so we might think of ruling out that old address. >> On the other hand, valid postings are still made to the `cwi.nl' address, >> even if rarely. I fear some members might find rude being forced to switch >> to `python.org'. And besides, I'm sure `python.org' will get included >> in all spammers' lists, sooner or later, so this would be just postponing >> the real problem. Sigh! >> >> My attitude about SPAM, and am not sure I am fully right, is that I rely >> on mailing lists to filter the SPAM they get before forwarding it to me, >> while I consider this is more my responsibility to filter the rest, which >> directly gets addressed to me without going through mailing lists. >> >> Opinions? Suggestions? Spam? I stopped noticing spam after I subscribed to this list ;-) Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Thursday, July 05, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ ">From the Department of Redundancy Dept." _/ From juergen.erhard at gmx.net Thu Jul 12 14:21:58 2001 From: juergen.erhard at gmx.net (=?ISO-8859-1?Q?=22J=FCrgen_A=2E_Erhard=22?=) Date: Thu, 12 Jul 2001 20:21:58 +0200 Subject: How popular is Python, anyway? (was: Long Live Python!) In-Reply-To: <slrn9kpv3p.ooh.philh@comuno.freeserve.co.uk> References: <E566B020833BD311B6610008C791A39705CA5230@il93exm04.css.mot.com> <mailman.994804336.23495.python-list@python.org> <slrn9koofo.mjk.philh@comuno.freeserve.co.uk> <slrn9kpgtq.5ug.gergo.barany@hold.otthon.at> <slrn9kpv3p.ooh.philh@comuno.freeserve.co.uk> Message-ID: <12072001.3@wanderer.local.jae.ddns.org> >>>>> "phil" == phil hunt <philh at comuno.freeserve.co.uk> writes: phil> On 11 Jul 2001 21:20:02 GMT, Gergo Barany <gergo.barany at gmx.net> wrote: >> phil hunt <philh at comuno.freeserve.co.uk> wrote: >>> [snip flamebait crap] >> >> If anyone is going to to respond to this thread, *please* take >> comp.lang.c out of the Newsgroups: list. We don't do advocacy here. >> Followups set. phil> My post was an entirely objective statistical summary, and contained phil> no subjective or opinion-based data at all. phil> If you think that facts are "crap" and hard statistical analysis I wouldn't call those numbers you presented "hard statistical analysis". Not that those numbers aren't corrent... but what the "analysis" lacked is some analysis of how good a measurement those numbers are given what they are used for. Things like "margin of error" come to mind. (But then again, that is something you rarely hear about in statistics presented in the "news" either) Bye, J -- J?rgen A. Erhard (juergen.erhard at gmx.net, jae at users.sourceforge.net) MARS: http://members.tripod.com/Juergen_Erhard/mars_index.html There's an NDA in the FSF: Free Software FouNDAtion. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 248 bytes Desc: not available URL: <http://mail.python.org/pipermail/python-list/attachments/20010712/ed7c641f/attachment.sig> From greg at cosc.canterbury.ac.nz Tue Jul 10 00:03:33 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Tue, 10 Jul 2001 16:03:33 +1200 Subject: [OT] Eternal programming References: <mailman.994519931.6264.python-list@python.org> Message-ID: <3B4A7E95.B4AB2F71@cosc.canterbury.ac.nz> Roman Suzi wrote: > > What is left: > > Data storage, 8 bit bytes, latin letters, 10 digits, some computers with > some formal programming languages, and some programmers ;-) who are > capable to program very simple core interpreter in the language they will > have at hands. (Even mathematicians will be enough). If the English language has changed too much, and there's no-one left who can understand the spec, you might have a bit of a problem... -- 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 rb at tiscali.be Mon Jul 16 05:35:18 2001 From: rb at tiscali.be (Raphael Bauduin) Date: Mon, 16 Jul 2001 11:35:18 +0200 Subject: command substitution Message-ID: <newscache$vy7kgg$wzn$1@news.freegates.be> Hi! I was looking for a solution like in bash, which let you put the standard output of a command in a variable(in bash, you can do it like OUT=`ls` or OUT=$(ls) ). If you have another way to take the standard output of a command and put it in a variable, it would be helpfull too. Thanks. Raph -- Open Source and Free Software Developers Meeting See you at the 2002 edition. Check the 2001 sessions on www.opensource-tv.com Visit http://www.osdem.org and subscribe to the mailing list! From jcopella at cfl.rr.com Tue Jul 10 11:57:37 2001 From: jcopella at cfl.rr.com (John Copella) Date: Tue, 10 Jul 2001 15:57:37 GMT Subject: Adding timeouts to Internet sockets Message-ID: <RBF27.212379$WB1.31341412@typhoon.tampabay.rr.com> How have developers added timeout behavior to Internet sockets in Python? I am developing an application that uses ftplib, and I need to timeout if the server is unavailable, etc. I note that Tim O'Malley has a package out (http://www.vex.net/parnassus/apyllo.py?i=87800233) that very cleverly and transparently does this (or seems to). Has anyone used it? My application will be mission-critical, and I would prefer to use whatever is considered the current best practice. Please reply via email, as my access to newsgroups is limited. Any help on this matter is greatly appreciated! John Copella Aerologic Inc. From tjreedy at home.com Tue Jul 24 12:23:36 2001 From: tjreedy at home.com (Terry Reedy) Date: Tue, 24 Jul 2001 16:23:36 GMT Subject: A way to accommodate laguage changes References: <3B5CB83B.F3B7D51@home.net> <5E877.23798$EP6.5677355@news1.rdc2.pa.home.com> <mailman.995975980.22956.python-list@python.org> Message-ID: <cih77.25353$EP6.5926849@news1.rdc2.pa.home.com> "Skip Montanaro" <skip at pobox.com> wrote in message news:mailman.995975980.22956.python-list at python.org... > Terry> To run newly written code under old versions of the interpreter, > Terry> you have to eschew *all* features added after the oldest version > Terry> you want to support. For 1.5.2, this means list comprehensions, > Terry> augmented assignments, nested scopes, iterators, generators, > Terry> type-class unification features, and what ever else is next > Terry> added. > > Yeah, but that presumes that the features you do use don't change meaning. Exactly > Terry> For the proposed division change, the 'new' meanings will be > Terry> int/int and float//float. So write float(int)/int and > Terry> floor(float/float) instead. Only write int//int or float/float. > Terry> With the tokenizer module, it will then be easy to change all > Terry> instances of int//int to int/int (old meaning). > > Interesting solution. which is based on the forward-conversion program that I believe you posted. Both should be part of the transition package distributed with 2.2+. Terry J. Reedy From paulp at ActiveState.com Fri Jul 13 15:38:49 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Fri, 13 Jul 2001 12:38:49 -0700 Subject: [Python-Dev] Re: PEP: Defining Unicode Literal Encodings References: <3B4EE391.19995171@lemburg.com> <3B4F4608.207DBA7B@ActiveState.com> <200107131916.f6DJGLU16857@odiug.digicool.com> Message-ID: <3B4F4E49.C299C356@ActiveState.com> Guido van Rossum wrote: > >... > > Hm, then the directive would syntactically have to *precede* the > docstring. It makes sense for the directive to precede the docstring because the directive should be able to change the definition of the docstring! > That currently doesn't work -- the docstring may only be > preceded by blank lines and comments. Lots of tools for processing > docstrings already have this built into them. The directive statement is inherently a backwards incompatible extension. It is a grammar change. Many tools sniff out the docstring from the loaded module anyhow. > Is it worth breaking > them so that editors can remain stupid? I would say that the more important consideration is that it just makes sense to figure out what encoding you are using before you start processing strings! -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From quinn at retch.ugcs.caltech.edu Sun Jul 8 22:40:23 2001 From: quinn at retch.ugcs.caltech.edu (Quinn Dunkan) Date: 9 Jul 2001 02:40:23 GMT Subject: readline()/readlines() inconsistent? References: <3B482C44.6E6EB163@snakefarm.org> <slrn9ki07c.vu.tim@vegeta.ath.cx> Message-ID: <slrn9ki6cn.8ud.quinn@retch.ugcs.caltech.edu> On Mon, 09 Jul 2001 00:43:02 GMT, Tim Hammerquist <tim at vegeta.ath.cx> wrote: >Carsten Gaebler <clpy at snakefarm.org> wrote: >> Hi there! >> >> I've just come across a strange difference between readline() and >> readlines(): >> >> Python 2.1 (#17, Jun 15 2001, 15:24:30) >> [GCC 2.95.2 19991024 (release)] on linux2 >> Type "copyright", "credits" or "license" for more information. >> >>> f = open("foobar", "w") >> >>> f.readline() >> '' >> >>> f.close() >> >>> >> >>> f = open("foobar", "w") >> >>> f.readlines() >> Traceback (most recent call last): >> File "<stdin>", line 1, in ? >> IOError: [Errno 9] Bad file descriptor >> >>> > >Same happens on my box. > >$ cat /proc/version >Linux version 2.2.15-4mdk (chmou at kenobi.mandrakesoft.com) >(gcc version 2.95.3 19991030 (prerelease)) #1 Wed May 10 15:31:30 CEST 2000 > >$ python >Python 2.0 (#1, Oct 16 2000, 18:10:03) >[GCC 2.95.2 19991024 (release)] on linux2 >[ snip ] > >BTW, is file.xreadlines() a new feature in Py2.1? Yep. >Of course, an obvious question is, if you want to read _and_ write, why >weren't you using 'r+' or 'w+' to begin with? > >I hope someone can answer this, but is this a matter of file I/O >implementation between different OS's? Or is this a Python >implementation issue? Despite what the documentation may say, readlines does not use readline. readlines uses fread() (since it doesn't have to worry about reading too much) and then checks with ferror(). readline uses getc() (or perhaps fgets()) and, when it gets EOF for error, proceeds to *not* check for error (clears it, in fact). So I'd say linux, SunOS, and Irix are correct here and OSX is wrong (must not be reporting via ferror() correctly). I'd say python is wrong here too, by not being consistent. If readline checks, readlines should too. From jochen at riekhof.de Sat Jul 21 05:30:54 2001 From: jochen at riekhof.de (Jochen Riekhof) Date: Sat, 21 Jul 2001 11:30:54 +0200 Subject: ActivePython ASP comobject.getCOMObject() does not work References: <9j6tac$b96$00$1@news.t-online.com> <3B576D8C.9080705@ActiveState.com> <Xns90E478A656FFBjimpublishingresourc@207.126.101.100> <9j9mtn$e9f$07$1@news.t-online.com> <Xns90E4B8DA3D90Ajimpublishingresourc@207.126.101.100> Message-ID: <9jbi4b$q64$01$1@news.t-online.com> > I have no clue, but I would hazard a guess that there's an out param in the > "OrboPCT.OrboPCTRead" object you're using. Yes, you may well be right! As Python passes all things by value, there has to be some means to returne the first ByRf string parameter! This will be it. Thanks a lot! Am, any idea where I can get a comprehensive introduction to all this com stuff. The delivered docs seem a bit slim to me. Ciao ...Jochen From guido at python.org Fri Jul 27 10:01:52 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 27 Jul 2001 14:01:52 GMT Subject: PEP 238 (revised) References: <cp4rrz5onj.fsf@cj20424-a.reston1.va.home.com> <eppstein-F2006B.15303626072001@news.service.uci.edu> Message-ID: <cplmla4gjg.fsf@cj20424-a.reston1.va.home.com> David Eppstein <eppstein at ics.uci.edu> writes: > I agree with the previous poster who said to use "quotient" instead of > "floor division". Also, both types of division are mathematical results, > just of different operators. So maybe instead of the unclear phrase "the > mathematical result" to denote, you know, the floating point style > division, maybe you could call it the ratio. > > Example of this substitution made to first two paras: > > The current division (/) operator has an ambiguous meaning for > numerical arguments: it returns the integer quotient of two ints or > longs, but it returns a reasonable approximation of the ratio of two > floats or complex numbers. This makes expressions expecting float or > complex results error-prone when integers are not expected but > possible as inputs. > > We propose to fix this by introducing different operators for > different operations: x/y to return a reasonable approximation of the > ratio, x//y to return the quotient. We call the current, mixed > meaning of x/y "classic division". You've got me halfway convinced here. Let me think about that a bit. It certainly makes shorter names! --Guido van Rossum (home page: http://www.python.org/~guido/) From BPettersen at NAREX.com Fri Jul 6 11:36:22 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Fri, 6 Jul 2001 09:36:22 -0600 Subject: Comment on PEP-0238 Message-ID: <6957F6A694B49A4096F7CFD0D900042F27DB8E@admin56.narex.com> > From: Guido van Rossum [mailto:guido at python.org] > > "Robert J. Harrison" <rjh at 3-cities.com> writes: > > > Again, my major objection to this proposal is that it gives us > > nothing and breaks a lot of existing code. > > Other educators disagree. Take the case of VPython. > > The VPython folks have used Python very successfully to teach freshman > physics students at Carnegie Mellon to create 3D models. Many > students had little or no programming experience. The goal of the > course wasn't to teach programming, it was to teach understanding of > physics. Throughout the course, students were writing Python programs > implementibg various laws of physics. Here's a quote from Bruce > Sherwood, one of the teachers (without permission, but I'm sure he > doesn't mind): [snip] Ok, let's agree that studies have shown that when using Python for educational purposes to teach somthing besides Python, then having integer division return float results causes less surprise. Let's further hypothesize that when using Python to teach programming (either as a first or a secondary language) that it would be less surprising for a majority of the students to have integer division return float results. That still leaves a ton of professional programmers that for years have relied on the current semantics with broken code. E.g. in my case, I know there is code I wrote that is running at my last employer that would most probably silently start returning incorrect results. Even if having integer division returning float results would have been the right decision when Python started out (and I believe that it would have been), it is now simply too late to change and the reasons for changing at _this_ point are simply not compelling enough to break that much code. Sometimes when you make a mistake, you just have to learn to live with it. -- bjorn From tim.hochberg at ieee.org Fri Jul 27 10:11:19 2001 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Fri, 27 Jul 2001 14:11:19 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <eppstein-03540D.13070222072001@news.service.uci.edu> <LNBBLJKPBEHFEDALKOLCOECNLAAA.tim.one@home.com> <mailman.995899647.346.python-list@python.org> <tclolt053o18f8q0ntb7n4aggitdkmeg4h@4ax.com> <Io_67.23543$B7.3779351@ruti.visi.com> <slrn9lp2m5.vp.Gareth.McCaughan@g.local> <p56plt8q4rs3bgcqbepk61q2r3g0tr2vhe@4ax.com> <slrn9ls3ae.2fm.Gareth.McCaughan@g.local> <cpitghbq05.fsf@cj20424-a.reston1.va.home.com> <MWD77.27751$EP6.6983549@news1.rdc2.pa.home.com> <9jnt9p$qhe$1@newsy.ifm.liu.se> <SYV77.27286$B7.4239335@ruti.visi.com> <cpitgf7itx.fsf@cj20424-a.reston1.va.home.com> <WIY77.27607$B7.4257794@ruti.visi.com> <cp3d7j75jv.fsf@cj20424-a.reston1.va.home.com> <Uj587.32158$EP6.8364145@news1.rdc2.pa.home.com> <cpvgke4hlx.fsf@cj20424-a.reston1.va.home.com> Message-ID: <bEe87.53103$Cy.6853667@news1.rdc1.az.home.com> "Guido van Rossum" <guido at python.org> : > "Terry Reedy" <tjreedy at home.com> writes: > > > If I write def(seq, n, k): return seq[3*n//k] and a call receives > > n=20.0 instead of 20, it would accord with the polymorphic rationale > > for new / and // to go ahead and return the item intended. Or perhaps > > floored numbers should be marked as exact (if the marking is > > independent of type). > > Good point. What does Scheme do? Floor, ceiling, truncate and round all return integers. It seems that it wouldn't really be possible to have // do that consistently without PEP 237 though. -tim From guido at digicool.com Fri Jul 13 15:16:21 2001 From: guido at digicool.com (Guido van Rossum) Date: Fri, 13 Jul 2001 15:16:21 -0400 Subject: [Python-Dev] Re: PEP: Defining Unicode Literal Encodings In-Reply-To: Your message of "Fri, 13 Jul 2001 12:03:36 PDT." <3B4F4608.207DBA7B@ActiveState.com> References: <3B4EE391.19995171@lemburg.com> <3B4F4608.207DBA7B@ActiveState.com> Message-ID: <200107131916.f6DJGLU16857@odiug.digicool.com> > I strongly think we should restrict the directive to one per file and in > fact I would say it should be one of the first two lines. It should be > immediately following the shebang line if there is one. This is to allow > text editors to detect it as they detect XML encoding declarations. Hm, then the directive would syntactically have to *precede* the docstring. That currently doesn't work -- the docstring may only be preceded by blank lines and comments. Lots of tools for processing docstrings already have this built into them. Is it worth breaking them so that editors can remain stupid? --Guido van Rossum (home page: http://www.python.org/~guido/) From gmcm at hypernet.com Fri Jul 20 16:55:45 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: Fri, 20 Jul 2001 16:55:45 -0400 Subject: ANN: 3rd beta of Win32 Installer release 4 Message-ID: <3B586291.2027.1035396D@localhost> The thrid beta of version 4 of the Win32 Installer package is here: http://www.mcmillan-inc.com/installer_dnld.html This beta fixes some bugs in package support and dependency analysis (mxDateTIme is working again, PyXML works properly once the package is included). The docs feature a more gentle introduction for those who want to stay away from the complexities. Version 4 handles all Python versions from 1.5 onward (it's been tested with 1.5 and 2.1). It has a number of new capabilities: - set a Windows version resource in the executable (NT / Win2K only), including the ability to create a version resource from Python - a utility to analyze the dependency tree of a script / module (including a cross-reference) - warnings issued when dynamic code encountered (__import__, exec, eval) - COM client support (including using gencache.EnsureModule to generate support on the end-user's machine). What is it? The Installer is a set of tools for distributing Python applications. The target machines do not need to have Python installed, or may have a different version of Python installed. The Windows version (there's a more limited Linux version, too), has top level scripts for 3 configurations: - Standalone: create a single directory installation for your app - Simple: wraps a Standalone with a simple install script - Freeze: creates an executable that unpacks itself at run time, and cleans up afterward. More complex distributions can be created by writing your own config file and passing it to Builder. Old-Python-style license. Contact: gmcm at hypernet.com <P><A HREF="http://www.mcmillan-inc.com/installer_dnld.html"> Win32 Installer release 4a2</A> A compiler-less way of distributing Python apps on Windows. (20-July-01) - Gordon From jdavis at empires.org Mon Jul 23 04:24:51 2001 From: jdavis at empires.org (Jeff Davis) Date: Mon, 23 Jul 2001 01:24:51 -0700 Subject: web sessions support Message-ID: <O8R67.2110$De6.330884@news.pacbell.net> I have been looking around and I have not been able to find a session module for python (for the web). Basically I just need a normal session manager that can work somewhat like the one in PHP. I have recently been moving away from PHP to python for web stuff and I need a session manager. If no such module exists, I would write my own. Thanks. Regards, Jeff Davis From urner at alumni.princeton.edu Fri Jul 27 13:00:10 2001 From: urner at alumni.princeton.edu (Kirby Urner) Date: Fri, 27 Jul 2001 10:00:10 -0700 Subject: In defense of PEP0238 (plus PS) Message-ID: <7p63mtgg6e6ge38tvv91b364lb4heo90di@4ax.com> I've talked myself back into supporting PEP0238, after many of the eloquent posts here had swayed me the other way. A latest snap shot of my thought process: http://mail.python.org/pipermail/edu-sig/2001-July/001579.html Kirby PS: I'm really enjoying the generators and iterators stuff. 2.2a is a lot of fun. The language is steadily becoming more powerful. For more on this: http://mail.python.org/pipermail/edu-sig/2001-July/author.html posts by Kirby Urner (me) Note, in http://mail.python.org/pipermail/edu-sig/2001-July/001548.html there's a coding error, should read: def primes(): """ Generator: Yield next higher prime, starting at 2, accruing successive primes in global list pr """ global pr pr = [2] i,new = 1,1 ^^^^^^^ Of course the 2.2a docs themselves contain examples. From db3l at fitlinxx.com Tue Jul 24 19:49:45 2001 From: db3l at fitlinxx.com (David Bolen) Date: 24 Jul 2001 19:49:45 -0400 Subject: re bad leadership References: <0+yM4IAgmKX7EwIQ@jessikat.fsnet.co.uk> <20010724171838.A21770@xs4all.nl> <mailman.995992122.3012.python-list@python.org> <4crrlt0jbn9ovvkli3qvhqbc5do3lmpg4j@4ax.com> <%kn77.25759$EP6.6204923@news1.rdc2.pa.home.com> Message-ID: <u4rs1khuu.fsf@ctwd0143.fitlinxx.com> "Terry Reedy" <tjreedy at home.com> writes: > > So why not swap the proposed meanings of // and /? I realize this > is the > > third time I've said this but I think it would silence a lot of > objections > > and no one seems to have noticed the other two times. > > This would break as much or more code as the current proposal. Read > the PEP. Are you sure? I can't really see anything in the PEP that would seem to imply this. It talks about comparing // to functions like div(), but not the use of // for the new behavior over /. I can't see how this approach would break _any_ code, since // isn't an operator now and thus can't be used in any other way by current code. In fact, it parses as a syntax error. I buy the obvious aesthetic argument about really wanting to fix the obvious division operator, /, but can't see how using // would have any backwards-compatibility problems. -- -- 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 db3l at fitlinxx.com Fri Jul 27 18:07:13 2001 From: db3l at fitlinxx.com (David Bolen) Date: 27 Jul 2001 18:07:13 -0400 Subject: Deposing Dictators References: <9jmjne$q54$1@wisteria.csv.warwick.ac.uk> <3b602daf.1623450@nntp.sprynet.com> <slrn9m111q.e6f.Gareth.McCaughan@g.local> <dOoGUKA3PKY7EwWa@jessikat.fsnet.co.uk> <cpsnfi2z9w.fsf@cj20424-a.reston1.va.home.com> <$dK+wKA$tZY7Ewin@jessikat.demon.co.uk> <3b61a98d$0$11917@wodc7nh0.news.uu.net> <3B61B01F.6C6B2B5D@Lugoj.Com> <3b61bef1$0$11920@wodc7nh0.news.uu.net> Message-ID: <uitgem3fy.fsf@ctwd0143.fitlinxx.com> "Rufus V. Smith" <nospam at nospam> writes: > Of the hundreds of books you have read, there is no lack of context. > > In these parts, lack of context is often a rule rather than exception. Not to mention most of the books I've read that are representing inter-personal communication tend to describe facial features and behavior of the people involved rather explicitly, e.g., 'I wish you were hit by lightning,' she said, grinning mischievously. There really is a wealth of non-verbal information exchanged during face to face communication (or even audio-only) that needs to be taken into account in written replacements, particularly in an informal environment such as Usenet. Emoticons may not be perfect, but they can help, without being burdensome in terms of verbosity. -- -- 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 quinn at regurgitate.ugcs.caltech.edu Fri Jul 20 00:21:31 2001 From: quinn at regurgitate.ugcs.caltech.edu (Quinn Dunkan) Date: 20 Jul 2001 04:21:31 GMT Subject: Case insensitivity References: <mailman.995506711.21636.python-list@python.org> <cpvgkofyru.fsf@cj20424-a.reston1.va.home.com> Message-ID: <slrn9lfcea.b57.quinn@regurgitate.ugcs.caltech.edu> On Thu, 19 Jul 2001 20:30:15 GMT, Guido van Rossum <guido at python.org> wrote: >To me, the only real important question is, how can we introduce >case-sensitivity for novices without breaking the millions of lines of >existing Python code. One option could be: forget it, it's too late. >Another: put the case-insensitivity in the tools. Given that changing the language itself at this point is too late (and I think it is), the question is "for newcomers, does the additional complexity added by a layer of indirection in the tools cancel out the benefit of case insensitivity?" Obviously, that's assuming there is a benefit and it's significant (and just how significant is what no one agrees on). But if I were I newbie, I wouldn't like to hear "these are just training wheels, the real language has slightly different rules". Don't underestimate the newbie appeal of "what you see is all there is" (not that it ever is in python, given magic methods etc., but we shouldn't make it worse). An editor that optionally gives warnings about names with only case differences seems pretty innoccuous, though. Giving people a friendly editor is in the same spirit of avoiding "ok, well, to learn python first you need to learn the unix shell, to be able to manage your source files and run vi, oh yes, then you need to learn to use vi, just memorize this table of commands, ok, then..." So I'd say, please don't change the language itself, but it would be interesting to see experiments on a friendly python-oriented editing environment (to simplify things like finding modules and documentation, importing, reloading, etc.). From aramanat at optonline.net Thu Jul 5 21:06:23 2001 From: aramanat at optonline.net (Arun Ramanathan) Date: Fri, 06 Jul 2001 01:06:23 GMT Subject: system exec ? References: <9i1er4$mth$1@news.businessobjects.com> Message-ID: <3B453A1F.5B537BE7@optonline.net> alphaZeta wrote: > Hi, > > I didn't find any documentation (lib and tut) about how to execute a program > in a python script. > Does anybody know ? import os result = os.popen('program').read() or import commands result = commands.getoutput('program') Arun From m.1.robinson at herts.ac.uk Thu Jul 26 09:17:50 2001 From: m.1.robinson at herts.ac.uk (Mark Robinson) Date: Thu, 26 Jul 2001 14:17:50 +0100 Subject: emacs python mode References: <3B5BF5C7.3070707@herts.ac.uk> Message-ID: <3B60187E.20808@herts.ac.uk> Thanks guys, simple as that ;) blobby From skip at pobox.com Mon Jul 9 10:33:29 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 9 Jul 2001 09:33:29 -0500 Subject: "has" Operator In-Reply-To: <9ibe9n$ffu$1@news.mathworks.com> References: <Pine.LNX.4.30.0107080115240.17775-100000@rnd.onego.ru> <mailman.994543873.6493.python-list@python.org> <tkfa751vldoo66@news.supernews.com> <cpelrriogf.fsf@cj20424-a.reston1.va.home.com> <slrn9khonr.gg0.quinn@yak.ugcs.caltech.edu> <9ibe9n$ffu$1@news.mathworks.com> Message-ID: <15177.49337.856485.512856@beluga.mojam.com> Joshua> On the other side of things, it seems this could be introduced Joshua> into the language without making 'has' a keyword--no syntactic Joshua> rules currently use concatenation. This is a good point. I sometimes use this sort of construct: has = {"foo":1, "bar":1, ...}.has_key ... if has(a): ... -- Skip Montanaro (skip at pobox.com) (847)971-7098 From thomas at xs4all.net Sun Jul 15 11:18:17 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Sun, 15 Jul 2001 17:18:17 +0200 Subject: Python, C++, Java, Smalltalk, Eiffel,... In-Reply-To: <9is8rm$46d$1@panix3.panix.com> References: <9is8rm$46d$1@panix3.panix.com> Message-ID: <20010715171817.D5396@xs4all.nl> On Sun, Jul 15, 2001 at 10:20:38AM -0400, kj0 wrote: > Where can I find a reasonably non-partisan but also reasonably > detailed comparison of the more popular OO languages (C++, Java, > Python, etc.). (All the comparisons I've found are clearly slanted to > demonstrate the superiority of the authors' favorite OO language--I'm > sure it would be easy to find one written by unapologetic Python > advocates :-) ) > I'm not looking to find out which of these languages is "better"; I > don't care for ranking here. The problem is that there isn't one "better", just "better in the eyes of the author", and that is oddly enough also the reason why you, as you state in the first paragraph, are unable to find one that isn't biased :) > What I want to know is how the various > popular OO languages compare in terms of OO and general programming > features (e.g. multiple inheritance; classes-as-objects; garbage > collection; closures; scoping; contracts; debugging; etc.). I seriously think your best bet is to start learning each language. You can't compare apples and oranges unless you ate them both, and you need to learn that, for instance, you *peel* the orange first, and you avoid the middle part of the apple, and you avoid the seeds of both these fruits (but they are considered the best parts of other fruits.) It'll take the most time, but it'll be the most satisfying answer, as programming language preferences are pretty personal. I think Python should be the strawberry. It's nice and small, easy to digest, no need to bite chunks out of it, almost all of it is edible, and whatever warts it has are plainly visible from the outside :) I-had-strawberries-for-breakfast-ly y'rs, -- Thomas Wouters <thomas at xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From malcolm at commsecure.com.au Tue Jul 3 03:22:14 2001 From: malcolm at commsecure.com.au (Malcolm Tredinnick) Date: Tue, 3 Jul 2001 15:22:14 +0800 Subject: How to call a method with variing arguments In-Reply-To: <e956b5f1.0107022240.776c1734@posting.google.com>; from meinmailfilter@gmx.de on Mon, Jul 02, 2001 at 11:40:49PM -0700 References: <e956b5f1.0107022240.776c1734@posting.google.com> Message-ID: <20010703152214.A29149@Vetinari.home> On Mon, Jul 02, 2001 at 11:40:49PM -0700, Heiko wrote: > Hello, > I want to do this: > > ClassObject = Class() > ClassObject.Method(Arg1, Arg2, Arg3) > ... > ClassObject.Method(Arg1, Arg2, Arg3, Arg4, Arg5 ....) > ... > ClassObject.Method() > ... > and so on. > > Means that I want to call a method with a variing number of arguments > and the method decides what to do. Define Method as def Method(self, *args): # stuff goes here Inside this method, 'args' will be a tuple of the arguments in the order they are passed and you can do whatever you like with them. Look at the page ref/function.html in the Language Documentation for more information (about halfway down that page). > If possible, it would be nice, if the sequence of the arguments > doesn?t matter, and the method realizes which argument is on which > position (but that is a "nice to have"). I don't really know what you mean here, since I don't know how the function is meant to know which argument belongs where. Cheers, Malcolm -- Kleptomania: take something for it. From stevewilliams at wwc.com Thu Jul 12 13:53:46 2001 From: stevewilliams at wwc.com (Steve Williams) Date: Thu, 12 Jul 2001 17:53:46 GMT Subject: Postgres support References: <gul1kts5l6aolk55o7vguk97uorjd08j9f@4ax.com> <5174eed0.0107061058.5446dac9@posting.google.com> <9i6vm3073b@enews3.newsguy.com> <3B4719E1.C5540B19@wwc.com> <9i7t0k01add@enews3.newsguy.com> <3B47C125.A65E5EAC@wwc.com> <23891c90.0107100801.14066af0@posting.google.com> <3B4B458C.A0F96E5D@wwc.com> <23891c90.0107120037.705cbe74@posting.google.com> Message-ID: <3B4DE4D5.74D41FE4@wwc.com> Paul Boddie wrote: > Steve Williams <stevewilliams at wwc.com> wrote in message news:<3B4B458C.A0F96E5D at wwc.com>... > > Paul Boddie wrote: > > > [snip] > I've corrected your quoting here... > Well, that was a cut and paste from a (nicely) working DCOM server. . . > > OK, so you're using paramstyle as 'qmark', [more snip] Yes. Although dictionaries and named parameters might be nice and 'Pythonic', 'qmarks' are a part of the mental baggage I carry from platform to platform. [snip] > > I was surprised to see Sybase ASA directly supporting ODBC - going > against what Mr Wilson was asserting about its death - but, in > general, I suppose that the greater the number of layers between one's > application and the database system, the greater the risk for > something to fail in obscure ways. I live in eternal fear of 'Function Sequence Error'. > In the case of Sybase ASA, I found > things to be more reliable if I linked mxODBC directly to the library > provided, rather than through the iODBC driver manager. > If only I had the ability on AIX. . . > > > In general, I don't see much emphasis on relational databases in the Python > > jungle. > > I think that it only appears that way because of the low traffic on > the DB-SIG list and because there isn't any other focal point for > database-related activity. > > Paul To contribute software to the database community, one must have a machine; cooperating sysadmins and dbadmins; database software, documentation and libraries; a compiler; machine and personal time; development experience and database experience. The lack of any one of these can prove fatal. For Wintel or Linux and for FSF/Open Source databases such as mySQL or PostGres, these are (perhaps) easily come by. For the mainstream relational databases on other platforms--DB2, Oracle, Sybase--it's hard, hard, hard. To produce something that works uniformly and reliably across multiple types of databases and multiple platforms seems even more difficult. From arne at leithe.spammenot.no Mon Jul 16 23:02:58 2001 From: arne at leithe.spammenot.no (Arne Leithe) Date: Tue, 17 Jul 2001 03:02:58 GMT Subject: Partition Problem References: <tku1tt92ac2g8e@corp.supernews.co.uk> <3B4FBEA0.D5A6DC8A@engcorp.com> <9ioru22pc9@enews4.newsguy.com> <3B5042C2.F821D916@engcorp.com> <9itb14$2oi$1@newsg1.svr.pol.co.uk> <Xns90E0B338278B2arneleitheno@148.122.208.74> <9iv5e9$bru$1@newsg1.svr.pol.co.uk> <fSI47.12086$p7.3693169@news1.rdc2.pa.home.com> Message-ID: <Xns90E1337E8B341arneleitheno@148.122.208.74> "Terry Reedy" <tjreedy at home.com> wrote in news:fSI47.12086$p7.3693169 at news1.rdc2.pa.home.com: > [...] > As for speed, P(50,6) takes 100 seconds on my machine (5427 partitions) > while p6(50) and even p6(70) (26207 partitions) take less that a second > to start printing. P(70,6) would probably take hours to do the same. > Computing exactly what you want with nothing wasted is always best. I disagree :-) What's best in the majority of cases is an algorithm that's readable, maintainable, extensible etc. If speed isn't an issue (and nobody said it would be an issue in this case), there would be no reason whatsoever to optimise it for speed at the cost of the criterias mentioned above. In fact, he stated very well what he wanted - the sets of six numbers to sum up to 17 (and 20). Quite often, though, a more general solution is required. In an algorithm like the one discussed here, we probably want to be able to change: a) The "sum" b) How many numbers to sum up c) The minimum number in b) (including 0) This all depends on the problem domain, though. Depending on the variations from the original problem, speed and memory might become issues, of course. What is important to avoid in any case, though, is repeating code where the number of repetitions depend on one of the criterias (as b above). I pity such code, it's almost as it's alive and begs to be put it out of its misery. Anyway, here is a new version of the algorithm I posted before, this time speed is considered and you can specify criterium b in the function. (You actually specify the maxiumum of slots in the solution - if zeros can be part of the solution the rest can be filled with zeros.) def Bags(res, max_pockets, start = 1): if max_pockets == 1: return [[res]] return [[i] + bag for i in range(start, res / 2 + 1) \ for bag in Bags(res - i, max_pockets - 1, i)] + [[res]] > To solve this problem for any k using this approach, we could write a > program that will write and compile the python code for a particular > value of k (using x1 to xk instead of a to whatever). But the said approach is very, very unmaintainable, even though it might be "exactly what he wants" in this case. Arne Leithe From eppstein at ics.uci.edu Mon Jul 23 11:17:09 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Mon, 23 Jul 2001 08:17:09 -0700 Subject: A use for integer quotients References: <mailman.995866298.23496.python-list@python.org> <eppstein-E19F08.00451323072001@news.service.uci.edu> <3B5BDCB4.A2010560@letterror.com> Message-ID: <eppstein-73449E.08170923072001@news.service.uci.edu> In article <3B5BDCB4.A2010560 at letterror.com>, Just van Rossum <just at letterror.com> wrote: > Do you really want 2047 bytes to be shown as 1 kbyte? Integer division > is a lousy tool in this particular example... In an unrelated program I had some more complicated code (in a different language, which is why I didn't reuse it) that would take a number n, and output n itself, n/1000 + "k", or n/1000000 + "M", where the output number was either an integer of two or three digits, or a decimal with a single digit on either side of the decimal point. So 2047 would have been '2.0k'. (Don't argue with me about decimal vs binary k, this was to output number of nodes in a search space not file sizes.) In the current program, the sizes being shown are for the original un-shrunk images from a digicam, and are never anywhere near as small as 2047 bytes, so I used simpler logic to simplify the size output. In both cases, I want integer divisions (in the other program, even the decimals were formatted using integer division). -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From emile at fenx.com Fri Jul 6 11:58:25 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 6 Jul 2001 08:58:25 -0700 Subject: Maintaining the Python FAQ References: <mailman.994428256.27172.python-list@python.org> <cpvgl6jbyz.fsf@cj20424-a.reston1.va.home.com> Message-ID: <9i4neh$h1jne$1@ID-11957.news.dfncis.de> The first reference to the faq on python.org does this. It's not so much a question of why would you, more so how could you not the first time. Maybe drop the complete reference on the front page, leaving the reference to it on the faq wizard page so that you know when clicking it that you'll get a bunch. http://python.org/doc/FAQ.html -- Emile van Sebille emile at fenx.com --------- "Guido van Rossum" <guido at python.org> wrote in message news:cpvgl6jbyz.fsf at cj20424-a.reston1.va.home.com... > Oleg Broytmann <phd at phd.fep.ru> writes: > > > On Fri, 6 Jul 2001, Guido van Rossum wrote: > > > Hm. To what extent is the current FAQ wizard a problem for its > > > > For me the biggest problem is not the FAQ Wizard, but FAQ.html - it is > > too big. 270K is too big for the Net. Let us split it intopages. > > Huh? The FAQ wizard gives you plenty of ways to access individual > items or sections. Why would you ever download the whole FAQ? > > --Guido van Rossum (home page: http://www.python.org/~guido/) From paulp at ActiveState.com Thu Jul 12 13:32:39 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Thu, 12 Jul 2001 10:32:39 -0700 Subject: Assignement Overloading References: <3b48bd83$0$7113$4d4efb8e@news.be.uu.net> Message-ID: <3B4DDF36.EFAED7F5@ActiveState.com> Pierre Denis wrote: > > I am trying to emulate some kind of type checking in Python (sorry for the heresy). Because of the dynamic typing, my unpretentious > goal is to intercept the assignment statement in order to perform a consistency check between the variable and the object to assign. I'd suggest you look at for ideas or even a starting point: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/nondist/sandbox/typecheck/ -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From jkraska1 at san.rr.com Wed Jul 4 11:36:52 2001 From: jkraska1 at san.rr.com (Courageous) Date: Wed, 04 Jul 2001 15:36:52 GMT Subject: Two problems with backslashes References: <Xns90D4A141E71CDgustaflalgonetse@194.213.69.148> <mailman.994256588.17929.python-list@python.org> Message-ID: <bde6kt0c8f8fdfcf204qprakatj9v9ooa2@4ax.com> > path = r'e:\test\test.txt' What am I looking at here, and how do Iearn more about it? IOW, what's the 'r' do, and is there more to this? C// From new_name at mit.edu Fri Jul 20 23:45:55 2001 From: new_name at mit.edu (Alex) Date: 20 Jul 2001 23:45:55 -0400 Subject: whats this mean? References: <20010720213533.19217.00000446@ng-fb1.aol.com> Message-ID: <etdhew754i4.fsf@lola-granola.mit.edu> See http://www.python.org/doc/ref/try.html#l2h-439 for the syntax of try/except. "except socket.error, why" assigns the value raised with the exception to the name "why". Play with this a bit: >>> try: raise SyntaxError('example') ... except SyntaxError, why: print why ... example >>> Alex. From steve at lurking.demon.co.uk Mon Jul 23 00:35:01 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Mon, 23 Jul 2001 05:35:01 +0100 Subject: Pedants R us (was RE: Language change and code breaks) References: <mailman.995851359.16397.python-list@python.org> Message-ID: <3d8nltsgmc6cs0rq35oopkk9u97ohlea7c@4ax.com> On Mon, 23 Jul 2001 11:21:11 +1000, "Delaney, Timothy" <tdelaney at avaya.com> wrote: >> >Guido van Rossum wrote: >> >> In my usage, a "programmer" is someone who is a >> >> professional code-slinger, 8-12 hours a day. >> > >> >Eek - I hope you don't really mean that last subclause! >> >> A *real* programmer gets in a good six hours code-slinging in their >> sleep - that period when all the hard problems find their neat >> original solutions. Apart from the ones that get scribbled on a >> beer-mat, that is ;-) > >Nah - all the best solutions are worked out in the shower. > >I am currently campaigning for all programmer's cubicles at my place of work >to have showers installed. I predict that productivity will increase 5-fold. Apart from one small problem. Half the company will be hanging around female programmers cubicles to, erm, discuss their programming problems ;-) From donn at u.washington.edu Mon Jul 16 13:12:46 2001 From: donn at u.washington.edu (Donn Cave) Date: 16 Jul 2001 17:12:46 GMT Subject: Python, C++, Java, Smalltalk, Eiffel,... References: <9is8rm$46d$1@panix3.panix.com> <slrn9l5ngp.87g.jajvirta@sirppi.helsinki.fi> Message-ID: <9iv7ae$gs0$1@nntp6.u.washington.edu> Quoth jajvirta at cc.helsinki.fi (Jarno J Virtanen): | 15 Jul 2001 10:20:38 -0400 kj0 wrote: | > Where can I find a reasonably non-partisan but also reasonably | > detailed comparison of the more popular OO languages (C++, Java, | > Python, etc.). | [snip] | | Here's one: http://www.lib.uchicago.edu/keith/crisis/ | | It's subjective, but he clearly states what he wants and then ranks | programming languages according to the criterias. Interesting reading. He says "crisis", but it seems to be several years since - hope it was resolved meanwhile, but maybe it's a good thing to be always searching a little. One thing about this and other comparisons to be seen on the web, OCaml belongs on the list if only for its speed. I have been trying to learn a little of it lately. He mentions that the syntax is full of annoying warts, and my forehead is getting permanent wrinkles from too much squinting. But it's interesting that such an abstract model (function programming) would run so close to the top of the charts for speed. (And too bad that doesn't work for Erlang or Haskell.) And there are some good things - e.g., something as simple as a record type (a.k.a. struct), for which I still hanker a bit with Python. Donn Cave, donn at u.washington.edu From tundra at tundraware.com Tue Jul 31 15:00:02 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 31 Jul 2001 19:00:02 GMT Subject: Long: Python Is Really Middleware References: <3B667EBA.DA6C298@tundraware.com> <3B66F611.B12948A6@tundraware.com> <3B66FC0F.965568C0@ActiveState.com> Message-ID: <3B66FECB.90597896@tundraware.com> Paul Prescod wrote: > > I would suggest you use "index.html" to shorten that URL. :) Sheesh, there's a critic in very crowd... OK, if you insist, URL changed to: http://www.tundraware.com/Technology/Python-Is-Middleware/index.html or just http://www.tundraware.com/Technology/Python-Is-Middleware -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From max at alcyone.com Tue Jul 24 20:49:28 2001 From: max at alcyone.com (Erik Max Francis) Date: Tue, 24 Jul 2001 17:49:28 -0700 Subject: Bug? References: <4835e825.0107241639.bbf438e@posting.google.com> Message-ID: <3B5E1798.B44E7B0D@alcyone.com> Ricardo Correia wrote: > --------------------------------------------------- > mainlist = [1, 2, 3, 4, 5] > copy = mainlist > > for item in copy: > print item, > mainlist.remove(item) > --------------------------------------------------- > > Shouldn't this produce '1 2 3 4 5'? > > I only get '1 3 5' and unfortunately because of this my program > doesn't work. The problem is that the variable named copy isn't a copy, it's a reference. Try instead: copy = mainlist[:] # now copy is truly a copy -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ What is now prov'd was once only imagin'd. \__/ William Blake Alcyone Systems' Daily Planet / http://www.alcyone.com/planet.html A new, virtual planet, every day. From clpy at snakefarm.org Wed Jul 11 08:47:13 2001 From: clpy at snakefarm.org (Carsten Gaebler) Date: Wed, 11 Jul 2001 14:47:13 +0200 Subject: Bug in __imul__ References: <9ihg33$irjha$1@ID-11957.news.dfncis.de> Message-ID: <3B4C4AD1.BB994EFD@snakefarm.org> Emile van Sebille wrote: > > Does it bother anyone that > > a *= 3 + 4 > > returns a different value from > > a = a * 3 + 4 > > ?? No, because a *= 3 + 4 means a = a * (3 + 4). No bug here. cg. From info at black-karma.de Thu Jul 12 16:04:01 2001 From: info at black-karma.de (Harvest T. Moon) Date: Thu, 12 Jul 2001 22:04:01 +0200 Subject: win32gui Message-ID: <9ikvsg$jim2i$1@ID-22517.news.dfncis.de> hi :) is there any tutorial/documentation on how to use the ActiveState Win32GUI extension? thnx i.a., Harvest T. Moon -- a life less ordinary!! From Gareth.McCaughan at pobox.com Wed Jul 25 17:28:14 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Wed, 25 Jul 2001 22:28:14 +0100 Subject: A use for integer quotients References: <mailman.995866298.23496.python-list@python.org> <cpzo9veuml.fsf@cj20424-a.reston1.va.home.com> <230720010741551768%jwbaxter@spamcop.com> <cpae1tboxg.fsf@cj20424-a.reston1.va.home.com> <4h0tltgbrn2b50mueqd2vsgtt3psvkvosv@4ax.com> Message-ID: <slrn9luefe.5a2.Gareth.McCaughan@g.local> Stephen Horne wrote: [GvR:] > >Well, so far the only arguments I've heard come down to > > > >(1) int/int *ought* to return an int; > ... > >IMO, argument (1) is misguided. I've heard all the variations many > >times by now and none are convincing to me; they are either wrong, > >like "that's how mathematicians define it" or "that's how all > >right-thinking programming languages define it", or they miss the > >point, like "it's easy to explain to newbies that int/int returns > >int". > > Please read my 'Steve Summary' message - it addresses all these and > more. > > If you can prove that the set of mathematicians only includes those > who are dealing with the currently interesting discrete-mathematics > problems, or you can prove that magically warping discrete measures > into continuous measures is useful for typical bread-and-butter > programming tasks, I'd be interested to hear it. > > I define a mathematician as someone who applies mathematics, and who > understands the mathematical principles being applied. I don't limit > it to people working in field theory or some such, however interesting > it may be and however pervasive it may be in current > college/university study and specialist application of discrete > mathematics. Any narrowing of that definition should be explicit or at > least for day-to-day practical reasons. > > I define practical as the normal case, not the first-day newbies > expectations and not specialist fields. I am a professional applied mathematician. I was trained as a pure mathematician. 1/2 is not 0. I have never knowingly met a mathematician or any persuasion who thought that 1/2 was 0. By the way, any definition of "mathematician" that excludes pure mathematicians is spectacularly broken. -- Gareth McCaughan Gareth.McCaughan at pobox.com .sig under construc From grante at visi.com Mon Jul 23 10:53:47 2001 From: grante at visi.com (Grant Edwards) Date: Mon, 23 Jul 2001 14:53:47 GMT Subject: PEP0238 lament References: <mailman.995814276.15005.python-list@python.org> <slrn9lm3u8.as.sill@sill.silmarill.org> <5sdnlt072hm6hp17nluu6f0fqq4bvr6mj8@4ax.com> Message-ID: <%TW67.22987$B7.3756018@ruti.visi.com> In article <5sdnlt072hm6hp17nluu6f0fqq4bvr6mj8 at 4ax.com>, Stephen Horne wrote: >On Sun, 22 Jul 2001 17:40:10 GMT, sill at optonline.net (Rainy) wrote: > >>First of all, it's really ugly. It's the ugliest thing in python for a newbie, >>imho. Yes, 1/2 is 0. You have to type 1.0/2 to get 0.5. No, there is no good >>reason for that, just memorize it. Ugh. > >No reason! > >Every five-year-old knows that 5 divided by 2 is 2 remainder 1. What >is the problem? > >Integer division *is* important. Confusing integers and floats is a >sign of sloppy thinking, and a clue that far more bugs are going to >result. Right. If you want redesign the language to prevent programmers from creating bugs due to using the wrong numeric data types, then you're only hope is to eliminate all but one of the numeric types, and that numeric data type better do what everybody expects all the time. Can't be done. -- Grant Edwards grante Yow! I always have fun at because I'm out of my visi.com mind!!! From grumble at usa.net Tue Jul 10 16:24:00 2001 From: grumble at usa.net (jcm) Date: 10 Jul 2001 20:24:00 GMT Subject: Python speed References: <roG27.666914$166.13798179@news1.rdc1.bc.home.com> <pXG27.1312$M9.140003@typhoon.we.rr.com> <9ifjjh$1e3$1@news.mathworks.com> <3B4B562F.77C1B79@yahoo.com> Message-ID: <9ifo90$4hh$1@news.mathworks.com> Paul Winkler <slinkp23 at yahoo.com> wrote: > jcm wrote: >> >> Pete Shinners <shredwheat at mediaone.net> wrote: >> ... >> >> > for doing a MUD, the language speed is not going to have >> > much noticeable effect, since network speed is far slower >> > than any of the languages can handle. >> >> This isn't necessarily true. If you have a lot of objects with state >> that changes often (wandering monsters, etc), computation-speed can >> become an issue. > I still don't see why python wouldn't be up to the job. > If things are working well but too slowly, it's time to think about > optimization. Well, I say this because I've written a mud engine in Python and it's slow. Using this engine on a PII 266 running RedHat 6.1, 400 wandering monsters (with nothing else going on in the mud) will peg the cpu. In a production mud, you might want to do something intelligent about wandering monsters (like have them stop wandering if no players are nearby to save cpu-time), but there will also be lots else going on. There might be some clever optimizations that could be made. Anyway, my only point was that computation-speed can become an issue. From reageer.in at de.nieuwsgroep Sun Jul 8 11:03:30 2001 From: reageer.in at de.nieuwsgroep (Rene Pijlman) Date: Sun, 08 Jul 2001 17:03:30 +0200 Subject: [ZOPE] External Method process limits? References: <9i9rmn$kc6$1@node21.cwnet.roc.gblx.net> Message-ID: <detgkt4tbklojg2lothn6jm6ak0pnls874@4ax.com> missive at frontiernet.net (Lee Harr) schreef: >Here is the error message I get: >Error Type: TypeError >Error Value: expected string, ImplicitAcquirerWrapper found >File /usr/local/www/Zope/Extensions/Thumbnail.py, line 18, in makeThumbnail >Any wisdom? Yes, the error is on line 18 of /usr/local/www/Zope/Extensions/Thumbnail.py :-) Post lines 1-25 if you want more help. -- Vriendelijke groet, Ren? Pijlman <rpijlman at spamcop.net> Wat wil jij leren? http://www.leren.nl/ From s713221 at student.gu.edu.au Fri Jul 20 22:20:18 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Sat, 21 Jul 2001 12:20:18 +1000 Subject: Language change and code breaks References: <6957F6A694B49A4096F7CFD0D900042F27D55F@admin56.narex.com> <mailman.995575532.23146.python-list@python.org> Message-ID: <3B58E6E2.A88F3206@student.gu.edu.au> Guido van Rossum wrote: > > > TRuE, tHe ExPRESsiVity oF ThE lANGuaGE is ProBAbLY nOt cRipPled, > > hOWEvEr, tHere ARe SigNIficantLy FeweR ideNtIFIeRs AVaILABlE whICh mEAns > > iT is LESs eXPRessIvE. IN pArTicULar, cOMmON Idioms liKE naMiNg CLASseS > > stArTiNg WiTh UppER cASE lETtERS, AND instaNCeS OF THose cLAsSes > > begINNiNG with A lOwER caSE LettER CaN NO LongeR Be usED. > > Very funny (not). You misunderstood the intention. The programming > environment should be case-preserving, and automatically correct > identifiers to use the same case as used when they were defined. Okay *interested* Does this mean if I do this: >>> a Traceback (most recent call last): File "<stdin>", line 1, in ? NameError: name 'a' is not defined >>> A = aclass(...) >>> a (returns A) I'd have to try it out to see what it would be like, but I'd still prefer if I got an error message when I did the following: >>> a = anotherclass(...) Hmmm. I don't know if it would be sensible to be draconian, but if this did raise an *Error, it would enforce users to avoid the c=C() convention. Question is, is learning this feature ( "NO. *whack* You can't do c=C()"), bad coding practice that it is, easier than learning to deal with case-sensitivity? Hmmmm. My vote is still on more helpful NameError messages that attempt to track down different-cased variables. It'd be using similar code as a case-preserving system, but not going as far as returning an instance which may or may not be the instance that the programmer wants. Anycase *placing his trust in Guido's expertise* -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From kens at sightreader.com Thu Jul 26 16:32:40 2001 From: kens at sightreader.com (Ken Seehof) Date: Thu, 26 Jul 2001 13:32:40 -0700 Subject: how on earth do i get a drive list? References: <9jpqlh$phf$1@uranium.btinternet.com> Message-ID: <01cd01c11612$1ea47000$6501a8c0@pacbell.net> import string, os def drives(): d = [] for c in string.lowercase: if os.path.exists('%s:/'%c): d.append('%s:'%c) return d >>> drives() ['a:', 'c:', 'd:', 'g:'] Cheers, - Ken Seehof ----- Original Message ----- From: "G. Willoughby" <thecalm at NOSPAM.btinternet.com> Newsgroups: comp.lang.python To: <python-list at python.org> Sent: Thursday, July 26, 2001 12:23 PM Subject: how on earth do i get a drive list? > how on earth do i get a drive list? i've been searching for a command to > display a tuple or list containing all available drives, but i can't find > it! is it just me or are the standard python docs quite confusing. oh well > any ideas out there? > > G. Willoughby > > > -- > http://mail.python.org/mailman/listinfo/python-list From tom-list at home.com Mon Jul 30 14:32:05 2001 From: tom-list at home.com (Tom) Date: Mon, 30 Jul 2001 14:32:05 -0400 Subject: Typing system vs. Java References: <mailman.996258291.15055.python-list@python.org> <psog0besc97.fsf@jekyll.curl.com> Message-ID: <3b65a820_7@Usenet.com> "Christopher Barber" <cbarber at curl.com> wrote in message news:psog0besc97.fsf at jekyll.curl.com... > <brueckd at tbye.com> writes: > > > In most jobs I've used C/C++ or Java and for me the stronger the typing > > rules the more problems (and in turn bugs) it caused. > > I am really surprised to hear this. My experience has been the opposite. I agree with you. Strong typing can be very useful. Its better to have the compiler catch an error than to catch it during unit testing. The ideal language would support both strong and weak typing. Tom. > > For example, if I need to store a list of points and color > > values I can't just make an array of (x,y,color) tuples. I need to > > create a class to hold them and then create instances and store them in > > an array or Vector. > > You seem to be complaining about the lack of tuples, not static type-checking > per-se. > > > Strong typing seems to prevent a very small class of errors at great > > expense, and none of the errors it prevents should escape good testing > > (which you should have anyway). > > I am all for unit testing, but I know from experience that it is *extremely* > difficult to comprehensively test a code unit, and virtually impossible if you > do not have a good code coverage tool. If the compiler can catch a type error > for me at compile-time, that is at least one less unit test I have to write. > > I agree that static type declarations add complexity to a language, but there > is a significant body of developers that really appreciate what they can do > for you. It would really be nice if Python could add some sort of optional > type declarations. It should be technically feasible. > > - Christopher Posted Via Usenet.com Premium Usenet Newsgroup Services ---------------------------------------------------------- ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY ** ---------------------------------------------------------- http://www.usenet.com From thomas.heller at ion-tof.com Mon Jul 2 09:25:18 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Mon, 2 Jul 2001 15:25:18 +0200 Subject: win32gui References: <9hpg2o$f4pdk$1@ID-59885.news.dfncis.de> <3B406737.1030707@ActiveState.com> Message-ID: <9hpsk9$fd0vh$1@ID-59885.news.dfncis.de> "Mark Hammond" <MarkH at ActiveState.com> wrote in message news:3B406737.1030707 at ActiveState.com... > Thomas Heller wrote: > > > All this (basically) works, the window is shown, > > but nothing is printed from the test function. > > Wading with the debugger through the code, it seems > > the 'test' function is never called. > > The reason seems to be that the default window-proc > > from win32gui is called, and SetClassLong() is never > > called with 'test' as the parameter. > > Has anyone got this to work? Am I doning something wrong? > > > It is supposed to work, but I can't find any example code. I found the mistake I made: CreateWindow() should have used the atom-name _returned_ by the RegisterClass() call and _not_ the lpszClassName member of WNDCLASS. Thanks Thomas From sholden at holdenweb.com Tue Jul 31 13:12:08 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 31 Jul 2001 13:12:08 -0400 Subject: error occur when using py2exe References: <mailman.996506697.27250.python-list@python.org> <3b66e351.4492439@news.onemain.com> Message-ID: <aCB97.12856$WD1.527988@e420r-atl2.usenetserver.com> <engsol at teleport.com> wrote in message news:3b66e351.4492439 at news.onemain.com... > On Mon, 30 Jul 2001 23:23:02 +0800 (CST), "sdf" <wqh-2 at 263.net> wrote: > > >I type the following,but error appear. > > >I put the the myscript.py file under d:/python21/program/ > > >I think I must give a directory to the setup ,but when I use > > >setup(name="myscript",scripts=["/program/myscript.py"],) > > >error also jump out. How can I fix it > > Don't you need to 'escape' the path slashes? > > "C:\\dir\\file.py" for example? > > engsol (python newbie) Backslashes ("\") need escaping as you suggest, but forward slashes ("/") have no special semantics inside string literals, and can therefore be used without any escaping. In *most* (but, annoyingly, not quite all) contexts, your Windows Python programs can use forward slashes instead of backward ones inside paths, and still be perfectly well understood. This is how the original poster was handling the problem. Nice to see a newbie jumping in to help, though. Your instincts are fine. Keep up the good work! regards Steve -- http://www.holdenweb.com/ From m.faassen at vet.uu.nl Mon Jul 23 18:27:30 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 23 Jul 2001 22:27:30 GMT Subject: PEP0238 lament References: <mailman.995915981.12340.python-list@python.org> Message-ID: <9ji8ci$ciq$2@newshost.accu.uu.nl> Tim Peters <tim at digicool.com> wrote: > [Martijn Faassen] >> This discussion is entirely self selected too. What I'm pointing >> out is that your 3/4 number is fairly meaningless in this discussion. > In context, it was a directly relevant response to a question of Arthur's > that had gone unanswered. Out of context, it may was well be blue cheese. Okay, sorry I took it out of context; I realized this when I saw another reply of yours. > I'm afraid this whole thread has turned into too much "typical Usenet" > excess to be worth the effort of following it anymore. You're right -- it's one of those issues (like case sensitivity) that everybody has some opinion about and everybody can easily talk about. Sort of like the way everybody in a company for which a website is being developed will be able to talk about the way the layout should look like (cool, stylish! but will fail to actually do much thinking about the content, which is what a website is actually all about. Withdrawing from the thread. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From gerhard.nospam at bigfoot.de Tue Jul 3 11:49:28 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Tue, 3 Jul 2001 17:49:28 +0200 Subject: Postgres support References: <gul1kts5l6aolk55o7vguk97uorjd08j9f@4ax.com> <slrn9k1plb.2hd.gerhard.nospam@lilith.hqd-internal> <mailman.994116064.9517.python-list@python.org> <aie3kt8r1i8qego0sfqh30qhupqtaje19a@4ax.com> Message-ID: <slrn9k3noj.4e5.gerhard.nospam@lilith.hqd-internal> Some more random quabble from me ... On Tue, 03 Jul 2001 08:33:43 -0400, robin at illusionsexeculink.com wrote: >Skip Montanaro <skip at pobox.com> wrote: > >>You can do one of three things: >> >> * implement it and keep it to yourself >> * implement it and release it for others to use/improve >> * find someone willing to do it for you for a fee (perhaps a fee of $0) > >It would have to be #3 for me, as I am not C proficient. I thought >that an appeal to this knowledgable group was in order first, and this >seems to have produced a comprehensive low-level answer by Gerhard. > >What is still needed is a high-level perspective on the greater >problem of providing a Python distribution that is "ready for action" >across major database and OS platforms. I am quite happy with the database modules I use. If they have too many bugs or missing functionality for you, you should tell the maintainers and perhaps use option #3. If all you want is a packaged version of Python with database modules included, this can be done relatively easy. It's mostly a packaging issue. I don't quite get the point of this, though. Providing automatic downloading and installation of binary packages is an issue that is dealt with in the Catalog SIG and others. I personally want to have RPMs on Linux and for deployment on Windows, I would create my own custom installer, which isn't all that difficult since py2exe does most of the job for me. >I hope someone at python.org or ActiveState or somewhere is aware of >this need and are working to fill it. The ActiveState installer on win32 already has the option of installing MySQLdb. I don't know if they plan to extend this to other platforms and modules, though. Gerhard -- mail: gerhard <at> bigfoot <dot> 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 rossi at earthling.net Sat Jul 14 08:12:38 2001 From: rossi at earthling.net (Thorsten Roskowetz) Date: Sat, 14 Jul 2001 14:12:38 +0200 Subject: FrameMaker exposed in Python (PyMaker anyone)? References: <9in4dk$eap$06$1@news.t-online.com> <9inm6l$jirpg$1@ID-7529.news.dfncis.de> Message-ID: <9ipcss$467$03$1@news.t-online.com> "Karl M. Syring" <syring at email.com> schrieb: > "Thorsten Roskowetz" <rossi at earthling.net> schrieb > > Hi, > > > > is there a Python extension that allows scripting of the > > FrameMaker API. Google (and www.python.org) pointed me > > to a project called PyMaker but the link is dead > > (http://home.t-online.de/home/Ulrich.Herold/). > > No, the page is alife! > > Karl M. Syring Ulrich's homepage is alive, yes. But not the link to PyMaker itself. Thorsten From guido at python.org Wed Jul 25 01:06:51 2001 From: guido at python.org (Guido van Rossum) Date: Wed, 25 Jul 2001 05:06:51 GMT Subject: from __past__ import integerDivision (was Re: A modest PEP0238 suggestion) References: <3b5c6e08.27535083@aplnews> <kr2pltsb9gmehe4vtqm8so37924tdfs59s@4ax.com> <9jiak1$3s96$3@node21.cwnet.roc.gblx.net> Message-ID: <cpwv4xa97a.fsf@cj20424-a.reston1.va.home.com> missive at frontiernet.net (Lee Harr) writes: > I think this is what the PEP is proposing: > > // is current / behaviour > / is new int/int --> fp No, a//b would always return floor(a/b). > we already have people importing things from the __future__, > how difficult would it be to let people drag things from the __past__? This has been suggested before. It's just as easy (in fact in a sense it's easier, since you know what the past was, but you may be wrong about what the future might bring :-). But the problem (as I see it) is that there will never be a point where we can throw away support for the past behavior, because there will always be code around that imports it. The future statement doesn't have this problem -- at some point, you're *there* and the future statement is redundant. Of course, the __future__ module must remember all the names of future features, but the support everywhere else in Python can be removed. > It would certainly make maintaining old applications that rely > on the old behaviour much easier to port over to the new one. Or you keep a copy of the old interpreter around. If you are unwilling or unable to upgrade the application, I see no reason to switch to a different language either. --Guido van Rossum (home page: http://www.python.org/~guido/) From fgeiger at datec.at Tue Jul 3 11:12:05 2001 From: fgeiger at datec.at (Franz GEIGER) Date: Tue, 3 Jul 2001 17:12:05 +0200 Subject: Eiffel better than Python ? References: <f20ea932.0107030100.6c740683@posting.google.com> <9hsf0c0210e@enews1.newsguy.com> Message-ID: <9hsnd3$7h3$1@newsreaderg1.core.theplanet.net> I am curious: What do you Haskell use for? Regards Franz P.S.: I know that your bag of tools contain at least Python, (MSV)C++, MSVB, and Haskell. Curious again: How do you use your bag of tools? "Alex Martelli" <aleaxit at yahoo.com> wrote in message news:9hsf0c0210e at enews1.newsguy.com... > "Tomasz Stochmal" <tom at peresys.co.za> wrote in message > news:f20ea932.0107030100.6c740683 at posting.google.com... > > I have read the following book which gives C/C++ heavy bashing > > > > http://www.elj.com/cppcv3/ > > > > Conclusion is to use Java or even better choice is Eiffel > > > > Should I stop using Python and jump on Eiffel wagon ? > > > > Anybody that tried both languages ? > > > > How do they compare ? > > Eiffel has reasonably-good strict, compile-time typing. > > Python is totally oriented to dynamic, run-time typing > (often erroneously called "weak typing" -- that is, in > fact, something else). > > So, they don't compare much: they've taken widely > different language-design choices from way back. Eiffel > will do a good job of finding type mismatches at compile > time (not a perfect one due to the covariance problem), > Python won't even try and will rather maximize your > productivity so you can most easily and productively > develop and run lots and lots of tests (you need to test > a LOT even in a compile-time-typed language of course, > but it does occasionally diagnose an error earlier -- in > exchange, you have to do a lot more work, of course). > > If you want a language that's even LESS compromising > than Eiffel in terms of typing, with *NO* possibility > whatsoever of a typing-error escaping the compiler, > try Haskell instead. It's VERY instructive to become > productive in Haskell, and it's fun if you do it with > a book such as Hudak's "The Haskell School of Expression". > > Then you can come back to Python with much deeper > appreciation for the role of immutability, list > comprehensions, functional programming, type deduction > by the compiler (Eiffel doesn't do that for you: you > have to tell the compiler everything -- Haskell is > designed so the compiler can DEDUCE types on your > behalf, although you do normally, redundantly, also > state them "out loud" so the compiler can catch your > logic mistakes). When you're back to Python from > Haskell I suspect you'll miss Haskell's typeclasses, > such an UTTERLY elegant approach!, and the implied > lazy-evaluation of everything, perhaps the syntax > sugar that allows any function to be used as an infix > operator. I think you WON'T miss Haskell's "monads", > a concept so powerful, refined and elegant that its > full import keeps escaping most of us:-). In syntax > sugar terms, Haskell will give you significant whitespace > use that's not too far from Python, but you'll see lots > of (well-used) punctuation in lieu of keywords -- not > a big deal either way, of course. > > In the end, I think Python is far more productive > for all kind of real-world uses, but an apercu on > statically-type-checked, nothing-is-mutable, lazy- > everything, &c, IS interesting and instructive. > Eiffel only does *part* of that for you... > > > Alex > > > From achim.domma at syynx.de Tue Jul 31 16:59:08 2001 From: achim.domma at syynx.de (Achim Domma) Date: Tue, 31 Jul 2001 22:59:08 +0200 Subject: Large pages using Zope Message-ID: <9k766t$dc0$04$1@news.t-online.com> Hi, I just finished the first step : I succeded in introducing Python as our prefered scripting language, replacing JScript and VBScript in the future. Now we need a way to script webpages with it. I would like to use Zope, but I have to answer questions like 'How do we know that it's fast/stable enough ?'. Can anybody help ? Are there any big references, which are using Zope ? thanks Achim From wqh-2 at 263.net Tue Jul 31 07:51:47 2001 From: wqh-2 at 263.net (sdf) Date: Tue, 31 Jul 2001 19:51:47 +0800 (CST) Subject: how to know the end of a file(use readline) Message-ID: <3B669BD3.11778@mta5> I use readline to process the whole ,but I do not know how to control it,when it is the end of the file __________________________________________ DVD??????????10?? http://shopping.263.net/category02.htm ?????????????????????? http://shopping.263.net/category10.htm From Randy.L.Kemp at motorola.com Fri Jul 13 11:22:16 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Fri, 13 Jul 2001 11:22:16 -0400 Subject: Book count test Message-ID: <E566B020833BD311B6610008C791A39705CA5242@il93exm04.css.mot.com> I went to www.amazon.com and counted the number of books in these categories Python - 136 (including snake books) Java - 1621 Perl - 430 C++ - 1341 PHP - 38 ASP - 172 Oracle - 682 From eppstein at ics.uci.edu Mon Jul 30 01:13:18 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Sun, 29 Jul 2001 22:13:18 -0700 Subject: [OT] Number theory [Was: A use for integer quotients] References: <yCK67.17615$EP6.4467503@news1.rdc2.pa.home.com> <mailman.995860718.9550.python-list@python.org> <mailman.995862939.15013.python-list@python.org> <mailman.995883879.12071.python-list@python.org> <3B5C5665.8D41D1F1@tundraware.com> <slrn.pl.9los0f.jh4.qrczak@qrnik.zagroda> <3B5C749A.59F97320@tundraware.com> <JDa77.97061$Rr4.549007@ozemail.com.au> <Xns90E97C9849AD5robindotgarneratinam@172.18.25.3> <IjA77.97824$Rr4.589251@ozemail.com.au> <3b602afa.930850@nntp.sprynet.com> <slrn9m121m.e6f.Gareth.McCaughan@g.local> <3b617133.1013412@nntp.sprynet.com> <slrn9m3ssq.1c5.Gareth.McCaughan@g.local> <3b62c8c4.2448381@nntp.sprynet.com> <slrn9m61e6.1jof.Gareth.McCaughan@g.local> <3b6409e0.2079581@nntp.sprynet.com> <3b645f76.747435355@wa.news.verio.net> Message-ID: <eppstein-CF33D7.22131829072001@news.service.uci.edu> In article <3b645f76.747435355 at wa.news.verio.net>, bokr at accessone.com (Bengt Richter) wrote: > ISTM that thinking of bit twiddling as operating on integers > is not clean conceptually. I.e., I think there is an implicit > coercion to a set type for the twiddle operation and then implicitly > back to integer again when supposedly twiddling two integers > with a binary twiddling operation (same for unary, of course). Bit-twiddling operations like bitwise xor are generally not nice continuous operations on (binary representations of) real numbers, e.g. because 0.11111... and 1.00000... are the same as real numbers but very different as bitstrings. However, I think bit twiddling is nice and continuous if instead you use 2-adic numbers (overcondensed tutorial: 2-adic integers are binary numbers where the bit sequence goes to infinity to the left instead of to the right, e.g. 3 1/4 = .....000011.01 -- just apply usual 2's complement arithmetic to these sequences and everything works). Of course, this doesn't do much for your attempt to make this thread relevant to Python again... -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From gustafl at algonet.se Sat Jul 14 20:59:20 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 15 Jul 2001 00:59:20 GMT Subject: Importing XML modules in py2exe or Installer? References: <Xns90DE9C2957BDgustaflalgonetse@194.213.69.152> <Xns90DE68B66343Agmcmhypernetcom@199.171.54.154> <Xns90DEC227B102Cgustaflalgonetse@194.213.69.148> <Xns90DE9C0C61AFAgmcmhypernetcom@199.171.54.155> Message-ID: <Xns90DF1E7FD2E35gustaflalgonetse@194.213.69.152> Gordon McMillan <gmcm at hypernet.com> wrote: >So put the line >packages=_xmlplus >in the APPZLIB section. Okay, now I used Standalone first. Got a .cfg file and changed it according to the above. Then I ran in again with Builder. Is this really the normal operation? I had expected to first make a config file and then make an exe, or that you would get an opportunity to save the modified config file and run Standalone on it again. But I guess this is a special case, and the second run is normally not needed. When I run Builder, I get the following two warnings (among many others that seem non-significant): W: __import__ hack detected at line 54 of xml.dom.domreg W: __import__ hack detected at line 100 of xml.sax Does this mean that the import of the XML modules wasn't successful? My script needs a special config file, written in XML, in the same directory as the script itself. I was happy to see that before I had added the XML file to this directory, jane.exe complained in the right way: E:\python\gustaf\dist_jane>jane No profiles file found. However, when I add the XML file to the directory, it fails: E:\python\gustaf\dist_jane>jane Traceback (most recent call last): File "<string>", line 54, in ? File "e:\python\gustaf\friend.py", line 19, in __init__ self.profile = self.load() File "e:\python\gustaf\friend.py", line 31, in load doc = parse(self.file) File "e:\python\_xmlplus\dom\minidom.py", line 839, in parse return _doparse(pulldom.parse, args, kwargs) File "e:\python\_xmlplus\dom\minidom.py", line 830, in _doparse events = apply(func, args, kwargs) File "e:\python\_xmlplus\dom\pulldom.py", line 288, in parse parser = xml.sax.make_parser() File "e:\python\_xmlplus\sax\sax2exts.py", line 34, in make_parser return XMLParserFactory.make_parser(parser_list) File "e:\python\_xmlplus\sax\saxexts.py", line 75, in make_parser sys.modules[parser_name].create_parser = _create_parser KeyError: xml.sax.drivers2.drv_pyexpat I take it as a sign that the XML modules can't be found. Is there anything I can do to facilitate the search for extra modules? Have already tried to use an absolute path. Regards, Gustaf Liljegren From PeterPanCrunchy at rebeccaphillips.com Thu Jul 19 13:24:55 2001 From: PeterPanCrunchy at rebeccaphillips.com (PeterPanCrunchy at rebeccaphillips.com) Date: Thu, 19 Jul 2001 17:24:55 -0000 Subject: Guido van Rossum is secretly Rick Moranis Message-ID: <9j7557+lp54@eGroups.com> I can prove that Guido van Rossum is secretly Rick Moranis. Rick Moranis, movie star: http://www.boxofficemania.com/actors/r/rick_moranis/rick_moranis.jpg Guido van Rossum, Python inventor: http://www.python.org/~guido/images/Guido at 200dpi.jpg Randy From duncan at NOSPAMrcp.co.uk Mon Jul 9 04:33:33 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Mon, 9 Jul 2001 08:33:33 +0000 (UTC) Subject: Marking a Python COM server safe for Internet Explorer References: <3B45A5AD.12631.573C6B@localhost> <mailman.994444271.3218.python-list@python.org> Message-ID: <Xns90D95FE52A469duncanrcpcouk@127.0.0.1> "Bill Bell" <bill-bell at bill-bell.hamilton.on.ca> wrote in news:mailman.994444271.3218.python-list at python.org: > 2. In order to reach the stage where this message is emitted the > control must have been installed on the user's computer (which, I > suppose, corresponds to the chicken). Moreover, if your control isn't marked as safe for scripting, IE creates the control before it pops up the box asking you whether you want to allow the script to run. In other words, if your control is written in Python, the __init__ method is called *before* the user is asked whether to permit it. When you think about it, this is the only way it can work, since IE cannot tell that the control is unsafe until it has created it and asked it whether it supports IObjectSafety. So any unsafe control may be created by any script, it is just that the script cannot do anything further with the control. -- 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 kirschh at lionbioscience.com Tue Jul 17 03:23:39 2001 From: kirschh at lionbioscience.com (Harald Kirsch) Date: 17 Jul 2001 09:23:39 +0200 Subject: memory leak with dynamically defined functions? References: <mailman.995315008.1887.python-list@python.org> <yv2r8vgt48l.fsf@lionsp093.lion-ag.de> Message-ID: <yv2k818t3wk.fsf@lionsp093.lion-ag.de> Too bad having to followup on my own posting. Harald Kirsch <kirschh at lionbioscience.com> writes: > zooko at zooko.com writes: > > > But if I allocate memory and store a reference to it in a default argument to > > an inner function, like this: > > > > >>> def silliest_func(): > > >>> x = [0] * (2**10) > > >>> def inner_silliest_func(x=x): > > >>> pass > > >>> return inner_silliest_func > > >>> > > >>> blarg = {} > > >>> for i in range(2**13): > > >>> blarg[i] = silliest_func() > > This creates 2**13 references to one and the same object, namely > silliest_func which (I suspect) has just one reference to an object > inner_silliest_func. Should read: This creates 2**13 references to one and the same object, namely inner_silliest_func. > > > > > and then remove the references to this memory, like this: > > > > >>> del blarg > > This removes the 2**13 references again. And copies of the > inner_silliest_func were never produced and need not be freed. > > > > > none of the memory is freed up! > > The only memory that can and should be freed is the one for the list > object blarg and this is about > sizeof(PyListObject)+2**13*sizeof(void*) (see > Python/Objects/listobject.c/PyList_New). This is roughly 32kBytes on > 32bit machines. I doubt that you will notice freeing such a rather > small amount of memory. > > > > > Even stimulating the garbage collector, with: > > > > >>> import gc > > >>> gc.collect() > > 0 > > I guess you see this because `del blarg' did already all that there > was to do. > > However, from your description it looks like you might have simplified > your example too such that the true problem cannot be demonstrated. > > Regards, > Harald Kirsch > -- > ----------------+------------------------------------------------------ > Harald Kirsch | kirschh at lionbioscience.com | "How old is the epsilon?" > LION bioscience | +49 6221 4038 172 | -- Paul Erd?s > *** Please do not send me copies of your posts. *** -- ----------------+------------------------------------------------------ Harald Kirsch | kirschh at lionbioscience.com | "How old is the epsilon?" LION bioscience | +49 6221 4038 172 | -- Paul Erd?s *** Please do not send me copies of your posts. *** From peter at engcorp.com Wed Jul 18 07:33:45 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 18 Jul 2001 07:33:45 -0400 Subject: Finding Display Settings ?? References: <s0d57.12936$Xr6.106667@news-server.bigpond.net.au> Message-ID: <3B557419.E6315CC@engcorp.com> Peter Moscatt wrote: > > Which module/library would I import so that I can test for the current > display settings ?? Since you didn't specify platform or essentially anything else, one has to assume.... >>> import win32api >>> print win32api.GetSystemMetrics(0) 1024 >>> print win32api.GetSystemMetrics(1) 768 MS documentation should provide more detail on these and other values returns by this system call. For this, you have to have the win32all package installed. Obviously it works only on Windows... (you did mean Windows, didn't you?) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From guido at python.org Fri Jul 6 07:40:52 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 06 Jul 2001 11:40:52 GMT Subject: Augmented Assignement (was: Re: PEP scepticism) References: <mailman.993952381.32699.python-list@python.org> <zbN%6.415855$oc7.58414702@news2.rdc2.tx.home.com> <q0avjto87p59hn7gv28r5cf1c84j2fb8c7@4ax.com> <naO%6.416271$oc7.58537852@news2.rdc2.tx.home.com> <vm40kt8knq3pplpv1rarjubl73vnl12ure@4ax.com> <20010702145211.M8098@xs4all.nl> <oqlmm7tl6j.fsf@lin2.sram.qc.ca> <mailman.994101900.21513.python-list@python.org> Message-ID: <cpae2il23l.fsf@cj20424-a.reston1.va.home.com> Thomas Wouters <thomas at xs4all.net> writes: > This thread reminds me a great deal about whether generators should be > defined using 'def' or 'generate' -- it took me one (1) generator to realize > how natural it was with def, and most (not all) counterarguments were > basically trying to tell me I was wrong to feel that way :-) Bingo! It takes a Pythonic mind to get this feeling of what's right. Clearly the opponents are not Pythonic enough. So there! :-) --Guido van Rossum (home page: http://www.python.org/~guido/) From com-nospam at ccraig.org Tue Jul 17 09:49:54 2001 From: com-nospam at ccraig.org (Christopher A. Craig) Date: 17 Jul 2001 09:49:54 -0400 Subject: Most efficient solution? References: <31575A892FF6D1118F5800600846864D78BE8E@intrepid> <mailman.995298207.17374.python-list@python.org> Message-ID: <87snfvsm0t.fsf@elbereth.ccraig.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 ** For this post presume that "a" is len(A) and "b" is len(B) "Jeffery D. Collins" <jcollins at boulder.net> writes: > How about this: > > import operator > h = {} > map(operator.setitem, [h]*len(B), B, B) # create a dictionary of B > bb = filter(h.get, A) # find all elements of A in B (include repeats) > map(A.remove, bb) This is very elegant, but incorrect. Since you are setting h[B]=B you have no guarantee that h.get(i) is true if h[i] exists. import operator h = {} map(operator.setitem, [h]*len(B), B, [None]*len(B)) bb = filter(h.get, A) map(A.remove, bb) Additionally, A.remove() is O(a) so this ends up taking O(a*b), which is bad. Also we can avoid having to create the list [None]*len(B) by using has_key() instead of get(). You could fix this with: import operator h = {} map(operator.setitem, [h]*len(B), B, B) A= [ x for x in A if not h.has_key(x) ] Which is pretty good, but possibly overly clever. My tests (Python 2.1 on an Ultra 10 with Solaris 8) show that h = {} for i in B: h[i]=None A=[ x for x in A if not h.has_key(x)] outperforms this (very) slightly (probably because the creation of [h]*len(B) is more expensive than the explicit for loop). - -- Christopher A. Craig <com-nospam at ccraig.org> "It's the one thing I understand, I guess." Bill Gates, about BASIC -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: Processed by Mailcrypt iEYEARECAAYFAjtUQoEACgkQjVztv3T8pzspwwCggU7i+KENEizbf14VGR1o7vLU tWsAoMhTH+SkviUcSx7K+KWztqcIf4zG =slOC -----END PGP SIGNATURE----- From bokr at accessone.com Sat Jul 7 09:09:05 2001 From: bokr at accessone.com (Bengt Richter) Date: Sat, 07 Jul 2001 13:09:05 GMT Subject: I'm Sure There's A Better Way References: <3B465858.CB7F38E8@tundraware.com> Message-ID: <3b470811.1282245131@wa.news.verio.net> On 07 Jul 2001 00:40:01 GMT, Tim Daneliuk <tundra at tundraware.com> wrote: >I want a function to check a string to make sure it is a legitimate >dollar amount. Which means it follows these rules: > >First character is numeric or "-" >At most, one "." is allowed and, if present, is followed by exactly two digits >All the remaining characters must be in the range "0" - "9" > > >I wrote the attached to check a string for these rules, but I can't help >wondering if my feeble newbie python coding isn't already better done >elswhere and/or using existing logic. Any ideas all? TIA.... Code follows - > > > ># Check and see if passed string is a legit amount > >def IsNum(num): > if num == "": > return FALSE > digits = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "."] > z = num.split(".") > if len(z) > 2: # At Most, only once decimal permitted. > return FALSE > if len(z) == 2: > if len(z[1]) != 2: # Exactly two digits must follow decimal > return FALSE > if (num[0] == '-') and (len(num) > 1): # 1st char can be sign if more chars follow > num = num[1:] # Drop sign for purposes of checking > for x in num: # Make sure all chars are legit digits > if not digits.count(x): > return FALSE > return TRUE > >-- I think you could do it just checking for a full match with a regular expression. Return 1 and 0 instead of 'yes' and 'no' for more typical usage. The latter was just for interactive readability :) If you require a decimal to the left of the decimal point, you could write mo = re.match(r'^-?\d+(\.\d\d)?$',num) instead of the below >>> import re >>> def IsNum(num): ... mo = re.match(r'^-?(\d*\.\d\d|\d+)$',num) ... if mo and mo.group()==num: return 'yes' ... return 'no' ... >>> IsNum('-123.456') 'no' >>> IsNum('-123.45') 'yes' >>> IsNum('-1.3.45') 'no' >>> IsNum('-1.345') 'no' >>> IsNum('-1345') 'yes' >>> IsNum('.1345') 'no' >>> IsNum('.13') 'yes' >>> IsNum('-13') 'yes' >>> IsNum('-1') 'yes' >>> IsNum('-0') 'yes' Not thoroughly tested ;-) From tjreedy at home.com Thu Jul 12 13:15:40 2001 From: tjreedy at home.com (Terry Reedy) Date: Thu, 12 Jul 2001 17:15:40 GMT Subject: Newbie Question: Regular Expressions References: <mailman.994953021.32263.python-list@python.org> Message-ID: <0Xk37.1056$%6.208181@news1.rdc2.pa.home.com> <fett at tradersdata.com> wrote in message news:mailman.994953021.32263.python-list at python.org... > I have a really dumb program that i would like to make smarter. I need > to take a file on my hard drive and filter out everything except for the > standings which are written in it. I have tried to use regular > expressions with no success, but i still think that they are probably > the best way. I created the following simple fix, but it is unreliable > if the data changed posistions. Try S.find('League Standings') , then find the first thing you *don't* want. > > > input = open('rawdata', 'r') > S = input.read() > print S[4021:6095] > > Output : > League Standings > American League > EAST W L PCT GB HOME ROAD EAST CENT WEST NL L10 STRK > Red Sox 43 29 .597 - 23-15 20-14 23-13 8-7 6-6 6-3 6-4 L2 > Yankees 41 31 .569 2.0 21-15 20-16 19-11 12-9 5-7 5-4 6-3 W2 > Blue Jays 35 38 .479 8.5 18-20 17-18 14-13 6-7 11-13 4-5 5-5 W3 > Orioles 34 39 .466 9.5 20-20 14-19 15-17 9-12 6-5 4-5 5-5 L1 > ........( it continues with all the standings) > > > Also could you tell me if its possible to download the data from the > web-page in python so that it doesnt even have to deal with opening the > file. I believe you want standard library module urllib so you can say 'S=urlopen(url).read()' (never used myself yet, so check details). Terry J. Reedy From europax at home.com Sat Jul 14 23:00:46 2001 From: europax at home.com (Pugsley) Date: Sun, 15 Jul 2001 03:00:46 GMT Subject: Need help with "global" variables Message-ID: <yH747.348232$p33.7087093@news1.sttls1.wa.home.com> I'm converting a number crunching program from C to Numeric Python, and I'm really getting stuck on how to deal with global variables. For example, there are about 30 variables that are defined in the main program that I want to be global and available in the functions in the modules. (the modules are seperate files that I import). A simple example would be: def foo(arg1, arg2): global bar1, bar2, bar3, etc. result= bar1+bar2+bar3+ arg1+arg2 return result But all I get are errors stating that the global variables have not been defined. This behavior seems to run counter to what is implied in some books that I've been reading. What am I doing wrong? Thanks, Rob. From nhodgson at bigpond.net.au Tue Jul 24 19:41:21 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Tue, 24 Jul 2001 23:41:21 GMT Subject: Any Suggestions for an Editor with MS-Windows ? References: <92757716C8BFF476.D432477A795DB759.E2FB05E062137965@lp.airnews.net> <3B5BDC16.3A348DF6@oce.nl> <mailman.995990628.669.python-list@python.org> Message-ID: <BIn77.28461$Xr6.228964@news-server.bigpond.net.au> Geoff Talvola: > At 03:43 PM 7/24/01 +0000, Robert Amesz wrote: > > >SciTE Edit (I believe the URL is something like www.scintilla.org) is > >pretty nice for us Pythoneers. If only it could open multiple files... > > SciTE _can_ open multiple files if you configure it properly! > You just have to edit some of the settings in > SciTEGlobal.properties. I think I had to make the tabbar > visible and increase the number of buffers, or something > along those lines. You can either add a line to the global properties file: buffers=10 or do this on the command line: SciTE -buffers=10 10 buffers is the maximum currently available. This is caused by needing to dimension UI elements and 10 makes it easy to assign accelerator keys. The reason this is the default is that I use SciTE in single document mode and start extra processes if there is a need for having multiple files open. There are still some bugs with multiple buffers although these are not serious problems. An alternate set of properties files which sets up multiple buffers is available from Philippe Lhoste's site: http://jove.prohosting.com/~philho/softwares/PhiLhoSoft/SciTE/index.html Neil From pmoscatt at bigpond.net.au Thu Jul 19 05:23:43 2001 From: pmoscatt at bigpond.net.au (Peter Moscatt) Date: Thu, 19 Jul 2001 09:23:43 GMT Subject: Retreiving a single number from a list of numbers ? References: <3b565953@news.iprimus.com.au> <3B566F26.24C4F807@altavista.com> Message-ID: <zGx57.15014$Xr6.123559@news-server.bigpond.net.au> Hi Alex, Great.... just what I wanted. I have being trying thinks like a(1) instead of using [] and was wondering why I was getting errors :-) Thanks again Alex. Pete Alex K wrote: > Peter Moscatt wrote: >> >> I am trying to extract a value from a variable that contains more than >> one value. >> >> For example: >> If I assigned the result of wxGetClientDisplayRect() to the var 'a' >> like: >> a = wxGetClientDisplayRect() >> >> the 'a' would return something like (0, 0, 800. 540) >> >> How then would I assign the 800 from 'a' and give it to a var called 'b' >> ?? >> >> Regards >> Pete > >>>> a=(0, 0, 800, 540) >>>> a > (0, 0, 800, 540) >>>> a[2] <-- slicing > 800 >>>> (0, 0, 800, 540)[0] > 0 >>>> (0, 0, 800, 540)[3] > 540 >>>> > From amardeep at tct.hut.fi Sun Jul 8 10:42:03 2001 From: amardeep at tct.hut.fi (Amardeep Singh) Date: Sun, 8 Jul 2001 17:42:03 +0300 (EET DST) Subject: Unix Scripting Host In-Reply-To: <slrn9kgl52.o9.gerhard.nospam@lilith.hqd-internal> Message-ID: <Pine.GSO.4.33.0107081712170.6735-100000@keskus.tct.hut.fi> On Sun, 8 Jul 2001, Gerhard H?ring wrote: > My findings currently are: > - DCOP: client side usage is easy; server-side more difficult; KDE only; can > use XML-RPC instead because KDE has a DCOP-XMLRPC bridge > - SOAP/XML-RPC: very easy to use from Python; much encoding/decoding overhead > - CORBA: very good Python support with omniORBpy; omniORB 4/omniORBpy2 will > improve performance by taking shortcuts when the C++ and Python code is in > the same address space (no loopback interface involved) > - XPCOM: still have to get this to work on my machine, but looks promising; no > wide language support currently available (only C++/Python) also add orbit/bonobo to your list relevant links are http://orbit-resource.sourceforge.net/ (ORBit) http://orbit-python.sault.org/ (ORBit-python) http://cvs.gnome.org/lxr/source/bonobo-python/ (bonobo-python) http://soapy.sourceforge.net/ (SOAP for python) > > Gerhard > -- ------------------------------------------------------------- amardeep singh iit guwahati iamamardeep at yahoo.com From nospam at nospam.de Sun Jul 15 09:40:14 2001 From: nospam at nospam.de (Uwe Hoffmann) Date: Sun, 15 Jul 2001 15:40:14 +0200 Subject: How to add type "int" to string ? References: <692684d4.0107150512.5b7d9ccd@posting.google.com> Message-ID: <3B519D3E.77DB1652@nospam.de> shuibo wrote: > > Hello all : > in my program I want to give a char variable a Hex value , for example : > a = "Hello World" > a = a + 0x00 > but it display "cannot add type int to string" > what can I do ? > thanks very very much ! a = a + chr(0x00) if that's what you want ? From guido at python.org Wed Jul 25 01:22:32 2001 From: guido at python.org (Guido van Rossum) Date: Wed, 25 Jul 2001 05:22:32 GMT Subject: Language change and code breaks References: <Pine.LNX.4.33.0107191316390.24983-100000@bms> <mailman.995571273.18192.python-list@python.org> <9j7gv8$9mg@dispatch.concentric.net> <cppuawfqbm.fsf@cj20424-a.reston1.va.home.com> <Pine.LNX.4.33.0107231434170.15565-100000@oliphant.ee.byu.edu> <532qlt453irrepptskcvp213d44r3so2e2@4ax.com> <cp4rs2qf6p.fsf@cj20424-a.reston1.va.home.com> <3B5DF282.87266DA2@earthlink.net> Message-ID: <cpr8v5a8h5.fsf@cj20424-a.reston1.va.home.com> "Joseph A. Knapka" <jknapka at earthlink.net> writes: > Guido van Rossum <guido at python.org> writes: > > >> I would very much prefer a case *insensitive* language with tools > >> that enforce *uniform* case usage. > > > > And that's of course what I have in mind. > > I'm confused. Are you proposing: > > (1) A case *sensitive* language (that is, no change),with tools to > enforce case consistency; or > > (2) A case *insensitive* language (God forbid), with tools to > enforce case consistency; or > > (3) Something else? I have changed my mind. I think that if I had to start over, I would indeed try my hands at a case-insensitive language aimed at teaching programming to beginners, with tools to enforce case consistency. Given that nobody else who currently uses Python thinks this is a good idea, I then settled on a case-sensitive language with case-preserving tools. But now I think neither is worth fighting for. --Guido van Rossum (home page: http://www.python.org/~guido/) From hamish_lawson at yahoo.co.uk Mon Jul 30 13:50:30 2001 From: hamish_lawson at yahoo.co.uk (Hamish Lawson) Date: 30 Jul 2001 10:50:30 -0700 Subject: FEEDBACK WANTED: Type/class unification References: <cp66cd12yp.fsf@cj20424-a.reston1.va.home.com> Message-ID: <915a998f.0107300950.6ee1790@posting.google.com> > If there's anyone who believes the type/class unification should not > become a feature in Python 2.2, please speak up now or forever hold > your peace... (But I'd rather you speak up!) I'd welcome it. I don't believe any of my code would break, but I'm willing to put up with it if it does. Hamish Lawson From qrczak at knm.org.pl Tue Jul 24 12:22:44 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 24 Jul 2001 16:22:44 GMT Subject: function while true - list function? References: <88f77.300$e%3.6743@news.lhr.globix.net> <ENg77.543485$eK2.113992779@news4.rdc1.on.home.com> Message-ID: <slrn.pl.9lr86k.pv2.qrczak@qrnik.zagroda> Tue, 24 Jul 2001 15:48:52 GMT, Nick Perkins <nperkins7 at home.com> pisze: > Here's another way to do it, using generators: > (in python 2.2) And here is another (Python 2.2): def gen_unroll(fn, *args, **kwds): return iter(lambda: fn(*args, **kwds), None) -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From moshez at zadka.site.co.il Sun Jul 15 23:54:03 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Mon, 16 Jul 2001 06:54:03 +0300 Subject: OO misconceptions (was: Re: Long Live Python!) In-Reply-To: <slrn9l49me.p58.tim@vegeta.ath.cx> References: <slrn9l49me.p58.tim@vegeta.ath.cx>, <mailman.994969462.27792.python-list@python.org> <hevsktcrnpckttnkgi1arcue5kjjsbrrb5@4ax.com> <mailman.995046506.2514.python-list@python.org> <9ir1l7$3ja$1@panix2.panix.com> <9irfbc11jaq@enews1.newsguy.com> Message-ID: <E15LzSN-0007d7-00@darjeeling> On Sun, 15 Jul 2001 23:15:17 GMT, tim at vegeta.ath.cx (Tim Hammerquist) wrote: > I wouldn't implement a RDBMS in Python. What a shame! Fortunately for us, someone else has. See Gadfly > An application's scalability has much more to do with the programmer's > use of algorithms and abstraction than with the language in which it's > implemented...no matter how much money ActiveState has invested in it. Similar systems take longer to build correctly in C or C++ then in Python. You could also write a scalable application in assembler, or machine code -- it would just take longer. -- gpg --keyserver keyserver.pgp.com --recv-keys 46D01BD6 54C4E1FE Secure (inaccessible): 4BD1 7705 EEC0 260A 7F21 4817 C7FC A636 46D0 1BD6 Insecure (accessible): C5A5 A8FA CA39 AB03 10B8 F116 1713 1BCF 54C4 E1FE From joonas at olen.to Mon Jul 16 07:01:40 2001 From: joonas at olen.to (Joonas Paalasmaa) Date: Mon, 16 Jul 2001 11:01:40 GMT Subject: command substitution References: <newscache$vy7kgg$wzn$1@news.freegates.be> <3B52C0AD.93608611@olen.to> Message-ID: <3B52CA35.C45DB413@olen.to> Joonas Paalasmaa wrote: > > Raphael Bauduin wrote: > > > > Hi! > > > > I was looking for a solution like in bash, which let you put the standard > > output of a command in a variable(in bash, you can do it like OUT=`ls` or > > OUT=$(ls) ). > > > > If you have another way to take the standard output of a command and put it > > in a variable, it would be helpfull too. > > out = popen("ls", "r").read() > > And if you want a list of files. > out = popen("ls", "r").readlines() Oops! This may work better. import os out = os.popen("ls", "r").read() From tim at vegeta.ath.cx Sun Jul 8 18:57:52 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Sun, 08 Jul 2001 22:57:52 GMT Subject: Confusion about dictionaries - keys use value or identity? References: <mailman.994626808.10039.python-list@python.org> <if527.46135$he.3215290@e420r-atl1.usenetserver.com> Message-ID: <slrn9khq26.vu.tim@vegeta.ath.cx> Steve Holden <sholden at holdenweb.com> wrote: > "Tim Peters" <tim.one at home.com> wrote in message > news:mailman.994626808.10039.python-list at python.org... > > > > "perl"<"python"-is-true-either-way-though-ly y'rs - tim > > > > and-we-all-assume-python>perl-anyway-ly y'rs - steve Speak for yourself. =) Python != Perl Comparisons such as "better" or "worse" in an overall context are pointless and inherently flawed. Besides: >>> 'qbasic' > 'python' 1 And what's to stop someone from creating a language called Zardoz? >>> 'perl' < 'zardoz' 1 >>> 'python' < 'zardoz' 1 -- -Tim Hammerquist <timmy at cpan.org> Trust the computer industry to shorten the term "Year 2000" to Y2K. It was this kind of thinking that got us in trouble in the first place. -- Adrian Tyvand From sill at optonline.net Sat Jul 14 22:11:50 2001 From: sill at optonline.net (Rainy) Date: Sun, 15 Jul 2001 02:11:50 GMT Subject: How popular is Python, anyway? (was: Long Live Python!) References: <E566B020833BD311B6610008C791A39705CA5230@il93exm04.css.mot.com> <mailman.994804336.23495.python-list@python.org> <slrn9koofo.mjk.philh@comuno.freeserve.co.uk> <slrn9kpr3e.527.sill@sill.silmarill.org> <Gzj37.13006$B7.2564502@ruti.visi.com> <slrn9ks0mh.9oi.sill@sill.silmarill.org> <yox4rsh6w82.fsf@karhu.tp.spt.fi> <slrn9kutbc.36s.sill@sill.silmarill.org> <3B4F9D27.CF8DC351@engcorp.com> <slrn9l1r0a.ai.sill@sill.silmarill.org> <3B50F47D.BD251C00@engcorp.com> Message-ID: <slrn9l1ut9.ai.sill@sill.silmarill.org> On Sat, 14 Jul 2001 21:40:13 -0400, Peter Hansen <peter at engcorp.com> wrote: > Rainy wrote: >> >> On Fri, 13 Jul 2001 21:15:19 -0400, Peter Hansen <peter at engcorp.com> wrote: >> > I understand what you mean here, but I'm not sure I believe in the >> > idea that there really are scripts you write once and never have to extend. >> >> Well, there *are* such scripts, but the problem is, you don't know if the one >> you're writing is going to be one of these or not. I made an educated guess >> that the one in question will be write-once and was right, > ^^^^^^^^^^^^^ > So far. :-) Touche! ;-) -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: http://silmarill.org/cymbaline From ransen_spam_me_not at nemo.it Sat Jul 21 12:06:28 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Sat, 21 Jul 2001 16:06:28 GMT Subject: KeyboardInterrupt References: <3b57e9e8.1285896@news.newsguy.com> <uitgn8aj7.fsf@ctwd0143.fitlinxx.com> Message-ID: <3b58f95a.333056@news.newsguy.com> On 20 Jul 2001 19:07:24 -0400, David Bolen <db3l at fitlinxx.com> wrote: >ransen_spam_me_not at nemo.it (Owen F. Ransen) writes: >> How can I get my program to be more responsive to control-C? > >Are you by any chance writing code that tends to have catch-all >"except" clauses? >-- David No, it just calculates and writes a big file. If I print now and then I can use control-C to exit, but that is an ugly solution... -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From pinard at iro.umontreal.ca Thu Jul 26 19:32:50 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 26 Jul 2001 19:32:50 -0400 Subject: Operator symbol for "nb_intdivide" In-Reply-To: <cpg0bj5pb3.fsf@cj20424-a.reston1.va.home.com> References: <C0Z77.8508$uM6.1020602@news1.telusplanet.net> <cpg0bj5pb3.fsf@cj20424-a.reston1.va.home.com> Message-ID: <oqelr3e065.fsf@lin2.sram.qc.ca> [Guido van Rossum] > > I would like to suggest to use a clearly distinguishable one-character > > symbol for the "nb_intdivide". [...] Among the still free symbols ("?", > > "@", "$" I guess) I would suggest to use "$" for the integer division. > You had me there for a moment... :-) By revising the code base, Python people observed that integer division, used as such, is not used very often, and among the few cases that were observed, could be avoided sometimes. It is not worth spoiling a still unused character for an operation, like integer division, which is not often required in practice. Do not touch unused characters, and let's protect them with care and tender, yet rather firmly, like we already do for many animal races prone to extinction. :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From opengeometry at yahoo.ca Mon Jul 16 13:44:19 2001 From: opengeometry at yahoo.ca (William Park) Date: Mon, 16 Jul 2001 13:44:19 -0400 Subject: Most efficient solution? In-Reply-To: <9iv38i0ppd@enews2.newsguy.com>; from aleaxit@yahoo.com on Mon, Jul 16, 2001 at 06:03:27PM +0200 References: <mailman.995289809.28477.python-list@python.org> <9iv38i0ppd@enews2.newsguy.com> Message-ID: <20010716134419.A1125@node0.opengeometry.ca> On Mon, Jul 16, 2001 at 06:03:27PM +0200, Alex Martelli wrote: > "Jay Parlar" <jparlar at home.com> wrote in message > news:mailman.995289809.28477.python-list at python.org... > ... > > for eachItem in A: > > if eachItem in B: > > A.remove(eachItem) > > > > Now, this will work fine, > > Are you sure about that? Normally, modifying the list > you're iterating on does NOT work fine. Good point. Most of us knew what he meant, though. -- William Park, Open Geometry Consulting, <opengeometry at yahoo.ca> 8 CPUs cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc. From guido at python.org Sat Jul 21 18:37:30 2001 From: guido at python.org (Guido van Rossum) Date: Sat, 21 Jul 2001 22:37:30 GMT Subject: interpreter improvements References: <5e8bd451.0107190224.7171e61@posting.google.com> <mailman.995692716.8559.python-list@python.org> <5e8bd451.0107210040.2e2d9a0e@posting.google.com> <mailman.995725417.10018.python-list@python.org> Message-ID: <cpbsmdgb9d.fsf@cj20424-a.reston1.va.home.com> > kp87 at lycos.com (kevin parks) writes: > > > Anyway, i spend all day in the interpreter and i was > > hoping to make it a more pleasant experience. I can't > > believe you can't do: > > > > >>> foo(somereallylongbitofcodegoeshere, > > itsrealllybothersomeifyoumistype) [change a bunch of crap here] > > >>> !foo In IDLE, you can type foo and hit ^P. --Guido van Rossum (home page: http://www.python.org/~guido/) From kens at sightreader.com Tue Jul 10 13:11:04 2001 From: kens at sightreader.com (Ken Seehof) Date: Tue, 10 Jul 2001 10:11:04 -0700 Subject: BASIC or Python? References: <3d157fa0.0107051904.7ec368b8@posting.google.com> <slrn9kcfuq.2b7g.kamikaze@kuoi.asui.uidaho.edu> <0t_17.14670$Fk7.131382@news.indigo.ie> <slrn9kkgfp.dj6.kamikaze@kuoi.asui.uidaho.edu> <9idp67$jln$2@gondor.sdsu.edu> <3B4B1DE7.142B815C@noaa.gov> Message-ID: <022501c10963$4fc04ee0$0e4ab43f@kens> From: "Benjamin.Altman" <benjamin.altman at noaa.gov> > stremler at rohan.sdsu.edu wrote: > > > I'll just quote: > > > > This is also one reason I dislike Python. Indentation is part of the > > documentation of the program, and as such it shouldn't be parsed by the > > compiler. -- Peter da Silva (September 1999) > > > > Who cares? The above is just personal opinion and preference like everything else - not a rule or > law. Uh, yeah. So indentation, like all documentation, should be possibly inconsistent with actual program behaviour. I get it :-) While we're at it, doc strings are obviously documentation and should not be parsed by the compiler. Variable names are also documentation; a dubious concept added by Assembler. It's much better to access variables by machine address to avoid burdening the compiler with excess documentation :-) From j.spies at hccnet.nl Mon Jul 2 18:11:48 2001 From: j.spies at hccnet.nl (Jaap Spies) Date: Tue, 03 Jul 2001 00:11:48 +0200 Subject: Is Python Dead? References: <MNS%6.355$Xs4.225014@news.pacbell.net> <9hphiu0dks@drn.newsguy.com> Message-ID: <3B40F1A4.1000602@hccnet.nl> Armin Steinhoff wrote: > It seems that Python should strive to be great at the ABC's before it > attempts poetry. > > --Ed > You should know that the roots of Python are in the ABC Programming Language and as I mentioned before reading/writing Python is really Poetry! Jaap Spies From guido at python.org Wed Jul 25 12:00:20 2001 From: guido at python.org (Guido van Rossum) Date: Wed, 25 Jul 2001 16:00:20 GMT Subject: PEP238 and zope References: <3B5DE0F7.9070001@nospiced.ham.devis.com> <cpitgha7pe.fsf@cj20424-a.reston1.va.home.com> <3B5ECF9E.8000103@nospiced.ham.devis.com> Message-ID: <cpwv4x80dr.fsf@cj20424-a.reston1.va.home.com> Tom Jenkins <tjenkins at nospiced.ham.devis.com> writes: > Yes zope is typically much more aggressive in breaking old zope code, > but the breakage is typically in the security mechanisms not in the > underlying fundamentals. It also means I have to try and minimize the > effects. Quite frankly I thought python code in our Python Methods was > safe. You can rest in peace now. The float division won't become the default before Python 3.0. > my-naivete-astonishes-even-me-sometimes-ly yours It's one of your most charming personality traits. ;-) --Guido van Rossum (home page: http://www.python.org/~guido/) From alankarmisra at hotmail.com Mon Jul 30 17:06:03 2001 From: alankarmisra at hotmail.com (gods1child) Date: 30 Jul 2001 14:06:03 -0700 Subject: .pyo compilation Message-ID: <25b2e0d9.0107301306.16864cf7@posting.google.com> How do I dis/enable optimization of bytecodes in the current interpreter from within a script (as opposed to the standard -O option on firing up the interpreter). Need something that compiles to .pyo no matter what and py_compile isnt helping me (I think). Tnx. From guido at digicool.com Thu Jul 19 08:00:39 2001 From: guido at digicool.com (Guido van Rossum) Date: Thu, 19 Jul 2001 08:00:39 -0400 Subject: Language change and code breaks In-Reply-To: Your message of "Wed, 18 Jul 2001 21:54:43 EDT." <Pine.NXT.4.21.0107182150180.370-100000@localhost.virginia.edu> References: <Pine.NXT.4.21.0107182150180.370-100000@localhost.virginia.edu> Message-ID: <200107191200.IAA06994@cj20424-a.reston1.va.home.com> > Now that we're in a new century, I think it's time to update to a > new excuse! I didn't mean it as an excuse! > How about: > > Now that everyone's making the transition to multiple language support, > unicode and multiple encodings, how to you portably define/implement > case-insensitive comparison? Sorry, no problem. The Unicode standard defines for each character whether it is upper or lower case, and what the corresponding character is in the other case (if any). --Guido van Rossum (home page: http://www.python.org/~guido/) From paul at svensson.org Thu Jul 12 14:49:21 2001 From: paul at svensson.org (Paul Svensson) Date: 12 Jul 2001 18:49:21 GMT Subject: rationalising division (Was: Re: [Fwd: Comment on PEP-0238]) References: <3B474536.DE27A538@3-cities.com> <mailman.994529832.2013.python-list@python.org> <7ef50c46.0107080945.30bfa5b4@posting.google.com> <tkrg43ilksi315@news.supernews.com> Message-ID: <9ikrfh$f6k$1@newsy.ifm.liu.se> "John Roth" <johnroth at ameritech.net> writes: >"Robert J. Harrison" <rjh at 3-cities.com> wrote in message >news:7ef50c46.0107080945.30bfa5b4 at posting.google.com... >> >> Other thoughts >> >> - Accelerating the consideration of Rationals. > >It's inconsistant to have a rational type, and have integer division return >a float! Either integer division should return a rational, or we should take >PEPs 239 and 240 out and bury them. (In fact, if integer division returns >a rational, then there is no need for PEP 240 - 1/2 is perfectly good as >a rational literal! > >If we make integer division return a float now, then we're simply creating >another problem when we implment rationals sometime down the path. I would guess that expecting a float and getting a rational would cause significantly less disturbance that expecting a (truncated) integer and getting a (non-truncated) float (or vice versa). However, if/when Python grows support for rationals, it would annoy me greatly if 1/2 was interpreted as anything but a literal rational, (or at least a compile time expression yielding same (yes I know Python currently doesn't have compile time expressions)). Other things to consider is the ongoing work to bridge the gap between longs and ints, ideas about fixed precision decimals, etc. Long/long -> float or long/int -> float seems like a mistake, but returning a rational instead makes sense (with long rationals). There are really two issues involved in making a significant change such as this: Is the grass really greener on the other side ? And if so, is there any way to get there from here ? My impression of the discussion is that the consensus so far is 'maybe' and 'it's too painful', and that's why we're still arguing. I still think it's to early to bury PEP 238, as the answers to these questions are very lightly to change when we gain experience from other modifications to python's numerical system. I agree that PEPs 238 and 239 definitely need to be considered together (in which case 240 seems dubious at best), but I'd rather see that done by slowing down then by speeding up. If there's anything we can do right now, it would be a very small first step. Without causing any harm to existing code, we can add the possibility to generate warnings about int/int discarding non-zero fractions, and a "from __future__ import div" for a div operator doing he right thing. Then, let's keep arguing. /Paul From bkc at Murkworks.com Tue Jul 31 13:07:10 2001 From: bkc at Murkworks.com (Brad Clements) Date: Tue, 31 Jul 2001 13:07:10 -0400 Subject: Need Beta Testers: Windows gvIB binaries for Python 2.1 Message-ID: <3b66e5f4_2@news.newsgroups.com> If you want to try the gvIB (Going Virtual Interbase DB Adapter) on Python 2.1 for Windows, please email me and I'll send you the .exe to try. It's a binary distutils self-installer. Or, would .zip be better in these days of sircam? -- 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 infobot at skinnyhippo.com Wed Jul 4 14:11:40 2001 From: infobot at skinnyhippo.com (infobot) Date: 4 Jul 2001 11:11:40 -0700 Subject: Python win32all installation warning dialogs. References: <b15c2672.0106131711.5351653@posting.google.com> <3B2856EE.4070109@ActiveState.com> Message-ID: <b15c2672.0107041011.3e612b3d@posting.google.com> Sorry Mark & Stefan, massively late followup since I got swamped in work and an office relocation. Anyway, you were both right, I had one of the dodgy comcat dlls - version 5.0 from MSIE I think. Tried getting hold of the new ones but worked easier to just reinstall the OS (it needed it anyway) - am now using fresh Windows2000Professional & MSIE5.5 installation and no problem at all with Win32all. Thank you very much. chas ...................................................................... Mark Hammond wrote: > > 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. -------------------------------------------------------------- Stefan Migowsky wrote: > 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 From phawkins at spamnotconnact.com Sun Jul 22 23:07:32 2001 From: phawkins at spamnotconnact.com (phawkins at spamnotconnact.com) Date: 22 Jul 2001 23:07:32 -0400 Subject: subclassing Exceptions References: <9ihklt8u0vvh1aa0mg6tadbmjo9mot47e0@4ax.com> <mailman.995773776.14791.python-list@python.org> <v3mklt0fcn31un5en9pr90lvnh44935qi4@4ax.com> <3B5B137E.3606B75D@alcyone.com> <9t6mltc0nhqt4enj7dq0n0c9s3u9ens4eb@4ax.com> <3B5B26F9.A2C71182@alcyone.com> <88gmltsdpn4brhtr7ng71b7c22qqlhlfac@4ax.com> Message-ID: <wkpuascphn.fsf@mail.connact.com> Oh, fer crying out loud, Sheila just wants an example of exceptions in use; she said so quite specifically and unambiguously. The hard part about exceptions is that they're way simpler than you think. Here you go, Sheila, a nice little camera interface, uses exceptions. It uses an argument instead of defining __str__, which I hadn't realized was a possibility. Hmmm, interesting (playing in Idle), defining __str__ as you do causes an exception to not take an argument. See next post... import string import commands import exceptions import re import os.path from glob import glob class Camera: """A class abstracting the camera interface; designed to call a command-line interface tool""" def __init__(self, camera = "/dev/kodak"): if not os.path.exists(camera): raise NoDevice, "device does not exist" + camera else: self.__camera = camera result = commands.getoutput("/usr/local/bin/ks -d " + self.__camera + " settime") def download_images(self): if self.is_on(): result = commands.getoutput("/usr/local/bin/ks -d " + self.__camera + " download") else: raise NotResponding, "Camera not responding" def download_thumbs(self): if self.is_on(): result = commands.getoutput("/usr/local/bin/ks -d " + self.__camera + " thumbs") else: raise NotResponding, "Camera not responding" self.convert_thumbnails() def convert_thumbnails(self): for thumb in glob('*.ppm'): thumb_path, discard = os.path.splitext(thumb) if not os.path.exists(thumb_path + 'thmb.jpg'): commands.getoutput('convert ' + thumb + " " + thumb_path + 'thmb.jpg') def is_on(self): result = commands.getoutput("/usr/local/bin/ks -d " + self.__camera + " getpowermode") if re.search("camera is on", result): return 1 elif re.search("camera is off", result): return 0 else: raise IOError, "Bad output from camera check -- " + result def delete_all_images(self): if self.is_on(): result = commands.getoutput("/usr/local/bin/ks -d " + self.__camera + " delall") else: raise NotResponding, "Camera not responding" def n_images(self): if self.is_on(): result = commands.getoutput("/usr/local/bin/ks -d " + self.__camera + " status") match = re.search("(\d+)", result) return int(match.group(1)) else: raise NotResponding, "Camera not responding" def shoot(self): # Todo: add a timestamp every time this is called; check and wait 30 seconds # before shooting again so camera can finish processing. if self.is_on(): result = commands.getoutput("/usr/local/bin/ks -d " + self.__camera + " shoot") else: raise NotResponding, "Camera not responding" class CameraError(exceptions.Exception): def __init__ (self, args = None): self.args = args class NoDevice(CameraError): pass class NotResponding(CameraError): pass -- Patricia J. Hawkins Hawkins Internet Applications, LLC From ajm at enteract.com Thu Jul 5 18:06:24 2001 From: ajm at enteract.com (Alan Miller) Date: Thu, 5 Jul 2001 17:06:24 -0500 Subject: Language Shootout References: <ldi4ktoc90c8kbeqq7epkq2dskp99etc3i@4ax.com> <9hv5qp$8g7$1@tyfon.itea.ntnu.no> Message-ID: <MPG.15aea0bfeeaaa4a59897dd@news-enteract> Magnus Lie Hetland (mlh at idi.ntnu.no) wrote: >"Ben" <b.e.n. at .r.e.h.a.m.e...c.o.m> wrote in message >news:ldi4ktoc90c8kbeqq7epkq2dskp99etc3i at 4ax.com... >> >> http://www.bagley.org/~doug/shootout/ >Odd... This gives a 404... On ... Err.. Slashdot, >it seems :-| The creator of the page had it hosted on a home(?) box with a traffic cap. He got Slashdotted, so he changed the dynamic DNS entries to point back to Slashdot instead. ajm From aleaxit at yahoo.com Wed Jul 4 05:37:25 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 4 Jul 2001 11:37:25 +0200 Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> <9hrj3q$cj1@news1.gtech.com> <bebbba07.0107031040.593143f8@posting.google.com> <9htgsb$ck3@news1.gtech.com> Message-ID: <9huo4n01jfl@enews1.newsguy.com> "Peter Milliken" <peter.milliken at gtech.com> wrote in message news:9htgsb$ck3 at news1.gtech.com... ... > There are studies that indicate that productivity in strongly typed > languages is higher (2:1 in one study I read - unfortunately, they are > "thin" on the ground because you need two identical ability teams doing the > same application in two different languages to get meaningful comparisions - > but it has been done and that was the result) than loosely typed languages. I'll appreciate some URL's, thanks. In exchange, please look at Lutz Prechelt et al's 1999 "phonecode" study -- e.g. at http://wwwipd.ira.uka.de/~prechelt/documents/jccpp_tr.pdf. 80 implementations of the same specs, some in "scripting languages" (Perl, Python, Tcl, Rexx), some in "system languages" (Java, C, C++). As it happens, Python was the only language for which NONE of the submitted programs was 'unusable' (11 of the original 91 were not further evaluated, being completely unusable). Overall results (my biased summary): programmer productivity is highest (by far) in Perl or Python (no statistically significant differences between Perl and Python). Program performance is highest in C and C++, followed by Perl and Python, followed by Java, with Tcl and Rexx far slower yet. Many of Prechelt's conclusions are invalidated by grouping Tcl and Rexx together with Perl and Python, but fortunately he also supplies raw data so you can redo the analysis. > Agreed, but one of my original points was about programmer ability. A The difference between the best and worst programmers in any single given language is far larger than any difference among languages, as evidenced in Prechelt's study -- in both productivity, and in correctness and performance of the resulting programs. E.g., the fastest Python and Perl programs are *HUNDREDS* of times faster than the slowest C and C++ ones, incredible as that may seem for what was a rather simple overall task. > successful. There is no one single factor that anyone can point to and say > "if you do that or use this" then you will be successful in your Oh yes there is -- have only the BEST programmers. How to insure THAT is left as an exercise for the reader:-). > Unfortunately, language choice is a very sensitive issue, and generally > doesn't come down to any rational factors - a lot of times it is "because I > like it" or "this is the newest, popular language, if I learn that one then > I can enhance my employment prospects" :-). The latter is a perfectly-rational factor. If you want to swing programmers' motivations towards "doing the best we possibly can on THIS one product", you have to make that compatible with their overall motivation of "have an interesting and financially rewarding career". Stock options, cash prizes for specific targets, whatever. Non-financial forms of recognition can also be very important...! If you want/need to treat your programmers as interchangeable parts, don't be surprised if they treat your project as just one short step within a long career. My impression is that most development shops underestimate the importance of keeping their best programmers and attracting other super-performers -- because it's not acknowledged yet that the individual performance variation between the best programmer in the best environment, and a mediocre programmer in a mediocre environment, is MANY orders of magnitude (easily a factor of 1,000 -- look at those *hundreds of times performance ratios* above-quoted for best-Python vs worst-C...!!!). Once this little fact does start to be realized, we may move into a kind of "superstar economy" for developers, as is currently in force in sports, show-business, CEO's, traders, and some professions (lawyers, doctors), where top performers earn _disproportionately_ more than mediocre counterparts -- which will have its own problems (and how!), but very different ones from today's relative "flattening" (where a performance that's 1,000 times better is only rewarded 10 or 20 times better, if that). Alex From jorjun at mac.com Sat Jul 21 08:28:22 2001 From: jorjun at mac.com (jorjun) Date: Sat, 21 Jul 2001 13:28:22 +0100 Subject: Case insensitivity References: <mailman.995506711.21636.python-list@python.org> <cpvgkofyru.fsf@cj20424-a.reston1.va.home.com> <9j9vfo$tpg$1@inputplus.demon.co.uk> Message-ID: <3B597566.FD190D74@mac.com> I don't believe that case insensitivity would neccessarily just deprive our expression. For instance I CAN imagine calling something "can" most of the time, but also "CAN" for emphasis. Taking case sensitivity to an absurd extreme : perhaps, now that most editors are GUI we could also use font or style sensitivity - bold/italic, etc. Peter (hardly ever serious) Ralph Corderoy wrote: > > Hi, > > > My own intuition and experience tells me that there seem to be two > > kinds of people: some folks think case-sensitively, others think > > case-insensitively. > > Doesn't the fact that most people learn the written form of their > natural language ahead of programming mean that they're used to the > concept of case (if their language has it) and understand that CAN and > can are different, the former being a different case to encode extra > information -- that it is an abbreviation. > > Sorry to add my twopence in an already crowded and `done to death' > thread. > > Ralph. From jwbaxter at spamcop.com Wed Jul 18 20:34:30 2001 From: jwbaxter at spamcop.com (John W. Baxter) Date: Wed, 18 Jul 2001 17:34:30 -0700 Subject: PEP: Defining Python Source Code Encodings References: <mailman.995466090.32686.python-list@python.org> Message-ID: <180720011734309383%jwbaxter@spamcop.com> In article <mailman.995466090.32686.python-list at python.org>, M.-A. Lemburg <mal at lemburg.com> wrote: > Here's an update of the pre-PEP. After this round of comments, the > PEP will be checked into CVS (provided Barry assigns a PEP number, > hi Barry ;-) > > -- > > Title: Defining Python Source Code Encodings > Version: $Revision: 1.2 $ > Author: mal at lemburg.com (Marc-Andr? Lemburg) > Status: Draft > Problem > > In Python 2.1, Unicode literals can only be written using the > Latin-1 based encoding "unicode-escape". This makes the > programming environment rather unfriendly to Python users who live > and work in non-Latin-1 locales such as many of the Asian > countries. Programmers can write their 8-bit strings using the > favourite encoding, but are bound to the "unicode-escape" encoding > for Unicode literals. This is a good statement of the problem. And the problem is real (although not for unilingual me, at this time). [At age 62, I'm very likely to remain essentially unilingual...French and German classes in the 1950s notwithstanding. I have trouble enough with one language.] >...[really important and well-presented stuff omitted] > > Scope > > This PEP only affects Python source code which makes use of the > proposed magic comment. Without the magic comment in the proposed > position, Python will treat the source file as it does currently > to maintain backwards compatibility. Ah...I had missed the Scope statement before, or it is new/different. It is much more likely that I missed it than that Marc-Andr? [the diacritical left here...whether it arrives or not I'll have to see] failed to say it before. As stated here, I can ignore the new feature and it won't affect me. Thank you. This statement of scope means I can sit on the sidelines and watch (perhaps cheering now and then). --John From arne at leithe.spammenot.no Mon Jul 16 11:36:20 2001 From: arne at leithe.spammenot.no (Arne Leithe) Date: Mon, 16 Jul 2001 15:36:20 GMT Subject: Partition Problem References: <tku1tt92ac2g8e@corp.supernews.co.uk> <3B4FBEA0.D5A6DC8A@engcorp.com> <9ioru22pc9@enews4.newsguy.com> <3B5042C2.F821D916@engcorp.com> <9itb14$2oi$1@newsg1.svr.pol.co.uk> Message-ID: <Xns90E0B338278B2arneleitheno@148.122.208.74> "Donovan Hide" <donovanhide at bigfoot.com> wrote in news:9itb14$2oi$1 at newsg1.svr.pol.co.uk: > [...] > a=Partition(7,4) > print a > > [[4, 1, 1, 1], [3, 2, 1, 1],[2,2,2,1]] How about this: def Bags(res, start = 1): return [[i] + bag for i in range(start, res / 2 + 1) \ for bag in Bags(res - i, i)] + [[res]] print filter(lambda e: len(e) == 4, Bags(7)) output: [[1, 1, 1, 4], [1, 1, 2, 3], [1, 2, 2, 2]] You can of course extend the filter any way you like, or remove it. Arne Leithe From chris.gonnerman at newcenturycomputers.net Mon Jul 23 09:04:39 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Mon, 23 Jul 2001 08:04:39 -0500 Subject: Alternate numeric proposal References: <mailman.995864377.19861.python-list@python.org> <3B5BC7EC.3FD6932@alcyone.com> Message-ID: <009001c11378$08f10120$0101010a@local> ----- Original Message ----- From: "Erik Max Francis" <max at alcyone.com> > Chris Gonnerman wrote: > > > > I have been following (and participating) in the integer division > > argument for some time (and a divisive one it is, too), and while > > standing in the shower (really!) an idea came to me. > > > > Why don't we add a hook to Python to control the numeric evaluation > > rules directly? > ... > > The module writer says, HEY, what about me? I need consistent math > > in my module! > > That's exactly the problem here. One of the primary reasons people are > objecting to the change is because it means a fundamental change in the > core language: a builtin operator behaves differently. The solution is > not generalizing all builtin operators, certainly -- that makes the > problem infinitely worse. Read a bit further down my rambling post and you'll see that I suggest allowing modules to declare their own default math rules. The semantics I was trying to figure out at 12:05 AM local time this morning are clearer in the daylight: Lookup operators in module scope, Fall back to global (__builtins__) scope, then Default to (some standard) operators package I was hoping that it could be arranged so that the main program/module could call import tutorial_math and have it installed immediately in the global scope, but then calling import advanced_math in a module would have to *not* screw with the global scope. Now I think that the main program should do this: import tutorial_math __builtins__.numerics = tutorial_math.numerics where the .install() function would rewrite the global setting. A module would do this: import rational_math __numerics__ = rational_math.numerics Going through the entire standard library and inserting the *same two lines* a the top of all the pure Python modules wouldn't be hard at all. Having offered this, I'm not sure I like it... but I do like the idea of programmers of all stripes (novice to advanced) being able to specify how basic arithmetic should work. Novices would (we hope) use only math modules created by experts, but this gives the experts powerful tools. Also, it's explicit rather than implicit. From NOSPAM.hnguyen421 at NOSPAM.hotmail.com Thu Jul 5 05:35:04 2001 From: NOSPAM.hnguyen421 at NOSPAM.hotmail.com (alphaZeta) Date: Thu, 5 Jul 2001 11:35:04 +0200 Subject: system exec ? Message-ID: <9i1er4$mth$1@news.businessobjects.com> Hi, I didn't find any documentation (lib and tut) about how to execute a program in a python script. Does anybody know ? For example : I would like to store in a variable the result of a call to the system. alike : >>> a = sys.exe("ls -l") Cheers, From jkraska1 at san.rr.com Tue Jul 24 02:04:36 2001 From: jkraska1 at san.rr.com (Courageous) Date: Tue, 24 Jul 2001 06:04:36 GMT Subject: PEP0238 lament References: <LNBBLJKPBEHFEDALKOLCEEEILAAA.tim.one@home.com> <mailman.995948081.23225.python-list@python.org> Message-ID: <5g2qlt8dj64f6tbdqalnrc6bf33e8rokjd@4ax.com> On Tue, 24 Jul 2001 00:13:23 -0400, Justin Sheehy <justin at iago.org> wrote: >"Tim Peters" <tim.one at home.com> writes: > >> Good thing you stopped before mentioning Perl (yes, 1/2 is 0.5 there) > >Sure, but 1 == "1" there as well. This isn't that onerous. Presumably the way this could be invented would be with string objects supporting a toInt() method. I don't think I like this kind of implictness in this particular situation, however. C// From neal at metaslash.com Sun Jul 22 13:53:08 2001 From: neal at metaslash.com (Neal Norwitz) Date: Sun, 22 Jul 2001 13:53:08 -0400 Subject: ANN: PyChecker version 0.7.5 Message-ID: <3B5B1304.1CB93B81@metaslash.com> In keeping with the open source spirit--release early, release often-- I am releasing another version of PyChecker. Or at least half a version... It's amazing how motivation it is to code after spending a week doing doc. So that means the doc is even more lacking for PyChecker. :-) There are several highlights to this version. The most significant changes involve the new functionality to suppress warnings. Two mechanisms are provided to get PyChecker to shut up. 1) You can put directives in the code: __pychecker__ = 'no-namedargs maxlines=0 maxbranches=0' This will turn off checking for named arguments, max lines, and max branches. If the line is used at the module scope, the new configuration will be used for the module, including classes, functions, and methods in the module. If the line is used within a function/method, the new configuration will be used within the function/method only. 2) You can define suppressions, a dictionary, in .pycheckrc. suppressions = { 'mymodule': 'maxreturns=0' } This will turn off max returns for all functions/methods within mymodule. You can specify modules, classes, functions/methods as the keys: 'mymodule.myfunc' 'mymodule.myclass' 'mymodule.myclass.mymethod' The suppressions will only effect the scope specified. Regular expressions aren't currently supported. Would that be useful? This change affected the way the command line processing occurred. The names used in warning suppression are the same as those used for command line processing. So for the long arguments, if you specify the argument as "arg" that means the argument will be turned on. If you specify "no-arg" that means the argument will be turned off. Other than that change, there were more warnings added (and catching more cases). Also, I tried to clean up a lot of the spurious warnings. So you should get a better result set now. The only big problem that exists (that I know of) is that packages are not handled properly. I hope to fix that and add a lot more static type checks. Let me know if you have any problems, questions, suggestions, etc. Change Log: * Suppress warnings on a per module/function/class/method basis with new suppressions = {} in .pycheckrc * Suppress warnings by setting __pychecker__ in source code * Change long argument behaviour --arg sets arg to true, --no-arg sets arg to false (also works for warning suppression) * Add -U/--reuseattr check if function/class/method names are reused * Add -T/--argsused check for unused method/function arguments * Add -G/--selfused ignore if self is unused in a method (requires --argsused) * Add -q/--stdlib to disable warnings from the standard library * Add -o/--override warning when a method has different signature than one being overridden in a base class * Add -F/--rcfile to generate a .pycheckrc file * Fix checking files in standard library before local file * Fix spurious warning when using from X import Y and imports in methods (Module (m) re-imported) * Fix spurious warning when doing: from X import Y, Z * Fix spurious warning when deriving from Exception() and instantiating object with multiple arguments * Fix method argument checks when calling base class methods * Fix error msg to base constructors (msg count was wrong) * Fix access to builtin module attributes (e.g., sys.exc_value) generating 'No attribute warnings' 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 aleaxit at yahoo.com Sun Jul 8 04:05:48 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 8 Jul 2001 10:05:48 +0200 Subject: anonymous variable References: <9i791n$3bh$1@macareux.ens-lyon.fr> <9i7tjq01b9o@enews3.newsguy.com> <9i88o3$hj41s$1@ID-91128.news.dfncis.de> Message-ID: <9i945202rvq@enews3.newsguy.com> "Vladimir Nesterovsky" <vnestr at netvision.net.il> wrote in message news:9i88o3$hj41s$1 at ID-91128.news.dfncis.de... > It might be viewed as a "value sort" or "sort by value", > meaning that a natural sort is done on a list as if each > its element was represented by some value comparable > with the "<" operator, produced by a user-specified function: Right; in addition (which I didn't show in my last post, but explain in my Cookbook entry at http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52234) it's also pretty easy to make it stable (so that items of the original list that map to the same comparable remain in the same order as in the original list, a frequent spec:-). > def vsort (ls, f): > x = map(lambda e,g=f : (g(e),e), ls) > x.sort() > return map(lambda p:p[1],x) > > and call it > > alist = vsort(alist, lambda x: x[2]) > > This is doing the same thing that your function is doing by a > different syntax; knowing as little Python as I do I just don't > know which way's faster. :-) One should measure times in each specific case, but, roughly, list comprehensions tend to be a smidgeon faster than map with a lambda, a smidgeon slower than map when a real function is already available and needs to be called anyway. > In Perl they call it Schwartzian transform, but the paradigm's That's what I thought, too, and I mention it in the Cookbook entry, but I'm told the Schwartzian Transform is _specifically_ about making it all a one-liner with Perl's grep. So I coined the 'decorate=sort=undecorate' (DSU) name for the pattern in the more-general case; descriptive, if nothing else:-). Alex From cribeiro at mail.inet.com.br Tue Jul 3 18:27:29 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Tue, 03 Jul 2001 19:27:29 -0300 Subject: Python for air traffic control? In-Reply-To: <bebbba07.0107031040.593143f8@posting.google.com> References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> <9hrj3q$cj1@news1.gtech.com> Message-ID: <5.0.2.1.0.20010703190237.02c051d0@mail.inet.com.br> Many of the concerns raised on the group are related to memory-related problems: allocation/deallocation and garbage collection, which can be an plentiful source of bugs. I have some specific suggestions to deal with them, which may or not be applicable in your case. - You can avoid allocation/deallocation in some languages by using static structures, or by preallocating as much memory as possible. For example, you could preallocate a vector to contain all the data from the aircrafts. In this case you would have a maximum limit hardcoded in the software, but this is not as bad as it may seem, because the limit is *deterministic*. One of the problems of relying on dynamic allocation is that you never know when it is going to fail, because it depends on the amount of memory allocated for other purposes. This technique is can't be easily applied in Python due to the nature of the language. It is still possible to do it in some particular cases, but not as extensively as in C/C++. - Don't rely on a long-running process for everything. Use multiple short-running processes for batch-style tasks, and a lightweight dispatcher to coordinate them. The batch-style tasks must be run on separate interpreters. While the performance penalty may be not as acceptable for many real-time tasks, you have one specific advantage: every new instance of the interpreter always start with a fresh memory heap. This will allow you to avoid fragmentation-related problems, which may happen on any platform after a long time (not to mention Win98, where it *always* happen in few time). The second technique must not be used alone, but it can be combined with other optimizations with good results. The basic idea is there, it's just a matter of using it wisely. Carlos Ribeiro From emile at fenx.com Thu Jul 12 13:18:30 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 12 Jul 2001 10:18:30 -0700 Subject: Can anyone offer a suggestion? References: <9ikgpq$j1cff$1@ID-11957.news.dfncis.de> <9ikhp6$jivuc$1@ID-11957.news.dfncis.de> Message-ID: <9ikmdl$je7vm$1@ID-11957.news.dfncis.de> Not that anyone cares, but I think I've figured out that what's going on is that the '*' is sometimes trying to act on the string and that properly formatting the argument as a single tuple fixes the problem. I'm still not sure why it sometimes appears to accept non-parenthetical '*'d arguments, but I'm guessing it's got something to do with coercion, and that's a problem for another day. Thanks for listening and have a nice day... ;-) -- Emile van Sebille emile at fenx.com --------- "Emile van Sebille" <emile at fenx.com> wrote in message news:9ikhp6$jivuc$1 at ID-11957.news.dfncis.de... > I found it in the source (I think), in stringobject.c there's a formatfloat > routine that looks like it requires a float. If this is the right routine, > I'm still stumped. > > -- > > Emile van Sebille > emile at fenx.com > From db3l at fitlinxx.com Tue Jul 31 17:30:52 2001 From: db3l at fitlinxx.com (David Bolen) Date: 31 Jul 2001 17:30:52 -0400 Subject: Arg decoding with a template? References: <ljidmtouqj6som2t9ecagbkj95c53kjaeh@4ax.com> <4oA97.5883$9i1.519137@e420r-atl1.usenetserver.com> <duodmt0itqq9t1kq6bs5dhpnk9io64p2sj@4ax.com> <ulml5sz7m.fsf@ctwd0143.fitlinxx.com> <jvD97.6781$9i1.583088@e420r-atl1.usenetserver.com> Message-ID: <ubsm0u6pf.fsf@ctwd0143.fitlinxx.com> "Steve Holden" <sholden at holdenweb.com> writes: > "David Bolen" <db3l at fitlinxx.com> wrote in message > news:ulml5sz7m.fsf at ctwd0143.fitlinxx.com... > > Dale Strickland-Clark <dale at riverhall.NOSPAMco.uk> writes: > > > > > "Steve Holden" <sholden at holdenweb.com> wrote: > > > > Oh no I didn't. Which is to say, the message would make more sense with the > above attribution deleted, since all (now double-) quoted comments are > Dale's. Sorry - my apologies for any mis-attribution - I just took what was in Dale's posting, although you seem to have added an extra level of > - my post only had a single > in front of Dale's stuff and nothing in front of the "Dale ... writes" line. > There is, of course, a history for both "-" and "/", and in point of fact > TOPS-10 was using "/" for command switches (as ISTR they were called) before > Unix was around. Wrote the command line processor for a TOPS-10 SPITBOL > compiler, and a switch with a value used a colon separator, as in > > sbl /code:sixbit myprog.sbl Yep, and not only that but with the CCMD JSYS (at least under TOPS-20) having the CLI handle all command completion and help with ?, including for options and arguments to options was terrific. Nicest CLI for an OS I've ever used, and I still think it's the best interactive command interface approach. Somewhat of a drain to actually construct all the proper tables in code though, but worth it. Although personally, I still find "-" looks a little nicer on a command line. -- -- 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.hochberg at ieee.org Thu Jul 26 15:21:22 2001 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Thu, 26 Jul 2001 19:21:22 GMT Subject: Toppling the numeric tower References: <DLW77.49367$Cy.6275542@news1.rdc1.az.home.com> <eppstein-749F84.08434526072001@news.service.uci.edu> Message-ID: <S4_77.49614$Cy.6352181@news1.rdc1.az.home.com> "David Eppstein" <eppstein at ics.uci.edu> wrote in message news:eppstein-749F84.08434526072001 at news.service.uci.edu... > In article <DLW77.49367$Cy.6275542 at news1.rdc1.az.home.com>, > "Tim Hochberg" <tim.hochberg at ieee.org> wrote: [SNIP] > > I would strip this down to > > > > A. iscomplex() > > B. isexact() > > C. isintegral() > > I have to say that this would be more convenient for situations such as > defining your own extension of number types for, say, exact arithmetic in > Q[sqrt(3)]. Or even better Q[sqrt(-3)]. I was wishing I was able to do > this recently for a different project unrelated to Python, unfortunately > the program I was using didn't make it easy to plug in your own number > types... > > But a couple points of clarification: > (1) is it safe to assume that isintegral() implies isexact()? Probably. Numbers that return true for from isintegral() should be usable anywhere that Python integers are used today. In particular, if a and b are integral in this sense then a & b, a ^ b, a | b, a << b, a >> b and sequence[a] should all work. One could allow numbers that are have integral values but are not exact (e.g., 1e0, 2e0, etc) to be used in these circumstances, but consider the following: >>> 1e0 << 2e0 4 # exact or 4e0 # inexact Either answer sucks: the first turns two inexact operands into an exact result, while the second represents the results of bit twiddling, a discrete operation if ever there was one, as an inexact, floating point number. The best choice is to insist on exact numbers for integer operations. Note that I don't know that this is the meaning for isintegral meant by PEP 228, but it is the one that makes sense to me. > (2) should isintegral() return true for algebraic integers that are not > rational integers? No, for the reasons I've given above. It may be that there is a better way to spell isintegral that makes it clear that it means isusablewhereoldpythonintswereusable(). -tim From whats_really_hot at hotmail.com Fri Jul 6 08:15:30 2001 From: whats_really_hot at hotmail.com (whats_really_hot) Date: Fri, 6 Jul 2001 15:15:30 +0300 Subject: any books for python for downloading? References: <993939668.727430@athnrd02.forthnet.gr> <0yX%6.1611$h45.10769@news.uk.colt.net> Message-ID: <994422510.510089@athnrd02.forthnet.gr> yea.great sites but they don't have any books for downloading, only for web reading and this requires time -internet time, which is unfortunately expensive. so, any other proposals for sites that contain text about python tutoring? every recommendation is welcome! thanks in advance! From paul at boddie.net Thu Jul 5 05:22:34 2001 From: paul at boddie.net (Paul Boddie) Date: 5 Jul 2001 02:22:34 -0700 Subject: basic (mx) ODBC question References: <994236193.821045@nntp01.uskonet.com> Message-ID: <23891c90.0107050122.6aed9455@posting.google.com> "Hanna Joo" <hanna at chagford.com> wrote in message news:<994236193.821045 at nntp01.uskonet.com>... > Hi all > > I don't understand ODBC well. From the little that I understand - postgresql > has its ODBC driver (on linux). I am connecting from windows. mxODBC is a > module I can use. mxODBC suggests that if I am connecting from windows, I > should (from here mad rambling because I don't know what the doc is saying) > compile using VC compiler on windows. That may depend on binary availability of the package for Windows. I don't remember anyone releasing binaries for mxODBC recently. > I thought ==> > > ODBC python talks to on windows -- ODBC manager on Win machine -- ODBC > module of pgsql. > (on win machine) (between win machine and > linux server) (linux server) The problem with ODBC by itself is that, as far as I am aware, it doesn't address the issue of communication between client and server, program and database system, or whatever. Therefore, you need to choose drivers which will let you have the distributed communication that you desire. In the past, I have used drivers for an obscure, proprietary database system which can be installed in the Windows ODBC driver manager and which can be configured to communicate with remote servers running the database instances. I don't know whether there are any such drivers for postgresql, but then I have never used it on Windows or UNIX (or both!). > mxODBC has many subpackages for various DBs.. how does it work then? Does it > work like the following? > > python talks (or uses) to mxODBC that is postgresql specific -- ODBC module > of pgsql > (same machine) Going from my experiences with mxODBC on UNIX [1], one can compile mxODBC with a specific subpackage which knows about a particular ODBC implementation. In my case, I compiled it with knowledge of the Sybase Adaptive Server Anywhere ODBC library. This meant that mxODBC linked directly to that library at run-time. > Or... > > python talks to mxODBC that creates an entry for win ODBC that is postgres > specific -- ODBC module of pgsql Well, this would mean compiling the Windows subpackage, which I presume is aware of the details of the Windows ODBC driver manager. If you have a postgresql driver for the Windows ODBC driver manager, then mxODBC doesn't need to know explicitly that it's using postgresql, but the postgresql driver obviously needs to integrate with the driver manager. > or... > > python talks to ODBC on linux -- iODBC on same machine -- ODBC module of > pgsql > (same machine) This can also be done, although you're removing Windows from the architecture, unless you are suggesting that Python is talking across a network to the Linux host where iODBC resides; this would involve you inventing or discovering a protocol which lets this happen, since ODBC doesn't mandate such protocols itself. I have seen an ODBC network gateway package, but this exported Windows-resident database systems to other hosts, not the other way around. > mxODBC has different subpackages as I said, one being Windows.. I don't > understand how that works.. different packages for different databases and > one for windows? Well, there's an iODBC subpackage, if I remember correctly, so you could say that there are "different packages for different databases, one for Windows and one for UNIX". ;-) But the most pertinent detail is the "point of integration" between mxODBC and the ODBC drivers. Either one integrates mxODBC with a driver manager (Windows or iODBC), or one integrates it with a particular database system's own driver (Sybase ASA). The advantage of integrating with a driver manager is the lack of need to recompile mxODBC should you change or add database systems. The advantage of integrating with a specific implementation is, in practice, increased functionality, performance (I would think) and reliability. > (realizing post lacks focus as a result of pathetic lack of understanding) > > Can sombody direct me to a site where I may be able to find out more about > this ODBC issue? The mxODBC site may provide some detail, but you might want to visit my "mxODBC Configuration Guide" [1] which provides links to software which may let you achieve your distributed environment ambitions. Regards, Paul [1] http://www.paul.boddie.net/Python/mxODBC.html From Gareth.McCaughan at pobox.com Sun Jul 8 14:35:48 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Sun, 8 Jul 2001 19:35:48 +0100 Subject: Comment on PEP-0238 References: <mailman.994532533.10229.python-list@python.org> Message-ID: <slrn9kha04.1pf2.Gareth.McCaughan@g.local> Tim Peters wrote: > Alternative: Given the point about dumbdbm above, the missing half is a > builtin to return (mathematically) ceiling(i/j) too. A very direct approach > to both is to forget div/idiv and introduce two-argument builtins > > floor(i, j) # return floor of mathematical quotient > ceiling(i, j) # return ceiling of mathematical quotient > > instead. They should also have 1-argument flavors, corresponding to the > current math.floor and math.ceil. This would emphasize that the real point > to all this stuff is computing floors and ceilings, not really about the > numeric types of division arguments (that's always been a red herring!). All you have to do now is to add two more similar functions called "round" and "truncate", and you've rediscovered the approach taken by Common Lisp. (Except that CL's floor/... functions return two values, the quotient and the remainder; but CL takes a different approach to multiple return values from Python's.) If I liked Python less than I do, I'd see a sign of Greenspun's Tenth Rule of Programming at work. -- Gareth McCaughan Gareth.McCaughan at pobox.com .sig under construc From matt at mondoinfo.com Wed Jul 25 19:41:23 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Wed, 25 Jul 2001 23:41:23 GMT Subject: Language change and code breaks References: <Pine.LNX.4.33.0107191316390.24983-100000@bms> <mailman.995571273.18192.python-list@python.org> <9j7gv8$9mg@dispatch.concentric.net> <cppuawfqbm.fsf@cj20424-a.reston1.va.home.com> <Pine.LNX.4.33.0107231434170.15565-100000@oliphant.ee.byu.edu> <532qlt453irrepptskcvp213d44r3so2e2@4ax.com> <cp4rs2qf6p.fsf@cj20424-a.reston1.va.home.com> <3B5DF282.87266DA2@earthlink.net> <cpr8v5a8h5.fsf@cj20424-a.reston1.va.home.com> Message-ID: <slrn9lum92.ll.matt@happy-hour.mondoinfo.com> On Wed, 25 Jul 2001 05:22:32 GMT, Guido van Rossum <guido at python.org> wrote: >I have changed my mind. I think that if I had to start over, I would >indeed try my hands at a case-insensitive language aimed at teaching >programming to beginners, with tools to enforce case consistency. >Given that nobody else who currently uses Python thinks this is a >good idea No quite nobody. But I tend to stay out of the flamewars. >I then settled on a case-sensitive language with case-preserving >tools. But now I think neither is worth fighting for. Both are excellent ideas if you ask me but, alas, I fear you're right. Regards, Matt From new_name at mit.edu Fri Jul 13 12:31:19 2001 From: new_name at mit.edu (Alex) Date: 13 Jul 2001 12:31:19 -0400 Subject: PyDNS? References: <3B4ECBE0.96898063@stroeder.com> Message-ID: <etdn168bxk8.fsf@hodge-podge.mit.edu> There's name resolution facilities in adzapper, for what it's worth. I can't remember whether they're part of medusa, or not, but you may want to check it out. Alex. From guido at python.org Tue Jul 24 15:33:34 2001 From: guido at python.org (Guido van Rossum) Date: Tue, 24 Jul 2001 19:33:34 GMT Subject: 2.2 features References: <gER67.534750$eK2.111982758@news4.rdc1.on.home.com> <slrn.pl.9lo6uq.ss0.qrczak@qrnik.zagroda> Message-ID: <cpg0bmqfzs.fsf@cj20424-a.reston1.va.home.com> Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl> writes: > Mon, 23 Jul 2001 08:55:40 GMT, Nick Perkins <nperkins7 at home.com> pisze: > > > Isn't there anything in 2.2 that deserves even a fraction of the discussion > > going on about div? (which has been beaten to death 9 times) > > > > getset(), staticmethod(), classmethod(), etc... > > I must say that the current state of type/class unification is so > complex that I don't understand the details, all these slots and > wrappers and types, and why > 5 .__new__(list, '42') == 42 > for example. Sorry, that's a bug; this should be rejected as list is not a subtype of int. > I home that the following piece of documentation is temporary! > > Isn't this backwards incompatible? Won't it break existing code? It > would, if we changed the method resolution order for all classes. > However, in Python 2.2, the new lookup rule will only be applied to > types derived from built-in types, which is a new feature. Class > statements without a base class create "classic classes", and so do > class statements whose base classes are themselves classic classes. > For classic classes the classic lookup rule will be used. (To > experiment with the new lookup rule for classic classes, you will be > able to specify a different metaclass explicitly.) We'll also provide > a tool that analyzes a class hierarchy looking for methods that would > be affected by a change in method resolution order. There are many things that could be improved here. What exactly is bothering you about it? --Guido van Rossum (home page: http://www.python.org/~guido/) From com-nospam at ccraig.org Fri Jul 20 20:17:12 2001 From: com-nospam at ccraig.org (Christopher A. Craig) Date: 20 Jul 2001 20:17:12 -0400 Subject: Most efficient solution? In-Reply-To: <E6367.7541$EP6.2460187@news1.rdc2.pa.home.com> References: <mailman.995289809.28477.python-list@python.org> <slrn9l5urp.nto.alf@leo.logilab.fr> <OeF47.11959$p7.3571067@news1.rdc2.pa.home.com> <wkk813nz6e.fsf@mail.connact.com> <mailman.995662297.13101.python-list@python.org> <E6367.7541$EP6.2460187@news1.rdc2.pa.home.com> Message-ID: <87y9pj6sqf.fsf@elbereth.ccraig.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 "Terry Reedy" <tjreedy at home.com> writes: > To compare program running times, they should compute the same thing. > > How long does dict2 take if you remove the not, so it makes the list > of 1500 elements that revised dict does, instead of the 'not' list of > 6000? > > How long does dict take if you feed filter with 'lambda x, > f=c.has_key: f(x)', so it make the 'not' list of 6000 elements? > dict2 without the not takes (predictably) about twice as long as dict (.038 seconds vs. .019) (because the explicit loops in the list comprehensions are slower) dict with a not takes (also predictably) slightly longer than dict2 (.06 vs .055) (because the overhead of a lambda is higher than the loops) My point was not to compare dict to dict2, but to show that the original author's comp() was greatly outperformed by a proper dictionary solution. (Note that I'm using a new computer, so the numbers don't align with the one I used for the first set of tests) - -- Christopher A. Craig <com-nospam at ccraig.org> Perl is worse than Python because people wanted it worse -- Larry Wall -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: Processed by Mailcrypt iEYEARECAAYFAjtYyggACgkQjVztv3T8pztQNQCaA3MNfa6wr3eHuBHhPA20te2t hjcAn0CFRVX+SJ3p2gEDjiTSPI41sCbM =DwzQ -----END PGP SIGNATURE----- From jeff at ccvcorp.com Tue Jul 3 14:33:12 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Tue, 03 Jul 2001 11:33:12 -0700 Subject: run activepython v2.1 from a folder? References: <a50631f6.0107021259.209fbae8@posting.google.com> Message-ID: <3B420FE8.AEC3D57A@ccvcorp.com> newgene wrote: > Is it possible to solve this problem and run the activepython v2.1 > from a folder independent on system registry? > > Thank you > > Newgene I believe that ActivePython is dependent upon the system registry, so this may not be possible for you. However, PythonWare has a registry-independent distro at http://www.pythonware.com/products/python/index.htm This should work for your purposes, if I'm interpereting those purposes and PythonWare's info correctly. :) Jeff Shannon Technician/Programmer Credit International From JamesL at Lugoj.Com Tue Jul 24 17:26:11 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Tue, 24 Jul 2001 14:26:11 -0700 Subject: Proposal for .py2, py3, etc. extensions. Was: A way to accommodate laguage changes References: <3B5CB83B.F3B7D51@home.net> <5E877.23798$EP6.5677355@news1.rdc2.pa.home.com> <23891c90.0107240128.4715d705@posting.google.com> <3B5DC56F.3B84E77D@alcyone.com> <3B5DE39C.543DA6@home.net> Message-ID: <3B5DE7F3.EB5EC5F1@Lugoj.Com> Chris Barker wrote: > > Erik Max Francis wrote: > > Paul Boddie wrote: > > > > > "from __past__ import" anyone? ;-) > > > > This occurred to me as well, but it still doesn't address the problem of > > backward compatibility. With a from __past__ import construct or not, > > legacy code will still break. The problem is not fixing old code, it's > > being unable to fix old code that is no longer accessible (either from > > being passed around or by being instrumented at a client site). > > Exactly. I think everyone would be a LOT happier if you could run old > code on a new interpreter, without ANY CHANGES AT ALL. > > I think my proposal will allow that, someone plese commment on it!! Sure: your proposal isn't bad. That is, absent any "pragma" the interpreter assumes "old" semantics. But it does require programmers doing new development to add that line of text in all their modules. And it has the nice effect of spitting out an error when run by a 1.5.2 interpreter. But it can get tiresome always adding that. So perhaps one should put the indicator in the module name itself: In the interest of proposing a solution everyone can live with, may I suggest adoption of new module name extensions? A module named "module.py2" will not be picked up or understood by Python 1.x on any platforms that I am aware of. These would be compiled to either ".pyc", ".py2c", or ".pc2", depending on whether one can compile the new semantics into code old interpreters can handle, and whether it is now okay to allow more than 3 letters in file extensions on all popular platforms and file systems. But hopefully everyone gets the idea. Anyone see any insurmountable flaws with this? (Just trying to help; I hate to abandon Python without at least trying one diplomatic solution to at least one serious objection.) From mirko.liss at web.de Thu Jul 19 04:47:18 2001 From: mirko.liss at web.de (Mirko Liss) Date: Thu, 19 Jul 2001 10:47:18 +0200 Subject: Language change and code breaks In-Reply-To: <slrn9lc1rt.6j0.grey@teleute.dmiyu.org> References: <mailman.995378792.16515.python-list@python.org> <cpvgkq1f2b.fsf@cj20424-a.reston1.va.home.com> <slrn9lc1rt.6j0.grey@teleute.dmiyu.org> Message-ID: <20010719084721.75050AE1.NOFFLE@niccolo.ke4.de> On Wed, 18 Jul 2001, Steve Lamb wrote: [..case-sensitivity..] > Eh, preference is for case sensitivity. Besides, I far prefer case > sensitivity with tab completion than case insensitivity without. :) What about case-sensitive Python combined with case-insensitive tab-completion in IDLE? With an option to switch it off, of course. That way, beginners won't be bound to the 'case-sensitivity' discipline by endless error messages but they'll be gently reminded when typing the code. Since that IDE is written in python, that function could be easily extended to handle diacritics, umlauts, even smilies &c, if one really thinks the students need this. And if one doesn't like it, he or she can switch it off. Let's keep Python really simple. We can always provide conveniences in external tools which are not necessary for the functioning of the core language. Friendly regards, Mirko Liss From sholden at holdenweb.com Sun Jul 8 16:27:08 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sun, 8 Jul 2001 16:27:08 -0400 Subject: Confusion about dictionaries - keys use value or identity? References: <roy-58C72C.12353708072001@news1.panix.com> Message-ID: <Fk327.14800$i8.1312575@e420r-atl3.usenetserver.com> "Roy Smith" <roy at panix.com> wrote in message news:roy-58C72C.12353708072001 at news1.panix.com... > I'm kind of confused about exactly what happens when I use a string as a > dictionary key. Section 3.2 of the reference manual seems to imply that > keys are compared by identity: > > > The only types of values not acceptable as keys are values containing > > lists or dictionaries or other mutable types that are compared by value > > rather than by object identity > > but experimenting shows they it seems to really use value, not identity: > > >>> a = 'foo' > >>> b = 'f' + 'o' + 'o' > >>> a == b > 1 > >>> a is b > 0 > >>> x = {} > >>> x[a] = 'this is a' > >>> x[b] > 'this is a' > > Is there a way to force the comparison to be by identity? I'm > contemplating building a cache (using a dictionary), and key comparison by > identity should be significantly faster than by value, because I'm going to > be using rather long strings as keys. Paul Prescod has given you an answer to most of your post. As far as using strings goes, unless they are all the same legnth and al have the same leading characters the comparison might not be as slow asyou think (although it clearly won't be as fast as identity). Key comparison of strings will test the lengths fisrt, and if the lengths are the same will stop once two unequal characters are found... regards Steve -- http://www.holdenweb.com/ From mal at lemburg.com Thu Jul 12 14:56:05 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Thu, 12 Jul 2001 20:56:05 +0200 Subject: ANN: eGenix.com mx EXPERIMENTAL Extension Package 0.3.0 Message-ID: <3B4DF2C5.2AF2810F@lemburg.com> ________________________________________________________________________ ANNOUNCING: eGenix.com mx EXPERIMENTAL Extension Package for Python Version 0.3.0 Experimental Python extensions providing important and useful services for Python programmers. ________________________________________________________________________ WHAT IS IT ?: The eGenix.com mx EXPERIMENTAL Extensions for Python are a collection of alpha and beta quality software tools for Python which will be integrated into the other mx Extension Packages after they have matured to professional quality tools. Python is an open-oriented Open Source programming language which runs on all modern platforms (http://www.python.org/). By integrating ease-of-use, clarity in coding, enterprise application connectivity and rapid application design, Python establishes an ideal programming platform for todays IT challenges. ________________________________________________________________________ WHAT'S NEW ? The mxNumber package was updated to better integrate the provided number types with Python's builtin types. In addition to providing more coercion paths, the integer object in mxNumber has also grown a whole set of useful methods. And last, not least, there's a web-page for mxNumber which provide some details about the new types. It is still far from being complete, but provides some good starting points for those living on the bleading edge. ________________________________________________________________________ EGENIX.COM MX EXPERIMENTAL PACKAGE OVERVIEW: mxNumber - Python Interface to GNU MP Number Types mxNumber provides direct access to the high performance numeric types available in the GNU Multi-Precision Lib (GMP). This library is licensed under the LGPL and runs on practically all Unix platforms. eGenix.com has ported the GMP lib to Windows, to also provide our Windows users with the added benefit of being able to do arbitrary precision calculations. The package currently provide these numerical types: 1. Integer(value) -- arbitrary precision integers much like Python long only faster 2. Rational(nom,denom) -- rational numbers with Integers as numerator and denominator 3. Float(value[,prec]) -- floating point number with at least prec bits precision 4. FareyRational(value, maxden) -- calculate the best rational represenation n/d of value such that d < maxden ________________________________________________________________________ WHERE CAN I GET IT ? The download archives and instructions for installing the packages can be found at: http://www.lemburg.com/files/python/ ________________________________________________________________________ WHAT DOES IT COST ? The EXPERIMENTAL packages uses different licenses in its subpackages. Please refer to the subpackage documentation for details. Some of them may be integrated into the BASE package, others will be integrated into the COMMERCIAL package. The package come with full source code ________________________________________________________________________ WHERE CAN I GET SUPPORT ? There currently is no support for these packages, since they are still in alpha or beta. Feedback is welcome, though, so don't hesitate to write us about the quirks you find. ________________________________________________________________________ REFERENCE: <P><A HREF="http://www.lemburg.com/files/python/">eGenix.com mx EXPERIMENTAL Extension Package 0.3.0</A> - eGenix.com mx EXPERIMENTAL Extension Package 0.3.0 with precompiled binaries for Windows and Linux. (12-Jul-2001) ________________________________________________________________________ Enjoy, -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From jeff at ccvcorp.com Tue Jul 31 14:27:42 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Tue, 31 Jul 2001 11:27:42 -0700 Subject: Deposing Dictators References: <9jmjne$q54$1@wisteria.csv.warwick.ac.uk> <3b602daf.1623450@nntp.sprynet.com> <slrn9m111q.e6f.Gareth.McCaughan@g.local> <dOoGUKA3PKY7EwWa@jessikat.fsnet.co.uk> <cpsnfi2z9w.fsf@cj20424-a.reston1.va.home.com> <$dK+wKA$tZY7Ewin@jessikat.demon.co.uk> <3b61a98d$0$11917@wodc7nh0.news.uu.net> <3B61B01F.6C6B2B5D@Lugoj.Com> <6c8b7eb9.0107271358.4783d9c1@posting.google.com> Message-ID: <3B66F89E.77E64413@ccvcorp.com> Dirck Blaskey wrote: > When I first heard about this back then, I had a > knee-jerk-dogmatic-negative-reaction to it. Now, I believe > I understand the motivation for the change better, and I also > understand where the reaction comes from. I'd just like to add my wholehearted concurrence on this. My initial thought on division change was one of horror. After having read through the (relatively few) reasoned responses, my opinion has changed. It is obvious that Guido *does* know what he's doing, even if not everyone agrees with the direction he wants to take. I think that part of the problem, that inspired such FUD, was the lack of a clearly explained rationale in the relevant PEPs and early discussions here--probably in part because the rationale had been explained to death in other fora. Seeing the division change as a necessary precursor to full numeric-model integration makes this an entirely different issue than "we think the current division might confuse a few people", which (unfortunately) is the impression that some people (I at least) received at the start of this mess. In short, I think we should all try to have a little more faith in Guido, even if we don't agree with all of his proposals. His design instincts have proved to be right, time and time again. Python is a wonderful language to work with, and is an *incredible* relief to come back to after dealing with some of the other mess I have to work with. (A primitive, proprietary dialect of basic that makes VB look clean, and an ugly proprietary language that makes *that* basic look pleasant! And all on a platform where *every* variable is global.... >shudder< ) Thanks, Guido, and all of the PythonLabs crew. Jeff Shannon Technician/Programmer Credit International From shalehperry at home.com Fri Jul 20 11:36:45 2001 From: shalehperry at home.com (Sean 'Shaleh' Perry) Date: Fri, 20 Jul 2001 08:36:45 -0700 (PDT) Subject: Python equivalent of two Perl statements In-Reply-To: <E566B020833BD311B6610008C791A39705CA526E@il93exm04.css.mot.com> Message-ID: <XFMail.20010720083645.shalehperry@home.com> On 20-Jul-2001 Kemp Randy-W18971 wrote: > What is the equivalent of these Perl statements in Python? > > $time = scalar(localtime); > print "This FTP request started on $time \n"; > import time now = time.ctime(time.time()) print now time.time() returns seconds since the epoch, ctime() turns it into the string like perl does. There are several other interesting time printing functions in the 'time' module. From scarblac at pino.selwerd.nl Thu Jul 12 05:12:36 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 12 Jul 2001 09:12:36 GMT Subject: LAMBDA IS IT USELESS? References: <tO837.679712$166.14009323@news1.rdc1.bc.home.com> Message-ID: <slrn9kqqdj.1c7.scarblac@pino.selwerd.nl> EricIDLE <grayson-wilson at home.com> wrote in comp.lang.python: > Ok well I dont quite grasp the Lambda concept heres an example. > > def mult(x,y): > return x * y > f = reduce(lambda x,y: x*y,n) > print f > > *NOTE The varible N is defined in the code before this excerpt. Note that the def mult is completely unused here. > Anyways back to the point the book says this is easier!?!? > > But comon sense tells me this is easier. > > def mult(x,y): > return x * y > f = reduce(mult,n) > print f > > Isnt that easier?? It's exactly the same to me, but the first is only one line (if you delete the def). I'd use operator.mul though, it's faster. > Or do I not get lambda? You do, every lambda can be trivially rewritten as a def, just not inside an expression: you need to def the function before the expression. > *NOTE ... I think its just a way to complicate things OR just a way to avoid > typing the function name beacuse.... I dont know they are scared of the > names they give them. Using a def is a few more lines, it needs a name, and it puts a bit of space between the definition of the function and the expression. But they're more powerful. Lambda is a minor convenience at most, of course, and a minor annoyance according to some (among whom is Guido, iirc). Nowadays I'd rather use a list comprehension than a map(lambda ....) construction. -- Remco Gerlich From mac4-devnull at theory.org Mon Jul 23 19:57:20 2001 From: mac4-devnull at theory.org (Neil Macneale) Date: Mon, 23 Jul 2001 16:57:20 -0700 Subject: intersection and union idea Message-ID: <3b5cb9d4$0$325$8eec23a@newsreader.tycho.net> I was day dreaming about python today, and I realized that it would be very python-ish to have intersection and union operators for lists and tuples. Eg: >>> (1,2,3,4) | (1,3,6,8) (1,2,3,4,6,8) >>> (1,2,3,4) & (1,3,6,8) (1,3) Does such an operator exist? I am sure someone else has thought of this before. Neil Macneale -- To reply to me via email, remove the '-devnull' from my address. From joonas.paalasmaa at nokia.com Thu Jul 12 09:34:23 2001 From: joonas.paalasmaa at nokia.com (Joonas Paalasmaa) Date: Thu, 12 Jul 2001 13:34:23 GMT Subject: More CGI ?'s... References: <mailman.994883900.13704.python-list@python.org> Message-ID: <3B4DA7F9.9406D959@nokia.com> "Vincent A. Primavera" wrote: > > Hello, > Is there a way to access each row's data from this text area with python's > cgi module(cgi.FieldStorage to be exact...)? > > <B>Notes:</B><BR> > <TEXTAREA NAME="Notes" ROWS=6 COLS=25> > </TEXTAREA> import cgi form = cgi.FieldStorage() Notes = form.getvalue("Notes") or "" #None would cause some problems Lines = Notes.split("\r\n") for x in range(len(Lines)): print "line",x+1,":",Lines[x],"<br>" - Joonas From akhar at videotron.ca Sat Jul 14 23:11:17 2001 From: akhar at videotron.ca (akhar) Date: Sat, 14 Jul 2001 20:11:17 -0700 Subject: Re-sizing images in Python? References: <q6547.41446$B56.8781902@news2-win.server.ntlworld.com> Message-ID: <wf547.21414$Kg7.1547337@wagner.videotron.net> Look into PIL(python Imaging library) has all you need. Stephane "Darren Watson" <Darren.Watson3 at ntlworld.com> wrote in message news:q6547.41446$B56.8781902 at news2-win.server.ntlworld.com... > I would be very grateful for any advice that fellow list members can provide > about Pythons ability to resize image files (jpg and gif). > > I would like to write a script that can process all the files in a directory > and resize the images to a specified size (passed in as an argument). > However, I am not sure if this is a task that Python 2.1 can perform or if > it is, which library to use. > > If possible I would like the script to scale images in order to 'best fit' a > particular area. > > Many Thanks > > -- > > Darren Watson > > > From new_name at mit.edu Tue Jul 10 09:29:00 2001 From: new_name at mit.edu (Alex) Date: 10 Jul 2001 09:29:00 -0400 Subject: Q: mpg123 with Python References: <9ierhe$c3u$1@sun.rhrk.uni-kl.de> Message-ID: <etdbsms29r7.fsf@pickled-herring.mit.edu> http://www.google.com/search?hl=en&safe=off&q=mp3.py Alex. From tundra at tundraware.com Fri Jul 13 18:30:01 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 13 Jul 2001 22:30:01 GMT Subject: not safe at all References: <mm8tkt4te3qnbpv3nh5nhsi591o1osln73@4ax.com> <slrn9ku3c3.mrk.9nick9m@localhost.localdomain> <u26ukt4vot7b1qu02hkp8l1pnmdi0sfp3l@4ax.com> Message-ID: <3B4F743C.66778F9F@tundraware.com> Dennis Roark wrote: > <SNIP> > > Python is an attractive language. But for a large program I > would still rather be forced to declare the name of a > variable (and its type) rather than risk misspelling or > misuse 500 lines later in the program. My original note was > not intended to be an indictment of Python, but only to > bring up some reasons that for me make more strongly typed > languages like C++ or Object Pascal better at coding very > large projects. > Umm, the world's largest systems are not written in C++ or even C. I spent almost 10 years at UAL's Apollo Reservation system which was the largest commercial transaction system in the world (probably still is number one or two). All the core system was written in *assembler* running an OS that had no memory protection. Yup, a bad application segment could take down the whole business. Why? For SPEEEEEEED. I have programmed extensively in C, assembler, BASIC, PL/M and a some in C++, Forth, Pascal, AWK, Perl, Java... For my money, I have *never* seen a language more suited for rapid applications development - even pretty good sized applications - that strongly encourages the programmer to write clean, easy to read code, than *Python* - this after only a month or two of fiddling with it. The academic debates about early- vs. late binding, static- vs. dynamic typing, procedural- vs. object, and so on mean very little in practice, in my experience. The thing that is never taught in language design and compiler classes is that what matters to the programmer is *safe and readable ***SYNTAX*** with predictable semantics*. The rest of it is of interest only to language implementors and designers. Furthermore, bear in mind that code "portability" is no where near as important in the commercial sector as it is in academics. Commercial applications are typically the largest around. They are purpose built to do things which distinguish their company from the pack and create unique value-add. It is rarely important to be able to move code around at will. What *is* important is code *reliability*, *cost of ownership*, *readability*, and portability of *programmer's skills*. In this light, C++ is an abomination. It was a really good research exercise which demonstrated just how flexible the whole Unix paradigm really is for making things extensible, but as a production language is it clumsy, ugly, hard to read, and full of subtle semantic traps. In the past few years I have been a technology executive in a variety of companies. In every case, unless there is no other way out, I have stopped the use of C++. I'd rather see people coding in perl, awk, or now, python by a bunch. The cost of maintaining and owning C++ is demonstrably higher than any of the alternatives. It is a systems programming language in OO drag and has the worst of all possible worlds - the ease of shooting your foot off that a systems language has, the complexity of OO, and syntactic obscurity that does little more than preserve the Programming High Priesthood. It is thankfully dying a slow death precisely because there are much better choices. Applications programmers need to do different things in different ways than Systems programmers. No language can serve both well, in my experience. IMHO, that's why C++ failed - it tried to be all things to all programmers and ended up being a convoluted mess. ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From gerson.kurz at t-online.de Tue Jul 3 15:56:59 2001 From: gerson.kurz at t-online.de (Gerson Kurz) Date: Tue, 03 Jul 2001 19:56:59 GMT Subject: Alternate Syntax for dictionary elements References: <3b421046.1836046@news.t-online.de> <slrn9k471b.hhl.quinn@hork.ugcs.caltech.edu> Message-ID: <3b421cec.5073656@news.t-online.de> On 3 Jul 2001 19:25:31 GMT, quinn at hork.ugcs.caltech.edu (Quinn Dunkan) wrote: >And here's why using a dict as you did above is probably silly: You don't need >to manually encode type information if the language can do it for you. Making >a Button class will automatically attach that type to its instances. >Furthermore, a fundamental property of all objects (as opposed to true values >like an algebraic data type) is that they have unique ids seperate from their >values. The language will maintain them for you, and to fetch them you can >use the id() function. The 'name' field is the only necessary one. > >"Yes", you're saying, "but it was only an example." :) Well, you're right, I wrote up classes later, but mainly so that the code is more easily extended. 2 reasons for using dicts rather than classes: - You can easily create the data an object stores *dynamically*, i.e. from user input. - The class approach is a lot of overhead compared with writing a simple dict, when all you want to store is a name. Plus, classes are slower : Xoring a variable in a dict 1000000 times took 2.91 seconds. Xoring a variable in a class 1000000 times took 3.39 seconds. From sdm7g at Virginia.EDU Wed Jul 11 14:35:35 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Wed, 11 Jul 2001 14:35:35 -0400 (EDT) Subject: Language change and code breaks In-Reply-To: <cplmlvh6dx.fsf@cj20424-a.reston1.va.home.com> Message-ID: <Pine.NXT.4.21.0107111427580.379-100000@localhost.virginia.edu> On Wed, 11 Jul 2001, Guido van Rossum wrote: > Very good sumary, Terry. I'm beginning to get second thoughts about > integer division -- maybe it's better to leave well enough alone, and > try to fix areas of the language that could really stand some fixing > (such as subclassing built-in types). Is it possible that changes to built-in types to allow subclassing could be made to also allow redefining operators for built-in types ? Then "/" could be mapped to either behaviour, and gradual introduction could be a matter of changing the default behaviour in a future version. I know some folks will object to the idea of redefining basic function, but Python already allows that for a lot of built-in functions (import and others). [I haven't had the stamina to read every message in this thread, so please forgive me if this has already been suggested.] -- Steve Majewski From peter at engcorp.com Thu Jul 12 23:24:05 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 12 Jul 2001 23:24:05 -0400 Subject: Scripting vs. whatever, again (was Re: Long Live Python!) References: <mailman.994970962.7500.python-list@python.org> <3B4E5586.82D8ACA8@engcorp.com> <slrn9ksnh3.jl.grante@tuxtop.visi.com> Message-ID: <3B4E69D5.5CB278F2@engcorp.com> Grant Edwards wrote: > > On Thu, 12 Jul 2001 21:57:26 -0400, Peter Hansen <peter at engcorp.com> wrote: > > >> ...then would want to argue about the difference between a "script" > >> and a "program". I see it this way, if a script is only, > >> "Automating a sequence of operations" -- C programs are scripts -- > >> there must be more to it, eh. Just to clarify, I did not write the above. I merely quoted it. > I interpret "scripting" as automating a series of operations > that would probably be done interactively by a user otherwise. Would you call a C program which implemented those same steps a "script" ? (I realize you would not typically use C for this, but if you did?) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From aahz at panix.com Sat Jul 28 13:29:14 2001 From: aahz at panix.com (Aahz Maruch) Date: 28 Jul 2001 10:29:14 -0700 Subject: re bad leadership References: <0+yM4IAgmKX7EwIQ@jessikat.fsnet.co.uk> Message-ID: <9juspa$8p0$1@panix2.panix.com> In article <0+yM4IAgmKX7EwIQ at jessikat.fsnet.co.uk>, Robin Becker <robin at jessikat.fsnet.co.uk> wrote: > >MDFL What does this stand 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 Fortune cookie: Watch your relations with other people carefully, be reserved. From skip at pobox.com Tue Jul 24 13:28:21 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 24 Jul 2001 12:28:21 -0500 Subject: 2.0b2: SystemError: frexp() result out of range In-Reply-To: <vktpuaqnuu0.fsf@pc153s.cs.york.ac.uk> References: <vktpuaqnuu0.fsf@pc153s.cs.york.ac.uk> Message-ID: <15197.45109.323013.471818@beluga.mojam.com> Anthony> Please, if I were to ask nicely for our local installation of Anthony> python to be upgraded, would the bug shown below to go away? >>> cPickle.dump(float('inf'), f, 1) ... SystemError: frexp() result out of range Yeah, I believe so: >>> float('inf') inf >>> marshal.dumps(float('inf')) 'f\x03inf' >>> import cPickle >>> cPickle.dumps(float('inf')) 'Finf\n.' >>> import sys >>> print sys.version_info (2, 1, 1, 'final', 0) -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From johann at physics.berkeley.edu Wed Jul 18 16:30:52 2001 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 18 Jul 2001 13:30:52 -0700 Subject: Python 2 times slower than Perl References: <mailman.995443830.26172.python-list@python.org> <3B55724D.465E8A44@engcorp.com> <mt7kx6b3v0.fsf@astron.berkeley.edu> <Pine.SOL.4.30.0107182005070.21247-100000@mimosa.csv.warwick.ac.uk> Message-ID: <mtg0bugetf.fsf@astron.berkeley.edu> John J Lee writes: > When do you ever write Python code that does this kind of thing?? For > example, if you're doing lots of fp work, don't you use Numeric? I don't, really. If I have to do this, I write a C module and do it there, but it's a PITA. If I could find some way to write decent- speed numerical integrators (say) in pure python, then I'd do it. If I could just write my entire code in, say, OCaML or Common Lisp, rather than in a mixture of C++ and Python, then I'd be very happy. Numeric only helps with half the problem, since I do more integration/function evaluation than I do matrix math. That being said, I find python a great tool that is fast enough, once I move speed critical parts out to C++. However, the less I move to C++, the happier I am. And ignore my numbers for python. I discovered that the version of python on my laptop wasn't compiled with -O2, so the run time was artificially high. -- Johann Hibschman johann at physics.berkeley.edu From ark at research.att.com Fri Jul 27 18:18:33 2001 From: ark at research.att.com (Andrew Koenig) Date: Fri, 27 Jul 2001 22:18:33 GMT Subject: Nasty typo in PEP 238 (revised) References: <cp4rrz5onj.fsf@cj20424-a.reston1.va.home.com> <eppstein-D847A7.18400826072001@news.service.uci.edu> <yu99n15qdzs7.fsf@europa.research.att.com> <eppstein-88B0F0.11425427072001@news.service.uci.edu> Message-ID: <yu997kwudnie.fsf@europa.research.att.com> David> In article <yu99n15qdzs7.fsf at europa.research.att.com>, David> Andrew Koenig <ark at research.att.com> wrote: >> >> A. Use x*1.0/y for true division, divmod(x, y)[0] for int >> >> division. Especially the latter is best hidden inside a >> >> function. You may also write floor(x)/y for true division if >> >> you are sure that you don't expect complex numbers. >> David> Shouldn't this be float(x)/y ? >> What if x is complex? David> Did you read the last line? Evidently not. :-) What I saw was float(x)/y and thought it was being suggested as an alternative for x*1.0/y without reading the whole context. Sorry about that. -- Andrew Koenig, ark at research.att.com, http://www.research.att.com/info/ark From schaffer at optonline.net Sat Jul 7 10:40:56 2001 From: schaffer at optonline.net (Les Schaffer) Date: Sat, 07 Jul 2001 14:40:56 GMT Subject: win32ras: pyd built for win98 to fix phonebook methods Message-ID: <1f7ektcggljf59ab7e4aj7mf7fg5ujot96@4ax.com> Hi: i needed to have win32ras phonebook functionality working on a win98 system, so i grabbed the cvs sources for win32all from active state and recompiled the win32ras module with WINVER set to 0x400. after installing the new version of win32ras.pyd, along with a new PyWinTypes22.dll, the phonebook methods now work, whereas before they were failing like so: >>> from win32ras import * >>> EnumConnections() Traceback (most recent call last): File "<interactive input>", line 1, in ? api_error: (610, 'RasEnumConnections(NULL)', 'The buffer is invalid.') but now: >>> from win32ras import * >>> EnumConnections() [] > >> EnumEntries() [('GiantISP',), ('CooperLED',)] >>> i'd like to bang on this a little bit before i post the pyd/dll to my web site. if anyone else is trying to use phonebook stuff on winXX < 2000 and wants to try out the recompiled extensions first, let me know and i will email them (they are small -- 25 and 56 kB respectively). les schaffer From whisper at oz.nospamnet Tue Jul 3 12:53:13 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 3 Jul 2001 16:53:13 GMT Subject: MS "bans" GPL References: <7iq1ktcmslo24kbr8qvob2g3hpgleuf025@4ax.com> <9hshbp$oqv$2@216.39.170.247> <slrn9k3ji4.49l.gerhard.nospam@lilith.hqd-internal> Message-ID: <9hst9p$oqv$5@216.39.170.247> In article <slrn9k3ji4.49l.gerhard.nospam at lilith.hqd-internal>, gerhard.nospam at bigfoot.de says... <snip> > You don't try to spread FUD, do you? No matter what MS or any other company > writes into their "license agreements", not everything is compatible with > German or US or whatever laws. > > Gerhard > I'm gratified to know that you are aware enough to know that, and that further you can afford to take Microsoft to court if needs be. The parts about MS excluding open source software from running on their os's and the part about XP being evil where and are my supposition and opinion respectively. The part about the UK is 100% as reported by http://www.theregister.co.uk. Microsoft, like other companies and even governments, either counts on people's ignorance or inability to contest their behavior (governments are somewhat easier to correct - IF YOU HAVE THE MONEY). BTW, the people who make the Opera browser ARE taking the UK government to court over trade restraint. Fact: Over the last several revisions of selected OS's Microsoft has either been restricting what they can be used for in licenses or releasing the software with restrictions built-in that limit what can be done with that software. Microsoft announced during the beta of Windows NT that they where going to limit the number of concurrent tcp/ip sockets open to outside (i.e over the web) at any one time. After much public outcry, they "relented" and simply put it in the NT workstation EULA. In Windows 2000 Pro, they just built it into the OS (see IIS concurrent connections option in the MMC). You might also recall the hue and cry when some magazines published information about how to bypass some registry settings that allowed NT Workstation to operate as NT Server. Fact: It has been fairly widely reported that Microsoft will initiate their annual subscription based costing model when Windows XP starts shipping. Rather then pay for an upgrade when you want it, you'll pay it annually or the software will stop working. There's also been user beta testing of a per use pricing scheme in (at least) the UK for MS Office. Opinion: It would not be illegal for Microsoft to make it a condition of use that you not install open source software if you want to use their OS. It's not restraint of trade since technically, open software is not traded - there's no _overt_ exchange of value nor is there a "buyer" or a "seller" who could be harmed monetarily through such a restraint (besides, you have the freedom to choose another OS according to MS). Personally, I think XP is going to drive more people into the Linux camp (GOOD!). (NOTE: i'm not suggesting that there is no inherent value to open source software!) When it comes to Microsoft, FUD is a good survival trait ihmo. I sure Fear their power, am (NOT) Uncertain of their integrity and (have no) Doubt (of) their motives. $US 55+ billion per year isn't enough I guess. (That's based on a single quarter's gross of $13.4 billion I heard once.) Dave LeBlanc From greg at cosc.canterbury.ac.nz Tue Jul 17 22:55:30 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 18 Jul 2001 14:55:30 +1200 Subject: Nested List Comprehension References: <9iss5k$2dcd$1@news.idiom.com> <3B529CB7.8030905@T-Online.de> Message-ID: <3B54FAA2.D7E04ECB@cosc.canterbury.ac.nz> Burkhard Kroesen wrote: > > Maybe you feel more comfortable with > multtab = [x*y for x in range(13) for y in range(13)] But that doesn't produce what he wanted, which was for multtab[x][y] to be equal to x*y. But if there were such a thing as dictionary comprehensions, he could use multtab = {(x,y):x*y for x in range(13) for y in range(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 rneely at home.com Mon Jul 16 02:32:10 2001 From: rneely at home.com (Rob Neely) Date: 15 Jul 2001 23:32:10 -0700 Subject: Starting a Frame dependent on destruction of another Frame... Message-ID: <6f0b3be9.0107152232.21f297e6@posting.google.com> I have a simple problem I'm trying to solve with Tkinter. When my application runs, I want a frame to pop up asking the user for some info (a directory name). When they hit the "OK" button, I want that frame to destroy itself, and start up another toplevel frame which will be populated with some widgets based on what was entered in the first frame. I've enclosed a very stripped down example below. If you run this program in linux (under KDE), the only way to get to the second frame is to close the window with the window manager (ie - clicking the "x" in the KDE window decorations). When I run it from MS-windows - even that doesn't work... Can anyone show me how I might configure the following applet so clicking the "OK" button will destroy the frame and start up the next frame? Or more generally - how should one set up an application where one frame is started only after another has destroyed itself. I've tried as many combinations that I can think of - and this is the closest I've gotten! Thanks in advance! --Rob from Tkinter import * class Splash(Frame): def __init__(self, parent=None): Frame.__init__(self, parent) b = Button(self, text="OK", command=self.splash_done) b.pack() self.pack() def splash_done(self): print "Clicked OK" self.destroy() class Mainapp(Frame): def __init__(self, parent=None): Frame.__init__(self, parent) l = Label(self, text="Main frame opened") l.pack() self.pack() Splash().mainloop() Mainapp().mainloop() From plakal-nospam at nospam-cs.wisc.edu Thu Jul 26 03:55:45 2001 From: plakal-nospam at nospam-cs.wisc.edu (Manoj Plakal) Date: Thu, 26 Jul 2001 07:55:45 GMT Subject: Use "quotient"? (was Re: proposed language change to int/int==float (was: PEP0238 lament)) References: <eppstein-03540D.13070222072001@news.service.uci.edu> <p56plt8q4rs3bgcqbepk61q2r3g0tr2vhe@4ax.com> <slrn9ls3ae.2fm.Gareth.McCaughan@g.local> <cpitghbq05.fsf@cj20424-a.reston1.va.home.com> Message-ID: <52Q77.181728$mG4.85523836@news1.mntp1.il.home.com> Guido van Rossum <guido at python.org> wrote on Tuesday 24 July 2001 23:18: > Gareth.McCaughan at pobox.com (Gareth McCaughan) writes: >> To any mathematician on the planet, 1/2 is, well, 1/2. >> A rational number quite different from 0. > > Right. It seems to me that the word "division" is being sorely overloaded in these threads as well as in PEP 238. Would it be more precise (mathematically and otherwise) to reword things like this: - currently, the symbol `/' in Python programs signifies two different operators depending on the arguments: - the QUOTIENT operator with 2 integer arguments - the DIVISION operator with at least 1 float argument - the proposed change is to make '/' always signify the DIVISION operator and '//' always signify the QUOTIENT operator Seems to be more clear than saying "integer division" or "truncating division" or "float division". Just my 2 cents ... Manoj From peter at engcorp.com Sat Jul 14 00:42:13 2001 From: peter at engcorp.com (Peter Hansen) Date: Sat, 14 Jul 2001 00:42:13 -0400 Subject: Scripting vs. whatever, again (was Re: Long Live Python!) References: <mailman.995053524.27415.python-list@python.org> Message-ID: <3B4FCDA5.15F3D932@engcorp.com> James_Althoff at i2.com wrote: > > Peter Hansen wrote: > >(And I don't know the nature of the compilation stage: > >is it automated as with Python, or manual as with Java?) > > Jython has the same "auto-compile and run" mechanism as CPython. Nice: the best of both worlds yet again. On the top of scripting: > .. The "script" in this case is not script *because* it is > written in Python. It is "script" because it is code that has "script" > -like capabilites and is being used in a "script"-like role (it is embedded > in the framework of my application, you can write a few lines of code in a > configuration file and not have to compile it and link it, etc.). And Roman Suzi wrote simultaneously: > All said, I conclude that being "scripting language" is a role, > described above and not language feature in itself. "Role" being the operative word in both the above. That makes perfect sense to me, too. Thanks for your explanations. Now I can go back to programming more scripts... er, I mean scripting my programs... well, you know what I mean. :) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From peter at engcorp.com Fri Jul 13 23:26:16 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 13 Jul 2001 23:26:16 -0400 Subject: How to run codeobjects in Python? References: <mailman.995024902.7812.python-list@python.org> <9imphr015u5@enews1.newsguy.com> Message-ID: <3B4FBBD8.45F56742@engcorp.com> Alex Martelli wrote: > > "Vesselin Peev" <vesselinpeev at hotmail.com> wrote [...]: > > Can anyone tell me how to use the so called "code objects" in Python, for > ... > You asked this 6+ hours ago under subject "How can I run precompiled > code objects?" and I answered 26 minutes before you reposted. Have > a little patience, already: netnews propagation delays and varying > timezones mean it WILL take a little time for you to get answers! Alex, please consider moving closer to the Eastern Standard timezone so that you may answer my questions more quickly. What's so special about Italy anyway? And why would you consider creating an Italian version of comp.lang.python when that would distract you from your work in *this* newsgroup? The nerve! ;-) From tjreedy at home.com Tue Jul 3 02:36:13 2001 From: tjreedy at home.com (Terry Reedy) Date: Tue, 03 Jul 2001 06:36:13 GMT Subject: Comment on PEP-0238 References: <3B3BE855.A6223E70@3-cities.com> <cp7kxvlake.fsf@cj20424-a.reston1.va.home.com> <Y4J%6.4084$Z6.2010194@news1.rdc2.pa.home.com> <mailman.994016102.30019.python-list@python.org> <7ef50c46.0107020554.31cc948b@posting.google.com> <mailman.994084684.19932.python-list@python.org> <tn507.6448$Z6.3115703@news1.rdc2.pa.home.com> <mailman.994115046.6243.python-list@python.org> Message-ID: <xJd07.953$c7.228697@news1.rdc2.pa.home.com> "Paul Prescod" <paulp at ActiveState.com> wrote in message news:mailman.994115046.6243.python-list at python.org... > I strongly feel that in the modern world, people will see an unadorned > 82/4 as 20.5. So?... My point was that numbers in real, consequential computations *are* adorned with a unit, even if just implicitly, and that people should *think* about what that adornment/tagging is. > Go ask someone on the street: "What's 11 divided by 2." If > they are good enough at mathematics to even figure out an answer, they > will usually respond 5.5. Yes, given an underspecified abstract question of no consequence, especially verbally, people will often fill in the blank with something that lets them answer. So? (see above). > Very few would bother to ask you whether you mean "count division." The question under debate is whether we should keep the existing method of *telling* a Python interpreter what me mean, which I strongly favor, or break scads of code to change it to something else, as some have proposed. ... > I do not think it is very good idea to use two syntaxes that are > semantically equivalent in "real math" to indicate divisibility. Since I am advocating no change, I am unclear as to what you mean here. >. And maybe one day we could say > that 5.00 represents not double-precision math but *triple* precsion. > Adding zeros to the end could get you more and more precision. I believe something like this is part of the IBM decimal arithmetic proposal/project. 1.0/3 = .3, 1.00/3 = .33, etc (in which case, 1/3 = 0 by the same rule) ... > In a dynamically typed language with no type declarations it makes more > sense to define the nature of the operation *at the point of the > operation* and not at the point where the value is initialized. As noted in another thread, Python is deeply polymorphic. The meanings of 3*2 and '3'*2, or 3+2 versus '3'+'2', for instance are more different that 8/3 versus 8.0/3. This nature of the operation *is* defined by the initializations of the values. Do you suggest that we unbundle such other usages also? >If you > write a function like this: > > def teachersPerClassRoom(teachers, classroom): > return teachers/classroom > > you absolutely do NOT want the users of this function to accidently > subvert it and get meaningless answers by passing it "3.0" instead of > "3". > Therefore to make this safe, you need to do this: > > def teachersPerClassRoom(teachers, classroom): > return int(teachers)/int(classroom) The same is true whenever you want to block some of the polymorphic possibilities of a Python expression. Consider def muladd(a,b,c): return a*b+c and a user passing in 2, 'hello', 'goodbye'. Any expresion with names (variables) instead of all literals opens the door to polymophic possibilities depending on the type of the compile-time unspecified values. But the question under debate is whether the compiler should silently coerce pairs of integers, including unambiguous pairs of literals, to a pair of floats when they happen to be connected with '/' instead of one of the many other operators. To me, this would be a major wart. > > Requiring that people think about divisibility in choosing a number representation is > > no more burdensome (and I think less so) than requiring them to think about > > mutability in choosing a tuple versus list sequence representation. > > Many Python hot-shots admit to occasionally being bitten by the > int/float problem whereas we never have trouble with tuple/list. Very funny. According to my memory, the case is more the opposite. Hardly a month go by that some newbie does not ask "What is a tuple?", "What is the difference between tuples and lists?", "Why do we have both?", "How can I decide which to use?", "Couldn't we simplify Python by merging them together?", and repeatedly, some version of "I changed a list and now its changed when I access it by a different name [or anonymous reference]!!! Why???". Terry J. Reedy From phrxy at csv.warwick.ac.uk Thu Jul 12 12:03:52 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Thu, 12 Jul 2001 17:03:52 +0100 Subject: noncommercial Python+QT on Windows? (was Re: qt or gtk?) In-Reply-To: <4a249347.0107120725.3c4569ea@posting.google.com> References: <slrn9ios1q.el.sill@sill.silmarill.org> <9gk8he$8gl$1@brokaw.wa.com> <16074dce.0106181045.139d80a5@posting.google.com> <3b3b40a0@news.uia.ac.be> <9hfjho05to@enews1.newsguy.com> <mailman.993768352.14849.python-list@python.org> <Pine.SOL.4.30.0106292039570.18740-100000@mimosa.csv.warwick.ac.uk> <9hjriq$pc8$1@news1.xs4all.nl> <4a249347.0107120725.3c4569ea@posting.google.com> Message-ID: <Pine.SOL.4.30.0107121701580.2157-100000@mimosa.csv.warwick.ac.uk> On 12 Jul 2001, Robert wrote: > Are there binaries anywhere for those of us without a compiler? Not yet. There was one, but he had to take it down because he used the non-non-commercial version of Qt to compile it. There will be one soon, I expect. John From guido at python.org Fri Jul 6 07:48:18 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 06 Jul 2001 11:48:18 GMT Subject: Augmented Assignment (was: Re: PEP scepticism) References: <mailman.994035602.29848.python-list@python.org> <nBQ%6.417370$oc7.58837743@news2.rdc2.tx.home.com> <mailman.994058342.19156.python-list@python.org> Message-ID: <cp4rsql1r7.fsf@cj20424-a.reston1.va.home.com> Thomas Wouters <thomas at xs4all.net> writes: > On Mon, Jul 02, 2001 at 02:00:51AM +0000, Rainer Deyke wrote: > > An interesting (and AFAIK legal) optimization would be to make > > tuples act as mutable objects with respect to augmented assignment > > if their reference is 1. > > But they are never 1 unless you're in a C extention that just created it. > When you call 'x += y', the refcount for both x and y is always 2 when the > arguments arrive at the __iadd__ (or C equivalent.) > > So you mean '2'. But then you could run into trouble on, say, > > () += y > > because the empty tuple is shared, just like interned strings and integers. > The refcount *could* be 2, and you end up modifying someone else's empty > tuple. No, because "() += y" is syntactically illegal. It wouldn't be a useful optimization anyway, because += on a tuple would have to reallocate the tuple, which is tantamount to allocating a new one anyway, thus losing most of the advantage. --Guido van Rossum (home page: http://www.python.org/~guido/) From fschaef at ces.clemson.edu Fri Jul 6 13:24:34 2001 From: fschaef at ces.clemson.edu (Schaefer, F.) Date: Fri, 06 Jul 2001 10:24:34 -0700 Subject: Crop a transparent Gif Message-ID: <3B45F452.383AB459@ces.clemson.edu> Hi, I'm trying to crop some sprites out of a bigger resource GIF-File. Using PIL everything works fine, except that the transparency is not maintained, when cropping a transparent gif image. Does anybody have any idea howto maintain transparency ? Thanks, Frank From -$Paul$- at verence.demon.co.uk Tue Jul 10 14:16:14 2001 From: -$Paul$- at verence.demon.co.uk (Paul Wright) Date: 10 Jul 2001 18:16:14 -0000 Subject: Is Python Dead? Long Live Python! References: <MNS%6.355$Xs4.225014@news.pacbell.net> <mailman.994599260.9137.python-list@python.org> <5174eed0.0107091109.d3a53f6@posting.google.com> <mailman.994711525.24100.python-list@python.org> Message-ID: <9ifgpe$1b5$1@verence.demon.co.uk> In article <mailman.994711525.24100.python-list at python.org>, Paul Prescod <paulp at ActiveState.com> wrote: >> > From what I can tell, PHP and Ruby >> > are flying past Python in acceptance rates. The difference that I see >> > in these groups, is a sensitivity to industry, rather than an >> > adoration for pure acedemic elegance. > >I think even the Ruby people would be surprised to hear about Edward's >statistics about it flying past Python! Shurely he means that the derivative of the number of users wrt time is greater for Ruby than for Python, which may be true because Python has a far larger user base and so is nearer "saturation". -- ----- Paul Wright ------| No storm can shake my inmost calm, -paul.wright at pobox.com--| while to that rock I'm clinging. http://pobox.com/~pw201 | Since love is lord of heaven and earth | how can I keep from singing? From chris.gonnerman at newcenturycomputers.net Thu Jul 26 08:26:29 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Thu, 26 Jul 2001 07:26:29 -0500 Subject: from __past__ import integerDivision (was Re: A modest PEP0238 suggestion) References: <Pine.LNX.4.33.0107260002070.8592-100000@bms> Message-ID: <006301c115ce$33c0bc80$0101010a@local> ----- Original Message ----- From: "Bruce Sass" <bsass at freenet.edmonton.ab.ca> > > My proposal for > > > > from __numerics__ import original > > > > is the same sort of thing. When the "original" semantics disappear, the > > user gets an obvious error message. > > __future__ and __past__ both imply reference to some specific time, > and it is reasonable to expect what they are being used for will go > away when that time becomes inconsequential to the present (i.e., the > future has already come, or the past is distant). > > __<something specific>__ has no such transitory implications, and > would best be left for permanent features. Perhaps for sets of > incompatible features that must all be in the language. True. However, my proposal covers both the "original" Python division semantics and the addition of optional rational, fixedpoint, decimal, and any other sort of numeric system the twisted mind of Man can come up with. The key word is *optional* as I don't want rationals, probably ever, but I would love decimal floats and fixedpoints as builtins; the rational camp would love rationals (naturally) but probably most couldn't care less about decimal floats or fixedpoints. The "original" semantics under my proposal would be "invented" as already deprecated, and would be removed in 3.0 as the current plan stands. We have deprecated and subsequently removed things before without the __future__ directives and it didn't kill us; hence I see the question of "transitory implications" as only of minor concern. Remember, explicit (even in documentation) is better than implicit. From deltapigz at telocity.com Wed Jul 25 14:07:06 2001 From: deltapigz at telocity.com (Adonis Vargas) Date: Wed, 25 Jul 2001 14:07:06 -0400 Subject: Redirecting broswers in Py Message-ID: <3B5F0AC8.BF54029C@telocity.com> the script accepts the connection then processes information once that is done i want to be able to send the broswer to X page. i have found something and used it in the line below: c.send("<META HTTP-EQUIV=\"Refresh\"Content=0;Host=\"http://www.someurl.com\">") but i think im going at this completely wrong. any help would greatly be appreciated. Adonis From sdm7g at Virginia.EDU Tue Jul 10 15:18:14 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Tue, 10 Jul 2001 15:18:14 -0400 (EDT) Subject: license suggestions? In-Reply-To: <3b4b4a70$0$319$8eec23a@newsreader.tycho.net> Message-ID: <Pine.NXT.4.21.0107101515350.278-100000@localhost.virginia.edu> Old Russian joke: Capitalism is the economic system where man exploits man, but Communism is just the opposite! -- Steve On Tue, 10 Jul 2001, Neil Macneale wrote: > In article <mailman.994649774.8137.python-list at python.org>, "Chris Watson" > <chris at voodooland.net> wrote: > > > > > Communism \Com"mu*nism\, n. [F. communisme, fr. commun common.] > > A scheme of equalizing the social conditions of life; specifically, > > a scheme which contemplates the abolition of inequalities in the > > possession of property, as by distributing all wealth equally to > > all, or by holding all wealth in common for the equal use and > > advantage of all. > > > > communism > > n 1: a form of socialism that abolishes private ownership > > 2: a political theory favoring collectivism in a classless > > society > > > > You can't compare communism and capitalism. One is a political structure > while the other economic structure. It makes more sense to say that you > perfer Capitalism over Socialism, or Democracy over Communism. I am for > democracy, and socialism, so I'm going with GPL :-) > From mixo at beth.uniforum.org.za Fri Jul 20 10:00:56 2001 From: mixo at beth.uniforum.org.za (mixo) Date: Fri, 20 Jul 2001 16:00:56 +0200 Subject: KeyboardInterrupt References: <3b57e9e8.1285896@news.newsguy.com> <3B581A4F.381F3072@engcorp.com> Message-ID: <3B583998.3AFF2E75@beth.uniforum.org.za> Peter Hansen wrote: > "Owen F. Ransen" wrote: > > > > The Quick Python Book says that KeyboardInterrupt is > > tested regularly when the Python interpreter is running, > > but I have a program which may run for several minutes > > without printing anything, and I find I cannot break out of > > it with control-C. > > > > How can I get my program to be more responsive to control-C? > > This could be a platform-dependent issue. > > Are you by any chance running on Win2K? I doubt it is a Win2K (or any other version of windoze version ) issue as I had (and still have) a similar problem :I had to press controls-C 2 times to break out of a program! (the program listens on a port for connections - and actually threads) From tim.one at home.com Fri Jul 27 18:39:43 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 27 Jul 2001 18:39:43 -0400 Subject: int(a), b = divmod(x, y) In-Reply-To: <lvf3mto2i116sl1nrjn6q6p1ckt0c3ddbe@4ax.com> Message-ID: <LNBBLJKPBEHFEDALKOLCMENALBAA.tim.one@home.com> [Stephen Horne] > I don't know why the first output in the tuple isn't an int anyway. > After all, it *is* a member of the set of integers even if it is > currently represented using a float. > > A quick example... > > >>> divmod(5.1,2.0) > (2.0, 1.0999999999999996) > > So why doesn't this return... > > >>> divmod(5.1,2.0) > (2, 1.0999999999999996) > > If the 2 is used anywhere a float is needed it will be cast to float > implicitly anyway once PEP238 goes through. float divmod() always returns floats today; that's all there is to it. It can't always return (short) ints, because e.g., >>> divmod(1e98, 2) (5e+97, 0.0) >>> That is, 5e97 is outside the range of Python ints on any platform today. It could always return a long (unbounded) int for the quotient, but that would be time- and space-inefficient, and it's hard to think of a case where that be more useful than a float. From nperkins7 at home.com Sun Jul 1 21:20:16 2001 From: nperkins7 at home.com (Nick Perkins) Date: Mon, 02 Jul 2001 01:20:16 GMT Subject: problems with class initiation References: <mailman.994017363.31520.python-list@python.org> Message-ID: <k%P%6.388737$eK2.79089127@news4.rdc1.on.home.com> You could pass a reference to your 'prefs' to the constructor of 'Second'.. class Second: def __init__(self,prefs): self.prefs = prefs def init_fn(self): return self.prefs.a Now class Second keeps it's own reference to the 'prefs' object, instead of relying on using some other binding to the same object. class Main: def __init__(self): self.prefs = Preferences() self.fns = [] second = Second(self.prefs) # depending what you wanted, either of: self.fns.append(second.init_fn) # appends the function itself, or... self.fns.append(second.init_fn()) # calls the fn, and appends the result if __name__ == '__main__': app = Main() Since you have a list called fns, I wonder whether you intend to have a list of functions, in which case, the first of the two commented lines does what you want. On a more general note, it looks like you are using classes for everything, where some of these things might be better off as simple functions. Unlike java, not everything has to be a class. (for starters, class 'main' should probably be just a function: def main(): ... From piet at cs.uu.nl Fri Jul 27 11:15:09 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 27 Jul 2001 17:15:09 +0200 Subject: Language change and code breaks References: <mailman.995378792.16515.python-list@python.org> <cpvgkq1f2b.fsf@cj20424-a.reston1.va.home.com> <ud76rn4p8.fsf@cs.uu.nl> <3B5D88B1.774A4D70@Bibliothek.Uni-Augsburg.de> <wzhew2gm27.fsf@sunshine.cs.uu.nl> <3B601CBE.627D3D22@Bibliothek.Uni-Augsburg.de> <9jpbi8$32v$1@samos.cs.uu.nl> <9jpj4j$182a$1@nntp4.u.washington.edu> <cplmlb5q2t.fsf@cj20424-a.reston1.va.home.com> <Vk087.27863$B7.4280302@ruti.visi.com> <3B60A0ED.BAAFE3A9@Lugoj.Com> <uelr2er7q.fsf@cs.uu.nl> <cpy9pa2zik.fsf@cj20424-a.reston1.va.home.com> Message-ID: <u1yn2e742.fsf@cs.uu.nl> >>>>> Guido van Rossum <guido at python.org> (GvR) writes: GvR> piet at cs.uu.nl writes: >> I wrote several parts of the CDC Cyber Algol 68 compiler (and later also an >> Algol 60 compiler) and we just moved the address of the following >> instruction to the stack (`manually') and then jumped to the procedure >> address. And of course we used 12 bit characters and the language was >> case-sensitive. GvR> Our lives touched! I used that Algol 68 compiler. It also (very GvR> indirectly) affected Python: that compiler had a very strong worldview GvR> of its own that often didn't match that of other languages and tools GvR> on the system, and that made it hard to mix tools. I found this a GvR> nuisance (ABC had the same nuisance even stronger), and when I GvR> designed Python, one of my requirements was that it blend in with its GvR> environment. This explains why Python extensions are so useful. One of the later versions had an interface with FORTRAN. But in general, yes, the worldview of Algol68 was very different from the other languages at that moment. -- Piet van Oostrum <piet at cs.uu.nl> URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From tripie at cpan.org Tue Jul 31 09:28:39 2001 From: tripie at cpan.org (Tomas Styblo) Date: 31 Jul 2001 06:28:39 -0700 Subject: Static class members ? Message-ID: <fe01b1af.0107310528.14ff4092@posting.google.com> """ Static class members ? Hello. I've found no way to properly create static data members in Python classes. By static members I mean data that are shared by all instances of a class. A textbook example of usage of static data is a counter of all instances of said class. I tried the following: """ # Beginning of a module. class Parent: INSTANCES = 0 def __init__(): Parent.INSTANCES = Parent.INSTANCES + 1 def get_INSTANCES(): return Parent.INSTANCES """ That works OK. Problems come when I derive a new class from this Parent. Inherited methods in the derived class then reference the static data in Parent. This is not what I expect and need. The second way I tried was: """ # Beginning of a module. INSTANCES = 0 class Parent: def __init__(): INSTANCES = INSTANCES + 1 def get_INSTANCES(): return INSTANCES """ This also isn't an optimal solution, because the derived class doesn't pass the "empty subclass" inheritance test. I have to manually add the "static" variables to its module to make it work. Anyone please know what the optimal solution of this problem is ? Tomas Styblo tripie at cpan.org """ From tim.one at home.com Wed Jul 18 15:15:23 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 18 Jul 2001 15:15:23 -0400 Subject: bug in python's scope handling? In-Reply-To: <slrn9lbmfi.1at.philipprw@chello213047126184.14.univie.teleweb.at> Message-ID: <LNBBLJKPBEHFEDALKOLCOEEOKPAA.tim.one@home.com> [Philipp Weinfurter, on "a = a + 1", or some such] > ... > i don't mean to be pedantic, but the rules are that if a variable > is not found in local scope, then the compiler looks up the global > scope and python doesn't follow this rule here. Except you made that rule up <wink>. The actual rule is that if a name is bound anywhere within a code block, that name is local throughout the entire code block. This determination is made at compile-time, not at runtime. In "a = a + 1", a is bound to within the code block, therefore all instances of "a" within the code block refer to a (the same) local vrbl. From skip at pobox.com Thu Jul 26 21:53:48 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 26 Jul 2001 20:53:48 -0500 Subject: Tests for calendar module In-Reply-To: <3B60A388.C6E11F75@yahoo.com> References: <3B60A388.C6E11F75@yahoo.com> Message-ID: <15200.51628.144595.253949@beluga.mojam.com> Paul> 1) Who maintains calendar.py? Lots of contributors listed in the Paul> cvs logs. It's just part of the core library. If you submit a patch to sourceforge, it will get assigned to somebody. (Maybe me.) Paul> 2) I found a couple of possible bugs in calendar.py. Who should I Paul> provide details and patches to? Same thing. Patches here: https://sourceforge.net/tracker/?group_id=5470&atid=305470 Bugs here: https://sourceforge.net/tracker/?group_id=5470&atid=105470 -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From dgrisby at uk.research.att.com Tue Jul 24 05:42:20 2001 From: dgrisby at uk.research.att.com (Duncan Grisby) Date: 24 Jul 2001 09:42:20 GMT Subject: PEP0238 lament References: <mailman.995814276.15005.python-list@python.org> <cp66clexxt.fsf@cj20424-a.reston1.va.home.com> <9jhbfj$79s$1@pea.uk.research.att.com> <mailman.995930743.17137.python-list@python.org> Message-ID: <9jjfts$9k2$1@pea.uk.research.att.com> In article <mailman.995930743.17137.python-list at python.org>, Paul Prescod <paulp at ActiveState.com> wrote: >All backwards compatibility issues are a matter of patience. Do you >think that anybody would complain if something that was deprecated >between Python 1.4 and Python 1.5 was formally removed now? Maybe it >will take ten years for us to provide a migration path to new-style >division. That is not an argument for putting of the beginning of that >process. If we had started two years ago we would be two years closer to >being able to fix the problem finally. It is Guido's job to take the >long view. The thing about this change is that it is different from other changes there have been (that I'm aware of), in that it changes a fundamental part of the language semantics. Switching from the current / behaviour to the new proposal is not the same as _removing_ a feature -- it is _changing_ a feature. That is far more insidious. I agree, by the way, that if we were discussing a new language, it would be sensible to use / for fractional division and // for integer division (and just as sensible to do the reverse). I'm amazed at the passion behind people arguing about what, to me, is an arbitrary language choice. But that isn't the issue here. We aren't designing a new language, we're modifying an existing one. I return to my question. Suppose Python 2.2 is released with this __future__ division. Now suppose I must maintain some code which can run on Python 2.0, 2.1 and 2.2, which needs integer division. What am I to do? I can continue to use /, safe in the knowledge that I haven't done the __future__ import, but that doesn't take the long-term view -- it would be similarly foolish to write new code which uses "yield" as an identifier, since I know that it's going to break later. So what can I do? I can't even do something ugly like if sys.hexversion > 0x2000200: c = a // b else: c = a / b since the a // b gives a syntax error. The only option I can think of is to avoid integer division altogether, and implement it myself by other means. That just uglifies everything (and makes it slower, but that's not what bothers me most). In an ideal world, everyone would upgrade to new Python versions the moment they are released. The world just isn't like that, and people providing Python programs and libraries _have_ to support multiple Python versions. Cheers, Duncan. -- -- Duncan Grisby \ Research Engineer -- -- AT&T Laboratories Cambridge -- -- http://www.uk.research.att.com/~dpg1 -- From rnd at onego.ru Mon Jul 16 03:24:45 2001 From: rnd at onego.ru (Roman Suzi) Date: Mon, 16 Jul 2001 11:24:45 +0400 (MSD) Subject: module ns access vs. local access vs. builtin methods Message-ID: <Pine.LNX.4.30.0107161114170.18588-100000@rnd.onego.ru> I've got interesting profile results which show that using string methods is faster than other optimisation tricks: --- aaaa.py --- import profile, string def a1(s): for k in xrange(200): K = 0 for l in string.split(s): K = K+1 def a2(s, ssplit=string.split): for k in xrange(200): K = 0 for l in ssplit(s): K = K+1 def a3(s): for k in xrange(200): K = 0 for l in s.split(): K = K+1 def runner(x, y): for c in xrange(25): x(y) profile.run(""" runner(a1,"aaa "*50) """) profile.run(""" runner(a2,"aaa "*50) """) profile.run(""" runner(a3,"aaa "*50) """) ---------------------------------------- $ python2.1 aaaa.py > aaaa.res --- aaaa.res --- 5028 function calls in 2.690 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 2.620 2.620 <string>:2(?) 1 0.000 0.000 2.620 2.620 aaaa.py:21(runner) 25 1.150 0.046 2.620 0.105 aaaa.py:3(a1) 1 0.070 0.070 2.690 2.690 profile:0( runner(a1,"aaa "*50) ) 0 0.000 0.000 profile:0(profiler) 5000 1.470 0.000 1.470 0.000 string.py:103(split) 5028 function calls in 2.690 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 2.690 2.690 <string>:2(?) 1 0.000 0.000 2.690 2.690 aaaa.py:21(runner) 25 1.190 0.048 2.690 0.108 aaaa.py:9(a2) 1 0.000 0.000 2.690 2.690 profile:0( runner(a2,"aaa "*50) ) 0 0.000 0.000 profile:0(profiler) 5000 1.500 0.000 1.500 0.000 string.py:103(split) 28 function calls in 1.960 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 1.940 1.940 <string>:2(?) 25 1.940 0.078 1.940 0.078 aaaa.py:15(a3) 1 0.000 0.000 1.940 1.940 aaaa.py:21(runner) 1 0.020 0.020 1.960 1.960 profile:0( runner(a3,"aaa "*50) ) 0 0.000 0.000 profile:0(profiler) ------------------------- a3 is clear winner, which probably mean that calling methods of built-in types is faster than calling functions. And the trick with localising functions doesn't work (or maybe I did it wrong). Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Monday, July 16, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Every man's work is a portrait of himself." _/ From new_name at mit.edu Sat Jul 28 11:56:24 2001 From: new_name at mit.edu (Alex) Date: 28 Jul 2001 11:56:24 -0400 Subject: Creating package in Python References: <3b6288fc$1@news.barak.net.il> Message-ID: <etdd76lqc7r.fsf@lola-granola.mit.edu> Hard to say w/o more details. What error msg did you get when you attempted to import pgk.fib1? Have you read http://www.python.org/doc/essays/packages.html, by the way? Alex. From paul at svensson.org Thu Jul 26 11:32:55 2001 From: paul at svensson.org (Paul Svensson) Date: 26 Jul 2001 15:32:55 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <eppstein-03540D.13070222072001@news.service.uci.edu> <LNBBLJKPBEHFEDALKOLCOECNLAAA.tim.one@home.com> <mailman.995899647.346.python-list@python.org> <tclolt053o18f8q0ntb7n4aggitdkmeg4h@4ax.com> <Io_67.23543$B7.3779351@ruti.visi.com> <slrn9lp2m5.vp.Gareth.McCaughan@g.local> <p56plt8q4rs3bgcqbepk61q2r3g0tr2vhe@4ax.com> <slrn9ls3ae.2fm.Gareth.McCaughan@g.local> <cpitghbq05.fsf@cj20424-a.reston1.va.home.com> <m2wv4xdxlf.fsf@myc Message-ID: <9jpd77$qih$1@newsy.ifm.liu.se> Skip Montanaro <skip at pobox.com> writes: > Paul> The most obvious problem is that it implies that every rational > Paul> can be represented as a float -- this is *severe* brokenness you > Paul> don't need. [I think it also implies that floats with integral > Paul> values (1.0, etc.) should turn into integers.] > >You can't do that. Suppose that value you think is 1.0 really got truncated >during a previous calculation because your fp hardware doesn't have enough >bits and lost it? If you convert that to the integer 1 you're screwed >because you are pretending your inexact approximation of the real value is >the real value. You're better off admitting you have an inexact value and >planning accordingly. The only time the VM can convert from inexact to >exact (e.g., float->rational, float->int) is when the programmer says you >can with a cast. In the long term, I think the only manageable solution would be to separate the issue of exactness from the representation. /Paul (another one than the one above) From aahz at panix.com Sun Jul 15 22:13:57 2001 From: aahz at panix.com (Aahz Maruch) Date: 15 Jul 2001 19:13:57 -0700 Subject: OO misconceptions References: <mailman.994969462.27792.python-list@python.org> <slrn9l49me.p58.tim@vegeta.ath.cx> <3B52314B.F7F73ED5@engcorp.com> <slrn9l4h8v.p58.tim@vegeta.ath.cx> Message-ID: <9itil5$baf$1@panix2.panix.com> In article <slrn9l4h8v.p58.tim at vegeta.ath.cx>, Tim Hammerquist <timmy at cpan.org> wrote: > >All very good points. I have certain reservations, tho. I dread >waiting for Microsoft Word to startup as it is, written in compiled C++. >I fear for the speed of anything of that scale and complexity >implemented in Python. Maybe. Maybe not. Maybe the algorithms would be sufficiently better and the code enough smaller that the Python version of Word would be *faster*. You'd probably want the actual edit buffer and the screen painting done in C/C++ (just as in a game), but the rest of it...? -- --- 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 "How come we choose from just two people for President but more than 50 for Miss America?" --AEN From bill-bell at bill-bell.hamilton.on.ca Fri Jul 6 17:32:18 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Fri, 6 Jul 2001 17:32:18 -0400 Subject: Marking a Python COM server safe for Internet Explorer In-Reply-To: <994448502.568.45260.l6@yahoogroups.com> Message-ID: <3B45F622.26745.102DA0B@localhost> "Steve Holden" <sholden at holdenweb.com> wrote: > "Bill Bell" <bill-bell at bill-bell.hamilton.on.ca> wrote in ... > > > > As a kind of default, Internet Explorer will ask the user's > > permission before instantiating an ActiveX control. However, one can > > implement IObjectSafety to inform IE that one's control is safe, > > thus sparing the user the need to respond to the dialog box. > > > I must have misunderstood. Are you telling me that IE has a security > system to detect potentially unsafe downloaded content, but that it > won't use this system if the downloaded content tells it there's no > need? > > How very Microsoft. I must have missed something. Steve, This may not be as bad as it might have sounded. In order for IE to successfully query for IObjectSafety the ActiveX has to have been registered, right? And it couldn't be registered until it had been downloaded. And that couldn't happen unless the user agreed-- assuming that his/her IE is properly secured. Do I discern perhaps that your trust in, and admiration for, MS products are bounded? Take care. Bill From andreas at andreas-jung.com Fri Jul 20 10:10:53 2001 From: andreas at andreas-jung.com (Andreas Jung) Date: Fri, 20 Jul 2001 10:10:53 -0400 Subject: Large File Support In-Reply-To: <eiW57.266163$Z2.3224218@nnrp1.uunet.ca>; from rmacneil@interactdirect.com on Fri, Jul 20, 2001 at 09:23:43AM -0400 References: <eiW57.266163$Z2.3224218@nnrp1.uunet.ca> Message-ID: <20010720101053.A21188@yetix.digicool.com> On Fri, Jul 20, 2001 at 09:23:43AM -0400, Rod MacNeil wrote: > Hello NG, > > I need to build Python to include large file support on Redhat Linux 7.1. > > I tried the following instructions from section 8.1.1 in the Python docs but > it doesn't work: > > On large-file-capable Linux systems, this might work: > > > CC="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" > export CC > ./configure > That is an error in the Python docs. Replace CC by CFLAGS. This should do the job. Andreas From thomas.heller at ion-tof.com Fri Jul 20 06:00:55 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Fri, 20 Jul 2001 12:00:55 +0200 Subject: Importing XML modules in py2exe or Installer? References: <Xns90DE9C2957BDgustaflalgonetse@194.213.69.152> <9iq4oc$kme5j$1@ID-59885.news.dfncis.de> <Xns90DF21CFC7984gustaflalgonetse@194.213.69.152> <Xns90E25BD095F65gmcmhypernetcom@199.171.54.154> Message-ID: <9j8vgn$m0gtd$1@ID-59885.news.dfncis.de> "Gordon McMillan" <gmcm at hypernet.com> wrote in message news:Xns90E25BD095F65gmcmhypernetcom at 199.171.54.154... > [posted and mailed] > > Gustaf Liljegren wrote: > > [snip] > > > E:\jane>jane > > Traceback (most recent call last): > > File "<string>", line 54, in ? > > File "friend.pyc", line 22, in __init__ > > File "friend.pyc", line 49, in getName > > LookupError: unknown encoding > > This will probably clear up if you force > the "encodings" package into the build. > True. For other people having similar problems: Gustaf (the original poster) can now freeze his app with the command line: python setup.py py2exe -p xml -i encodings.latin_1 -e win32api He removed PyXML before because he didn't need it. There's way too much (import) magic going on in PyXML, such a simple approach does not work. Still the whole xml package must be included (-p xml) because otherwise no parsers are found. '-i encodings.latin_1' includes the latin_1 encoding, which is the only one he is using. Thomas From tom at peresys.co.za Tue Jul 3 05:00:39 2001 From: tom at peresys.co.za (Tomasz Stochmal) Date: 3 Jul 2001 02:00:39 -0700 Subject: Eiffel better than Python ? Message-ID: <f20ea932.0107030100.6c740683@posting.google.com> I have read the following book which gives C/C++ heavy bashing http://www.elj.com/cppcv3/ Conclusion is to use Java or even better choice is Eiffel Should I stop using Python and jump on Eiffel wagon ? Anybody that tried both languages ? How do they compare ? From jkn at nicorp.f9.co.uk Mon Jul 16 18:12:03 2001 From: jkn at nicorp.f9.co.uk (Jon Nicoll) Date: 16 Jul 2001 15:12:03 -0700 Subject: windows port access References: <3b520bcb@news.cybertours.com> <3B522E98.BAAA9E93@engcorp.com> <mailman.995288852.27369.python-list@python.org> Message-ID: <8351bb33.0107161412.6dcf7bf2@posting.google.com> Hi Chris [...] > > Unfortunately what Bryan is asking is not what you are answering. He wants > to access the I/O port 0x280, which he states is assigned to a "custom ISA > card" which (I assume) is not using the standard parallel port interface, > nor > serial, etc. and for which he evidently has no driver. This is exactly what my code can be used for - you can set it up to get access to arbitary IO ports (via the ioperm mechanism in Linux), and then read or write etc. as you like. Admittedly, it doesn't currently cater for interrupts. I originally started writing this to drive an ISA 8255/8253 card, and although this project-ette is currently in limbo, the basics are all there and working, if Bryan wants to do eg. polled access to an A/D card etc. > Under Linux, this can be done in C by following the instructions in the > "IO Port Programming mini-HOWTO" (check any Linux portal, i.e. linux.com, > for this document). All done! ;-) > [...] > Under Win32 I'm not sure what the procedure is, but I suspect a VxD file > will > be needed. You don't need a VxD (for W95 at least), although it's probably the 'better' way of doing things. My code is in C and turns into a little '.PYD' (= .DLL) file. In NT, you need a kernel mode driver, which I haven't yet got around to looking at. I've just resurrected my code and am looking at using distutils to get it in a form more easily distributed. Email me if would be of use to you in the meantime. Jon N From sh at ttsoftware.co.uk Mon Jul 23 08:50:51 2001 From: sh at ttsoftware.co.uk (Steve Horne) Date: Mon, 23 Jul 2001 13:50:51 +0100 Subject: PEP0238 lament References: <5sdnlt072hm6hp17nluu6f0fqq4bvr6mj8@4ax.com> <mailman.995873261.11975.python-list@python.org> Message-ID: <916olt0p3kciv0evmotdg6jev9bl29l57i@4ax.com> On Mon, 23 Jul 2001 03:26:52 -0400, "Tim Peters" <tim.one at home.com> wrote: >[]Stephen Horne] >> ... >> And what about the languages web developers are used to, such as >> VBScript and JavaScript. > >Good thing you stopped before mentioning Perl (yes, 1/2 is 0.5 there) -- I'm >afraid the "mimic other languages" approach requires picking languages very >carefully if you want the illusion of consistency. By the way, 1/2 is also >0.5 in standard JavaScript: My mistake. However, the overwhelming majority of code is written to a pattern where 1/2=0 - the simple fact Visual BASIC does it almost sets the standard itself - and C, C++ and Java are hardly obscure. I think you'll find it's the picking of languages where 1/2 = 0.5 that has to be done carefully - I can think of Pacal, Modula 2, LISP and - taking into account your correction - Perl and JavaScript. The last to are enough to prove that your *opinion* is valid, those are not in use to anywhere near the same extent as languages like C, C++, Java and BASIC. >produce-enough-frantic-arguments-at-random-and-some-are-likely- > to-backfire<wink>-ly y'rs - tim This argument still holds well enough on its own to prove that changing the division operator is *not* an *undeniably* good thing - it is at best a matter of opinion. *THAT* is all I need to prove - and I have done so with several different arguments. Furthermore it is not a random argument - it is a genuine concern with no less validity than those in favor of 1/2 being 0.5. Had Python started out differently, I'd still disagree but I wouldn't be making a big issue. But this is a code-breaker of the worse kind - it will create bugs in trusted programs that have been relied upon for years without problem, which the programmers have forgotten about (if the programmers are even still in the company) - and many of the bugs may not even be obvious when they occur. And it will happen a *lot* - division is *not* some obscure rarely-used feature, it is a basic arithmetic operation. The reward for advocating Python is apparently that you get to look a complete idiot in front of your boss when everything you've written goes pear shaped - *just* the kind of thankyou all the Python advocates have been looking for, I don't think. -- Steve Horne Home : steve at lurking.demon.co.uk Work : sh at ttsoftware.co.uk From steve at lurking.demon.co.uk Sun Jul 22 08:45:27 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Sun, 22 Jul 2001 13:45:27 +0100 Subject: Eiffel better than Python ? References: <f20ea932.0107030100.6c740683@posting.google.com> <%7i07.25728$he.1340574@e420r-atl1.usenetserver.com> <9hsi0d$oqv$3@216.39.170.247> Message-ID: <ilhllt0tkfe0d2lde5t7rvj22q47japlf4@4ax.com> On 3 Jul 2001 13:40:29 GMT, David LeBlanc <whisper at oz.nospamnet> wrote: >reason to use Basic? After all, supposedly 80% of all business apps are >written in Basic - presumably Visual Basick since they've pretty >effectively killed off that entire market segment. Personally, I think >i'd rather take up a career as William Park ;) You still see the odd business utility running in DOS - some old Turbo BASIC and QBASIC programs among them. Last I checked, QBasic was still provided on Windows CDs - it just doesn't install by default. I wouldn't be surprised if GWBASIC isn't hanging on in some strange corners of the world - and it's quite likely that some people have old Atari STs or Amigas with BASIC programs to do some task which work well enough that no-one felt a need to replace them. I actually have quite fond memories of GFA BASIC and STOS - though not *that* fond really. From tim.hochberg at ieee.org Thu Jul 26 18:57:32 2001 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Thu, 26 Jul 2001 22:57:32 GMT Subject: Toppling the numeric tower References: <DLW77.49367$Cy.6275542@news1.rdc1.az.home.com> <cpzo9r5qty.fsf@cj20424-a.reston1.va.home.com> Message-ID: <wf187.49830$Cy.6425268@news1.rdc1.az.home.com> "Guido van Rossum" <guido at python.org> wrote in message news:cpzo9r5qty.fsf at cj20424-a.reston1.va.home.com... > "Tim Hochberg" <tim.hochberg at ieee.org> writes: [SNIP] > > Real Complex > > | | > > rRational cRational -- Rational (Exact) > > rFloat cFloat -- Float (Inexact) > > I just don't see much use for complex rational... So then we're back > to my original tower (with rational). Hmmm.... Without complex rationals I suppose you are back to the tower. I may be viewing this through a warped lense: once upon a time I reimplemented NumPy in Java. There it was both much simpler and worked better to do type conversions based on a box instead of a tower. However, NumPy has many more types than PEP 228 proposes so it's a lesson that probably doesn't apply here. I must admit that complex rationals appeal to me mainly from a aesthetic and pedagogical point of view. I would probably have about as much use personally for complex rationals as I do for real rationals; that is, not very much. But in cases where I'd be tempted to use rationals (for instance slow, but sure, stability check on a misbehaving algorithm) I'd be about as likely to be using complex as real numbers. That's probably not typical though. Thinking about it, fixed precision binary decimal, which is also appears to be under discussion, would probably be more useful. Maybe someone who has a more compelling use for complex rationals will come forward and save my box. Otherwise ... alas poor box, we hardly knew ye. -tim From tim.one at home.com Mon Jul 30 02:05:19 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 30 Jul 2001 02:05:19 -0400 Subject: proposed language change to int/int==float (was: PEP0238 lament) In-Reply-To: <cpy9pa4hnh.fsf@cj20424-a.reston1.va.home.com> Message-ID: <LNBBLJKPBEHFEDALKOLCAEDHLCAA.tim.one@home.com> [Guido van Rossum] > ... > On the other hand, floats should never be usable as sequence index. > Scheme defines this quite nicely: > > http://www.swiss.ai.mit.edu/ftpdir/scheme-reports/r5rs-html/r5rs_8 .html#SEC50 > Except that Scheme has nothing against reals being used as sequence indices: exactness is orthogonal to numeric type in Scheme, and being usable as a sequence index relies on exactness. > (real? 3) #t > (complex? 3) #t > (integer? 3.0) #t > (exact? 3.0) #f > (exact? #e3.0) #t > complex? real? rational? integer? That's "the tower". If (f? x) is true for some f from that list, then (g? x) is also true for every g above f in the tower. The internal representation is undiscoverable in Scheme ("real" doesn't *mean* "HW floating-point storage" there). There is no simple relationship between a number's type and its representation inside a computer. Although most implementations of Scheme will offer at least two different representations of 3, these different representations denote the same integer. When the focus is on numbers as mathematical values, internal storage format should be irrelevant to semantics. From peter at engcorp.com Thu Jul 26 01:49:04 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 26 Jul 2001 01:49:04 -0400 Subject: Use of iterators for state machine (was Re: 2.2 features) References: <mailman.996098094.16930.python-list@python.org> Message-ID: <3B5FAF50.9AC8912C@engcorp.com> Tim Peters wrote: > > [Nick Perkins] > > I like generators a lot. Here's a fun one: > > > [...] > That's something of a strain in such a simple case, but in general the > ability to "get out of a loop early" without needing to materialize the > whole sequence first is a major practical application of the iterator > protocol. I like the potential for iterators for infinite sequences of several kinds (where the ability to "get out of a loop early" is an absolute requirement :-). I'm especially looking forward to using them to implement state machines. I suspect they will greatly simplify the readability of several different state machine patterns I tend to use. Has anyone with more of a background in the whole iterator concept (in other languages of course) tried this before? Any comments? -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From grante at visi.com Fri Jul 13 09:48:07 2001 From: grante at visi.com (Grant Edwards) Date: Fri, 13 Jul 2001 13:48:07 GMT Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> <bebbba07.0107021206.70a22aa8@posting.google.com> <861ynl4s34.fsf@hellcat.itga.com.au> Message-ID: <r_C37.14716$B7.2683002@ruti.visi.com> In article <861ynl4s34.fsf at hellcat.itga.com.au>, Gregory Bond wrote: >18k11tm001 at sneakemail.com (Russ) writes: > >> If I change the order of two ints in a >> function interface, for example, the C++ compiler won't have a clue >> that the interface has changed. > >If you do something like this for any project larger than 1 person and >a handful of files, you are in deep trouble irrespective of the >language. Unless you're passing parameters by keyword -- in which case the order doesn't matter. -- Grant Edwards grante Yow! Did I SELL OUT yet?? at visi.com From guido at python.org Wed Jul 25 01:02:27 2001 From: guido at python.org (Guido van Rossum) Date: Wed, 25 Jul 2001 05:02:27 GMT Subject: A modest PEP0238 suggestion References: <3b5c6e08.27535083@aplnews> <kr2pltsb9gmehe4vtqm8so37924tdfs59s@4ax.com> Message-ID: <cpzo9ta9el.fsf@cj20424-a.reston1.va.home.com> Stephen Horne <steve at lurking.demon.co.uk> writes: > More important is all the software that is somehow in-the-field - a > VERY serious problem. You can always use the solution that works so well in many other situations: don't upgrade Python, or at least keep a copy of Python 1.5.2 or 2.1 around, and use that for your unconverted code. This is a very common solution. --Guido van Rossum (home page: http://www.python.org/~guido/) From ToMuchSpam at ToHaveValid.com Sun Jul 8 21:29:34 2001 From: ToMuchSpam at ToHaveValid.com (RoadRunner_au) Date: Mon, 9 Jul 2001 11:29:34 +1000 Subject: pySOL Message-ID: <IL727.88787$Rr4.90891@ozemail.com.au> I am trying to get this game (pySOL) to run in windows 98, but as soon as the windows comes up with the game it crashes with the following error. SyntaxError: invalid syntax C:\Program Files\Python21>python C:\TMP\PYSOL\DATA\PYSOL_21.PYC Traceback (most recent call last): File "pysol.py", line 19853, in ? File "pysol.py", line 19851, in main File "pysol.py", line 19813, in pysol_main File "pysol.py", line 18904, in mainloop File "pysol.py", line 18984, in runGame File "pysol.py", line 3346, in helpAbout File "pysol.py", line 2365, in __init__ File "pysol.py", line 2287, in __init__ File "pysol.py", line 2024, in makeImage File "c:\program files\python21\lib\lib-tk\Tkinter.py", line 2972, in __init__ apply(Image.__init__, (self, 'photo', name, cnf, master), kw) File "c:\program files\python21\lib\lib-tk\Tkinter.py", line 2928, in __init__ self.tk.call(('image', 'create', imgtype, name,) + options) TclError: unknown option "-dither" C:\Program Files\Python21> Can anyone help with fixing this problem? thanks. From steve at lurking.demon.co.uk Mon Jul 23 00:34:59 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Mon, 23 Jul 2001 05:34:59 +0100 Subject: Future division patch available (PEP 238) References: <GNZwEiAJepW7Ew0F@jessikat.fsnet.co.uk> <mailman.995776716.24336.python-list@python.org> <mailman.995825018.9832.python-list@python.org> <9jfjd6$ad4$2@newshost.accu.uu.nl> Message-ID: <7u6nltoqdnqjjdiquu6ngtaruflhvbvdl5@4ax.com> On 22 Jul 2001 22:17:10 GMT, m.faassen at vet.uu.nl (Martijn Faassen) wrote: >Moshe Zadka <moshez at zadka.site.co.il> wrote: >> On Sun, 22 Jul 2001, Robin Becker <robin at jessikat.fsnet.co.uk> wrote: > >> [about //] >>> it just looks awful as well as annoying those who don't want this >>> change. > >> Any solution would have annoyed the other side, and one solution >> had to be taken. >> And no, "inertia" isn't an excuse. Python cannot be ruled by inertia, >> just as it cannot arbitrarily break backwards compat. > >People just differ in their opinions on what is inertia and what is >arbitrarily breaking backwards compatibility. Robin is probably in >the "arbitrarily breaking backwards compatibility" camp on this issue, >while you're in the "inertia" camp. I'm in the "just leave me here, >go on without me, I'll be okay" camp, myself. This is not *arbitrarily* breaking backwards compatibility - it is *irrationally* breaking backwards compatibility. Division on integers should be integer division. It is natural to have an integer result and a remainder - that was what people did for thousands of years before the idea of fractional parts was even thought of. Many measures are inherently integer, and it is a simple fact of life that you have to deal with the integer result and the remainder. Mathematically, integer division should be the inverse of integer multiplication, with no extra functionality bar the need to allow for the remainder. Well shock horror - that's exactly what we've got now and exactly what we're throwing away. Integer division is important to a huge range of applications - anything involving money stands out as the obvious case, but also cryptography and others. These are all valid viewpoints for keeping integer division exactly as it is - completely independent of the code breaking issue. Therefore, the idea that 1/2 should give 0.5 is a matter of opinion - not an ideal. If you want float results, use float arithmetic - it's simple, it works and it does *not* break existing source code. If you really want a division operator that treats everything as floats, then *that* is the new functionality and *that* should be the new operator. I don't mind such an operator being added - I will simply feel free to ignore it. Python would be a laughing stock without a division operator, and it will certainly be a laughing stock if we can't rely on it to do the same thing from one release to the next. It's a far to fundamental change just to please people with a particular mindset. And lets remember - even people *with* that mindset are going to have problems - they *must* have code with integer division or they would never have noticed the result being an integer. From iron at mso.oz.net Wed Jul 11 16:08:37 2001 From: iron at mso.oz.net (Mike Orr) Date: 11 Jul 2001 20:08:37 GMT Subject: MySQLdb not reading ~/.my.cnf ? References: <slrn9kk5lo.9ed.dennis@smart.cobolt.net> Message-ID: <9iibo5$ocg$0@216.39.144.220> Dennis Schoen <dennis at cobolt.net> wrote: > I'm trying to connect to a mysql db from a python script. I can > connect without any problem when i add explicitly the username and > passwd like this: > db = MySQLdb.connect(db=sys.argv[1], user=sys.argv[2], passwd=sys.argv[3]) > coming from perl I like the idea of ~/my.cnf, but when i just ommit the > parameters I get: > _mysql_exceptions.OperationalError: (1045, "Access denied for user: 'dennis at localhost' (Using password: NO)") > My ~/my.cnf file works fine, when used from other applications. Apparently, reading ~/.my.cnf is the responsibility of the application or library, and MySQLdb doesn't do it. It could, of course. Perhaps as an option to MySQLdb.connect(read_password_from_mycnf=0) or if passwd is None.... -- -Mike (Iron) Orr, iron at mso.oz.net (if mail problems: mso at jimpick.com) http://iron.cx/ English * Esperanto * Russkiy * Deutsch * Espan~ol From philh at comuno.freeserve.co.uk Fri Jul 6 19:35:54 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Sat, 7 Jul 2001 00:35:54 +0100 Subject: openssl-python Message-ID: <slrn9kciqp.5l8.philh@comuno.freeserve.co.uk> There's a package, openssl-python that lets you write python programs that call functions in the OpenSSL library. Unfortunately i cannot find a homepage for it. All there is that gets retuerned by Google is pages that link to RPMs for it. Where can i download a .tar.gz file? -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From tjenkins at nospiced.ham.devis.com Wed Jul 25 09:50:49 2001 From: tjenkins at nospiced.ham.devis.com (Tom Jenkins) Date: Wed, 25 Jul 2001 13:50:49 GMT Subject: PEP238 and zope References: <3B5DE0F7.9070001@nospiced.ham.devis.com> <cpitgha7pe.fsf@cj20424-a.reston1.va.home.com> Message-ID: <3B5ECF9E.8000103@nospiced.ham.devis.com> Guido van Rossum wrote: > Tom Jenkins <tjenkins at nospiced.ham.devis.com> writes: > > >>We're a zope shop. Its quite possible that the work we do now will be >>still in use for many years (not guaranteed but we still use code now >>that we wrote 2 years ago - before it was zope ;) ) >> >>We use Python Methods in Zope... python snippets stored directly in >>zope's zodb. grepping *.py won't find any of these snippets. I don't >>believe zope will surface any warnings that PEP238 stipulates (tho I may >>be wrong). How do we code _now_ so as to minimize our pain? >> > > I find it hard to believe that you use much division is Zope scripts, > but if you do, use divmod(x, y)[0] for int division and x*1.0/y for > float division. > > However, Zope typically comes with its own Python version, so all you > need to do is not upgrade the Zope version you are using. Also, I > believe that Zope is typically much more aggressive in breaking old > code, so you wouldn't want to upgrade your Zope anyway if you had a > lot of old code around that you couldn't afford to maintain. > Yes zope is typically much more aggressive in breaking old zope code, but the breakage is typically in the security mechanisms not in the underlying fundamentals. It also means I have to try and minimize the effects. Quite frankly I thought python code in our Python Methods was safe. my-naivete-astonishes-even-me-sometimes-ly yours Tom From see at below Mon Jul 2 09:16:31 2001 From: see at below (Paul Foley) Date: 03 Jul 2001 01:16:31 +1200 Subject: functional programming and default parameters References: <u7k81v6zf2.fsf@hpeesof.asc> <mailman.993838725.28543.python-list@python.org> <slrn9jscjd.m72.Gareth.McCaughan@g.local> <u78zi7k55m.fsf@hpeesof.asc> Message-ID: <m2r8vz5v4g.fsf@mycroft.actrix.gen.nz> On 02 Jul 2001 12:16:05 +0200, Ralf Muschall wrote: > The situation in python is remotely similar to lisp in that the loop > variable is created only once - just forcing python to create a fresh > scope needs a more verbose hack. > OTOH, > (#Mfuncall (#M(lambda (x) (lambda () x)) (scan-range :below 6))) > works :-) Assuming you have the SERIES package installed; but I think the fact that it does is just an accident -- #M is only meant to work on named functions. [But (lambda (x) (lambda () x)) has a name in CL, anyway; it's CONSTANTLY] And you want a list, so (collect (#Mfuncall (#Mconstantly (scan-range :below 6)))) -- You have been evaluated. You have a negative reference count. Prepare to be garbage collected. Persistence is futile. -- Erik Naggum (setq reply-to (concatenate 'string "Paul Foley " "<mycroft" '(#\@) "actrix.gen.nz>")) From canimalatmydejadotcom at nospam.com Fri Jul 20 14:23:25 2001 From: canimalatmydejadotcom at nospam.com (Matt) Date: Fri, 20 Jul 2001 18:23:25 GMT Subject: Case insensitivity References: <mailman.995647175.15752.python-list@python.org> <3B5867E8.6B8751F8@Lugoj.Com> Message-ID: <Xns90E48917CC7EFcanimalmydejacom@24.94.170.10> James Logajan <JamesL at Lugoj.Com> wrote in news:3B5867E8.6B8751F8 at Lugoj.Com: > Dan Bergan wrote: >> (Declare the variable in mixed-case) >> Dim myVariable as Integer >> >> (then I purposely type in the wrong case when I use 'myVariable') >> myvaraible = 1 '<==TYPO! > > Well, if you "correct" that to myVaraible you would still be in error, > because you accidentally exchanged "ia" with "ai" in addition to > changing "V" to "v". Python will not inform you about about some typos, > whether case-related, dropped characters, exchanged characters, or > added characters. That's what Dan is saying he likes about VB. It will tell you about typos if your variables are mixed case. The auto-case correction in VB will inform Dan that he has made a typo, because the editor "snaps" variable names into their declared capitalization as soon as they are typed. In the example above, when Dan hits the spacebar after "myvaraible", the text will remain all lowercase because "myvaraible" is not declared, and Dan will know he has made an error. I do most of my programming in VB, I exploit this feature the same way Dan does, and I have had trouble getting used to Python's case sensitivity. I don't see a need to change the language to accomodate VB programmers, but having a case-checking option as part of the editor would be a blessing. (ActiveState, are you reading this?) Matt From guido at python.org Fri Jul 27 16:08:06 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 27 Jul 2001 20:08:06 GMT Subject: PEP0238 lament References: <mailman.996013330.29136.python-list@python.org> <cp8zhd9gm9.fsf@cj20424-a.reston1.va.home.com> <18289ee4.0107261001.664eb547@posting.google.com> <uae1qeqmt.fsf@cs.uu.nl> <18289ee4.0107271117.7df350d4@posting.google.com> Message-ID: <cpu1zy16g7.fsf@cj20424-a.reston1.va.home.com> david at boddie.net (David Boddie) writes: > It's strange. I don't mind the introduction of default float division > at some point in the future, despite having to rewrite many of my > modules with no future-proof, succinct integer division operator to > hand. However, diplomatic attempts to avoid breakage of legacy code > appear to have failed. I suspect that the best we can hope for is > non-silent breakage via compile-time exceptions. I'm assuming this was aimed at me, so I'll respond. Suppose that python 3.x would *always* have to be invoked as "python3". Would that still break legacy code? This approach was used successfully by Perl. I just don't want to encumber the language itself with version encrustations. It offends my sense of elegance in language design. --Guido van Rossum (home page: http://www.python.org/~guido/) From quinn at yak.ugcs.caltech.edu Mon Jul 16 13:13:05 2001 From: quinn at yak.ugcs.caltech.edu (Quinn Dunkan) Date: 16 Jul 2001 17:13:05 GMT Subject: converting from perl: variable sized unpack References: <roy-B2459F.22112513072001@news1.panix.com> <mailman.995081424.8581.python-list@python.org> <slrn9l4esk.885.quinn@yak.ugcs.caltech.edu> <roy-E01423.21425015072001@news1.panix.com> <9iulp401r93@enews3.newsguy.com> Message-ID: <slrn9l6850.cr0.quinn@yak.ugcs.caltech.edu> On Mon, 16 Jul 2001 14:12:52 +0200, Alex Martelli <aleaxit at yahoo.com> wrote: >"Roy Smith" <roy at panix.com> wrote in message >news:roy-E01423.21425015072001 at news1.panix.com... >> quinn at yak.ugcs.caltech.edu (Quinn Dunkan) wrote: >> > Even without that, I argue that a bad pattern match should throw an >> > exception and not assign None >> >> I have to admit, that would be somewhat consistant with the way the rest >of >> the language works, but it sure would make it more complicated to do >> something like: >> >> if re.match (pattern1, string): >> do stuff Oops, note that I wasn't talking about regular expressions when I said "pattern match". The terminology is a holdover from some other languages. I should get in the habit of using the python terminology: sequence unpacking. And I'm perfectly happy that failed regular expressions don't raise. A failing regexp is not an exceptional situation---it's normal and expected and intended. It would be pretty annoying to have to wrap up every re.search in try/except. From claird at starbase.neosoft.com Sat Jul 28 12:20:18 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 28 Jul 2001 11:20:18 -0500 Subject: I want to do something: References: <jYy87.177$vM1.2880@e3500-atl1.usenetserver.com> <etdae1pqbzp.fsf@lola-granola.mit.edu> Message-ID: <9E498636EBFC006C.0B20514C36C78E95.408432537CAD3767@lp.airnews.net> In article <etdae1pqbzp.fsf at lola-granola.mit.edu>, Alex <new_name at mit.edu> wrote: > >If you're on unix, you might want to have a look at cron, which is >perfect for this kind of thing. Here's something I wrote for a friend . . . Also of possible interest: <URL: http://groups.google.com/groups?th=1a11303f10bad120 > -- Cameron Laird <claird at NeoSoft.com> Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From simonb at webone.com.au Sat Jul 14 22:05:51 2001 From: simonb at webone.com.au (simonb at webone.com.au) Date: Sun, 15 Jul 2001 12:05:51 +1000 Subject: parallel port?!? References: <3B513D42.933A0445@iinet.net.au> <mailman.995136984.18034.python-list@python.org> Message-ID: <3B50FA7F.3030600@webone.com.au> > >For Linux, you will need a module providing abstractions for the lp(4) >ioctl's. AFAIK there is no such module currently... somebody tell me >if I am wrong. > You can do ioctls from python; the fcntl module has ioctl. then to use the lp ioctls, use h2py from the source distribution or a beefed up h2py that i wrote you can find at http://programmer-software.com/~simon Simon From guido at python.org Wed Jul 25 01:40:29 2001 From: guido at python.org (Guido van Rossum) Date: Wed, 25 Jul 2001 05:40:29 GMT Subject: python2.2: type('name') -> <type 'str'> ?? References: <Pine.LNX.3.96.1010724175515.4646A-100000@latt.if.usp.br> Message-ID: <cpg0bla7n8.fsf@cj20424-a.reston1.va.home.com> Francisco <frandebo at latt.if.usp.br> writes: > I just compiled python2.2a and I'm getting this strange response to the > 'type' command: > > Python 2.2a1 (#2, Jul 24 2001, 12:24:09) > [GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2 > Type "copyright", "credits" or "license" for more information. > >>> type('') > <type 'str'> > > while I expected to get <type 'string'>. > > Am I missing something or I just messed up with the compilation?? No, the string type changed its name to match the str() function (which is now the same as the str type). --Guido van Rossum (home page: http://www.python.org/~guido/) From max at alcyone.com Mon Jul 16 01:27:13 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 15 Jul 2001 22:27:13 -0700 Subject: re Challenge: More Compact? References: <3B51E6B1.47E25214@tundraware.com> <92ae279c.0107151429.398e6e9e@posting.google.com> <slrn9l4fob.p58.tim@vegeta.ath.cx> <slrn9l4rck.rlt.quinn@regurgitate.ugcs.caltech.edu> Message-ID: <3B527B31.E715AE0E@alcyone.com> Quinn Dunkan wrote: > How about: > > for o in '.'.split(ip_addr): You mean ip_addr.split('.'). -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ All generalizations are dangerous, even this one. \__/ Dumas Fils The laws list / http://www.alcyone.com/max/physics/laws/ Laws, rules, principles, effects, paradoxes, etc. in physics. From sholden at holdenweb.com Wed Jul 18 15:14:15 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 18 Jul 2001 15:14:15 -0400 Subject: how to save strings to a temporary buffer? References: <mailman.995481031.2700.python-list@python.org> Message-ID: <Zbl57.33068$d4.1168768@e420r-atl1.usenetserver.com> <ed_tsang at yahoo.com> wrote in message news:mailman.995481031.2700.python-list at python.org... > How can I save string to a tempororay buffer and then write it to a > file afterwards? > > I have a function that output a formatted string each time it is > called; but instead of open a file and write it each time; I would > like to save these strings to a , may be a tmeporory buffer, and then > write it to a file when everythign is completed... how cna I do that? > thansk > You could just accumulate the strings in a list: pass the current list to the function and have it append() its current output. Then just write all the strings out at the end of the program. Or look at the StringIO or cStringIO modules. regards Steve -- http://www.holdenweb.com/ From tdelaney at avaya.com Sun Jul 1 20:59:55 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Mon, 2 Jul 2001 10:59:55 +1000 Subject: Augmented Assignment (was: Re: PEP scepticism) Message-ID: <B43D149A9AB2D411971300B0D03D7E8B0FC21C@natasha.auslabs.avaya.com> > 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 > >>> Actually, that's not quite true. It would be quite legal for id(b) to be identical in one case - since b is the only reference to the tuple, the original tuple could be collected, and a new tuple with the same id() could be allocated. It's unlikely, but possible. Tim Delaney From rnd at onego.ru Thu Jul 12 13:11:47 2001 From: rnd at onego.ru (Roman Suzi) Date: Thu, 12 Jul 2001 21:11:47 +0400 (MSD) Subject: list and implicit continuation may cause bugs in Python programs In-Reply-To: <07cb01c10ae4$64a3c440$9865fea9@SUXLAP> Message-ID: <Pine.LNX.4.30.0107122110180.3555-100000@rnd.onego.ru> On Thu, 12 Jul 2001, Andreas Jung wrote: > >----- Original Message ----- >From: "Roman Suzi" <rnd at onego.ru> >To: <python-list at python.org> >Sent: Donnerstag, 12. Juli 2001 09:00 >Subject: list and implicit continuation may cause bugs in Python programs > > >> FYI: >> >> Do not forget commas: >> >> list =[ "update", "y", "m", "d", "y1", "m1", "d1", "event", "url", >> "preview" ] >> >> list =[ "update", "y", "m", "d", "y1", "m1", "d1", "event", "url" >> "preview" ] >> >> Or Python will silently make: >> ['update', 'y', 'm', 'd', 'y1', 'm1', 'd1', 'event', 'urlpreview'] >> >> Does PyChecker check for these kind of things? >> > >For what reason should it check ? Both is valid Python code. In the second >case 'url' and 'preview' are concatenated. This is dedicated behaviour. > >Also the following is correct Python code: > >print "url" "preview" >print "url","preview" > >So there is no way to determine the programmers intention at this point. PyChecker is about determining ambiguity, like lint will give you warnings about if (a=b) { }; in C code. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Thursday, July 12, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Misfortune: The kind of fortune that never misses." _/ From nperkins7 at home.com Tue Jul 24 14:46:41 2001 From: nperkins7 at home.com (Nick Perkins) Date: Tue, 24 Jul 2001 18:46:41 GMT Subject: Version compatibility in division References: <mailman.995916220.13066.python-list@python.org> Message-ID: <loj77.544242$eK2.114179510@news4.rdc1.on.home.com> Good point. I suppose the only cross-version solution would be: # Script MUST run under various Python versions without change ... print int(container/widget) ,'widgets will fit in the container' It's a tiny bit verbose, but at least it's very explicit. From tim.one at home.com Fri Jul 27 00:59:07 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 27 Jul 2001 00:59:07 -0400 Subject: Nasty typo in PEP 238 (revised) In-Reply-To: <eppstein-7014B5.21120826072001@news.service.uci.edu> Message-ID: <LNBBLJKPBEHFEDALKOLCAEJJLBAA.tim.one@home.com> [David Eppstein] > floor converts ints to floats???? This seems exactly backwards > from what I would expect. Virtually all the functions in the math module wrap C library functions of the same names. floor() is a required double->double function in standard C, and Python's math.floor() exposes the platform C's floor() function. > And while it is certainly documented that way in the library > reference (section 5), it is contradicted by the footnote in section 2 > about using floor and ceil for "well-defined conversions" from float to > int, C89 didn't define the rounding behavior of float->int conversions, so floor and ceil were needed to force the issue as desired; as of earlier this afternoon, Python 2.2 now defines float->int as truncating ("round to 0") regardless of what the platform C happens to do. > as well as the claim in the reference manual that integer-division is > the same as applying floor to the result of mathematical division. The mathematical floor, yes; not the math.floor() function. > I have to consider this a big wart. The audience for math.floor() is floating-point users; you've already testified repeatedly you're not one of them <wink>. > Especially with the proposed changes to /, I would likely want to write > code like i = floor(a/b) and j = ceil(c/d) but apparently this is > going to need added coercions to get an integral type. Yes. But if you want the floor, use a // b instead: that's what it's there for. ceil is neither harder nor easier to get than before, and the best way to get the ceiling of an integer quotient in Python has always been def ceiling_of_quotient(i, j): q, r = divmod(i, j) return q + (r != 0) > Anyway, back to the PEP, I don't think calling floor(x) is a very > clear way of writing an int-to-float coercion, and it's still a bug > because it will give you incorrect results if x is a non-integral float. math.floor() isn't intended for int-to-float coercion, and I believe you were right the first time (that the specific occurrence of "floor" in the PEP that you pointed out was just a typo, and that "float" was intended there instead). From kirschh at lionbioscience.com Thu Jul 12 02:57:01 2001 From: kirschh at lionbioscience.com (Harald Kirsch) Date: 12 Jul 2001 08:57:01 +0200 Subject: shortest match regexp operator anyone? References: <yv266cz4aom.fsf@lionsp093.lion-ag.de> <3d66czqo78.fsf@ute.cnri.reston.va.us> Message-ID: <yv2sng23a9u.fsf@lionsp093.lion-ag.de> Andrew Kuchling <akuchlin at mems-exchange.org> writes: > Harald Kirsch <kirschh at lionbioscience.com> writes: > > With non-greedy matching, another approximation is '^.*?<A>B', however > > this matches 'xx<A>y<A>B', although it should not. > > It sounds like you want something similar to the (?> ...) in Perl 5.6. > Neither SRE nor the current version of PCRE support this, though. > Personally I'd just code it explicitly, as 'index = s.find('<A>') ; if > index != -1: # check for B ...'. Wordier, but doesn't require regex > arcana. Reading the docs about (?> ...) at http://www.perldoc.com/perl5.6/pod/perlre.html#DESCRIPTION I agree to the phrase `regex arcana'. And I don't see how it could simulate a shortest match. Thanks, Harald Kirsch. -- ----------------+------------------------------------------------------ Harald Kirsch | kirschh at lionbioscience.com | "How old is the epsilon?" LION bioscience | +49 6221 4038 172 | -- Paul Erd?s *** Please do not send me copies of your posts. *** From guido at python.org Wed Jul 25 01:12:17 2001 From: guido at python.org (Guido van Rossum) Date: Wed, 25 Jul 2001 05:12:17 GMT Subject: A modest PEP0238 suggestion References: <3b5c6e08.27535083@aplnews> <9jjk9g$8tk$1@newsy.ifm.liu.se> Message-ID: <cpu201a8y7.fsf@cj20424-a.reston1.va.home.com> paul at svensson.org (Paul Svensson) writes: (Thanks for your nice table, BTW.) > The only choices that make sense to me here are, either we break stuff, > or we do nothing. Either way, we'll most likely have to revisit the > issue if/when syntax for rationals is to be added to the language. Actually, adding rationals can be done almost entirely without breaking code... That is, *if* we adopt PEP-238 now. Changing 1/2 from returning a float to returning a rational won't have to break code, since the mathematical value of the result is the same. Changing it from returning 0 to returning a rational isn't any easier than changing it from returning 0 to returning a float -- exactly the same places will have to be changed. If you're for rationals, you're for PEP-238. --Guido van Rossum (home page: http://www.python.org/~guido/) From steve at lurking.demon.co.uk Mon Jul 23 19:05:11 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Tue, 24 Jul 2001 00:05:11 +0100 Subject: A use for integer quotients References: <3B5BA29B.E08FEEE9@alcyone.com> <yCK67.17615$EP6.4467503@news1.rdc2.pa.home.com> <mailman.995860718.9550.python-list@python.org> <mailman.995862939.15013.python-list@python.org> <mailman.995883879.12071.python-list@python.org> <3B5C5665.8D41D1F1@tundraware.com> <slrn.pl.9los0f.jh4.qrczak@qrnik.zagroda> <3B5C749A.59F97320@tundraware.com> <eppstein-6E0A27.12470423072001@news.service.uci.edu> <415pltcn73cga0lmvtmgdn3vb02f7d28kr@4ax.com> <slrn.pl.9lp6u8.hhd.qrczak@qrnik.zagroda> Message-ID: <h69plt04ff8j36ma26k9b2l13e5i04hg6e@4ax.com> On 23 Jul 2001 21:48:57 GMT, Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl> wrote: >I've never seen / as integer division in mathematics. The only notation >I know is > > | a | > | - | > |_ b _| How about ? - and how about 'fractions' (ie rationals with integer numerator and denominator). I've been here already - mathematicians use the same set of operators whatever set of values. They exact representations aren't available to simple ASCII text files, so we use a single alternate representation. The point is that we should the same symbol for the same meaning, exactly the same as mathemeticians. When a mathematician asks 'I can't find a divide symbol, how do I do that?' the answer should be simple - it should not depend on which set of values he happens to be working in at the time. The fact that we need to choose an alternative symbol should not be seen as a chance to break with principles that mathematicians have applied successfuly since well before Christs time. From markus at kepler.ibp.de Tue Jul 31 07:40:41 2001 From: markus at kepler.ibp.de (markus at kepler.ibp.de) Date: 31 Jul 2001 13:40:41 +0200 Subject: Non-Programmers (was: Changing the Division Operator) References: <mailman.996556736.30160.python-list@python.org> Message-ID: <m3k80piax2.fsf@kepler.ibp.de> Bruce Sass <bsass at freenet.edmonton.ab.ca> writes: > In this context, it comes from the CP4E motivation that people may be > called upon to script operations or interactions between their > `toys'... calling them "non-programmers" is shorter than saying, > `people who may need to program without knowing they are doing it' > (imo). We obviously need a good name. Maybe 'non-professional programmers'? Doesn't sound right. It should mean someone whose profession is something else and who has to write some code to get the work done. Something like the work of system administrators, who may have to write some code but whose programs probably will never run on other machines than those which they administrate. Perl is called a 'glue language', so should we call the work of system administrators and other 'non-programmers' as 'glue programming'? Sounds strange, but at least it is new. Any ideas? - Markus From sdm7g at Virginia.EDU Thu Jul 26 14:46:03 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Thu, 26 Jul 2001 14:46:03 -0400 (EDT) Subject: a break for comprehensions In-Reply-To: <ac677656.0107260936.2d0eb14d@posting.google.com> Message-ID: <Pine.NXT.4.21.0107261440210.419-100000@localhost.virginia.edu> >>> [ x for x in iter( iter([1,2,3,4,5,6,7,8,9]).next, 6 ) ] [1, 2, 3, 4, 5] >>> print iter.__doc__ iter(collection) -> iterator iter(callable, sentinel) -> iterator Get an iterator from an object. In the first form, the argument must supply its own iterator, or be a sequence. In the second form, the callable is called until it returns the sentinel. >>> iter(list).next gives you a callable object that sequentially returns each value -- which gets fed to the 2 arg variant of iter that takes a callable and a sentinel. When it hits the sentinal value, it stops. -- Steve Majewski From glenfant.nospam at bigfoot.com Wed Jul 25 11:46:42 2001 From: glenfant.nospam at bigfoot.com (Gilles Lenfant) Date: Wed, 25 Jul 2001 17:46:42 +0200 Subject: User authentication in SOAP References: <hOz77.41$bXi.178337792@news.telia.no> Message-ID: <9jmpb2$vmu$1@norfair.nerim.net> Hi, I don't know exactly what's the structure of the SOAP library you're using. I'm pretty familiar with Fred Lunth's xmlrpclib that has a transport layer and a XML message parsing/marshalling layer. If your SOAP library has a similar structure, you can subclass the http transport layer to provide the basic http authentication support. This is explained with source code in http://www.zope.org/Members/Amos/XML-RPC That's the way we provide B2B confidential data to our customers back-office application from a Zope server. As the SOAP library from www.secretlabs.com in structured in a same manner as their XML-RPC library (a Transport class), this should work (perhaps with few hacking). IMHO, including user credential in the SOAP message data section is not secure. Hope I helped. --Gilles "Thomas Weholt" <thomas at gatsoft.no> a ?crit dans le message news: hOz77.41$bXi.178337792 at news.telia.no... > Hi, > > Just looked at SOAPpy from ActZero and it looks just like the thing I need > for a small project. I just wondered what would be the best method of > implementing username/password-protected services in a SOAP-server? Does > SOAP define any rules for this at all or does it place that responsibility > on the server? > > Any hints appreciated. > > Thomas > > From tjreedy at home.com Tue Jul 24 12:20:42 2001 From: tjreedy at home.com (Terry Reedy) Date: Tue, 24 Jul 2001 16:20:42 GMT Subject: A way to accommodate laguage changes References: <3B5CB83B.F3B7D51@home.net> <5E877.23798$EP6.5677355@news1.rdc2.pa.home.com> <23891c90.0107240128.4715d705@posting.google.com> Message-ID: <ufh77.25352$EP6.5925441@news1.rdc2.pa.home.com> "Paul Boddie" <paul at boddie.net> wrote in message news:23891c90.0107240128.4715d705 at posting.google.com... [responding to me] ... > I assert that list comprehensions, nested scopes, generators and > type-class unification features are interesting, but not compelling > enough functionality to persuade most developers to upgrade That is an issue for each developer to decide in the context in which he works. For myself, I may jump for generators (and iterators in general). > > For the proposed division change, the 'new' meanings will be int/int > > and float//float. So write float(int)/int and floor(float/float) > > instead. Only write int//int or float/float. With the tokenizer > > module, it will then be easy to change all instances of int//int to > > int/int (old meaning). It should even even be possible to have > > package installers check sys.version and do this conversion on site as > > needed. For newly written code, the harder problem will be to not use > > any of the other neat new features, which mostly *cannot* be > > automatically back converted. > > I don't think the most significant problems raised in the currently > predominant discussion of the division operators, for example, have > anything to do with running newer code on older releases, I agree. I think the worst problem is the silent breakage of old, unmaintained code run on new releases. This is a problem specific to a semantic change such as that proposed. I wrote the above, in response to two people who raised the issue, precisely to show that running new code on old releases is a lesser problem. > "from __past__ import" anyone? ;-) I agree this would be nice, but it will not, in itself, save old code lacking this. Terry J. Reedy From mikael at isy.liu.se Mon Jul 16 03:36:34 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Mon, 16 Jul 2001 09:36:34 +0200 (MET DST) Subject: Bug in __imul__ In-Reply-To: <wzvgkwlhc1.fsf@sunshine.cs.uu.nl> Message-ID: <XFMail.20010716093616.mikael@isy.liu.se> On 13-Jul-2001 Piet van Oostrum wrote: > >>>>> Roman Suzi <rnd at onego.ru> (RS) writes: > > RS> There is a joke about americans: > > RS> they were confused that Excel give different result from > RS> pocket calculator: > > RS> [5] [+] [3] [*] [4] [=] > > RS> | 32 | > > My pocketcalculator gives 17. But then it's a Dutch one (Philips). In my experience, you can divide pocket calculators into two types based on wheather they have a button labelled '%' or not. Those that do have that button return 32, and those who do not have that button return 17. And that's regardless of the brand. It's up to you to decide from which bag you want to pick your pocket calculator. /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson <mikael at isy.liu.se> WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 16-Jul-2001 Time: 09:28:19 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From mal at lemburg.com Sat Jul 14 12:06:22 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Sat, 14 Jul 2001 18:06:22 +0200 Subject: online docs from pydoc? References: <Pine.LNX.4.30.0107141214150.10775-100000@rnd.onego.ru> Message-ID: <3B506DFE.4EA568CF@lemburg.com> Roman Suzi wrote: > > I've just explored wonderful pydoc package and > it occured to me that docs could be accessed via Web if > was specified: > > PYTHONDOCS=http://www.python.org/doc/current > > (or something like that) > > Is there any sense in it? Ping set up this web-site: http://web.pydoc.org/ I guess a link to it from python.org wouldn't be a bad idea... -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From steve at lurking.demon.co.uk Mon Jul 23 18:23:33 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Mon, 23 Jul 2001 23:23:33 +0100 Subject: A use for integer quotients References: <mailman.995866298.23496.python-list@python.org> <cpzo9veuml.fsf@cj20424-a.reston1.va.home.com> <8rdoltsi3fcph86pnkgckmiqich6d9qqng@4ax.com> <mtn15v2wiw.fsf@astron.berkeley.edu> Message-ID: <2b6plts93l46r4aip12u0veqfab01sfsau@4ax.com> On 23 Jul 2001 13:57:59 -0700, Johann Hibschman <johann at physics.berkeley.edu> wrote: >[followup accidentally mailed as well; sorry Steve!] > >Steve Horne writes: > >> Tell that to a mathematician, or an engineer, or even an accountant - >> all of these need to deal with inherently integer measures and >> therefore using integer operations. Any of these people who have >> Python scripts using division are going to have a problem. > >Well, I'll believe you for accountants, but they generally want >a fixed decimal class anyway, don't they? However... No - converting pence to pounds is just a presentation issue - all you do is draw a point. In a lot of my code you'll find a 'GUI' equivalent of... print "? " + str(amount / 100) + "." + str(amount % 100) I have *THOUSANDS* of lines like that. > >> Engineering - How would you feel if you knew a bridge was going to be >> built with 2.5 supports on each side? > >Engineers who use division almost always use floating point division. For tasks where it is appropriate yes - but those two half-supports aren't really doing much supporting, are they ;-) I use floats a lot for signal processing in C++ as a hobby, and I have worked in defence applications using C, Ada and assembler. These are all doing physics-style calculations in real time - if you can imagine the code to derive helicopter intrument data from two pressure sensors, a thermometer and a stick that tends to point into the wind, you're starting to get a vague idea. Now realise that that the pressure sensors rely on resonant frequency detection - you've got to keep them vibrating at roughly the right frequency (well into KHz range) and detect their tendency towards a higher frequency to watch for changes. All with a very slow microcontroller, a few registers, less than 1K RAM, and less ROM than a Spectrum. And *that* was *easy* compared with the direction probe and temperature sensor - the result of reducing mass production costs by having the absolute minimum hardware (the microcontroller and a few mainly passive extra components) and use easily copied software to do the job. Sorry - I forgot the bit about implementing a military standard communication protocol on dual redundant busses to pass the results on, and of course keeping an eye on the dual redundant box to detect and handle inconsistent results. I *KNOW* how programming for real engineering tasks works because I have spent quite a few years doing it. >> Mathematics - Mathemeticians practically *invented* integers, and note >> that integers were understood thousands of years before fractions, >> decimals or standard form. > >And mathematicians know you can't divide the integers, because they're >a ring and not a field. Depends on the context. A quotient and a remainder is common and simple, and the only thing that makes sense for general integers. >> Have you noticed how none of these groups consists of experienced >> programmers? > >Anyway, there are two camps. The proposed new behavior would make my >life easier, so I like it. It's also "the right thing" from a >mathematical point of view. Others clearly disagree. They are *NOT* the right thing from a mathematical point of view - integer division in mathematics gives an integer quotient and integer remainder as any five-year-old knows. If you are so keen on int <op> int -> float, why is it *ME* that has to change operators and not *YOU*. Is it really just that it makes *YOUR* life easier so sod everyone else? From bbollenbach at homenospam.com Thu Jul 5 17:32:20 2001 From: bbollenbach at homenospam.com (Brad Bollenbach) Date: Thu, 05 Jul 2001 21:32:20 GMT Subject: There's got to be an easy way to do this References: <mailman.994350130.18544.python-list@python.org> <v0517.75$hn5.63366@news1.rdc1.mb.home.com> Message-ID: <E1517.76$hn5.63447@news1.rdc1.mb.home.com> Erg...wait...I guess you meant user input, not input from a file or a database. Sorry. :) "Brad Bollenbach" <bbollenbach at homenospam.com> wrote in message news:v0517.75$hn5.63366 at news1.rdc1.mb.home.com... > Consider the underlying problem here before going any further. > > Generally speaking "data" isn't stored formatted. "Information" is data that > has /been/ formatted. In other words, your data model (whether flat file, or > database), should store phone numbers as: > > 1235554444 > > not > > (123) 555 - 4444 > > So by the sounds of it, if you have to do some trickery just to extract > _only digits_ out of a stored phone number, you might want to fix your data > model before you fix your code. > > "Lindstrom Greg - glinds" <Greg.Lindstrom at acxiom.com> wrote in message > news:mailman.994350130.18544.python-list at python.org... > > I am reading in a phone number field and would like to throw away > everything > > except the digits. Being an old C programmer, I know how I would do this. > > Even with my limited knowledge of Python, I know how I would do it: > > > > stripped_phone='' > > for c in phone_number: > > if c in digits: > > stripped_phone += c > > > > but with all of the data structure support native to Python, I'm sure > there > > is "an obvious way" to do it (perhaps it's because I'm not Dutch:-). > > > > Greg Lindstrom > > Acxiom Corporation, mail: CWY10011149 > > InfoBase Products Development office: (501) 342-1626 > > 301 Industrial Blvd, Conway, AR, 72032 fax: (501) 336-3911 > > email: Greg.Lindstrom at acxiom.com > > > > "When the solution is simple, God has spoken" > > > > Albert > Einstein > > > > > > > > From denro at earthlink.net Sat Jul 14 16:00:25 2001 From: denro at earthlink.net (Dennis Roark) Date: Sat, 14 Jul 2001 20:00:25 GMT Subject: not safe at all References: <mm8tkt4te3qnbpv3nh5nhsi591o1osln73@4ax.com> <m030ltord2kgp98mb7a397rl1bgtgar0en@4ax.com> Message-ID: <kr81ltkck185fba69ukgvn5hf1ivtosvar@4ax.com> Had no intent in starting such a burning war over the issue of typing. It does show how deeply held is the approval for Python among the newsgroup readers. I love it also, and as one of the responders said, it is "more fun" to program in Python than in other languages of my experience. But this will be an individual issue. I think we should try to keep personal insults out of what should be a discussion of ideas. I am offended by Christopher's assertion of lacking skill or not being smart enough to use dynamic typing, binding, and yes I did know what that meant before my original note. Had I not been smart enough to see the dynamic typing, then I don't think I could have made up my original example that started all this. I do know C++ (and Delphi, and VB -- ugh) much better than I know Python. I have some familiarity with LISP and small talk. I like the generics of other OO languages and the templates of C++, which is part of the reason I am not a big fan of Java. But why insult me now that I am expanding my base into Python? Dynamic typing, or binding, reference variables that can change the type pointed to, are to me still part of a weaker type safety than if they were not there. That is a personal preference, that is all. So let's hold back the ad hominem attacks and help each other progress. There is no perfect language, and all of the "good" languages have appropriate use. That includes both Python and C++. Not all programmers will ever agree what the appropriate use of a particular language should be. I understand Christian Tanzer's distinction between strong and weak typing and static verses dynamic type binding. And one of the things I and probably most C++ programmers like about C++ is that you can relax the typing by explicit casting. (The compiler should at least give warnings for implicit casts. And a cast of an instance of a user defined class is only permitted if the the class author wrote the corresponding copy constructor.) But that you must explicitly cast means that you know and can limit where you relax type safety. As far as forcing variable declarations are concerned, as to their names and types, yes it may be regarded as a "feature, not a bug" that Python does not have this. But I recall the evolution of a language that for other reasons I really do not like, Visual Basic. Originally, there was not a way to force declaration of variables. It was programmer pressure that forced MS to introduce the "option explicit" code directive which requires declaration. You can declare, and not type a variable (in which case it is a "variant") but to do so is often though to be sloppy coding. I am not standing up for VB which has too many annoying features, including inconsistent syntax, and a very broken object model. Along with the group, "Long live Python" but if someone mentions something they find weaker in Python, long live them too. --- Dennis Christopher L Spencer <clspence at one.net> wrote: >I often have to do this: >x=getsomestringfromparameterfile() >x=string(x) > > I consider this to be an advantage of Python. If you are not >skilled enough to use this feature, then I'd suggest you stick with >Pascal. > >Chris. > >On Fri, 13 Jul 2001 07:32:28 GMT, Dennis Roark <denro at earthlink.net> >wrote: > >>For amusement, run this little script which demonstrates a >>near ultimate in the lack of type safety in the language. >>(Perhaps there is a bit of type safety in that you can't do >>this: 4 + "one") But look at what you can do in the >>following script: >> >>x = 3 >>x = x + 2 >>print "x =", x >>x = "now I'm a string" >>print x >>x = [ 5, x ] >>print "and now a list:", x >> --------------------------------- Dennis Roark Dept. of Computer Science University of Sioux Falls Starting Points: http://home.earthlink.net/~denro --------------------------------- From peter at engcorp.com Sat Jul 7 10:33:32 2001 From: peter at engcorp.com (Peter Hansen) Date: Sat, 07 Jul 2001 10:33:32 -0400 Subject: Python: Database to Web Part II References: <5174eed0.0107060820.ff90805@posting.google.com> Message-ID: <3B471DBC.49A85B99@engcorp.com> Edward Wilson wrote: > > I have come to the harsh reality that 90% of the developers who use > Python are advanced developers doing mostly scientific research. I doubt that. I know of many people using Python for other purposes. In particular, I know of a group of 15 mostly junior and intermediate programmers using Python to write a variety of components, utilities, and applications used in telecommunications systems. Not research (although they do a little of that), and really scientific. I think the developers you refer to are a relatively visible minority. > I can't possibly use "EXPERIMENTAL" code in my day to > day work. If something goes wrong with my code, I lose my job, and if > it can be shown that I used experimental code downloaded from the > Internet, I could be charged with criminal negligence. I don't know what "experimental" means to you, but it seems likely that your own code could be considered more experimental than much of what you might download from the Net. I think you are right to be concerned about being fired for criminal negligence, but what could lead to that would be delivering inadequately reviewed and tested code, whether it was built on "free" stuff downloaded from the Net or on commercial software. The only advantage to commercial software is the possibility that you can divert attention away from your own incompetence (were that the case) and onto a third-party supplier which provided you the software in the first place. And yet it would still be your own negligence which led to the problem. We use a lot of code downloaded from the Net, not in life-safety situations but in mission critical ones. We have also adopted the philosophy of the Python and XP crowds, who promote the idea that testing is far more important than others traditionally believe. As long as we review and test adequately, even if we have used "experiemental" code downloaded from the net and it leads to a failure, we will not be guilty of criminal negligence. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From Klaus at pictura.de Tue Jul 10 05:51:51 2001 From: Klaus at pictura.de (Klaus Rienessl) Date: Tue, 10 Jul 2001 11:51:51 +0200 Subject: Screen-Library for text-based programs References: <mailman.994753095.11171.python-list@python.org> Message-ID: <9iej1a$vac$04$1@news.t-online.com> Sorry for my english. Do you know a library ? And where can I get this ? Klaus "Oleg Broytmann" <phd at phd.fep.ru> schrieb im Newsbeitrag news:mailman.994753095.11171.python-list at python.org... > On Tue, 10 Jul 2001, Klaus Rienessl wrote: > > I found the curses-library, but this seem to be very low-level. > > slang? newt? > > Oleg. > ---- > Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru > Programmers don't die, they just GOSUB without RETURN. > > From chrishbarker at home.net Mon Jul 9 14:53:57 2001 From: chrishbarker at home.net (Chris Barker) Date: Mon, 09 Jul 2001 11:53:57 -0700 Subject: Fixed mx.DateTime or alternative? References: <5.0.2.1.0.20010703093458.02498dc0@mail.mindspring.com> <mailman.994677322.2151.python-list@python.org> Message-ID: <3B49FDC5.296B0D92@home.net> "M.-A. Lemburg" wrote: > > >>> from mx import DateTime > > >>> dt = DateTime.now() > > >>> if dt==None: print 1 > > Side note: > > if x is None: ... > > is a possible workaround which is faster than using "==" ! I don't think this is an DateTime bug. I had the name problem with Numeric arrays, when rich comparison's were introduced: >>> from Numeric import * >>> a = array((1,2,3)) >>> a == None Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: function not supported for these types, and can't coerce to supported types >>> This worked just fine with older versions of Python. a is None works just fine, and I think is a cleaner way to code it anyway. In general, the introduction of rich comparisons means that if __eq__ is defined, special code would have to be written that handles the " == None" case. "is None" just makes more sense. -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 duncan at NOSPAMrcp.co.uk Tue Jul 10 06:45:35 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Tue, 10 Jul 2001 10:45:35 +0000 (UTC) Subject: backslash woes........ References: <3B4AC7C2.DD53F6BB@westerngeco.com> <Xns90DA74BD3B968duncanrcpcouk@127.0.0.1> Message-ID: <Xns90DA75C5FEBC9duncanrcpcouk@127.0.0.1> "Duncan Booth" <duncan at NOSPAMrcp.co.uk> wrote in news:Xns90DA74BD3B968duncanrcpcouk at 127.0.0.1: > Martin Franklin <martin.franklin at westerngeco.com> wrote in > news:3B4AC7C2.DD53F6BB at westerngeco.com: > >> I am having trouble with windows path names (i'm a UNIX'ite) Another useful tip to remember is that except for the DOS command prompt, and some badly behaved applications, Windows actually supports both forward slash and backslash as path separators. So in a Python program (or most other languages) you can use forward slashes anywhere you want to write a pathname. -- 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 eli-wallach at ugly.com Sun Jul 1 11:37:35 2001 From: eli-wallach at ugly.com (Mexican Bandit) Date: Sun, 01 Jul 2001 15:37:35 GMT Subject: Python cgi script - outputting images Message-ID: <pjgujtkkdihrjfelc5qo0acabavvuu5mvo@4ax.com> Hi, Wondering of anyone can help - Python newbie. I'm trying to write a Python cgi script which outputs a gif or jpg image from another server... ---- import urllib print "Content-Type: image/jpeg" print image = urllib.urlopen("http://127.0.0.1/splogo.jpg") print image.read() ---- The output of the image is corrupted. I suspect this is to do with 'print' turning everything into strings? How do I output raw image data? From sholden at holdenweb.com Mon Jul 2 10:57:23 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 2 Jul 2001 10:57:23 -0400 Subject: how do I get modules to stop eating memory References: <6f78b8b.0107020626.38939858@posting.google.com> Message-ID: <UW%%6.20433$he.1019955@e420r-atl1.usenetserver.com> "Charles Harrison" <speedy911 at mindspring.com> wrote in message news:6f78b8b.0107020626.38939858 at posting.google.com... > I posted a message about a week ago asking about deleting modules from > memory. I got several replies with things that should work, but they > didn't. Here's the scenario that I've been trying: > > - open the python shell and import sys and any other module > > Python 1.5.2 (#1, Aug 25 2000, 09:33:37) [GCC 2.96 20000731 > (experimental)] on linux-i386 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> import sys > >>> import BaseHTTPServer > > - I also run 'top' when im doing this to monitor the memory that > python is using. The 2112 is the memory used after importing the 2 > modules. > > 22738 charriso 0 0 2112 2112 1380 S 0.0 1.6 0:00 python > > - Now I do what should unload the module 'BaseHTTPServer' and free the > memory. > > >>> del BaseHTTPServer > >>> del sys.modules['BaseHTTPServer'] > > - And now top says that the memory usage is now 2120. > > 22738 charriso 0 0 2120 2120 1384 S 0.0 1.6 0:00 python > > - Prior to importing BaseHTTPServer the memory usage was 1432. > Shouldn't Python's memory usage have gone down to that number, or at > least down some? While its usage might have gone down, this doesn't necessarily mean the amount it's claiming from the operating system will have. Different implementations have different strategies. a) Even when you've deleted the module, that doesn't mean the garbage collector has run and collected the used memory; and b) Even after the GC collects it, you need to be sure that it will return memory to the OS for your working set used memory size to go down. regards Steve -- http://www.holdenweb.com/ From hsl at tcp.co.uk Tue Jul 10 02:02:17 2001 From: hsl at tcp.co.uk (Martin Rand) Date: Tue, 10 Jul 2001 07:02:17 +0100 Subject: BASIC or Python? References: <3d157fa0.0107051904.7ec368b8@posting.google.com> <slrn9kcfuq.2b7g.kamikaze@kuoi.asui.uidaho.edu> <0t_17.14670$Fk7.131382@news.indigo.ie> <slrn9kkgfp.dj6.kamikaze@kuoi.asui.uidaho.edu> <uBt27.15141$Fk7.136713@news.indigo.ie> Message-ID: <ba6lkt8edqanl9lak7grfsl45gjit88kc8@4ax.com> On Tue, 10 Jul 2001 02:17:31 GMT, gerryq at indigo.ie (Gerry Quinn) wrote: [snip] >In case anyone is fooled, here's an example from the tutorial at >www.python.org, which also has a FAQ on what Python is for: > >>>> for n in range(2, 10): >.. for x in range(2, n): >.. if n % x == 0: >.. print n, 'equals', x, '*', n/x >.. break >.. else: >.. print n, 'is a prime number' >.. > >Now some people may very well find that lovable, but I certainly don't. >Note how the clever language design means that the 'else' must be >level-indented with the 'for'. No doubt longer programs are even more >fun. The FAQ on increasing speed helpfully notes that function calls >are expensive... > Gerry, I only just bumbled into this thread; forgive me if I'm pointing out the obvious. Where would you choose to indent the 'else:' if you had a choice? Presumably you're aware that levelling it with the 'if' would have a different effect? Or were you objecting to the fact that Python has a 'for:' 'else:' construct in the first place? -- Martin Rand Highfield Software Ltd mwr at highfield-software.co.uk Phone: +44 (0)23 8025 2445 Fax: +44 (0)23 8025 2445 From aleaxit at yahoo.com Wed Jul 4 09:08:15 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 4 Jul 2001 15:08:15 +0200 Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> <9hrj3q$cj1@news1.gtech.com> <bebbba07.0107031040.593143f8@posting.google.com> <20010704013238.2DC8A00.NOFFLE@niccolo.ke4.de> <Xns90D489E9982B4duncanrcpcouk@127.0.0.1> Message-ID: <9hv4g101u04@enews1.newsguy.com> "Duncan Booth" <duncan at NOSPAMrcp.co.uk> wrote in message news:Xns90D489E9982B4duncanrcpcouk at 127.0.0.1... ... > Please tell me you don't do air traffic control for a living. I think I'll walk, thanks, it does look like a fine day. (I suspect this guy must be guilty only of even-more-deadpan and impenetrable humor than I sometimes perpetrate -- this just *can't* be for real). Alex From rnd at onego.ru Wed Jul 18 12:42:48 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 18 Jul 2001 20:42:48 +0400 (MSD) Subject: PEP: Defining Python Source Code Encodings In-Reply-To: <3B55907B.206DE96D@lemburg.com> Message-ID: <Pine.LNX.4.30.0107182023270.1370-100000@rnd.onego.ru> On Wed, 18 Jul 2001, M.-A. Lemburg wrote: >Roman Suzi wrote: >> On Tue, 17 Jul 2001, M.-A. Lemburg wrote: >> >> Nope. There must be no encode-decode back. Or it will slow down >> starting Python _scripts_ unnecessary. >> >> That is why I suggested "unknown" encoding - a safe default >> for those who do not want any back-and-force recodings. > >If you want to avoid having to decode and the reencode data >in ther parser, we would have to live with two sets of parsers >in Python -- one for Unicode and one for 8-bit data. No. I think there could be bypass, which will not affect the parser logic too much. >I don't think that anyone would like to maintain those two >sets, so it's basically either go all the way or not move >at all. > >> There clearly must be the way to prevent encode-decode. And it would be >> better if only EXPLICITLY given encoding will trigger encode-decode >> mechanism. > >That's not true: Python caches byte-code compiled versions of >scripts in .pyc|o files. So the performance problem is really not >all that important. I've just made a simple program called myf.py and made .pyo and .pyc then run strace -f to see which files it opens (tries to open). It doesn't touch .pyc or .pyo for sure: 2229 open("/etc/ld.so.preload", O_RDONLY) 2229 open("/etc/ld.so.cache", O_RDONLY) 2229 open("/lib/libdl.so.2", O_RDONLY) 2229 open("/lib/libpthread.so.0", O_RDONLY) 2229 open("/lib/libm.so.6", O_RDONLY) 2229 open("/lib/libc.so.6", O_RDONLY) 2229 open("myf.py", O_RDONLY) 2229 open("/usr/lib/python1.5/exceptions.so", O_RDONLY) 2229 open("/usr/lib/python1.5/exceptionsmodule.so", O_RDONLY) 2229 open("/usr/lib/python1.5/exceptions.py", O_RDONLY) 2229 open("/usr/lib/python1.5/exceptions.pyc", O_RDONLY) 2229 open("/usr/lib/python1.5/site.so", O_RDONLY) 2229 open("/usr/lib/python1.5/sitemodule.so", O_RDONLY) 2229 open("/usr/lib/python1.5/site.py", O_RDONLY) 2229 open("/usr/lib/python1.5/site.pyc", O_RDONLY) 2229 open("/usr/lib/python1.5/os.so", O_RDONLY) 2229 open("/usr/lib/python1.5/osmodule.so", O_RDONLY) 2229 open("/usr/lib/python1.5/os.py", O_RDONLY) 2229 open("/usr/lib/python1.5/os.pyc", O_RDONLY) 2229 open("/usr/lib/python1.5/posixpath.so", O_RDONLY) 2229 open("/usr/lib/python1.5/posixpathmodule.so", O_RDONLY) 2229 open("/usr/lib/python1.5/posixpath.py", O_RDONLY) 2229 open("/usr/lib/python1.5/posixpath.pyc", O_RDONLY) 2229 open("/usr/lib/python1.5/stat.so", O_RDONLY) 2229 open("/usr/lib/python1.5/statmodule.so", O_RDONLY) 2229 open("/usr/lib/python1.5/stat.py", O_RDONLY) 2229 open("/usr/lib/python1.5/stat.pyc", O_RDONLY) 2229 open("/usr/lib/python1.5/UserDict.so", O_RDONLY) 2229 open("/usr/lib/python1.5/UserDictmodule.so", O_RDONLY) 2229 open("/usr/lib/python1.5/UserDict.py", O_RDONLY) 2229 open("/usr/lib/python1.5/UserDict.pyc", O_RDONLY) 2229 open("/dev/null", O_RDONLY|O_NONBLOCK|O_DIRECTORY) 2229 open("/usr/lib/python1.5/site-packages", O_RDONLY|O_NONBLOCK|O_DIRECTORY) 2229 open("/usr/lib/python1.5/site-packages/NumPy.pth", O_RDONLY) 2229 open("/usr/lib/python1.5/site-packages/PIL.pth", O_RDONLY) 2229 open("/usr/lib/python1.5/site-packages/RNG.pth", O_RDONLY) 2229 open("/usr/lib/python1.5/sitecustomize.so", O_RDONLY) 2229 open("/usr/lib/python1.5/sitecustomizemodule.so", O_RDONLY) 2229 open("/usr/lib/python1.5/sitecustomize.py", O_RDONLY) 2229 open("/usr/lib/python1.5/sitecustomize.pyc", O_RDONLY) 2229 open("/usr/lib/python1.5/plat-linux-i386/sitecustomize.so", O_RDONLY) 2229 open("/usr/lib/python1.5/plat-linux-i386/sitecustomizemodule.so", O_RDONLY) 2229 open("/usr/lib/python1.5/plat-linux-i386/sitecustomize.py", O_RDONLY) 2229 open("/usr/lib/python1.5/plat-linux-i386/sitecustomize.pyc", O_RDONLY) 2229 open("/usr/lib/python1.5/lib-tk/sitecustomize.so", O_RDONLY) 2229 open("/usr/lib/python1.5/lib-tk/sitecustomizemodule.so", O_RDONLY) 2229 open("/usr/lib/python1.5/lib-tk/sitecustomize.py", O_RDONLY) 2229 open("/usr/lib/python1.5/lib-tk/sitecustomize.pyc", O_RDONLY) 2229 open("/usr/lib/python1.5/lib-dynload/sitecustomize.so", O_RDONLY) 2229 open("/usr/lib/python1.5/lib-dynload/sitecustomizemodule.so", O_RDONLY) 2229 open("/usr/lib/python1.5/lib-dynload/sitecustomize.py", O_RDONLY) 2229 open("/usr/lib/python1.5/lib-dynload/sitecustomize.pyc", O_RDONLY) 2229 open("/usr/lib/python1.5/site-packages/sitecustomize.so", O_RDONLY) 2229 open("/usr/lib/python1.5/site-packages/sitecustomizemodule.so", O_RDONLY) 2229 open("/usr/lib/python1.5/site-packages/sitecustomize.py", O_RDONLY) 2229 open("/usr/lib/python1.5/site-packages/sitecustomize.pyc", O_RDONLY) 2229 open("/usr/lib/python1.5/site-packages/NumPy/sitecustomize.so", O_RDONLY) 2229 open("/usr/lib/python1.5/site-packages/NumPy/sitecustomizemodule.so", O_RDONLY) 2229 open("/usr/lib/python1.5/site-packages/NumPy/sitecustomize.py", O_RDONLY) 2229 open("/usr/lib/python1.5/site-packages/NumPy/sitecustomize.pyc", O_RDONLY) 2229 open("/usr/lib/python1.5/site-packages/PIL/sitecustomize.so", O_RDONLY) 2229 open("/usr/lib/python1.5/site-packages/PIL/sitecustomizemodule.so", O_RDONLY) 2229 open("/usr/lib/python1.5/site-packages/PIL/sitecustomize.py", O_RDONLY) 2229 open("/usr/lib/python1.5/site-packages/PIL/sitecustomize.pyc", O_RDONLY) 2229 open("/usr/lib/python1.5/site-packages/RNG/sitecustomize.so", O_RDONLY) 2229 open("/usr/lib/python1.5/site-packages/RNG/sitecustomizemodule.so", O_RDONLY) 2229 open("/usr/lib/python1.5/site-packages/RNG/sitecustomize.py", O_RDONLY) 2229 open("/usr/lib/python1.5/site-packages/RNG/sitecustomize.pyc", O_RDONLY) So, I argue that a script myf.py is not cached in compiled for anywhere and is recompiled each time! >> ...and efficiency reasons too. re was slowed down significantly by adding >> Unicode support. > >I seriously doubt that. Fredrik (who wrote the sre engine) is an >optimization genius and in some cases even made the sre engine >faster than the string module implementations of e.g. find(). Well, u2 is no different from ASCII+latin1 for modern computers as they have 32 bit words... >> > > > To make this backwards compatible, the implementation would have to >> > > > assume Latin-1 as the original file encoding if not given (otherwise, >> > > > binary data currently stored in 8-bit strings wouldn't make the >> > > > roundtrip). >> > > ...as I said, there must be no assumed charset. Things must >> > > be left as is now when no explicit encoding given. >> > This is what the Latin-1 encoding assures. >> I still think something like "raw" is needed... >Latin-1 gives you this "raw" feature. I still can't get Netscape to print in cyrillic because it assumes that it's buttons and fonts are latin1! Sometimes assumptions are going to far to be allowed in the first place! >> > We've been discussing these on python-dev, but Guido is not >> > too keen on having them. >> >> And this is right. I even think encoding information could be EXTERNAL. > >No -- how are editors supposed to know about these external >files ? OK. But how do they know about encoding of the 8-bit documents? Documents have tags to show encoding. Then Python program must become a document with all those tags here and there. How do other languages solve this "problem"? >> > > > Comments are welcome ! >> > Thanks for your comments, >> I just hope the realisation of your PEP will not make Python scripts >> running slower ;-) while allowing truly useful i18n functionality. > >By the time the PEP will be implemented, CPUs will run at least 50% >faster than they do now -- this should answer your question ;-) Nope. This is extensive way of bloated programs (like W2K) hoping to increase Intel sells of CPUs. If computers were always so speedy as now, we all were using bubble sort. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Wednesday, July 18, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Hard work never killed anyone, but why chance it?" _/ From lisowski.tomasz at sssa.NOSPAM.com.pl Thu Jul 12 03:32:45 2001 From: lisowski.tomasz at sssa.NOSPAM.com.pl (Tomasz Lisowski) Date: Thu, 12 Jul 2001 09:32:45 +0200 Subject: catch empty sys.argv References: <3b4d491b.56611422@news.isis.de> Message-ID: <9ijjlc$gqt$1@news.tpi.pl> U?ytkownik "pedro" <pedro at athlet.de> napisa? w wiadomo?ci news:3b4d491b.56611422 at news.isis.de... > hi, > > my scripts gets a variable from .sys.argv[1] (a filename). when the > filename is not entered the scripts is completely useless, so i > thought i'd do a basic check like: > > if sys.argv[1] == '' > exit('enter something, stupid') Why don't you first check the length of the sys.argv list? Example: nArgs = len(sys.argv) if n == 0: exit('enter something, stupid') or alternatively, define a function: def arg(n): try: res = sys.argv[n] except IndexError: res = "" return res and use it: if arg(1) == '' exit('enter something, stupid') Tomasz Lisowski From kj7ny at email.com Wed Jul 25 00:38:55 2001 From: kj7ny at email.com (Robert Roberts) Date: Wed, 25 Jul 2001 04:38:55 GMT Subject: Python for Palm OS Message-ID: <20010725.4442652@mis.configured.host> I have heard several times that there is a version of Python for the palm os. Have palm version 3.5. Can anyone direct to the proper download? Thanks in advance. From tom-list at home.com Fri Jul 6 18:52:38 2001 From: tom-list at home.com (Tom) Date: Fri, 6 Jul 2001 18:52:38 -0400 Subject: the C++ Standard Library for Python References: <hin17.110546$Mf5.30282205@news3.rdc1.on.home.com> <QIo17.427166$eK2.86457968@news4.rdc1.on.home.com> Message-ID: <3b4640b4_4@Usenet.com> "Nick Perkins" <nperkins7 at home.com> wrote in message news:QIo17.427166$eK2.86457968 at news4.rdc1.on.home.com... > First impression: > Very cool!, especially the fact that it seems to play well with python > iterators. > (I just need Python 2.2 to take full advantage..) > It took me about 30 seconds to install and start using it! > I will definitely be checking this out further. > ( the website is also excellent ) > good work! Thanks. I too am looking forward to Python iterators. They will make it possible for me to get the STL algorithms working with Python mappings. Actually, it is possible now, but it wouldn't be efficient. Tom. > "Tom" <tom-list at home.com> wrote in message > news:hin17.110546$Mf5.30282205 at news3.rdc1.on.home.com... > > > > The core of the C++ Standard Library is now available for Python. This > > includes 4 sequence containers, 8 mapping containers, and approximately 60 > > algorithms. The algorithms can be applied to any of these containers, or > to > > any of the Python built-in sequences. > > > > This is an actual C++ standard library, exposed to Python, not a Python > > implementation of it - so it is all native code. > > > > It is being release under a standard Python style license. > > > > Please note that this is a beta release. > > > > http://www.malcolmson.com/pystl > > > > I'll watch this thread for comments and feedback (thanks in advance). > > > > > > > > > > Posted Via Usenet.com Premium Usenet Newsgroup Services ---------------------------------------------------------- ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY ** ---------------------------------------------------------- http://www.usenet.com From peter at engcorp.com Sat Jul 7 09:58:28 2001 From: peter at engcorp.com (Peter Hansen) Date: Sat, 07 Jul 2001 09:58:28 -0400 Subject: compile() question: SyntaxError: unexpected EOF while parsing Message-ID: <3B471584.3686D0E@engcorp.com> While examining the core of medusa's monitor.py, we've encountered a situation that looks on the face of it like an undesirable limitation or inconsistency of the Python compiler. (I fully expect to hear an explanation for why this is actually a Good Thing, but we haven't figured it out ourselves yet.) We expected the following two sequences to produce the same exception, but they do not. >>> good = 'if 1:' >>> compile(good, '', 'exec') Traceback (most recent call last): File "<stdin>", line 1, in ? File "<string>", line 1 if 1: ^ SyntaxError: unexpected EOF while parsing >>> bad = 'if 1:\n print 1\nelse:' >>> compile(bad, '', 'exec') Traceback (most recent call last): File "<stdin>", line 1, in ? File "<string>", line 3 else: ^ IndentationError: expected an indented block Medusa's monitor.py uses the "unexpected EOF while parsing" feature to infer that additional lines of text are going to be entered by the user (to satisfy the expected indented block for the "if"). This is how it knows when to deliver another "..." prompt and when to cancel entry of data and deliver a real exception. Unfortunately this means when it or any code which tries to use the same technique encounters the beginning of the "else:" block, it terminates with the second exception. (A workaround appears to be to precede everything with a dummy "if 1:" block, but I'm trying to learn why the built-in compile() doesn't consistently produce the "unexpected EOF while parsing" message in the second case.) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From bokr at accessone.com Mon Jul 30 12:30:06 2001 From: bokr at accessone.com (Bengt Richter) Date: Mon, 30 Jul 2001 16:30:06 GMT Subject: Language change and code breaks References: <mailman.995378792.16515.python-list@python.org> <cpvgkq1f2b.fsf@cj20424-a.reston1.va.home.com> <ud76rn4p8.fsf@cs.uu.nl> <3B5D88B1.774A4D70@Bibliothek.Uni-Augsburg.de> <wzhew2gm27.fsf@sunshine.cs.uu.nl> <3B601CBE.627D3D22@Bibliothek.Uni-Augsburg.de> <9jpbi8$32v$1@samos.cs.uu.nl> <3b61c8f0.577829094@wa.news.verio.net> <3B64E9D5.82A7B3E9@cosc.canterbury.ac.nz> Message-ID: <3b658707.823099644@wa.news.verio.net> On Mon, 30 Jul 2001 17:00:05 +1200, Greg Ewing <greg at cosc.canterbury.ac.nz> wrote: >Bengt Richter wrote: >> >> You may know the significance of fgjqkw then ;-) Well, if you know, you would probably also recognize the qk transposition typo :-( That should be fgjkqw >> If not, google for it. > Sorry. Dang! googles to http://www.fi.muni.cz/usr/jkucera/p109/p109sl4.htm In the page, search for 'f g j' with spaces. Interesting that google found that even with spaces in between. Your browser's search probably won't though, so search for 'f g j' (that's enough). Even though I don't read cz, it's not hard to tell ;-) >Burning with curiosity, I just tried that, but >didn't get anything. > From guido at zope.com Sun Jul 29 13:08:03 2001 From: guido at zope.com (Guido van Rossum) Date: Sun, 29 Jul 2001 13:08:03 -0400 Subject: FEEDBACK WANTED: Type/class unification In-Reply-To: Your message of "Sun, 29 Jul 2001 09:39:52 PDT." <3B643C58.1C6C94F9@ActiveState.com> References: <cp66cd12yp.fsf@cj20424-a.reston1.va.home.com> <mailman.996351001.12473.python-list@python.org> <cpwv4syrzd.fsf@cj20424-a.reston1.va.home.com> <3B643C58.1C6C94F9@ActiveState.com> Message-ID: <200107291708.NAA07525@cj20424-a.reston1.va.home.com> > > Same as currently if it's a class: look in inst.__dict__ for instance > > vars, then look in inst.__class__ for methods and class vars, then > > recursively look through int.__class__.__bases__ for inherited methods > > and class vars. Weed out duplicates. > > Is there any reason that this is not defined as a built-in function? I > propose a function called attrs(). Yes, it's a lot less useful than you seem to think. If you are interested in documentation, it's better to use something like pydoc which gives much more details. Right now, pydoc doesn't understand the new types yet, but eventually, before 2.2 final, pydoc (or more likely inspect.py) will be able to introspect according to PEP 252. > >... > > > 2. If I have an object that hides its attributes behind an __getattr__, > > > is there any way to tweak the list returned by the API described above? > > You didn't answer this one. If I'm wrapping a COM object and I want to > dynamically provide the list of methods and other attributes when some > asks (i.e. "override" dir() or attrs()). I thought I answered it by saying "you can't do that". But now that you've given more information, I understand your question better. I think you should be able to override the __dict__ attr of the type and put pseudo descriptors in there (see PEP 252 for the descriptor API). > > .... I'd like something as close to > > > this as is realistically possible: > > > > > > def attrs(x): > > > return [y for y in all_possible_strings if hasattr(x, y)] > > > > (Note: this may return an infinite list!) > > Right, that's why I'm asking for something as *close as realistically > possible*. i.e. a built-in function that gets me the attributes list. > > 99% of the time when I use dir(), I wish it behaved as I described > attrs() and I just have to work around its limitations. I would like for > there to be a function that returns as many attributes as is > realistically possible. Hm, I'd like you to tell me more about how you use dir(). I find getting the entire list of attributes overwhelming. --Guido van Rossum (home page: http://www.python.org/~guido/) From db3l at fitlinxx.com Wed Jul 11 15:46:11 2001 From: db3l at fitlinxx.com (David Bolen) Date: 11 Jul 2001 15:46:11 -0400 Subject: Newbie asks(2): How to do this line of C in Py? References: <tkmfvla7npuqfd@news.supernews.com> <uzoaci9zw.fsf@ctwd0143.fitlinxx.com> <7s9oktcv5vll2hberldlt51mcdg5qnitke@4ax.com> Message-ID: <usng3ckqk.fsf@ctwd0143.fitlinxx.com> Joe Potter <jm7potter at hotmail.com> writes: > I have followed these questions with great interest. I hope he keeps > asking for a while --- and folks here keep answering. > > As a newbie to Python, I find that the one liners in c are easy to > follow and the translation into Python show me where I am missing > Python techniques. There is, however, a risk in this technique as a single line translation from another language to Python is often a bit too fine grained to really serve as a good guide for translation, especially from a language such as C. The two languages do not necessarily provide the same functionality per line of code so you risk force fitting the translation since you don't have any surrounding context. In these cases so far, it's largely been translating a C library call into Python library calls so the one-to-one holds better than usual, but I do think that even newbies will be able to get a better grasp of the concepts with slightly larger code snippets. E.g., what you use strtok or sscanf in a C program for, you might attack quite differently in a Python program, even if direct translations of strtok and sscanf exist. (Then again, you might use the direct translation, but making that choice is assisted by more original context). Note I'm certainly not proposing that such requests not be answered, nor that they can't be helpful, but only that I think more benefit could be gained (by the original poster as well as other readers) with some addition information and/or sample code in the translation requests. But c.l.p is certainly one of the best communities in which I've participated in this regard - we'll answer just about anything as well as possible (even while suggesting better ways to phrase the questions :-)) -- -- 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 Mark.Tobin at attcanada.com Fri Jul 13 13:26:44 2001 From: Mark.Tobin at attcanada.com (Tobin, Mark) Date: Fri, 13 Jul 2001 11:26:44 -0600 Subject: FW: Newbie list question Message-ID: <3D7C088D6CCFD31190A5009027D30E9103391050@torex004.attcanada.ca> Whoops wrong list... Mark -----Original Message----- From: Tobin, Mark Sent: Friday, July 13, 2001 1:22 PM To: 'Joshua Marshall'; 'Matthew.alton at anheuser-busch.com'; 'tutor at python.org' Subject: RE: Newbie list question Does: foo += 'c' act like an append then? I always assumed it was the same as: foo = foo + 'c' which obviously should raise a TypeError. Here however it works, in that it appends 'c' to the object to which foo refers and thus to the object to which bar refers... Mark -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Joshua Marshall Sent: Friday, July 13, 2001 12:52 PM To: python-list at python.org Subject: Re: Newbie list question Matthew Alton <Matthew.Alton at anheuser-busch.com> wrote: ... >>>> foo = ['a', 'b', 'c'] # We have a list named 'foo.' Excellent. >>>> bar = foo # bar points to foo. Or does it? bar points to the same object that foo points to. It's not the case that bar is an alias for foo. >>>> baz = foo[:] # baz is a copy of foo. For clarity, it might be better to say baz points to a copy of the list which foo points to. >>>> foo > ['a', 'b', 'c'] >>>> bar > ['a', 'b', 'c'] >>>> baz > ['a', 'b', 'c'] # So far, so good. >>>> del foo[2] # Get rid of 'c' in foo and, therefore in > bar (?) >>>> foo > ['a', 'b'] # 'c' is gone from foo... >>>> bar > ['a', 'b'] # ... and also from bar, as expected. >>>> baz > ['a', 'b', 'c'] # baz, the copy, is unaffected. Also as > expected. >>>> foo = foo + ['c'] # Add 'c' back to foo. Here, the variable foo is rebound to a new list. The previous list (which bar still points to) is unaffected. If you had done "foo.append('c')" instead of "foo = foo + ['c']", than a 'c' would be appended to the list object that foo and bar both still refer to. -- http://mail.python.org/mailman/listinfo/python-list From tjreedy at home.com Fri Jul 27 11:11:38 2001 From: tjreedy at home.com (Terry Reedy) Date: Fri, 27 Jul 2001 15:11:38 GMT Subject: Is this an Intended behaviour of __getattr__? References: <uu787.103805$ph7.16107665@news.hananet.net> <OR887.104175$ph7.16309267@news.hananet.net> Message-ID: <Kwf87.34061$EP6.8716280@news1.rdc2.pa.home.com> "Grace" <nospam at nospam.com> wrote in message news:OR887.104175$ph7.16309267 at news.hananet.net... > I think when __repr__ and __str__ are called internally via the interpreter > as in the print statement, it passes through the __getattr__ method of Node > class while all exceptions are simply ignored. Correct. Overriding default print formatting is optional. When 'print' found neither __str__ nor __repr__ , it went ahead with the default: <__main__.Node instance at 0081608C> Terry J. Reedy From tjreedy at home.com Tue Jul 24 20:29:02 2001 From: tjreedy at home.com (Terry Reedy) Date: Wed, 25 Jul 2001 00:29:02 GMT Subject: PEP0238 lament References: <mailman.995839419.19134.python-list@python.org> <cEN67.17775$EP6.4652917@news1.rdc2.pa.home.com> <cp3d7ngazy.fsf@cj20424-a.reston1.va.home.com> <dzZ67.20235$EP6.5031096@news1.rdc2.pa.home.com> <cpr8v6ow8o.fsf@cj20424-a.reston1.va.home.com> Message-ID: <ipo77.25812$EP6.6287154@news1.rdc2.pa.home.com> "Guido van Rossum" <guido at python.org> wrote in message news:cpr8v6ow8o.fsf at cj20424-a.reston1.va.home.com... > "Terry Reedy" <tjreedy at home.com> [quoting from PEP0238, after Guido questioned my '2 years' paraphrase] > > The warning will be off by default in the 2.2 release, and on by > > default for in the next Python release, and will stay in effect > > for 24 months. > Touche. I couldn't find that passage in the PEP, and had even gone to > the trouble of searching for "year"... :-( > > --Guido van Rossum (home page: http://www.python.org/~guido/) How funny. I had just read PEP 5 which proffers a minimum of 1 year, so I automatically divided by 12 to compare, never dreaming that I would mislead someone into searching for '2 years' instead of '24 months'. Terry J. Reedy From Dominikus.Herzberg at eed.ericsson.se Wed Jul 25 03:07:09 2001 From: Dominikus.Herzberg at eed.ericsson.se (Dominikus.Herzberg at eed.ericsson.se) Date: Wed, 25 Jul 2001 09:07:09 +0200 Subject: How does Metaprogramming work? Message-ID: <3B5E701D.3A87AE45@eed.ericsson.se> Hi, I'm doing some metaprogramming -- the code works fine but I still don't precisely get how metaprogramming works internally. The usual pattern for defining a "MetaClass" is e.g. class InterfaceMetaClass: def __init__(self,name,bases,dict): self.__name__ = name self.__bases__ = bases self.__dict = dict # We can't use __dict__ here! The next step is instantiating this class object ... InterfaceType = InterfaceMetaClass("InterfaceType",(),{}) ... and to use this class instance as a base class within a class definition. The idea is to regard the "base class" InterfaceType as the type of the class object, e.g. class Port(InterfaceType): pass The fun part is that >>> type(Port) results in <type 'instance'> Why? I understand that class definitions are an executable statement in python. As soon as python passes the class definition Port, python first evaluates the inheritance list, here InterfaceType, which should evaluate to a class object. In this case, it evaluates to a class instance instead! This is clearly the point of where the magic begins ... but how does it continue. Why does Port finally evaluate to a class instance but having typical properties of a class object like __dict__ or __bases__? What does Port make this sort of a hybrid thing? Comments are appreciated! Thanks a lot, Dominikus From sholden at holdenweb.com Fri Jul 20 13:32:20 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 20 Jul 2001 13:32:20 -0400 Subject: The unPEP: List-Tuple Unification References: <3B586A1E.B037349D@javanet.com> Message-ID: <aTZ57.5911$qh7.379822@e420r-atl2.usenetserver.com> "Raymond Hettinger" <othello at javanet.com> wrote in message news:3B586A1E.B037349D at javanet.com... > It looks like types and classes are heading toward unification in 2.2a (oh yeah). > Now, I want to offer an idea that is sure to attract a few flames: > > 1. Give lists an assignable property called 'immutable' which defaults to zero. > 2. If the property gets set to one (i.e. mylist.immutable=1), then the list > disables future assignments. For example, mylist[3]='three' generates: > TypeError: object doesn't support item assignment > 3. Immutable lists can never be converted back to mutable. For example, > mylist.immutable=0 generates: > TypeError: immutable objects cannot be changed > 4. Immutable lists can be copied to mutable lists just like tuples can. For > example, mynewlist=list(mylist) makes a new mutable list. > 5. If a list is used as a dictionary key, then the immutable property > gets set to one automatically. > 6. Deprecate tuples. Simplify the tutorials. Get on with life. > > Hiding behind asbestos, > No asbestos required, but what's tha advantage over mylist = tuple(mylist) just-wonderingl-ly y'rs - steve -- http://www.holdenweb.com/ From sholden at holdenweb.com Tue Jul 31 23:13:51 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 31 Jul 2001 23:13:51 -0400 Subject: smtp authorization...how to? References: <3b675617.48549445@news.mailops.com> Message-ID: <orK97.8357$9i1.755330@e420r-atl1.usenetserver.com> "chajadan" <me at charliedaniels.com-1.net> wrote in message news:3b675617.48549445 at news.mailops.com... > I started pokin' around in the smtplib and tried sending an e-mail. > > My smtp server requires a username and password, yet there is no > method for either of these. That I saw. > > Is there an available module that incorporates these, or a simple way > to extend smtplib? > > Any pointers would be great. > The smtplib library just implements RFC821, I believe. Various extensions to the protocol have been implemented in various mailers, and if your ISP is standards-friendly they will be using something RFC2554-compliant. There's a little more information in http://www.ravenbrook.com/project/p4dti/issue/job000197/ but this is essentially a bug report, so there are no fixes there. One other possibility: some ISPs will authenticate your connection for sending if you use POP3 first, since POP *is* and authenticated protocol. You might try that. Sorry the news isn't better ... someone may have a patched smtplib you can use. regards Steve -- www.holdenweb.com From aleaxit at yahoo.com Wed Jul 11 11:46:14 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 11 Jul 2001 17:46:14 +0200 Subject: A modest proposal (was: Comment on PEP-0238) References: <mailman.994769237.24585.python-list@python.org> <cpr8vnh6ln.fsf@cj20424-a.reston1.va.home.com> Message-ID: <9ihse1011n3@enews4.newsguy.com> "Guido van Rossum" <guido at python.org> wrote in message news:cpr8vnh6ln.fsf at cj20424-a.reston1.va.home.com... > "Arthur Siegel" <ajs at ix.netcom.com> writes: > > > But it is Guido's language and Guido's call. Just wish it was > > all just left to his own sense of design elegance, which there > > is reason to trust - rather his public justifications, which I > > never find very satisfactory. > > Good point, Art. I trust my intuition more than my reasoning in these > things, and often when I try to defend my intuition against > challenges, what comes out are unsatisfactory rationalizations. > Sometimes Tim's "channelings" say it better than I could have said it > myself... :-) Being a great designer (or other kind of decision-maker) and being a good rationalizer/evangelist/salesperson/marketeer are really separate skills, and pretty much uncorrelated ones to boot. People in general just won't accept that, which of course suits us good rationalizers just fine (as we often get credited for better decisions than we actually make, just because we rationalize better than others do:-). Alex From gregj at pdxperts.com Sun Jul 8 18:40:47 2001 From: gregj at pdxperts.com (Greg Jorgensen) Date: Sun, 08 Jul 2001 22:40:47 GMT Subject: readline()/readlines() inconsistent? References: <3B482C44.6E6EB163@snakefarm.org> Message-ID: <Pj527.318558$p33.6392630@news1.sttls1.wa.home.com> "Carsten Gaebler" <clpy at snakefarm.org> wrote in message news:3B482C44.6E6EB163 at snakefarm.org... > I've just come across a strange difference between readline() and > readlines(): > > Python 2.1 (#17, Jun 15 2001, 15:24:30) > [GCC 2.95.2 19991024 (release)] on linux2 > Type "copyright", "credits" or "license" for more information. > >>> f = open("foobar", "w") > >>> f.readline() > '' > >>> f.close() > >>> > >>> f = open("foobar", "w") > >>> f.readlines() > Traceback (most recent call last): > File "<stdin>", line 1, in ? > IOError: [Errno 9] Bad file descriptor > >>> > > > Why does readlines() raise an exception while readline() does not? I > expected it to return an empty list. According to the docs readlines() > uses readline(). If I open the file "w+" everything's fine. Opinions? The same thing happens on Windows 2000 with Python 2.1. And xreadlines gives the same error. Greg Jorgensen PDXperts LLC Portland, Oregon, USA gregj at pdxperts.com From bsass at freenet.edmonton.ab.ca Thu Jul 12 20:26:21 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Thu, 12 Jul 2001 18:26:21 -0600 (MDT) Subject: Long Live Python! In-Reply-To: <15182.7171.508504.946071@beluga.mojam.com> Message-ID: <Pine.LNX.4.33.0107121819581.22138-100000@bms> On Thu, 12 Jul 2001, Skip Montanaro wrote: <...> > Well, no, but I might run this file as "python mycode.py" (ten-minute hack - > buyer beware) and type either Python or shell commands at the interpreter > prompt: <...> > The output looks like > > % python mycode.py > Python 2.1.1c1 (#13, Jul 10 2001, 17:30:38) > [GCC 2.96 20000731 (Linux-Mandrake 8.0 2.96-0.48mdk)] on linux2 > Type "copyright", "credits" or "license" for more information. > (Console) > >>> wc -l /etc/termcap > 16412 /etc/termcap > >>> f = open("/etc/termcap") > >>> f.readlines()[10] > '# Please e-mail changes to terminfo at thyrsus.com; the old termcap at berkeley.edu\n' > >>> > > ;-) The Python interpreter should do this right out-of-the-box, or maybe Python embedded in Bash would work. ;-) - Bruce From gerhard.nospam at bigfoot.de Sun Jul 1 11:19:05 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Sun, 1 Jul 2001 17:19:05 +0200 Subject: Unix Scripting Host References: <slrn9jt7s3.a56.gerhard.nospam@lilith.hqd-internal> <9hnaat$284$02$1@news.t-online.com> Message-ID: <slrn9jud7l.111.gerhard.nospam@lilith.hqd-internal> On Sun, 1 Jul 2001 16:00:18 +0200, Thorsten Roskowetz wrote: >"Gerhard H?ring" <gerhard.nospam at bigfoot.de> wrote: >> The closest thing I could find was XPCOM from the Mozilla project. I thought >> that KDE2 or GNOME might offer this already, but I didn't find anything >> (except the relatively heavyweight CORBA approach). >> >> Any suggestions/pointers? > >You might want to look at KDE's DCOP. Well, I did already. It looks cool and I even got the KSpread example to work, but it's tied to C++ and Qt. Gerhard -- mail: gerhard <at> bigfoot <dot> 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 Jul 11 22:10:33 2001 From: bokr at accessone.com (Bengt Richter) Date: Thu, 12 Jul 2001 02:10:33 GMT Subject: Developing Visual Studio add-ins in Python? References: <tH637.142074$R7.25090399@typhoon.kc.rr.com> Message-ID: <3b4d0701.1675128467@wa.news.verio.net> On Thu, 12 Jul 2001 01:03:21 GMT, "Russ Shotts" <rashotts at mn.rr.com> wrote: >Hi, > >Has anyone used Python to create a Visual Studio add-in? I need to perform >some fairly complex processing, and their VBScript macros just cannot handle >the task. > >Any pointers would be greatly appreciated. > I was just thinking about that when I saw that there's no automatic build number update for the VC++ build. (Not that you'd really need python for that ;-) When I get to building, I'll do something about the update, one way or another, unless I find it already done -- which seems awfully likely ;-) From new_name at mit.edu Sun Jul 15 23:31:52 2001 From: new_name at mit.edu (Alex) Date: 15 Jul 2001 23:31:52 -0400 Subject: re Challenge: More Compact? References: <3B51E6B1.47E25214@tundraware.com> <etdhewe0y3q.fsf@quiche-lorraine.mit.edu> <92ae279c.0107151846.7a19d24@posting.google.com> Message-ID: <etd1ynhtuqf.fsf@quiche-lorraine.mit.edu> Ah, good point. thanks. From kosh at aesaeion.com Sun Jul 8 12:47:51 2001 From: kosh at aesaeion.com (kosh) Date: Sun, 08 Jul 2001 17:15:51 +0028 Subject: license suggestions? References: <mailman.994632014.24563.python-list@python.org> Message-ID: <9iapjn$ja2$1@apollo.csd.net> Chris Watson wrote: > > > On Sat, 7 Jul 2001, Neil Macneale wrote: > >> I am wondering if there is a straight forward license which I can use for >> python code I plan to distribute. Is there a standard header, or >> possibly a link that can be placed in a header which basically says that >> people use the code at there own risk, and that they are free to change >> it? I ask here because I know there has been conflict between python and >> GPL. Is there some vanilla header that people in this group use? > > This is what I use. A standard 2 clause (clause 1 and 2) FreeBSD style > copyright but with my own clause 3 to PREVENT people from GPL'ing my code > and thereby RESTRICTING its useage. I call it the static BSD License. Once > it's BSDL'ed it can't be made any less free. It's the closest thing to > public domain you can get yet still cover you A$$ from liability, and the > like. It keeps the code BSDL'ed and prevents someone from GPL'ing it > basically. If a company wanted to license it differently I would have ZERO > problem letting them license it for their own needs whatever that may be. > I just REFUSE to let the code be GPL'ed. Hence clause 3. > This seems really strange to me. So you are saying you can integrate it into any proprietary product without problems? You can intergrate it into perl, python etc with their various licenses. Why do you specifically not want anyone to integrate it with GPL code but allow everything else? From tksee at yahoo.com Mon Jul 30 22:27:41 2001 From: tksee at yahoo.com (Tksee Lhsoh) Date: Tue, 31 Jul 2001 11:27:41 +0900 Subject: Unicode File Message-ID: <3B66179D.1D55B27C@yahoo.com> I would like to open and save a file in unicode. For example, s=open("unicode_filename").read(); seems to return oridinary string, not unicode. What should I do ? From sholden at holdenweb.com Fri Jul 13 11:33:40 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 13 Jul 2001 11:33:40 -0400 Subject: SocketServer and threading mixin? References: <m24rshy4xk.fsf@mouse.copelandconsulting.net> Message-ID: <wvE37.12482$u76.665779@e420r-atl3.usenetserver.com> Greg: There's a much higher probability your issues will be addressed if you visit python.sourceforge.net and use the bug reporting system to let the developers know about the problems. (You may have done this for all I know). It woul dbe a mistake to assume that posting on this newsgroup is sufficient to get a task on the development "to do" list. Furthermore, posting a bug saves the developers from having to do it themselves (since all bugs have to go into sourceforge before they get fixed). Have a good weekend. regards Steve -- http://www.holdenweb.com/ "Greg Copeland" <gtcopeland at earthlink.net> wrote in message news:m24rshy4xk.fsf at mouse.copelandconsulting.net... > > I've been following the bug report on the SocketServer module > and how it is broken with the threading mixin. The bug report > has been closed and the people that posted offered several > solutions, however, from what I've seen, SocketServer, the > module, is still broken and requires a minor patch or two to > work correctly. Does anyone know what the plans are to address > this issue down the road? Will there be an interim python release > which addresses this??? Would be nice since there is seemingly > lots of people that don't want to have to their user base patch > or replace python modules. > > Anyone? > > Greg From jp at NOSPAMdemonseed.net Tue Jul 3 22:19:10 2001 From: jp at NOSPAMdemonseed.net (jason petrone) Date: Wed, 4 Jul 2001 02:19:10 +0000 Subject: py2exe & wxWin References: <m2lmm6m1tg.fsf@mouse.copelandconsulting.net> Message-ID: <ueuth9.m2i.ln@demonseed.net> Greg Copeland <gtcopeland at earthlink.net> wrote: > Is it possible to use py2exe to package up a wxPython application? Yes. jlp From kp87 at lycos.com Sun Jul 29 04:49:23 2001 From: kp87 at lycos.com (kevin parks) Date: 29 Jul 2001 01:49:23 -0700 Subject: Deposing Dictators References: <mailman.996304554.3545.python-list@python.org> <%ez87.128332$%a.5630144@news1.rdc1.sdca.home.com> Message-ID: <5e8bd451.0107290049.27bb9e0e@posting.google.com> "Van Gale" <cgale1 at _remove_home.com> wrote in message news:<%ez87.128332$%a.5630144 at news1.rdc1.sdca.home.com>... > "Tim Peters" <tim.one at home.com> wrote in message > news:mailman.996304554.3545.python-list at python.org... > > > Time to move into the 21st century, Dirck! This alternative is often > > overlooked: > > > > http://www.cobolscript.com/ Yeah, but that dinosaur is really cute! instead of changing / couldn't we change from snakes to the dinosaur! My girlfriend hates snakes and so, hates my python books lying around the house (thanx Mr. Chun for not putting a snake on your book) I've had to cover them over with stickers. Worst yet, was when i brought home the ora _Learning Python_ book & proudly announced, "no snakes" only to reveal the rat on the cover. So my girlfriend wants to know why python has to have the worst animals and why we can have bunnies or little dinosaurs. I agree with her. Additionally i asked my mom what 1/2 should return and she said .5 of course. And since my mom is very smart i think that we should all shut our pieholes a update our code. The bad people should send written apologies to Guido, perferably cards with bunnies on them. I happen to love miffy so i suggest www.miffy.com. They have some things that you can print out and color in. cheers, kevin parks seoul, korea kp87 at lycos.com ps. my mom doesn't like tuples and thinks everything should be mutable. Guido, can you check with your mom and see what she thinks? Maybe tuples need to go, but then i won't have any reason to say tuples anymore and that would be a shame. From qrczak at knm.org.pl Mon Jul 30 02:09:11 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 30 Jul 2001 06:09:11 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <mailman.995989601.30748.python-list@python.org> <cp3d7lbo89.fsf@cj20424-a.reston1.va.home.com> <ubsm8epr5.fsf@ctwd0143.fitlinxx.com> <cp7kww92ph.fsf@cj20424-a.reston1.va.home.com> <m266cg73ig.fsf@mycroft.actrix.gen.nz> <3b60d65e.219212588@news.eircom.net> <cpy9pa4hnh.fsf@cj20424-a.reston1.va.home.com> <m2snfh3h05.fsf@mycroft.actrix.gen.nz> <slrn.pl.9m4r1a.eqf.qrczak@qrnik.zagroda> <3b64d4ce.777475039@wa.news.verio.net> Message-ID: <slrn.pl.9m9ug6.gim.qrczak@qrnik.zagroda> Mon, 30 Jul 2001 04:52:53 GMT, Bengt Richter <bokr at accessone.com> pisze: > I think several notions of exactness are getting mixed. > > Two relationships need to be separated: > 1. bit pattern representing a number <-> *mathematical value* > 2. *mathematical value* <-> significance in problem domain I disagree. The only interesting relationship is number which can be represented in a bit pattern <-> significance in problem domain. The number represented can differ much from the number intended because some operations (e.g. subtraction of positive numbers) may make the result very inexact. Which mathematical value are you talking about? The one represented by the bit pattern or the one which would be used if arithmetic was exact (assuming that it's a rational number at all)? In any case it boils down to the above relationship. > Exactness has to do with the first relationship. A particular bit > pattern representing a number uniquely identifies its corresponding > *mathematical value* by design. If the *mathematical value* is exactly > what you want, declare the representation exact, It's not useful to tag exact float values. Exactness depends on artificial conditions. Operations on them don't always produce exact results. In effect sometimes by accident you might get an exact result, but it's not guaranteed that the same computation of different data will give an exact result. It's better to statically known that results of a computation are not exact in general. If you want exact results, simply don't use floats. If you don't need exactness and know that the algorithm behaves well numerically, use floats for speed. I don't see the point in the compiler inferring whether it managed to get a particular result exact or not. Not to mention that it's inefficient to check whether operations on floats preserved exactness, so you hurt those who don't need exactness. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From rnd at onego.ru Tue Jul 10 04:37:09 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 10 Jul 2001 12:37:09 +0400 (MSD) Subject: [OT] Eternal programming In-Reply-To: <slrn9klav7.rp0.quinn@yak.ugcs.caltech.edu> Message-ID: <Pine.LNX.4.30.0107101231130.6857-100000@rnd.onego.ru> On 10 Jul 2001, Quinn Dunkan wrote: >>If the English language has changed too much, and >>there's no-one left who can understand the spec, >>you might have a bit of a problem... > >Let alone latin letters. Or even utf8. Or 8 bit bytes. I think the real >problem will be building a machine that can read old fashioned hard drives. >And if they do, will they still work? Consider all the 9 track tape rotting >away in closets. > >I think it's good that old software rots away. If you read carefully the goal, it's about saving procedures to access stored data: crypto technique, format converters, etc. I want to be able to restore my old tar.gz archive, etc. Yes, nobody will probably use it anymore, but the data it contains could be of interest. So, I want to make sure procedures will be written in such a language to allow fast retrieval. The fastest way to do it is to implement special very simple interpreter (in the language which will be available in the future) and then feed it with data input and receive data output. >If it's gone it's because >nobody needed it anymore. A lot of other software which would still be >interesting is interesting because of the specific platform it ran on and the >time at which it ran (consider Amiga demos). A language won't help for those, >you need a museum. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Tuesday, July 10, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "<CTRL>-<ALT>-<DEL> is the key to success" _/ From arisen at start.no Fri Jul 13 04:10:05 2001 From: arisen at start.no (=?ISO-8859-1?Q?Andr=E9?=) Date: 13 Jul 2001 01:10:05 -0700 Subject: IRC library for Python? References: <slrn9kscq0.2ld.grey@teleute.dmiyu.org> Message-ID: <fed2e489.0107130010.36692131@posting.google.com> grey at despair.dmiyu.org (Steve Lamb) wrote in message news:<slrn9kscq0.2ld.grey at teleute.dmiyu.org>... > I've been doing some searching and haven't found anything on the web or > deja. Is there an IRC library akin to SMTP/POP/IMAP/NNRP/et al for > Python in existence? There is a small, somewhat outdated (RFC 1459 has been obsoleted, i think) library at http://www.cs.uit.no/~andrer/rfc1459.py . I've used it to build some simple irc bots. -- Andr? Risnes From new_name at mit.edu Sun Jul 15 16:51:58 2001 From: new_name at mit.edu (Alex) Date: 15 Jul 2001 16:51:58 -0400 Subject: Nested List Comprehension References: <9iss5k$2dcd$1@news.idiom.com> Message-ID: <etdelrh29w1.fsf@quiche-lorraine.mit.edu> Yeah, I mucked around a bit with nested list comprehensions when I started using them. It causes the same sort of miserable readability problems that excessive use of the functional programming facilities do. Alex. From jeff at ccvcorp.com Wed Jul 25 18:15:04 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Wed, 25 Jul 2001 15:15:04 -0700 Subject: 2.2 features References: <gER67.534750$eK2.111982758@news4.rdc1.on.home.com> <ac677656.0107231024.3ab3e6f1@posting.google.com> <3B5F0867.7447E5FB@ccvcorp.com> <uzo9sd8le.fsf@ctwd0143.fitlinxx.com> Message-ID: <3B5F44E8.7333F9ED@ccvcorp.com> David Bolen wrote: > Jeff Shannon <jeff at ccvcorp.com> writes: > > > Haven't looked into this in detail, or even downloaded 2.2 yet, but... > > It's sort of noticeable from the question :-) > > > couldn't that be written as: > > > > if __name__ == '__main__': > > for i in fib(): > > print i, > > > > ??? > > Only if fib() was going to return the entire list of numbers in the > sequence as an already created list object. But fibonacci numbers are > an infinite sequence, so clearly you can't do that. Or you'd have to > artifically terminate it somewhere. > Hey, the specification never said anything about needing to *stop* .... ;) Jeff Shannon Technician/Programmer Credit International From govandema at yahoo.com Wed Jul 4 00:37:51 2001 From: govandema at yahoo.com (mag) Date: 3 Jul 2001 21:37:51 -0700 Subject: Tkinter Message-ID: <7724023.0107032037.196f286e@posting.google.com> I am want to run Tkinter applications from c embeeded python... Pl. guide me for that...means how to start? what type of settings I need to do? etc... MAG. From objectway at divalsim.it Wed Jul 4 07:30:09 2001 From: objectway at divalsim.it (Nicola Musatti) Date: Wed, 04 Jul 2001 13:30:09 +0200 Subject: Is there a K&R on Python? References: <mailman.994243868.13022.python-list@python.org> Message-ID: <3B42FE41.8A318469@divalsim.it> Simon Brunning wrote: [...] > Hmmm. I thought K&R *was* a tutorial. It certainly is, but it has qualities that make it a very good reference: it is concise, topics are rather self contained and the index is reasonably good. When the tutorial part is not clear enough the reference manual usually is. [Mark Lutz's 'Python Pocket Reference' (O'Reilly)] [David Beazley's 'Python Essential Reference' (New Riders)]] Thanks, I'll chjeck these out... [<http://www.brunningonline.net/simon/python/PQR.html>] ...and bookmark this. Cheers, Nicola From bokr at accessone.com Tue Jul 17 15:56:16 2001 From: bokr at accessone.com (Bengt Richter) Date: Tue, 17 Jul 2001 19:56:16 GMT Subject: PEP: Defining Python Source Code Encodings References: <mailman.995394873.14918.python-list@python.org> Message-ID: <3b549622.2170522105@wa.news.verio.net> On Tue, 17 Jul 2001 12:31:24 -0600 (MDT), Bruce Sass <bsass at freenet.edmonton.ab.ca> wrote: >On Tue, 17 Jul 2001, M.-A. Lemburg wrote: ><...> >> - which format to use for the magic comment, e.g. >> >> * Emacs style: >> >> #!/usr/bin/python >> # -*- encoding = 'utf-8' -*- > >This should work for everyone, but will it confuse emacs?. >I suppose, "# # ...", or "### ...", or almost any short sequence >starting with "#" will work, eh. > >> * Via meta-option to the interpreter: >> >> #!/usr/bin/python --encoding=utf-8 > >This will require editing if python is not in /usr/bin, and can not be >used to pass more than one argument to the command (python, in this >case). > >> * Using a special comment format: >> >> #!/usr/bin/python >> #!encoding = 'utf-8' > >This is confusing, and will only work on *nix (linux?) iff it is the >second (or later) line; if it is the first line... it will fail >because there is probably no executable named "encoding" available, >and if there is, "= 'utf8'" is unlikely to exist. > >please, >Avoid character sequences that have other meanings in this context. > A valid point. > >I think this should be done as a generic method for pre-processing >Python source before the compiler/interpreter has a look at it. > >e.g., > > # ## encoding utf-8 > >triggers whatever you encoding fans want, > > # ## format noweb > >runs the source through a filter which can extract code noweb marked >up code, and maybe even installs the weaved docs and tangled code >(via distutils?) > > # ## MySpecialMarkup > >runs the source through a filter named MySpecialMarkup. >MySpecialMarkup could be anything: extensions to docstrings, a >proprietary binary format, an entire package-in-a-file! > >Generally: #<magic> <directive> [<arguments>] > >If Python does not know what the <directive> is it should either look >in a set location for a program of the same name then use its output as >the source, or look into a table that maps <directive> to a procedure >which results in Python source. I think you're right about #! triggering confusion, but I think a fixed keyword as a prefix is helpful when e.g., grepping for files with directives. I withdraw my #!pragma (or #!pythma ;-) suggestion and propose r'^\s*#pragma\s' as the magic line prefix regular expression. From skip at pobox.com Thu Jul 5 15:50:45 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 5 Jul 2001 14:50:45 -0500 Subject: Time for a Python "distribution" ? was:Not enough Python library development In-Reply-To: <3B44B63A.BB507CBF@home.net> References: <mailman.993826974.11013.python-list@python.org> <cp1yo3l0si.fsf@cj20424-a.reston1.va.home.com> <mailman.994046162.21135.python-list@python.org> <3B44B63A.BB507CBF@home.net> Message-ID: <15172.50453.103749.142344@beluga.mojam.com> Chris> Unfortunately, not having all the major modules available for a Chris> single source really is a big limitation. Not only do people like Chris> me have to spend a whole lot more time installing stuff, Chris> developers are limited as to what they can expect a Python Chris> installation to include. I'm not sure there's too much farther to go from where Python's distutils sits now to where you need to go. I've used Perl's CPAN shell to install packages and recursively install their dependencies. While it's a bit chatty, I generally haven't had any problems with it. With distutils I believe you get more-or-less platform-independent package installation (at least that's the plan). If you can add package dependencies to a package's distutils spec and adopt a standard set of package download schemes (ftplib and urllib may be all that's needed) as well as a set of package mirror sites, then you've got something quite similar to CPAN. You also need a way to announce the canonical location of a package so mirrors can get at it. The Vaults of Parnassus may already contain that information. Obvious tasks I see: * binary vs. source - in particular, Windows users often won't have compilers * extend distutils (esp. setup.py) to allow authors to record package dependencies * establish a site mirror facility * solve problems with potential name clashes -- Skip Montanaro (skip at pobox.com) (847)971-7098 From rnd at onego.ru Tue Jul 3 01:47:20 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 3 Jul 2001 09:47:20 +0400 (MSD) Subject: problem with sending email In-Reply-To: <Zwc07.5269$Kf3.45103@www.newsranger.com> Message-ID: <Pine.LNX.4.21.BCL.0107030943150.720-100000@suzi.com.onego.ru> On Tue, 3 Jul 2001, Haris Lekatsas wrote: > How can I do that from a CGI script? One way: os.system("""/usr/sbin/sendmail -t << EOMESSAGE From: %(from)s To: %(towhom)s Subject: %(subject)s Message EOMESSAGE""" % vars()) Another way is to open sendmail thru the pipe: file = os.popen("/usr/sbin/sendmail -t", "w") ... file.write(letter) ... file.close() > In article <mailman.994069322.26388.python-list at python.org>, Roman Suzi says... > > > >On 2 Jul 2001 piet at cs.uu.nl wrote: > > > >> >>>>> Haris Lekatsas <nospam at newsranger.com> (HL) writes: > >> > >> HL> I have a problem running the script below on FreeBSD. When I run it from the > >> HL> UNIX prompt it runs fine and it sends a file (bigtextfile) of any size to > >> HL> the recipient address. Whenever a run the exact same script from a web > >> HL> browser as a CGI script it will send only about 17K of the bigfile and not > >> HL> the whole thing. I tried many different files and all of them get cut off > >> HL> at around 17K. It seems on other OS this problem does not appear. Any ideas > >> HL> why this is happening would be appreciated. > > > >What if you try to send mail by piping to "sendmail -t"? > > > >Sincerely yours, Roman A.Suzi > >-- > > - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From daring at ecs.fullerton.edu Thu Jul 19 12:05:47 2001 From: daring at ecs.fullerton.edu (Darin Goldstein) Date: 19 Jul 2001 09:05:47 -0700 Subject: What the heck is with PyRun_File? Message-ID: <f61c65b3.0107190805.498c0f4e@posting.google.com> I have been told to use this newsgroup as a last resource. I modified the file Demo/embed/demo.c in order to test out the functionality of the PyRun_File command. Most likely, I'm making some sort of boneheaded mistake that will probably be obvious to everyone and their dog, but I've been banging my head for over 2 hours and I can't figure out why this won't work. Everything compiles perfectly and things seem to run as usual. result does NOT come out NULL but the answer doesn't get parsed correctly. Ironically, when it prints out the string with the message that it's not parsing correctly, it only comes up with a smiley face. If someone could tell me what's wrong, I would VERY much appreciate it. Thanks for your help in advance. D ---------------<demo.c> /* Example of embedding Python in another program */ #include "Python.h" void initxyzzy(void); /* Forward */ main(int argc, char **argv) { PyObject *dict; FILE *fp; PyObject *result; char *helper; /* should be deleted */ double answer; /* Pass argv[0] to the Python interpreter */ Py_SetProgramName(argv[0]); /* Initialize the Python interpreter. Required. */ Py_Initialize(); /* Add a static module */ initxyzzy(); /* Define sys.argv. It is up to the application if you want this; you can also let it undefined (since the Python code is generally not a main program it has no business touching sys.argv...) */ PySys_SetArgv(argc, argv); /* Do some application specific code */ printf("Hello, brave new world\n\n"); /* Execute some Python statements (in module __main__) */ PyRun_SimpleString("import sys\n"); PyRun_SimpleString("print sys.builtin_module_names\n"); PyRun_SimpleString("print sys.modules.keys()\n"); PyRun_SimpleString("print sys.executable\n"); PyRun_SimpleString("print sys.argv\n"); /* We're going to try and run a Python file here. */ fp=fopen("costtemp.py","r"); if (fp==NULL) { printf("Failed to find the file costtemp.py.\n"); exit(EXIT_FAILURE); }; result=NULL; dict=PyDict_New(); result=PyRun_File(fp,"costtemp.py",Py_file_input, dict,dict); if (result==NULL) printf("This went wrong.\n"); if (!PyArg_ParseTuple(result,"d",&answer)) { printf("The answer didn't get parsed correctly: %s\n",PyObject_Str(result)); } else { printf("The answer is %.39f\n",answer); }; Py_DECREF(dict); Py_DECREF(result); fclose(fp); /* ********************************************** */ /* Note that you can call any public function of the Python interpreter here, e.g. call_object(). */ /* Some more application specific code */ printf("\nGoodbye, cruel world\n"); /* Exit, cleaning up the interpreter */ Py_Exit(0); /*NOTREACHED*/ } /* A static module */ /* 'self' is not used */ static PyObject * xyzzy_foo(PyObject *self, PyObject* args) { if (!PyArg_ParseTuple(args, "")) return NULL; return PyInt_FromLong(42L); } static PyMethodDef xyzzy_methods[] = { {"foo", xyzzy_foo, 1}, {NULL, NULL} /* sentinel */ }; void initxyzzy(void) { PyImport_AddModule("xyzzy"); Py_InitModule("xyzzy", xyzzy_methods); } -------------------------------------<costtemp.py> x=[-9999.999998975394191802479326725006103515625 , 9989.999999949799530440941452980041503906250 ] x[0]+2*x[1] From whisper at oz.nospamnet Thu Jul 5 14:39:06 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 5 Jul 2001 18:39:06 GMT Subject: MS "bans" GPL References: <7iq1ktcmslo24kbr8qvob2g3hpgleuf025@4ax.com> <9hshbp$oqv$2@216.39.170.247> <slrn9k3ji4.49l.gerhard.nospam@lilith.hqd-internal> <9hst9p$oqv$5@216.39.170.247> <9htctp0a0j@enews4.newsguy.com> Message-ID: <9i2c8a$oqv$6@216.39.170.247> In article <9htctp0a0j at enews4.newsguy.com>, aleaxit at yahoo.com says... > "David LeBlanc" <whisper at oz.nospamnet> wrote in message > news:9hst9p$oqv$5 at 216.39.170.247... > ... > > Opinion: It would not be illegal for Microsoft to make it a condition of > > use that you not install open source software if you want to use their > > OS. It's not restraint of trade since technically, open software is not > > traded - there's no _overt_ exchange of value nor is there a "buyer" or a > > "seller" who could be harmed monetarily through such a restraint > > Counter-opinion: where did you get the strange idea that open-source > software can't be traded/sold/bought? It's far from unusual for a > developer to develop application X for a specific customer (and for > plenty of $$$) and put X under the GPL (the developer may have to, > if he uses GPL'd stuff in X, or may simply choose to -- maybe he > thinks this will help spread X's use and his superior familiarity with > X's core sources gives him competitive advantage in bidding for > support & enhancement contracts on X once it's widespread, &c). > > > (besides, you have the freedom to choose another OS according to MS). > > Remember the US Appeals court did endorse the findings of fact > and law in the MS antitrust case -- so MS _is_ officially a monopoly. > This subjects them to much stricter restraints (in theory -- what > remedies will be decided against their illegal antitrust behavior is > another issue of course). > > > Alex I didn't say it couldn't be bought/sold/traded. As far as I know it's just that it generally isn't. In the cases when it is licensed for sale, then that particular version isn't open source is it? (Actually, I don't know how often people make other arrangements with an author for commmercial distribution.) I can think of one case where a restraint on using open source could be restraint of trade: in the case where someone is prevented from charging for service/support of that software (which is the compensation model that open source is based on, no?). Of course some clever M$ shark could say that since they can't use it in the first place due to their agreeing to the OS license, then that can't make a difference. After all, you gave up the right to choose in return for the <ahem> "value, quality and inovation" inherent in the <ahem ahem> "fine" m$ you bought (and soon will pay through the nose for until you die! - oh wait, you already do that with the loss in productivity, hardware costs, extra-cost documentation etc. etc. etc. ETC! My opinion... Dave LeBlanc From MarkH at ActiveState.com Tue Jul 17 20:15:27 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Wed, 18 Jul 2001 00:15:27 GMT Subject: Microsoft COM and "service" class References: <3B549159.1A381BE6@noaa.gov> Message-ID: <3B54D564.3060207@ActiveState.com> jim.vickroy wrote: > which I believe is caused by the following statement in my > implementation: > > win32serviceutil.ServiceFramework.__init__(self, args) > > I do not understand where and how the 'args' parameter is being defined. "args" comes from the service control manager. For "normal" services, the service args can be defined in the dialog used to start and stop services. > If I strip the "service" interface (which references the 'args' > parameter) from my class, it seems to work just fine as a COM object. > > Could someone offer some suggestions on what I need to do. Any chance of a trivial sample I can keep in the win32com test suite? This will help me to track it down once and for all. Mark. From steve at lurking.demon.co.uk Mon Jul 23 23:33:51 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Tue, 24 Jul 2001 04:33:51 +0100 Subject: PEP0238 lament References: <3B5CAED2.80B9CF3C@ActiveState.com> <mailman.995930922.17437.python-list@python.org> Message-ID: <ummplt0l2ov8qmlnlfcg99fk91skstrkr3@4ax.com> On Mon, 23 Jul 2001 19:27:50 -0400, "Tim Peters" <tim at digicool.com> wrote: >[Paul Prescod] >> This issue is constantly presented as some sort of dichotomy between >> "regular" programmers" and newbies. But really it is more of a >> dichotomy between those originally trained on typed languages and >> those on dynamically typed languages. > >Excellent point, Paul! The newbies get dumped on because they're the only >ones impudent enough to complain about it -- Guido hasn't crushed their >spirits yet <wink>. The only issue with newbies is whether or not we provide crutches to save them from needing to learn fundamental programming issues. Newbies are going to need to ask questions - that is an essential part of how learning works and should not be seen as some horrible shock. There will be many common questions, for which a FAQ and some patience and tolerance are the logical solutions. A faster learning curve is undeniably great, but pretending there's nothing to learn is not the same thing. Some time, the difference between integers and floats is going to make itself felt - letting people learn and extensively reinforce bad habits before explaining that is an example of what's known as falling into a comfort zone - it is *not* a positive gain. To quote a very tired saying, a stitch in time saves nine. From steve at lurking.demon.co.uk Mon Jul 23 00:35:02 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Mon, 23 Jul 2001 05:35:02 +0100 Subject: Stability of PYC files References: <e1gllts33oobp6vs3ppaor7uofl3eomehs@4ax.com> <cp8zhheyfa.fsf@cj20424-a.reston1.va.home.com> Message-ID: <nk8nltck9aprqtl0k52ek9mc44b0ru71sv@4ax.com> Thanks From machin_john_888 at hotmail.com Fri Jul 20 05:39:59 2001 From: machin_john_888 at hotmail.com (John Machin) Date: 20 Jul 2001 02:39:59 -0700 Subject: [Q] File Object -- function 'read' References: <mailman.995560073.30389.python-list@python.org> <3B579358.DCF39F49@engcorp.com> Message-ID: <92ae279c.0107200139.6aed7ee9@posting.google.com> Peter Hansen <peter at engcorp.com> wrote in message news:<3B579358.DCF39F49 at engcorp.com>... > > The main difference between the two, is that on Windows > (and DOS, and anything else in that ugly realm), "text" files > have 'newlines' (represented as \n but really just LF or > linefeed characters, or \x0a) converted to pairs of bytes, > specifically a Carriage Return (CR) followed by a Line Feed > (LF). > You didn't mention the no-pejorative-supplied Macintosh realm which uses a lone CR and the IBM mainframe realm which is something else again and there's also Unicode which would like you to use LS (line separator) and PS (paragraph separator) to say what you really mean ... see Unicode Tech Report #13 for a long list of instructions like "if you get byte X off system Y and the month has an 'r' in it and the programmer's name was Fred, then map X into Z; else if ...". ... and there was in a previous job a data supplier who reliably every month gave us records separated by not CRLF but LFCR; this tended to send Windows software into gibbering heaps. There is a much more hideous convention in DOS/Windows. An embedded control-Z is taken to mean end-of-file. This doesn't suck, it bites, and bites badly, needing such as the following (where the docstring is lightly edited to protect the guilty): def cleaned_lines(fh): """ Return a list of lines from the file object fh (which must have been opened in binary mode). CR (0x0D) and LF (0x0A) will be used to split the file into lines. Any other characters outside the range 0x20 to 0x7E (both inclusive) (i.e characters that are not printable ASCII characters) will be changed into "?". This is all because XXXXXXX don't validate their input. One employee has a ctrl-Z character in his YYYYY field. Ctrl-Z is the EOF (end-of-file) marker in the old CP/M operating system. This nasty idea of a data character meaning EOF was inherited by MS-DOS & MS Windows and makes much software stop reading a file prematurely in text mode if there is a ctrl-Z incorrectly embedded in the data. """ return fh.read().translate(translate_string).splitlines() By the way, is there a prize for largest ratio of doc to code? From volucris at hotmail.com Fri Jul 6 01:47:19 2001 From: volucris at hotmail.com (Volucris) Date: Fri, 6 Jul 2001 00:47:19 -0500 Subject: Tkinter doesn't work for MFC applications with Embedded Python? References: <48365474.0107052029.12d28427@posting.google.com> Message-ID: <3b45506f$0$330$6e49188b@news.goldengate.net> You might want to try 'print sys.exc_info()' instead of 'print "failed"'. It might help in closing in on the problem. -- Volucris (a) hotmail.com "Eu n?o falo uma ?nica palavra do portugu?s." "Deepak" <deepak9999 at mail.com> wrote in message news:48365474.0107052029.12d28427 at posting.google.com... > Hi, > I tried to go through all the related postings on the newsgroup > regarding this. > However, I haven't figured out a way to get Tkinter working in an MFC > application that uses embedded python interpreter... Here is the > simple code > that I am trying in the MFC application > > The code in C is simple like this: - > > #include <Python.h> > > void myFunc (int argc, char **argv) > { > Py_Initialize (); > PySys_SetArgv (argc, argv); > PyRun_SimpleString ("execfile('myTkinterApp.py')"); > } > > The code in Python script (myTkinterApp.py) is like this: - > > try: > import Tkinter > print 'Tkinter successfully imported' > try: > root = Tkinter.Tk () > print 'Successful' > except: > print 'failed' > except: > print 'Could not import Tkinter' > > > The result is that it prints: - > > Tkinter successfully imported > failed > > The STDOUT is redirected to print to one of the MFC windows. > I tried to run this by changing the STDOUT to default (standard) > STDOUT. However, even that did not help. > > Any examples or suggestions will be extremely valuable. > Deepak From asencio at mitre.org Tue Jul 31 16:09:08 2001 From: asencio at mitre.org (Angel Asencio) Date: Tue, 31 Jul 2001 16:09:08 -0400 Subject: Instances? Message-ID: <3B671064.73902FDF@mitre.org> Original class: class Foo: x = [] y = [] Code tested on IDLE: >>> a = classTest.Foo() >>> b = classTest.Foo() >>> a.x.append(3) >>> b.x [3] Then, chenged the class to: class Foo: def __init__(self): self.x = [] self.y = [] And the new result was: del(a) >>> del(b) >>> a = classTest.Foo() >>> b = classTest.Foo() >>> a.x.append(3) >>> b.x [] >>> a.x [3] >>> So, does not putting data attributes inside the __init__ would make them the equivalent to class variables on smalltalk or static variables in Java? Thanks, -- -Angel -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-list/attachments/20010731/2bfe3a6b/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: asencio.vcf Type: text/x-vcard Size: 317 bytes Desc: Card for Angel Asencio URL: <http://mail.python.org/pipermail/python-list/attachments/20010731/2bfe3a6b/attachment.vcf> From sholden at holdenweb.com Tue Jul 31 16:35:13 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 31 Jul 2001 16:35:13 -0400 Subject: Instances? References: <3B671064.73902FDF@mitre.org> Message-ID: <zAE97.13878$WD1.596135@e420r-atl2.usenetserver.com> "Angel Asencio" <asencio at mitre.org> wrote in message news:3B671064.73902FDF at mitre.org... > Original class: > > class Foo: > x = [] > y = [] > > Code tested on IDLE: > > >>> a = classTest.Foo() > >>> b = classTest.Foo() > >>> a.x.append(3) > >>> b.x > [3] > > Then, chenged the class to: > > class Foo: > def __init__(self): > self.x = [] > self.y = [] > > And the new result was: > > del(a) > >>> del(b) > >>> a = classTest.Foo() > >>> b = classTest.Foo() > >>> a.x.append(3) > >>> b.x > [] > >>> a.x > [3] > >>> > > So, does not putting data attributes inside the __init__ would > make them the equivalent to class variables on smalltalk or > static variables in Java? > Yes, variables bound in the class scope (such as the method names, which are bound by the def statements) effectively become attributes of the class. The same is true, of course, of names explicitly placed inside the class scope from outside by name qualification (e.g. Foo.classvar = 3). The tricky thing is that self.var will find a class variable var, but if you assign an instance variable var, that instance no longer sees the class variable var. Some code uses this to allow the class to establish default values for certain instance variables, but it's a bit obscure. regards Steve -- http://www.holdenweb.com/ From dinu at reportlab.com Mon Jul 23 03:02:41 2001 From: dinu at reportlab.com (Dinu Gherman) Date: Mon, 23 Jul 2001 07:02:41 GMT Subject: Help with PDF References: <mailman.995677535.12211.python-list@python.org> <20010721.071302.1704365084.1761@d150-169-166.home.cgocable.net> <3b598d0f.252655609@news.t-online.de> <20010722.170022.2058657199.10918@d150-169-166.home.cgocable.net> Message-ID: <3b5bcb75.399701630@news.t-online.de> On Sun, 22 Jul 2001 20:48:07 GMT, "Mark Nenadov" <mnenadov at stclairc.on.ca> wrote: >>>The best solution for Python and PDF that I have found is PDF-Lib >>>(www.pdflib.com). I have used it with Python, and it also work with a >>>wide variety of other languages. >> >> What do you mean by "best"? ;-) >> Dinu > >What do I mean by best? Exactly what I said... "The best solution .... >that I have found". I haven't tried ReportLab yet, so I can't make a >judgement on that yet... but PDF Lib is the best one that I have used so far. Certainly, but isn't that a bit vague without saying what you used PDFlib for? For the fun of it I suggest you run the test suite in reportlab/ test and then try to reproduce some of the generated PDF files with PDFlib using as as little generating Python code as with the reportlab package. Regards, Dinu -- Dinu C. Gherman dinu at reportlab dot com http://www.reportlab.com ................................................................ "The only possible values [for quality] are 'excellent' and 'in- sanely excellent', depending on whether lives are at stake or not. Otherwise you don't enjoy your work, you don't work well, and the project goes down the drain." (Kent Beck, "Extreme Programming Explained") From volucris at hotmail.com Thu Jul 12 06:54:46 2001 From: volucris at hotmail.com (Volucris) Date: Thu, 12 Jul 2001 05:54:46 -0500 Subject: ConfigParser and inifile References: <9ijr1q$29sq$1@news.lf.net> Message-ID: <3b4d816b$0$320$6e49188b@news.goldengate.net> "domi" <warp10 at hushmail.com> wrote in message news:9ijr1q$29sq$1 at news.lf.net... > Hello All, > > could someone solve this problem? > I would like to tell ConfigParser to parse an ini-file from one section to > the other. The ini-file looks like this: > > [section1] > name:... > group:... > > [section2] > name:... > group:... > > [section3] > name:... > group:... > > Now if I let the ConfigParser parse this ini-file like this: > > for section in config.sections(): > ...(do something) > > the parser doesn't step thru section1 to section2 and so on. I need the > given sequence in the ini-file. I don't think you can, because the sections are stored in a dictionary, which is in arbitrary order. You could prefix the section names with numbers (or letters for that matter). The numbers being in the order you want them stepped through. So do this instead: section_list = config.sections() section_list.sort() for section in section_list: ...(do something) > > Thanks, domi > -- Volucris (a) hotmail.com "Eu n?o falo uma ?nica palavra do portugu?s." From tim.one at home.com Sun Jul 22 18:02:31 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 22 Jul 2001 18:02:31 -0400 Subject: PEP0238 lament In-Reply-To: <9jffns$hma$1@newshost.accu.uu.nl> Message-ID: <LNBBLJKPBEHFEDALKOLCCEDBLAAA.tim.one@home.com> [Martijn Faassen] > ... > The audience was entirely self-selected; Unlike, say, the participants in this discussion? Hmm. You set a rather high standard here, Martijn <wink>. ? they were people with an interest in numeric models. Or uninterested in Stackless (its "competition" in that time slot). I suppose the next time we want advice about Unicode, we should just ask Americans. > Did Guido ask for a show of hands in the big session afterwards? No, not on this issue. > I don't recall; I kind of suspect the outcome would've been different. I actually think 1/2==0 bothers "the general" population more than those with a keen interest in numerics. Indeed, nobody with a keen interest in numerics has bugged Guido about this except Moshe, that I know of; the most visible repeated pressures have come from educators using Python as a means to some other end. >> The current integer division loses information silently and without a >> trace combined with that Python is not a statically typed language, >> there's simply no telling what e.g. >> >> def velocity(distance, time): >> return distance / time >> >> will compute by inspection. > There's no telling what: > > def add_stuff(a, b): > return a + b > > will compute by inspection either, though. You chopped all my following text, saying that the velocity() example wasn't about user-defined overloadings but about ordinary arithmetic on the builtin numeric types. A user trying e.g. velocity(3, 2) is simply going to be surprised -- as countless newbies have testified on c.l.py over the years. > ... > For working with pixels in GUIs and such, integer division can be a > useful thing, though. It can be useful for many things; that's not at issue, and nobody has ever proposed taking away the ability to get an integer result; the issue is how to spell that. From m.faassen at vet.uu.nl Sat Jul 7 17:08:51 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 7 Jul 2001 21:08:51 GMT Subject: PEP scepticism References: <mailman.994528591.28994.python-list@python.org> <cpy9q0iobo.fsf@cj20424-a.reston1.va.home.com> Message-ID: <9i7tp3$b2g$2@newshost.accu.uu.nl> Guido van Rossum <guido at python.org> wrote: > "Tim Peters" <tim.one at home.com> writes: >> [Robin Becker] >> > ... >> > Dictators often assume they know best, but observation shows them >> > to be uniformly wrong. >> >> Heh. Replace "Dictators" with "Humans", and I expect the truth-value of >> that assertion would be unaffected. >> >> BTW, in case newcomers are wondering, Guido didn't become BDFL by >> assassinating his predecessor, nor does he maintain Absolute Power by force >> of arms. Although he's been thinking about it <wink>. > The PSU has Robin's name and email address. Robin: be afraid, be very > afraid. It is time that an example be set! I thought *I* was that scary example! Who is Robin, anyway? Never heard of any Robins.. Disappointed-ly yours, 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 Mon Jul 9 19:18:06 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Tue, 10 Jul 2001 00:18:06 +0100 Subject: Language Shootout References: <mailman.994689198.3317.python-list@python.org> <3B49F724.1F3DF6B3@yahoo.com> <WZp27.2221$z21.439450@newsc.telia.net> Message-ID: <830eaJAuujS7Ewxk@jessikat.fsnet.co.uk> In article <WZp27.2221$z21.439450 at newsc.telia.net>, Fredrik Lundh <fredrik at pythonware.com> writes >Paul Winkler wrote: >> Doing it iteratively is much, much faster. > >does your fastest iterative solution beat this one? > >import sys > >def fib(n): > if n < 2: > return 1 > return fib(n-2) + fib(n-1) > >def fib(n, fib=fib, memo={}): > v = memo.get(n) > if v is None: > v = memo[n] = fib(n) > return v > >def main(): > N = int(sys.argv[1]) > print fib(N) > ></F> > > always if it's only used for one value :) -- Robin Becker From loewis at informatik.hu-berlin.de Wed Jul 25 10:13:16 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 25 Jul 2001 16:13:16 +0200 Subject: Version numbers in traceback References: <5nitltsbrurir59906mbdtectsoah2ppcc@4ax.com> Message-ID: <j4vgkhgkqr.fsf@informatik.hu-berlin.de> Dale Strickland-Clark <dale at riverhall.NOSPAMco.uk> writes: > Is there a standard way for a module to register its version number so that it is reported by > traceback or other debugging tools. > > I thought something nice and simple like > > _Module_Version_ = '10.5C' > > would be nice. The standard constant for a module version is __version__. However, there is no way to integrate it into a traceback. Instead, debugging tools would need to find out the module of each function in the traceback themselves (which sometimes cannot be done), and then access the __version__ if desired. I don't think that the traceback module should fetch __version__, though. Regards, Martin From nalcorso at isw.net.au Mon Jul 9 01:12:11 2001 From: nalcorso at isw.net.au (Nick Alcorso) Date: 8 Jul 2001 22:12:11 -0700 Subject: Hardware API Failing Message-ID: <b5e6e25d.0107082112.2d3b70e7@posting.google.com> I have written a C wrapper for an API which controls an ISA card and I am attempting to create a python module which makes calls to this wrapper. The module seems to build fine, and work mostly, for example the calls to all of the functions in the wrapper work (get called) and so do the ones to the Hardware API, however though the calls to the wrapper work, the calls to the API from the wrapper for some reason fail when they are called from python. If I use a test C app and link to the C wrapper then the hardware calls work, also if I embed lua and script from that then the calls work also. I am wondering if there is something in the environment that prevents python from controlling hardware? Any help would be much appreciated. Regards, Nick Alcorso From sholden at holdenweb.com Wed Jul 11 10:31:58 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 11 Jul 2001 10:31:58 -0400 Subject: evalstr References: <mailman.994843338.24567.python-list@python.org> <3B4C2A0E.60AA094@nokia.com> Message-ID: <8oZ27.41795$F%5.2523550@e420r-atl2.usenetserver.com> "Joonas Paalasmaa" <joonas.paalasmaa at nokia.com> wrote in message news:3B4C2A0E.60AA094 at nokia.com... > Shannon --jj Behrens wrote: > > > > Hello All, > > > > I wrote a useful C module for doing string > > interpolation. I find it indespensible when working > > with large blocks of triple-quoted text. When working > > with large blocks of triple-quoted text, nothing else > > is quite as convenient. Here's the Python doc: > > [lots of text snipped] > > > Please forgive my arrogance, but I think that it might > > even be useful enough to be included as a standard > > module. If, not perhaps you guys might have some > > suggestions as to what I can do with it. You may > > download the entire packages from: > > > > <http://ironorchid.com/jjinux/evalstr.tar.gz> > > I prefer the following method for evaluations inside strings. > > >>> class Eval: > def __getitem__(self, key): > return eval(key) > > > >>> foo = 3.0 > >>> spam = 5.0 > >>> print "%(foo/spam)s" % Eval() > 0.6 > >>> print "%(foo/spam).55f" % Eval() > 0.5999999999999999800000000000000000000000000000000000000 That's a very neat trick. Had you though of writing it up as a Python recipe? regards Steve -- http://www.holdenweb.com/ From claird at starbase.neosoft.com Sat Jul 28 10:25:33 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 28 Jul 2001 09:25:33 -0500 Subject: Distributed computing using SOAP. What about speed ? References: <LBA77.58$bXi.175168000@news.telia.no> <48F88F43C9842AD9.1E631B0D03856868.6FDBB21E772A6CB3@lp.airnews.net> <9js18m$n54$1@clematis.singnet.com.sg> Message-ID: <D4DB37387F4EA9A2.D6DD66D7FD6C9115.609F82073AFFEB7C@lp.airnews.net> In article <9js18m$n54$1 at clematis.singnet.com.sg>, Ng Pheng Siong <ngps at post1.com> wrote: . . . >There's BEEP, formerly known as BXXP. RFC 3080 and 3081, I think. > >A new Internet-draft talks about running SOAP over BEEP. > >See www.beepcore.org. > >(Python implementation seems to have fallen behind.) . . . The background of the Beepcore principals is in Tcl. 'Twill be entertaining to implement the RFCs for Py- thon, though, no? -- Cameron Laird <claird at NeoSoft.com> Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From roy at panix.com Sun Jul 1 10:06:14 2001 From: roy at panix.com (Roy Smith) Date: Sun, 01 Jul 2001 10:06:14 -0400 Subject: PEP scepticism References: <mailman.993747643.21070.python-list@python.org> <9hfqb5$dsllb$3@ID-89274.news.dfncis.de> <3dhex01n1m.fsf@ute.cnri.reston.va.us> Message-ID: <roy-900E5D.10061401072001@news1.panix.com> Andrew Kuchling <akuchlin at mems-exchange.org> 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. Just out of curiosity, how long must one dislike something before that dislike graduates from "knee-jerk reaction" to "considered opinion"? Having now used python for about 4 years, I still think indentation-for-grouping was a dumb idea. The problem is that it is just too easy to add or delete whitespace by accident (and without noticing), especially when cutting and pasting hunks of code from one place to another. When such whitespace munging makes the code look ugly, it's simply a minor annoyance. When it changes the meaning of the code, it's a language design mistake. The reason people rarely beat up on it anymore is becuase it's a lost battle. I continue to use python (despite the indenting problem) because there is enough other stuff in it that I like. But I don't think it's fair to call it a "knee-jerk reaction". From m.1.robinson at herts.ac.uk Thu Jul 26 09:23:26 2001 From: m.1.robinson at herts.ac.uk (Mark Robinson) Date: Thu, 26 Jul 2001 14:23:26 +0100 Subject: freeze.py (where is it?) References: <3B58494D.C82965AD@raqia.com> <dd144f8b.0107260325.6a0f21e4@posting.google.com> Message-ID: <3B6019CE.4070900@herts.ac.uk> can anyone tell me where I might find the freeze utility. It doesn't seem to be included in the windows installation of python 2.1. Am I just being blind or has it perhaps been superceeded by something better, I am only aware of it from a reference in 'programming python'. blobby From skip at pobox.com Fri Jul 6 09:33:41 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 6 Jul 2001 08:33:41 -0500 Subject: Time for a Python "distribution" ? was:Not enough Python library development In-Reply-To: <3dlmm2qlcv.fsf@ute.cnri.reston.va.us> References: <mailman.993826974.11013.python-list@python.org> <cp1yo3l0si.fsf@cj20424-a.reston1.va.home.com> <mailman.994046162.21135.python-list@python.org> <3B44B63A.BB507CBF@home.net> <mailman.994368791.9779.python-list@python.org> <Lsd17.8383$e5.1082989@newsb.telia.net> <3dlmm2qlcv.fsf@ute.cnri.reston.va.us> Message-ID: <15173.48693.568403.150776@beluga.mojam.com> amk> Bruce Sass's suggestion of using the Debian package manager is a amk> good one, because apt really provides exactly what we need. amk> Unfortunately porting it to Windows or Mac is probably hard, so we amk> could just steal its interface (which seems similar to pyppm's) and amk> reimplement it in pure Python. Couldn't RPM do similar things? It's got a somewhat stronger relationship to Python, so porting to Win/Mac might not be as difficult. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From new_name at mit.edu Mon Jul 16 11:57:13 2001 From: new_name at mit.edu (Alex) Date: 16 Jul 2001 11:57:13 -0400 Subject: Most efficient solution? References: <mailman.995289809.28477.python-list@python.org> <slrn9l5urp.nto.alf@leo.logilab.fr> <etdn164rk7f.fsf@quiche-lorraine.mit.edu> <slrn9l62om.o1k.alf@leo.logilab.fr> Message-ID: <etd8zhorhnq.fsf@quiche-lorraine.mit.edu> Oh, I'd thought hash lookups were constant time. That's interesting. From treaves at silverfields.com Thu Jul 12 13:33:04 2001 From: treaves at silverfields.com (Timothy Reaves) Date: Thu, 12 Jul 2001 13:33:04 -0400 Subject: Compile 2.1 problem In-Reply-To: <etdelrmoyl0.fsf@pickled-herring.mit.edu> References: <mailman.994956861.11471.python-list@python.org> <etdelrmoyl0.fsf@pickled-herring.mit.edu> Message-ID: <20010712133304.3415243d.treaves@silverfields.com> On 12 Jul 2001 13:18:35 -0400 Alex <new_name at mit.edu> wrote: > > What output do you get when you run the last command, > > ./python -tt \ > /var/tmp/python2-2.1-root/usr/lib/python2.1/compileall.py \ > /var/tmp/python2-2.1-root/usr/lib/python2.1 > > with the -v flag? > double # ./python -tt -v > /var/tmp/python2-2.1-root/usr/lib/python2.1/compileall.py > /var/tmp/python2-2.1-root/usr/lib/python2.1 bash: /var/tmp/python2-2.1-root/usr/lib/python2.1: Is a directory From me at mikerobin.com Thu Jul 5 19:05:58 2001 From: me at mikerobin.com (Michael Robin) Date: 5 Jul 2001 16:05:58 -0700 Subject: Performance in embeded / extended python References: <3b431024.15341289@news.iway.fr> <tk6tumj4ucre9d@news.supernews.com> <3b443731.3777511@news.iway.fr> Message-ID: <52e5ab5f.0107051505.86ac604@posting.google.com> In my current Python game "project" (can't really call it that yet...), I can get about 18fps if I choose 200 sprites, or about 60fps for 40 sprites, on a PIII850. (Cut this in half if a "radar" or other window is also active.) This is doing real-time 2d rotation of mult-segmented objects, position updating, and viewport mapping all in Python w/o any extensions. I'm probably going to move to an extension when I get to fancier objects, collision detection and some physics similation code that's probably o(n^2 or ^3), but for now things seem pretty good. m ----------- emmanuel.astier at winwise.fr (Emmanuel Astier) wrote in message news:<3b443731.3777511 at news.iway.fr>... > On Wed, 4 Jul 2001 13:08:19 -0700, "John Roth" > <johnroth at ameritech.net> wrote: > > > > >"Emmanuel Astier" <emmanuel.astier at winwise.fr> wrote in message > >news:3b431024.15341289 at news.iway.fr... > >> Hi, > >> > >> > >> I embedded and extended python for a game, and I was REALLY > >> disappointed by the performances I get... > >> > >> Every frame of my game ( should be 60 time by second ) I call my > >> Python logical part from my C game with : > > > >There's one thing that needs to be said right off - while there are > >many successful commercial games that use a scripting language to > >control the actual flow of the game, they don't, and I must repeat, > >they don't call the script every frame. As you've noticed, it's just > >too slow. It's the responsibility of the game engine (written in C > >or C++, with Assembler assists as needed for performance) to > >handle everything until, and only until, the engine needs a decision. > > I don't agree : I worked on a successful commercial game, and I writed > the script for this game, and it was REALLLY light, and I run it every > frame. > The language was far more simple and stupid that Python, but it was > aimed for a PSone ( 33Mhz ! ). > I was hoping that aiming a real PC, I could use a language like > Python. > But I agree my older script didn't had to handle 200 objects per > seconds. > > BTW, a game like Unreal has a script that's called every frame (all > the logical part is scripted), and it runs quite well :) > > > > >With 200 sprites, I presume you're doing some kind of arcade type > >game - lots of stuff flashing around the screen, and the gameplayer is > >pushing his hand-eye coordination to the limit. People don't use scripting > >languages for that, except possibly for transitions. > > The 200 sprites were just a test. > I intend to use the script for our engine, and having to specialize it > yet. > > > > >Scripting languages are used where there is an extended storyline > >embedded in the game, such as Adventure or RPG type games. The > >script handles the storyline and transition, and the game engine handles > >everything else. > > > >For example, in Zork: Grand Inquisitor, there's a point early in the > >game where the adventurer comes across a glass box on the wall, with the > >sign "in case of adventure, break glass." The mechanism to solve this puzzle > >requires a state machine with around five states and five or six inputs, > >each > >state transition requires that the scene is updated. There are literally > >hundreds > >of such situations in the game. > > > >If you tried to do this in C or C++, with the inevitable rewrites as the > >game > >designers tried to tweak it this way and that to make the game a compelling, > >memorable experiance, you'd run through your budget in no time flat. > > I totally agree... > > > > >> > >> PyObject_CallFunction( LogicalEntryPoint, NULL ); > >> > >> Logical Entry Point being a PyObject* pointing on the name of the > >> function. > > > >I presume that you've made sure that the function is preloaded in > >memory at all times - it does not have to be reloaded from disk > >or recompiled from a string. > > > Gulp............. > > Euh... I don't know how to be sure my function is preloaded, and not > on the disk... How can I do that ? > > > > > >> My function do only : > >> > >> for i in range ( 0, NbTestSprites - 1 ): > >> ListOfSprites[i].setPos( 100, 100 ) > >> > >> ie it sets the pos of 200 sprites. > >> ListOfSprites is a tuple of 200 sprites, sprites is a extension class, > >> and setPos one of its method. > > > >"for i in range(...)" creates 101 objects each time it's executed: it > >has to build a tuple, and objects for all numbers from 101 to 200. > >(numbers from -1 to 100 are preallocated in the interpreter). It's > >faster if this is done once, and then passed to the for loop: > > > >foobar = range(0, NbTestSprites - 1) > > > >for i in foobar: > > > >This only works if foobar is stored somewhere where it doesn't have > >to be recreated on each call. > > > > Designers will handle the scripts and I'm not sure they will use this > kind of optimisation ( using map seems a good win here too ). > > >> > >> I'm using Swig to extend Python with my C functions ( I Tried Boost > >> too, but there is even more overhead... ) > > > >Swig is intended to make extension more convenient. Convenience is > >usually exactly opposite to performance. Do it by hand. > > Swig is not really something appearing in the profile. > but the PyArg_ParseTuple function could appear... > > Thansk for your reponse, > > Emmanuel From aleaxit at yahoo.com Tue Jul 3 04:08:10 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 3 Jul 2001 10:08:10 +0200 Subject: How to call a method with variing arguments References: <e956b5f1.0107022240.776c1734@posting.google.com> Message-ID: <9hruvq016bo@enews1.newsguy.com> "Heiko" <meinmailfilter at gmx.de> wrote in message news:e956b5f1.0107022240.776c1734 at posting.google.com... > Hello, > I want to do this: > > ClassObject = Class() > ClassObject.Method(Arg1, Arg2, Arg3) > ... > ClassObject.Method(Arg1, Arg2, Arg3, Arg4, Arg5 ....) > ... > ClassObject.Method() > ... > and so on. Well, then, just do it! No problem. > Means that I want to call a method with a variing number of arguments > and the method decides what to do. Sure, Python supports that. > If possible, it would be nice, if the sequence of the arguments > doesn?t matter, and the method realizes which argument is on which > position (but that is a "nice to have"). This one I really don't understand. Anyway, once you do have a sequence of arguments (which is what you get), you may well decide to ignore the sequence's order and treat it as "a set". > So, how do I have to declare > the method, that this works? class Class: def Method(self, *args): print "Called with",len(args),"arguments" args is the tuple of actual argument values passed on the call -- it's up to the method to decide what to do with them. Alex From JamesL at Lugoj.Com Wed Jul 4 13:46:07 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Wed, 04 Jul 2001 10:46:07 -0700 Subject: tkinter/commands help References: <3B437AB7.86540660@optonline.net> Message-ID: <3B43565F.C4BA07EB@Lugoj.Com> Arun Ramanathan wrote: > > I am trying to run a rsh command from the commands module. > My code for a tkinter button and call back looks like this. > > from Tkinter import * > import commands > > def callme(): > result = commands.getoutput('rsh -l username hostname showrev -p') > mytext.delete(0.0,END) > mytext.insert(0.0,result) What happens when you substitute something like: def callme(): import time result = str(time.time()) .... Does that work? Also, you snipped too much code; you show "mytext" but don't show what it has been initialized to. That is all I can suggest since I don't have enough information to do more. From richard at bizarsoftware.com.au Tue Jul 24 21:04:12 2001 From: richard at bizarsoftware.com.au (Richard Jones) Date: Wed, 25 Jul 2001 11:04:12 +1000 Subject: Bug? In-Reply-To: <4835e825.0107241639.bbf438e@posting.google.com> References: <4835e825.0107241639.bbf438e@posting.google.com> Message-ID: <200107250101.LAA18417@goanna.adroit.net> On Wed, 25 Jul 2001 10:39, Ricardo Correia wrote: > Hi > > --------------------------------------------------- > mainlist = [1, 2, 3, 4, 5] > copy = mainlist > > for item in copy: > print item, > mainlist.remove(item) > --------------------------------------------------- > > Shouldn't this produce '1 2 3 4 5'? > > I only get '1 3 5' and unfortunately because of this my program doesn't > work. In the above, "copy" is not a copy of "mainlist". >>> mainlist = [1, 2, 3, 4, 5] >>> copy = mainlist >>> id(copy) 135189396 >>> id(mainlist) 135189396 >>> copy = mainlist[:] >>> id(copy) 135077076 >>> for item in copy: ... print item, ... mainlist.remove(item) ... 1 2 3 4 5 >>> The second copy assignment uses the slice mechanism to take a true copy of the contents of mainlist. Richard -- Richard Jones richard at bizarsoftware.com.au Senior Software Developer, Bizar Software (www.bizarsoftware.com.au) From rmacneil at interactdirect.com Fri Jul 20 09:23:43 2001 From: rmacneil at interactdirect.com (Rod MacNeil) Date: Fri, 20 Jul 2001 09:23:43 -0400 Subject: Large File Support Message-ID: <eiW57.266163$Z2.3224218@nnrp1.uunet.ca> Hello NG, I need to build Python to include large file support on Redhat Linux 7.1. I tried the following instructions from section 8.1.1 in the Python docs but it doesn't work: On large-file-capable Linux systems, this might work: CC="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" export CC ./configure I think this fails because the variable CC is expected to have the compiler name (gcc). Does anyone have any alternative instructions? Rod MacNeil rmacneil at interactdirect.com From akuchlin at mems-exchange.org Wed Jul 18 11:18:26 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 18 Jul 2001 11:18:26 -0400 Subject: Really Python leaks? References: <mailman.995461170.23230.python-list@python.org> Message-ID: <3dwv56p8ot.fsf@ute.cnri.reston.va.us> Vesselin Iliev Peev <VesselinPeev at operamail.com> writes: > I hope this is somehow not true, and perhaps Insure++ is incorrectly reporting > these, but has anyone tested Python in this way with a similar tool? Actually that probably isn't too surprising. Some of the C code, particularly in module initializers, will allocate memory for a dictionary or other structure, and then not free it. For earlier versions of Python, the developers had access to a copy of Purify; I don't know if they still do. Fixing these leaks isn't a big priority, because usually the interpreter will only be finalized before the program exits anyway. Still, if you can provide more information about where the leaks occur, perhaps they can be fixed. --amk From chrishbarker at home.net Thu Jul 5 17:40:26 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 05 Jul 2001 14:40:26 -0700 Subject: Question about scope References: <3B44D696.61A8B915@tundraware.com> Message-ID: <3B44DECA.7D64AE2C@home.net> Tim Daneliuk wrote: > I thought I understood python scoping, but I guess I don't. Consider this > code: > FALSE = 0 > TRUE = not FALSE > FLAG = TRUE > > def FlagFalse(): > FLAG = FALSE > > print str(FLAG) > FlagFalse() > print str(FLAG) > > I get: > 1 > 1 > > But I expected: > 1 > 0 > > If I declare FLAG as global in the function, it works properly, of course. > > I thought that python checked local scope for a variable first and if > it did not find it, it appealed to the local namespace. What am I missing > here - it's probably at the end of my nose, but I cannot seem to make sense > of it... Actually, it checks local first, but more importantly, you can't re-assign a global variable in a local scope (without using global). if you assign to a variable in a function, it is local to that function. The local version of FLAG has been set to FALSE, not the global one. When the function is byte compiled, it notices that you have assigned "FLAG" in your function, so sets it as a local name. That why you get an error if you try to do this: >> def FlagFalse(): ... print FLAG ... FLAG = FALSE ... >>> FlagFalse() Traceback (most recent call last): File "<stdin>", line 1, in ? File "<stdin>", line 2, in FlagFalse UnboundLocalError: local variable 'FLAG' referenced before assignment >>> Essentially you have only read-only access to immutable global variables. Mutable variables you can change, because you are not reassigning them, so you could do: >>> FLAG = [TRUE] >>> def FlagFalse(): ... FLAG[0] = FALSE ... >>> FLAG [1] >>> FlagFalse() >>> FLAG [0] FLAG is still pointing to the same list, you have just changed the contents. -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 tushar at hursley.ibm.com Fri Jul 6 18:25:48 2001 From: tushar at hursley.ibm.com (Tushar Wagle) Date: Fri, 06 Jul 2001 23:25:48 +0100 Subject: distutils woes - help appreciated! Message-ID: <3B463AEC.13949D66@hursley.ibm.com> Hello all, I'm starting-to-try-to-use (:) distutils (with Python 2.1 on Linux). For basic stuff, it's okay (and rather cool :), but I have a few problems/questions: 1. scripts: Can I install a script in a directory OTHER than /usr/local/bin? I'm hoping for an option like "script_dir='/usr/local/my_stuff'" (similar to 'package_dir'). 2. data_files I can't get this to work at all! I'm using something like: setup(... package_dir={'': 'src'}, packages=['jim', 'jim.data', 'jim.report', 'jim.web'], data_files=[('/x/website/htdocs/styles', ['src/web/styles/basic.css',])] ) where /x/website/htdocs is where I want to place my data files, and src/... is where the source file lives. (I tried removing the src/ , hoping that it might sensibly use the package_dir root, but to no avail.. :( Again, I would like to see something like 'data_dir' (cf 'package_dir')... It would be nice if script_dir and data_dir defaulted to package_dir (at least for my purposes where everything's under the src/ directory :) On a related note, I had tried something like: web_root = '/x/website' setup(... data_files=[(web_root + 'styles', os.listdir('./src/web/styles'))], ) but it looked like this couldn't work as the listdir was running inside the temporary 'build' directory, and all of my source files had NOT been copied there!! (I think it just copied the packages?...). Can I refer to the real source root directory somehow (ie rather than './')? 3. re-targetting dist-dir changing dist-dir (eg to 'release') works okay (files end up there correctly), but the 'dist' directory is always created nevertheless (and source rpms seem to end up there)!... ...I presume this is a bug! :) --- Other than these niggles, I'm impressed! As always with Python, what's normally a task which generates headaches and wastes many hours unproductively is simply and elegantly resolved...for the better of the Universe as a Whole! %-) Best Regards, Tushar (Python Beginner/Evangelist/Devotee! ;) From quinn at regurgitate.ugcs.caltech.edu Mon Jul 16 00:29:08 2001 From: quinn at regurgitate.ugcs.caltech.edu (Quinn Dunkan) Date: 16 Jul 2001 04:29:08 GMT Subject: re Challenge: More Compact? References: <3B51E6B1.47E25214@tundraware.com> <92ae279c.0107151429.398e6e9e@posting.google.com> <slrn9l4fob.p58.tim@vegeta.ath.cx> Message-ID: <slrn9l4rck.rlt.quinn@regurgitate.ugcs.caltech.edu> On Mon, 16 Jul 2001 00:58:46 GMT, Tim Hammerquist <tim at vegeta.ath.cx> wrote: >Tim Daneliuk <tundra at tundraware.com> wrote: >> The following re is (I think) the description of a legitimate IP addess in >> "quad" format (IPV4). My question is, can it be made even shorter? >> >> ipquad = r"^((\d\d?\d?\.){3}(\d\d?\d?))$" > >from 'Mastering Regular Expressions', p.124: > >'^([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.\ >([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])$' How about: for o in '.'.split(ip_addr): assert 0 <= int(o) <= 255, 'ip octet not a byte in "%s"' % ip_addr Re's can be handy, but their usefulness can trick you into trying to use them for things for which they're not suitable. From pete.forman at westerngeco.com Mon Jul 16 09:31:05 2001 From: pete.forman at westerngeco.com (Pete Forman) Date: 16 Jul 2001 14:31:05 +0100 Subject: Python, C++, Java, Smalltalk, Eiffel,... References: <9is8rm$46d$1@panix3.panix.com> Message-ID: <tuae25f1ba.fsf@kryten.bedford.waii.com> kj0 <kj0 at mailcity.com> writes: > Where can I find a reasonably non-partisan but also reasonably > detailed comparison of the more popular OO languages (C++, Java, > Python, etc.). Have a look at Peter Liu's Programming page. http://www.geocities.com/SiliconValley/Way/9731/xref_features.html That seems to cover the features of most popular OO languages except Eiffel and, er, Python. -- Pete Forman -./\.- Disclaimer: This post is originated WesternGeco -./\.- by myself and does not represent pete.forman at westerngeco.com -./\.- opinion of Schlumberger, Baker http://www.crosswinds.net/~petef -./\.- Hughes or their divisions. From tim at vegeta.ath.cx Wed Jul 25 00:16:12 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Wed, 25 Jul 2001 04:16:12 GMT Subject: OO misconceptions // Learning curve geometry/ References: <mailman.994969462.27792.python-list@python.org> <hevsktcrnpckttnkgi1arcue5kjjsbrrb5@4ax.com> <mailman.995046506.2514.python-list@python.org> <9ir1l7$3ja$1@panix2.panix.com> <9irfbc11jaq@enews1.newsguy.com> <slrn9l49me.p58.tim@vegeta.ath.cx> <mailman.995268208.1394.python-list@python.org> <slrn9l6kci.qqs.tim@vegeta.ath.cx> <3B538E16.65394C9D@engcorp.com> <slrn9l7a8r.rpe.tim@vegeta.ath.cx> <9j0rko025gf@enews3.newsguy.com> <slrn9l9k6t.va1.tim@vegeta.ath.cx> <bog57.219$Ax5.5503@news3.voicenet.com> <slrn9ldcug.mtd.tim@vegeta.ath.cx> <yoxzo9wyvul.fsf@karhu.tp.spt.fi> <slrn9lnm9u.nvk.tim@vegeta.ath.cx> <yoxy9pe98ru.fsf@karhu.tp.spt.fi> Message-ID: <slrn9lsini.ptj.tim@vegeta.ath.cx> Me parece que Ville Vainio <vvainio at karhu.tp.spt.fi> dijo: > tim at vegeta.ath.cx (Tim Hammerquist) writes: > > > glad you have found a language that works better for you than Perl > > A year ago I had nothing against Perl; it seemed wonderful to have > only one "special purpose" (text processing & extraction) language to > learn, instead of several (awk, sed, whatever). It's still great for > throwaway scripts for log analyzing/whatever. I didn't turn to python > because I had problems with Perl; I looked into it because I like > looking into different languages, and found it superior to perl > (though, like everybody, I was initially suspicious of the whitespace > thing... :-). This is probably what happened to most other pythonistas > as well. My story sounds very similar, except for a few points. I've done ASP pages, DB access, Tk GUIs, and (of course) CGIs in Perl. I just never considered it a "special purpose" language. (Nor did I find any shortcomings of Perl during these endeavors...none except those in Tk which are present in Tkinter as well...) ;) OTOH, I looked into Python for, apparently, the _exact_ same reason as you. However, I fell in love with the indentation code grouping immediately. Oh, how many Perl scripts I'd inherited from my predecessors in this easy-to-read format: sub do_something { process(); for $item (@array, $etc) { while ($some_condition) {process();}} someMoreProcessing stuff; ... } And now, imagine the functions 200+ lines long and poorly designed... =( No, Python's syntax guaranteed I'd never again run into that particular problem again. Yay! > Speaking of beauty, think of the iterators & generators in > Py2.2... yummy. Yes, I eagerly await all my newfound operator-toys. =) -- Be different: conform -- fortune-mod version 9708 From ggardiner at accelrys.com Fri Jul 13 07:05:46 2001 From: ggardiner at accelrys.com (Gardiner, Geoff) Date: Fri, 13 Jul 2001 12:05:46 +0100 Subject: Q: HTTP through multiple NICs Message-ID: <55E9531220EDD41186F50090274688BD2BF356@oranamesrvr0.synomics.com> I need to send HTTP traffic through multiple NICs (multihoming with different IP addresses AND different MAC addresses) on a single PC. The traffic doesn't need to be simultaneous (I think I'll try to walk before I run). I've got a working single-NIC test suite in Python, but haven't worked out how to direct traffic to more than one NIC - I'm a complete novice in this area. I can't find anywhere obvious in httplib or its superclasses for a NIC identifier or local IP address to be used to select the NIC. Can anyone suggest where I start with this - before I rush out and buy the NICs? I'm running Win NT at present, but could switch to Linux if that helps! Thanks, Geoff Gardiner From SBrunning at trisystems.co.uk Wed Jul 4 06:56:26 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Wed, 4 Jul 2001 11:56:26 +0100 Subject: Python for air traffic control? Message-ID: <31575A892FF6D1118F5800600846864D78BE12@intrepid> > From: Alex Martelli [SMTP:aleaxit at yahoo.com] > In exchange, please look at > Lutz Prechelt et al's 1999 "phonecode" study -- e.g. at > http://wwwipd.ira.uka.de/~prechelt/documents/jccpp_tr.pdf. This is a really interesting study, so far as it goes. What I'd *really* like to see, though, would be something similar to this which included metrics on the *maintainability* of code in various languages. It could run in a similar fashion to Prechelt's study, but then include a stage where the resultant program sources were forwarded on to different developers, along with a revised spec. I don't know about everybody else here, but I spend easily ten times as much time fixing and/or modifying existing code as I spend writing new stuff. I'd like to see Perl keep up with Python in *this* study! <wink> 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 paul at svensson.org Mon Jul 23 17:51:29 2001 From: paul at svensson.org (Paul Svensson) Date: 23 Jul 2001 21:51:29 GMT Subject: PEP0238 lament References: <3B5B3676.40F39389@alcyone.com> <eppstein-03540D.13070222072001@news.service.uci.edu> <mailman.995836120.7223.python-list@python.org> <vyIKbWAP62W7EwC+@jessikat.fsnet.co.uk> <9jg6ei$ges7$1@sky.inp.nsk.su> Message-ID: <9ji691$bt9$1@newsy.ifm.liu.se> "Andy Salnikov" <salnikov at inp.nsk.su> writes: >Guys, if you really need something returning floats for division, make it >new operator, I guess everyone could be made happy with 1/2 == 0 and 1//2 == >0.5. There are two common ways to do division. A) x / y = z such that z * y = x, B) x / y = z and x % y = r such that z = int(z), 0 <= r < x, z * y + r = x In current python, (B) is "z, r = divmod(x, y)", while (A) can be approximated by "(x + 0.0) / y". Unadorned "x / y" picks (A) or (B) depending on the types of x and y. Now we have three problems: 1) The current semantics of x/y are confusing and error-prone 2) (x + 0.0) / y is nonintuitive and ugly 3) divmod(x, y)[0] is nonintuitive and ugly Which problem(s) are we trying to solve ? No solution to (1) will avoid breaking existing code. We can solve (2) and (3) by adding _two_ new operators (or functions), or we can solve all three by changing x/y to always do (A) or always (B), and adding a new operator for the other. Andy's proposal for "1//2 = 0.5" solves (2), doing nothing about (1) and (3), and I find very little merit in such a half-done (1/3 done) solution. /Paul From Randy.L.Kemp at motorola.com Fri Jul 20 11:00:15 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Fri, 20 Jul 2001 10:00:15 -0500 Subject: Python equivalent of two Perl statements Message-ID: <E566B020833BD311B6610008C791A39705CA526E@il93exm04.css.mot.com> What is the equivalent of these Perl statements in Python? $time = scalar(localtime); print "This FTP request started on $time \n"; From pedro at athlet.de Wed Jul 11 18:47:38 2001 From: pedro at athlet.de (pedro) Date: Wed, 11 Jul 2001 22:47:38 GMT Subject: detect if file or dir Message-ID: <3b4cd747.27470810@news.isis.de> hi, how can i detect if sth. is a file or a directory? exists(directory) does tell me if sth. is a directory but exits my script wenn it hits a file. thx pedro From ahenshawatapowerdotcom Fri Jul 6 22:49:17 2001 From: ahenshawatapowerdotcom (Andrew Henshaw) Date: Fri, 6 Jul 2001 22:49:17 -0400 Subject: Inverse regex? Message-ID: <tkcud8arriomfa@corp.supernews.com> Has anybody seen or developed what might be called an inverse regex generator. We would like to do some unit testing of modules that have user input validated by regular expressions. It would be nice to throw some some strings at them and see if the propagated input causes an error in the code downstream. In other words, it may help to detect if our validation routines are insufficient. I understand that, in many cases, a complete list of valid strings is impossible. However, for certain regular expressions it would be certainly reasonable. For others, it will be possible, but practically impossible (set too large). For the impossible, and near impossible, it would be nice to generate a bounded set that hits many of the degenerate and extreme cases. Any ideas? Andrew Henshaw From aboufer at atlsci.com Tue Jul 24 10:11:09 2001 From: aboufer at atlsci.com (Ahmed Bouferguene) Date: Tue, 24 Jul 2001 10:11:09 -0400 Subject: thread module References: <20010723210218.11240.00000881@ng-fv1.aol.com> Message-ID: <3B5D81FD.646E42BA@atlsci.com> Greeings, Just one comment. You should try to use "threading" module which is better than the old "thread" . TheDustbustr wrote: > What args are encessary when you call thread.start_new_thread()? The module > index says: > > "start_new_thread (function, args[, kwargs]) > Start a new thread. The thread executes the function function with the argument > list args (which must be a tuple). The optional kwargs argument specifies a > dictionary of keyword arguments." > > How do I create a simple thread like so: > def hi(): > print "Hi!" > thread.start_new_thread(hi(),args) > > What are the args? From sholden at holdenweb.com Sun Jul 29 22:23:50 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sun, 29 Jul 2001 22:23:50 -0400 Subject: (in)exactness of complex numbers References: <mailman.996249232.22459.python-list@python.org> <cp4rry2qvh.fsf@cj20424-a.reston1.va.home.com> Message-ID: <mv397.633$WD1.118669@e420r-atl2.usenetserver.com> "Guido van Rossum" <guido at python.org> wrote in message news:cp4rry2qvh.fsf at cj20424-a.reston1.va.home.com... > Skip Montanaro <skip at pobox.com> writes: > > > Once these numeric changes are all implemented, if I define a complex > > constant with either integer real or imaginary parts, e.g. > > > > c = 1+2.1j > > > > d = 1.2+5j > > > > e = 4+7j > > > > should I get an integer back (exact) or a float (inexact) when asking for an > > attribute that was originally an integer? In general, can complex numbers > > be considered to have two exactness attributes? > > That's probably not worth the implementation complexity. I expect > that all floats and complex will be considered inexact, and all > rationals and ints exact. That seems to be the most practical set of > rules, even if it doesn't satisfy everybody. > Wouldn't it be more sensible to say that a complex is exact if both its real and imaginary components are exact? Or would that require too much (sorry, no pun intended) implementation complexity? regards Steve -- http://www.holdenweb.com/ From paul at boddie.net Fri Jul 27 06:22:13 2001 From: paul at boddie.net (Paul Boddie) Date: 27 Jul 2001 03:22:13 -0700 Subject: The error of building Python on HP UX References: <9jobt0$nh7$1@mail.cn99.com> <cpofq77phl.fsf@cj20424-a.reston1.va.home.com> <3B60BC42.8C790BCE@yahoo.com> Message-ID: <23891c90.0107270222.7856bec2@posting.google.com> SteveN <smnordby at yahoo.com> wrote in message news:<3B60BC42.8C790BCE at yahoo.com>... > Guido van Rossum wrote: > > > > (Couldn't resist. :-) > > > > It is indeed an error to attempt to build Python on HP UX. (See the > > endless laments in the SF bug database.) > > And yet HP makes it available: > http://hpux.connect.org.uk/hppd/hpux/Languages/python-2.1/ It's a fearsome experience to run Python on HP-UX too - see the screenshot they provide. ;-) From tim.one at home.com Mon Jul 30 01:07:17 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 30 Jul 2001 01:07:17 -0400 Subject: Language Niches (long) In-Reply-To: <3B6481DB.C5AEA46@ActiveState.com> Message-ID: <LNBBLJKPBEHFEDALKOLCEEDDLCAA.tim.one@home.com> [Paul Prescod] > ... > C became popular between twenty and thirty years ago. Twenty at best. In the early 80's, I was on an internal committee at Cray Research tasked to pick a system implementation language to replace most uses of Cray assembler (ah, CAL!). It came down to (heavily extended) Pascal or (heavily extended) Fortran. We unanimously dismissed C because, at the time, it appeared to be limited to universities, yet even Cray's university customers had absolutely no interest in it. My track record at predicting The Next Big Thing is unarguably consistent <wink>. c-rode-in-on-the-back-of-the-unix-virus-ly y'rs - tim From pmoscatt at bigpond.net.au Wed Jul 25 07:10:28 2001 From: pmoscatt at bigpond.net.au (Peter Moscatt) Date: Wed, 25 Jul 2001 11:10:28 GMT Subject: Finding Directory Structures ?? Message-ID: <EOx77.61374$Xr6.240081@news-server.bigpond.net.au> Using python, hows the better way of finding the structure of your filesystem. I thought it may have been Dir() but this brings back something completely different. Basically I want to create a app that shows a Tree with the various directories. Pete From nperkins7 at home.com Sun Jul 29 18:27:33 2001 From: nperkins7 at home.com (Nick Perkins) Date: Sun, 29 Jul 2001 22:27:33 GMT Subject: Try floating the Back Orifice's dumb PGP and Willy will recycle you! References: <FDC34627.2CE8C0C7@edefod.net> Message-ID: <p5097.586665$eK2.123322103@news4.rdc1.on.home.com> I laughed at the first one of these I read, thinking it might be the result of a python program, but now I have noticed that they are popping up on other newsgroups, too, all from different names. Once is funny. Twice is spam. I have seen four or five today. "Timothy Gibson" <barewy at edefod.net> wrote in message news:FDC34627.2CE8C0C7 at edefod.net... > If you'll recycle Gilbert's printer with keypads, it'll biweekly > interface the thought. Sometimes Alexandra will get the robot, and if > Samantha wistfully meets it too, the programmer will collaborate > outside the fast cybercafe. My extreme PERL won't disconnect before I > push it. He will engulf halfheartedly if William's plotter isn't > bizarre. Go cry a protocol! When will you save the chaotic > retarded zipdisks before Pilar does? Jeff wants to know seemingly, unless > Chester infects machines within Evan's administrator. Until > Jeff defiles the RAMs stupidly, Ann won't moan any solid cafes. > Where Frederick's discarded LAN outwits, Robette facilitates > in back of loud, plastic CIAs. Otherwise the terminal in Jonnie's > librarian might prepare. Try typeing the Back Orifice's dry > admin and Sherry will close you! Who shoots undoubtably, when > Martin dreams the disgusting firewall in the mail server? Don't try to > exclude the stacks wanly, eliminate them deeply. As badly as > Robette reloads, you can negotiate the operator much more strongly. > > > From jparlar at home.com Thu Jul 19 15:56:07 2001 From: jparlar at home.com (Jay Parlar) Date: Thu, 19 Jul 2001 15:56:07 -0400 Subject: Distributing a Python app Message-ID: <20010719195840.BHJ2711.femail24.sdc1.sfba.home.com@jparlar> I'm just wondering if anyone has any suggestions as to the best way to distribute an application written in Python, intended for people who don't have Python installed on their machines? Even possibly a commercial distrubtion program, if it's the best. I've been playing around with py2exe, with not much success (although that's a topic for a different day). Assuming I do get py2exe working properly, how would everyone suggest we distribute our application? (By the way, this application is for Windows machines). Jay Parlar ---------------------------------------------------------------- Software Engineering III McMaster University Hamilton, Ontario, Canada "Though there are many paths At the foot of the mountain All those who reach the top See the same moon." From benc1 at today.com.au Sat Jul 28 08:07:22 2001 From: benc1 at today.com.au (Ben C) Date: 28 Jul 2001 05:07:22 -0700 Subject: The Evolution Of Python Message-ID: <8beb91f5.0107280407.5a30341d@posting.google.com> In the ecosystem of programming languages I think that the argument "Oh you can't change that as it will break all my existing code" should not be used to stagnate the evolution of a language ... and infact if you think about it is quite selfish ... to have Python evolve will require a some effort from everyone who activley uses the language ... if it means reworking some code then so be it ... or if 1.X is the niche you like then stick with it ... I don't envy Guido at all ... he is in a tough position ... he has to consider IMO three choices: a\ Try to retain retrospective compatibility while still adding new features and evolving the language == bloats the language by adding extra operators and syntax (see Perl (more than one way to do everything) and VB (I think only the MS marketing dept think that VB is OO)) b\ Try not to change the language to keep maximum retrospective compatibility == stagnates the language (see Rexx==dinosaur ) c\ Change existing language features to improve the language == sacrifices retrospective compatibility for evolution (see all languages in their infancy ie. Mercury - http://www.cs.mu.oz.au/research/mercury/ ) I hope Guido will keep leaning towards c\ ... if change is needed to make the language more 'beautiful & eloquant' then so be it ... regards From ChuckEsterbrook at yahoo.com Wed Jul 11 22:37:55 2001 From: ChuckEsterbrook at yahoo.com (Chuck Esterbrook) Date: Wed, 11 Jul 2001 22:37:55 -0400 Subject: Fixed mx.DateTime or alternative? In-Reply-To: <3B4A23DA.9D737F43@lemburg.com> References: <5.0.2.1.0.20010703093458.02498dc0@mail.mindspring.com> <5.0.2.1.0.20010709085854.02491aa0@mail.mindspring.com> Message-ID: <5.0.2.1.0.20010711223722.024a2040@mail.mindspring.com> At 11:36 PM 7/9/2001 +0200, M.-A. Lemburg wrote: >In this case you could use: > > if a and b and (a == b): ... > >(DateTime instances are always true, None is false) That seems to break down if they are both None. str(a)==str(b) seems to be the safest bet until 2.0.2 comes out later this week. ;-) -Chuck From sheila at spamcop.net Sat Jul 7 16:54:56 2001 From: sheila at spamcop.net (Sheila King) Date: Sat, 07 Jul 2001 20:54:56 GMT Subject: license suggestions? References: <3b477513$0$322$8eec23a@newsreader.tycho.net> Message-ID: <entektsq6t2ulqlae3std75dak804fci24@4ax.com> On Sat, 07 Jul 2001 13:46:11 -0700, "Neil Macneale" <mac4-devnull at theory.org> wrote in comp.lang.python in article <3b477513$0$322$8eec23a at newsreader.tycho.net>: :I ask here because I know there has been conflict between python and :GPL. Is there some vanilla header that people in this group use? I'm distributing my Python script under the GPL. So far as I know, that is fine to do. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From dougfort at dougfort.net Tue Jul 3 10:28:37 2001 From: dougfort at dougfort.net (Doug Fort) Date: 3 Jul 2001 15:28:37 +0100 Subject: I'd Like to Contribute to an Open Source Project Message-ID: <3b41d693$1_7@news5.uncensored-news.com> I have some time on my hands. It seems like a good opportunity to do some noncommercial Python programming. Like my hero TV's Frank on MST3K, I'm more suited to be the lackey than the mad scientist. I've checked the 'Project Help Wanted' on SourceForge and don't see anything that really fits. Anybody need some Python code on an Open Source project? You can see some of my work at http://pyagent.sourceforge.net and at http://asynchttp.sourceforge.net. -- Doug Fort <dougfort at dougfort.net> 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 skip at pobox.com Wed Jul 18 00:00:42 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 17 Jul 2001 23:00:42 -0500 Subject: Inheritance in extension type In-Reply-To: <sit9ltc8uhs7glo8ijlv8mjm6krso2dhge@4ax.com> References: <sit9ltc8uhs7glo8ijlv8mjm6krso2dhge@4ax.com> Message-ID: <15189.2538.694442.853758@beluga.mojam.com> Lothar> I'm writting a C extension and i define two types A and B. How Lothar> can i specify that B inherits from A. That's not supported directly by the Python core. There is a version of Digital Creations' ExtensionClass module that supports this, however. Take a look at the ExtensionClass.[ch] that comes with recent (development) versions of PyGtk2: http://www.gnome.org/~james/ -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From michael at stroeder.com Fri Jul 20 04:17:55 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Fri, 20 Jul 2001 10:17:55 +0200 Subject: Case insensitivity References: <mailman.995506711.21636.python-list@python.org> <cpvgkofyru.fsf@cj20424-a.reston1.va.home.com> <9j8lag$srl$1@newsfeed.th.ifl.net> Message-ID: <3B57E933.63F10BC0@stroeder.com> Michael Abbott wrote: > > "Guido van Rossum" <guido at python.org> wrote in message > news:cpvgkofyru.fsf at cj20424-a.reston1.va.home.com... > > To me, the only real important question is, how can we introduce > > case-sensitivity for novices without breaking the millions of lines of > > existing Python code. One option could be: forget it, it's too late. > > Another: put the case-insensitivity in the tools. > > Please reassure me that this means what I think it does: you want to update > Python so that a future version of the language supports two modes, case > insensitive for beginners and case sensitive for experts? > > If so, please go ahead, and let me carry on, as an expert, using case to > make important, subtle but useful distinctions. But case-sensitive mode should be the default. Beginners mode should have to be turned on by command-line option. Ciao, Michael. From steve at lurking.demon.co.uk Mon Jul 23 03:20:06 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Mon, 23 Jul 2001 08:20:06 +0100 Subject: A use for integer quotients References: <yCK67.17615$EP6.4467503@news1.rdc2.pa.home.com> <mailman.995860718.9550.python-list@python.org> <eppstein-3AE912.21173322072001@news.service.uci.edu> Message-ID: <3qhnltk4c1h2i0eu7m1no068g6if7ej5tm@4ax.com> On Sun, 22 Jul 2001 21:17:33 -0700, David Eppstein <eppstein at ics.uci.edu> wrote: >In article <mailman.995860718.9550.python-list at python.org>, > Moshe Zadka <moshez at zadka.site.co.il> wrote: > >> Yes. Nobody said it wasn't of any use, people just claim it is *less* >> useful, and so should not be the most easily accessible. You can >> still have i//j for all your combinatorics needs. > >I don't suppose it would be possible to go through some repository of >Python sources and figure out the relative numbers of divisions of integer >arguments that end up an int versus the ones that are coerced to floats? >In my own code it's 100% int/int->int but that's a small unrepresentative >sample. Note I'm less interested in divisions of quantities that are >already floats as those would be unaffected by this proposal. I know that mine is 100% - I rarely use floats at all in Python. But what might be surprising is that in C++ - where I do a lot of digital signal processing work using floating point values - the answer is *still* 100%. If I need floating point division I use floating point division, but that has always meant that I'm using floating point arguments. The worst I found is a few cases if Sample_Rate / n, or 1.0 / n, or whatever where n was an integer that got implicitly cast - which Python does already. Integers and floats are two separate domains - both in implementation details and in their applications. From chrishbarker at home.net Fri Jul 27 15:27:44 2001 From: chrishbarker at home.net (Chris Barker) Date: Fri, 27 Jul 2001 12:27:44 -0700 Subject: PEP 238 (revised) References: <cp4rrz5onj.fsf@cj20424-a.reston1.va.home.com> Message-ID: <3B61C0B0.30477AFB@home.net> > Semantics of Floor Division > > Floor division will be implemented in all the Python numeric > types, and will have the semantics of > > a // b == floor(a/b) > > except that the type of a//b will be the type a and b will be > coerced into. Specifically, if a and b are of the same type, a//b > will be of that type too. so: 3//2 == 1 3.0//2.0 == 1.0 3.0//2 == 1.0 so if I want to use the result as an index, I'll need to use: int(x/y) kind of like I now use: int(floor(x/y)) What I don't get, is why // couldn't return an integer always? It will always have an integral value. I suppose one problem is that the range of integers that a float (C double) can handle is larger than a 32 bit integer can hold. This could be solved in the future with int/long inification, what will be the behaviour then? -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 mal at lemburg.com Fri Jul 13 17:56:40 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 13 Jul 2001 23:56:40 +0200 Subject: [Python-Dev] RE: Defining Unicode Literal Encodings References: <LNBBLJKPBEHFEDALKOLCAEEMKOAA.tim.one@home.com> Message-ID: <3B4F6E98.733B90DC@lemburg.com> Tim Peters wrote: > > [M.-A. Lemburg] > > PEP: 0263 (?) > > Title: Defining Unicode Literal Encodings > > Version: $Revision: 1.0 $ > > Author: mal at lemburg.com (Marc-Andr? Lemburg) > > Status: Draft > > Type: Standards Track > > Python-Version: 2.3 > > Created: 06-Jun-2001 > > Post-History: > > Since this depends on PEP 244, it should also have a > > Requires: 244 > > header line. Ok, I'll add that. > > ... > > ... can be set using the "directive" statement proposed in PEP 244. > > > > The syntax for the directives is as follows: > > > > 'directive' WS+ 'unicodeencoding' WS* '=' WS* PYTHONSTRINGLITERAL > > 'directive' WS+ 'rawunicodeencoding' WS* '=' WS* PYTHONSTRINGLITERAL > > PEP 244 doesn't allow these spellings: at most one atom is allowed after > the directive name, and > > = "whatever" > > isn't an atom. Remove the '=' and PEP 244 is happy, though. If you want to > keep the "=", PEP 244 has to change. True... would that pose a problem ? [Paul] > I think that there should be a single directive for: > > * unicode strings > * 8-bit strings > * comments > > If a user uses UTF-8 for 8-bit strings and Shift-JIS for Unicode, there > is basically no text editor in the world that is going to do the right > thing. And it isn't possible for a web server to properly associate an > encoding. In general, it isn't a useful configuration. Please don't mix 8-bit strings with Unicode literals: 8-bit strings don't carry any encoding information, so providing encoding information cannot be stored anywhere. Comments, OTOH, are part of the program text, so they have to be ASCII just like the Python source itself. Note that it doesn't make sense to use a non-ASCII superset for the Unicode literal encoding (as you and others have noted). Since all builtin Python encodings are ASCII-supersets, this shouldn't pose much of a problem, though ;-) > Also, no matter what the directive says, I think that \uXXXX should > continue to work. Just as in 8-bit strings, it should be possible to mix > and match direct encoded input and backslash-escaped characters. > Sometimes one is convenient (because of your keyboard setup) and > sometimes the other is convenient. This proposal exists only to improve > typing convenience so we should go all the way and allow both. Hmm, good point, but hard to implement. We'd probably need a two phase decoding for this to work: 1. decode the given Unicode literal encoding 2. decode any Unicode escapes in the Unicode string > I strongly think we should restrict the directive to one per file and in > fact I would say it should be one of the first two lines. It should be > immediately following the shebang line if there is one. This is to allow > text editors to detect it as they detect XML encoding declarations. > > My opinions are influenced by the fact that I've helped implement > Unicode support in an Python/XML editor. XML makes it easy to give the > user a good experience. Python could too if we are careful. I think that allowing one directive per file is the way to go, but I'm not sure about the exact position. Basically, I think it should go "near" the top, but not necessarily before any doc-string in the file. > [Guido] > > Hm, then the directive would syntactically have to *precede* the > > docstring. That currently doesn't work -- the docstring may only be > > preceded by blank lines and comments. Lots of tools for processing > > docstrings already have this built into them. Is it worth breaking > > them so that editors can remain stupid? > > No. Agreed. Note that the PEP doesn't require the directive to be placed before the doc-string. That point is still open. Technically, the compiler will only need to know about the encoding before the first Unicode literal in the source file. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From johnroth at ameritech.net Thu Jul 12 11:04:37 2001 From: johnroth at ameritech.net (John Roth) Date: Thu, 12 Jul 2001 08:04:37 -0700 Subject: [OT] Eternal programming References: <mailman.994779919.3199.python-list@python.org> Message-ID: <tkrf4ol6t4b338@news.supernews.com> FORTH is an interesting language - Postscript is a distant relative. Charles Moore originally wrote it to control telescopes; it's quite widely used for process control, hence it's machine orientation. In the hands of an expert, it's both incredibly productive and very accurate. Implementing FORTH in Python is an interesting project. In doing an implementation you need to be very careful about distinguishing among the artifacts of the current implementations and the core language concepts - things like real memory references are an artifact of implementations on real hardware, and don't have any relevance to the core concepts. I would think that you would want to start with a class named "Word" that encapsulates a word: that is two sequences of instances of class Word, one for run-time behavior and one for compile-time behavior. The class should have methods RunTime() and CompileTime(). Builtins should be subclasses of Word. RunTime() simply loops through the Run sequence and invokes each instance in turn. Let's see - loops. RunTime normally returns +1, but it can return any offset; this is used to implement looping and condition tests within a word. For compile time, you need dictionaries: FORTH dictionaries map very cleanly into Python dictionaries. The current compile time environment is a list of FORTH dictionaries. The dictionary returns the class instance that implements the word. The execution time stack needs to be a global object - since I'm not an OO purist, I'd make it a module level rather than a singleton object. Tastes vary. The return stack becomes the method invocation stack - it no longer has an explicit representation. That hoses some of the tricks used to make FOR loops work, and such, but alternate solutions can probably be found for those. Or maybe not - we may need a separate return stack that is only used for additional stuff, not the return addresses themselves. The thing to watch out for is to avoid taking too much advantage of Python tricks - portability means that it never quite fits into any environment elegantly. John Roth "Roman Suzi" <rnd at onego.ru> wrote in message news:mailman.994779919.3199.python-list at python.org... > On Tue, 10 Jul 2001, Mikael Olofsson wrote: > > > INTERCAL or Brainf***, anyone? > > The following script was written in half an hour > (after I found this page: > > http://chemlab.pc.maricopa.edu/pocket/pfmanual.html > > (Chemists are going to use Forth in nanotech programming. ;-) [...] > Sincerely yours, Roman A.Suzi > -- > - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - > > > From sk at nvg.ntnu.no Fri Jul 13 05:55:16 2001 From: sk at nvg.ntnu.no (Steinar Knutsen) Date: 13 Jul 2001 09:55:16 GMT Subject: IRC library for Python? References: <slrn9kscq0.2ld.grey@teleute.dmiyu.org> <fed2e489.0107130010.36692131@posting.google.com> Message-ID: <9imgi4$jl4$1@snipp.uninett.no> In article <fed2e489.0107130010.36692131 at posting.google.com>, Andr? <arisen at start.no> wrote: >grey at despair.dmiyu.org (Steve Lamb) wrote in message >news:<slrn9kscq0.2ld.grey at teleute.dmiyu.org>... > >> I've been doing some searching and haven't found anything on the web or >> deja. Is there an IRC library akin to SMTP/POP/IMAP/NNRP/et al for >> Python in existence? > >There is a small, somewhat outdated (RFC 1459 has been obsoleted, i >think) library at http://www.cs.uit.no/~andrer/rfc1459.py . I've used >it to build some simple irc bots. I have a library at http://sk.nvg.org/python/irc_uninett/ It follows RFC 2811 and 2812 pretty closely. It does not handle any of the client to client (DCC, CTCP) or server to server stuff (RFC 2813) though. -- Steinar From loewis at informatik.hu-berlin.de Sun Jul 1 06:50:34 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 01 Jul 2001 12:50:34 +0200 Subject: GCC 3.0, Standard ABI & C++/Python Integration References: <mailman.993664666.10985.python-list@python.org> Message-ID: <j4d77kvs79.fsf@informatik.hu-berlin.de> Nahuel Greco <ngreco at softhome.net> writes: > Will the standarization of the ABI in gcc 3.0 help to do a better > integration of C++ and python? No. Martin From sholden at holdenweb.com Sun Jul 29 23:37:47 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sun, 29 Jul 2001 23:37:47 -0400 Subject: Try floating the Back Orifice's dumb PGP and Willy will recycle you! References: <FDC34627.2CE8C0C7@edefod.net> <p5097.586665$eK2.123322103@news4.rdc1.on.home.com> <slrn9m95gj.5c2.QSB@animas.frontier.net> Message-ID: <PB497.1941$9i1.150098@e420r-atl1.usenetserver.com> "Allodoxaphobia" <QSB at QRM-QRN.net> wrote in message news:slrn9m95gj.5c2.QSB at animas.frontier.net... > On Sun, 29 Jul 2001 22:27:33 GMT, Nick Perkins scribbled: > >I laughed at the first one of these I read, > >thinking it might be the result of a python program, > >but now I have noticed that they are popping up > >on other newsgroups, too, all from different names. > >Once is funny. Twice is spam. > >I have seen four or five today. > > Take a look in news.admin.net-abuse.email, if you think "...4 or 5..." > might be a nuisance. > > And, trim your posts. Especially if you know them to be trash. > tnx. Hmm. My news server's "242860 not downloaded" message was quite enough to convince *me* that c.l.py is by no means the worst-off group. shan't-be-subscribing-to-that-one-ly y'rs - steve -- http://www.holdenweb.com/ From ralph at inputplus.demon.co.uk Mon Jul 9 11:24:11 2001 From: ralph at inputplus.demon.co.uk (Ralph Corderoy) Date: 9 Jul 2001 16:24:11 +0100 Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hrj3q$cj1@news1.gtech.com> <mailman.994154525.14580.python-list@python.org> <9htebs$ck2@news1.gtech.com> Message-ID: <9iciar$fqd$1@inputplus.demon.co.uk> Hi, > 1. No program EVER has 100% coverage during testing (unless it is > trivial - this for the nitpickers :-)). The bigger the program the > less likely full coverage has been achieved, ATC's are big programs. > Anyone who claims they have 100% tested an ATC are either fools or > liars - "every line and every circumstance" are NOT POSSIBLE, if you > think they are then I don't have anything more to say other than get > a few more years real world experience :-). So, if you plan to 100% > test a python ATC "each line and every circumstance" then my original > confidence that it would never be put into production holds (that's > one of the reason languages have exception handlers - to catch the > error that the programmer didn't foresee) :-). I've worked on an ATC program, in particular on the user interface side. The software ran on many Unix systems, one per controller. It was a mixture of Ada, C, and assembler. Dynamic memory allocation was widely used. The X Window System with Motif and PEX libraries was also utilised along with COTS products like TeleUSE. There were kernel extensions for network protocols, etc. First off, although the lawyers will clear the use of a buggy COTS product that has a company behind it they won't like the idea of a `free' piece of software, even one that's much more mature and bug free. I've been there. Perl, Flex, Bison, binutils, and lzop were just some of the tools used to analyse run-time data offline to prove correctness. In the online software the gzip algorithm code was used (as IIRC its licence allows). It was just plonked straight in. However, the lawyers had a issue with that so one of the COTS suppliers were asked to `supply' it to us. Problem solved. As you can see, they're political/law issues rather than technical suitability. And they can be solved. I imagine it's easier now than it was then given the publicity Free Software has achieved. As far as coverage testing goes you're right. They never get near complete coverage. In fact, often it is very poor indeed with the coverage test writers working from the source code they are trying to cover rather than a spec of the routine. After much complaining about this, often the routine was obviously wrong from straightforward reading of the code, I placed an Easter Egg in one part of the GUI. If certain conditions were met then an image of a plane, noise first in the ground, with smoke rising from its tail together with a man drifting down from a parachute appeared. Who says I don't have a GSOH :-) Despite the code that included the logic to make the image appear, together with the image, passing through peer code reviews, coverage testing, unit testing, integration, you name it, including others editing that area of the code, it was never discovered. Shortly before leaving the project, when it had been on-site, but not in a live system, for over a year, I announced its existence and removed it. The major problems, based on this experience, are many. None specific to ATC projects but just large software projects involving many companies with poor staff retainment/training. There are engineers that, as I think you said, should have been bakers, engineers who didn't know C, Unix, Ada, Motif, etc., coding on the project, management who only plan to be in their position for around 6 months and so don't care about doing it right but just doing it within schedule because then it's someone else's problem, and several sub-contracting companies where none of the parties want to be the first to announce a schedule slip. Hell, nothing seems to have changed since Fred Brooks wrote _The Mythical Man Month_. A book which few of my peers or managers had heard of. So Python in an ATC project? Sure, don't see why not. With the right libraries it's almost like a domain-specific language. You'll just need to educate others. Hope this helps, Ralph. From guido at python.org Wed Jul 25 01:33:08 2001 From: guido at python.org (Guido van Rossum) Date: Wed, 25 Jul 2001 05:33:08 GMT Subject: Future division patch available (PEP 238) References: <mailman.995776716.24336.python-list@python.org> <MPG.15c7942e7652fd7b989800@news-enteract> Message-ID: <cplmlda7zg.fsf@cj20424-a.reston1.va.home.com> Alan Miller <ajm at enteract.com> writes: > Guido van Rossum (guido at digicool.com) wrote: > >- after "from __future__ import division", / is changed to return a > > float result from int or long operands (and so is /=). > > So who's going to write slashnanny.py that will go through old code and > warn about existing operations that will be broken by the change? I don't know yet, but it will definitely be made available in some form, long before such code is actually broken. One idea is a command line switch that makes Python spit out a warning whenever an int division has a nonzero remainder, but there are more sophisticated ideas too, using type inference. --Guido van Rossum (home page: http://www.python.org/~guido/) From wyatts at onr.com Fri Jul 13 13:46:23 2001 From: wyatts at onr.com (wyatt stafford) Date: Fri, 13 Jul 2001 17:46:23 GMT Subject: greenbeen seeks advice References: <mailman.995043443.27208.python-list@python.org> Message-ID: <OtG37.24103$g96.665749@news.easynews.com> I looked through about 15 different articles/URLs, etc doing language comparisons, and the code examples, when available, on Python were usually shorter, and seemed to be easier to follow (ok, maybe "follow" is a charitable description of my current ability). Also, I found copies of the two books mentioned earlier and found they both contained compelling, persuasive arguements in favor of Python. Finally, I like the TV shows, movies, etc of Monty Python. wy "Lindstrom Greg - glinds" <Greg.Lindstrom at acxiom.com> wrote in message news:mailman.995043443.27208.python-list at python.org... > Welcome to the club! I am curious as to how you decided on Python? > IM(NS)HO, it is one of the best languages for just about all applications > ('cept MUDs :-). My daughter (age 10) has worked through the "How to Think > Like a Computer Scientist" (Python edition), and to my amazement, wrote a > program to find all of the words in a word-search puzzle she was doing (OK, > it needed *some* more work, but I found it to be a great effort). > > Come in on, and ask lots of questions! > > Greg Lindstrom > Acxiom Corporation, mail: CWY10011149 > InfoBase Products Development office: (501) 342-1626 > 301 Industrial Blvd, Conway, AR, 72032 fax: (501) 336-3911 > email: Greg.Lindstrom at acxiom.com > > "When the solution is simple, God has spoken" > > Albert Einstein > > > > -----Original Message----- > From: wyatt stafford [mailto:wyatts at onr.com] > Sent: Friday, July 13, 2001 11:33 AM > To: python-list at python.org > Subject: greenbeen seeks advice > > > Preamble: > > I am a computer/network support person who has decided to start programming > for a vocation (no previous experience beyond minor scripting, etc). After > some research I selected Python as a good place to start. I bought "Learn > to Program using Python" (Gauld) and "Quick Python" (Harms/McDonald). Also > checking out the tutorial, and other good info at www.python.org. I have > a leaping, intuitive learning style given to missing the obvious, so I am > concerned about having fatal gaps in my learning via home schooling plan. > > Questions: > > Beyond those mentioned above, may I have any recommendations for self study > resources (books, etc) or techniques that will help me be a good programmer, > in general? > > Do I need to know what is taught in CompSci 101/102/etc, to be great? > > thanks and happy weekend to all, > wyatt > > "Oh, that's not what I call bingeing" > > > > > From akuchlin at mems-exchange.org Thu Jul 12 10:18:22 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 12 Jul 2001 10:18:22 -0400 Subject: Pickle translation References: <jtr8vncn38.fsf@wazor.biostat.wisc.edu> <Bl237.4856$z21.493441@newsc.telia.net> <jtn16bchrx.fsf@wazor.biostat.wisc.edu> <mailman.994887559.21749.python-list@python.org> Message-ID: <3d3d82qlht.fsf@ute.cnri.reston.va.us> Skip Montanaro <skip at pobox.com> writes: > Interpretation of \x escapes was tightened up in 2.0 I believe. In versions > earlier than 2.0 '\xyy' is interpreted as the four-character sequence: > > \ x y y > > In 2.0 and 2.1 the ValueError you see is raised because "yy" can't be > interpreted as a hex number. But shouldn't pickle have been writing octal escapes in versions before 2.1? It shouldn't be generating \x escapes at all, I think. Perhaps the best way to debug this would be to send the pickle file to someone at Python Labs and have them dig into the problem. --amk From paul at boddie.net Thu Jul 12 05:13:50 2001 From: paul at boddie.net (Paul Boddie) Date: 12 Jul 2001 02:13:50 -0700 Subject: connecting to Oracle database References: <mailman.994917679.17455.python-list@python.org> Message-ID: <23891c90.0107120113.4d1c1607@posting.google.com> reddykkk at yahoo.com wrote in message news:<mailman.994917679.17455.python-list at python.org>... > hi all, i am learning Pyhton now. I am facing problems in connecting > to Oracle database. plz guid me how to start with. First, check out the Vaults of Parnassus for Oracle modules: http://www.vex.net/parnassus/apyllo.py?find=Oracle I would look at cx_Oracle and DCOracle first. If you can use ODBC (not usually the case with Oracle as standard, if I remember correctly), then try mxODBC: http://www.lemburg.com/files/python/mxODBC.html Then, take a look at this interesting article about the Python's Database API: http://www.amk.ca/python/writing/DB-API.html And look at the Python database topic guide index for more details: http://www.python.org/topics/database/ Have I got you started now? ;-) Paul From aahz at panix.com Sat Jul 14 23:16:06 2001 From: aahz at panix.com (Aahz Maruch) Date: 14 Jul 2001 20:16:06 -0700 Subject: Is this a true statement: Part III References: <9hsckg$4rt$1@taliesin.netcom.net.uk> <9hsmh1$gtt$1@panix2.panix.com> <86vgkx3c49.fsf@hellcat.itga.com.au> Message-ID: <9ir1tm$3rp$1@panix2.panix.com> In article <86vgkx3c49.fsf at hellcat.itga.com.au>, Gregory Bond <gnb at itga.com.au> wrote: >aahz at panix.com (Aahz Maruch) writes: >> >> The contractor chose to use C++. The DLL that was >> delivered failed miserably in following the spec > >Surely that says much more about the quality of the contractor than >the language they chose to use? Overall, yes, but you've lost the context: my point was that a person (me) who did not know C very well was able to recode that DLL correctly in about a week. I would *not* have been able to fix or rewrite the code using C++; that's an indicator of the complexity of C++. -- --- 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 "How come we choose from just two people for President but more than 50 for Miss America?" --AEN From gustafl at algonet.se Sun Jul 8 19:42:11 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 8 Jul 2001 23:42:11 GMT Subject: Empty sys.path[0] References: <mailman.994518012.886.python-list@python.org> <Xns90D7B5DD9220gustaflalgonetse@194.213.69.148> <3B473741.2BE14CB0@engcorp.com> Message-ID: <Xns90D9116ADA12Bgustaflalgonetse@194.213.69.148> Peter Hansen <peter at engcorp.com> wrote: >I think you mean the "sys" module above, not the "os" module. Yes, sorry. >and you run it from another directory (e.g. 'python c:\windows\test.py' >or 'python /tmp/test.py' what do you get? I made this script: import sys print sys.path[0] And here I run it from another directory: E:\>python e:\test\syspath.py e:\test That works. Now I run it from the same directory, but still with the full path: E:\test>python e:\test\syspath.py e:\test That works too, but look here when I run it with only the filename: E:\test>python syspath.py Nothing! This is the problem I have. It think the second and third case ought to mean the same. Regards, Gustaf Liljegren From coy.krill at verizon.net Wed Jul 25 13:43:10 2001 From: coy.krill at verizon.net (Coy Krill) Date: Wed, 25 Jul 2001 10:43:10 -0700 Subject: A few things :) References: <mailman.996068624.2375.python-list@python.org> Message-ID: <9jn0fn$6bdr$1@ID-59852.news.dfncis.de> I love Python because I'm dyslexic. I've programmed in BASIC, Pascal, C, RPG III/IV, CL, C++, and Python for a living over the past 12 years. Of all those languages Python is the easiest for me to sit down, read and follow what's going on. Looking at dumped dicts or lists of lists and/or tuples is straining, but luckily I don't do that too often. Also one the upside is the great cross-platform support (I use Linux almost exclusively, my wife runs Windows, and my son runs Linux and Mac OS.) Coy Lee Nutter wrote: > Also, I was just wondering, Why do you use python? To me its a hobby. > Why do some of you use it over other languages? I love the language, > don't get me wrong, I was just curious :) > > Thanks, From gustav at morpheus.demon.co.uk Sat Jul 28 15:20:05 2001 From: gustav at morpheus.demon.co.uk (Paul Moore) Date: Sat, 28 Jul 2001 20:20:05 +0100 Subject: FEEDBACK WANTED: Type/class unification References: <cp66cd12yp.fsf@cj20424-a.reston1.va.home.com> Message-ID: <8f36mtobhpll7f3qheja51v43oickn7q87@4ax.com> On Sat, 28 Jul 2001 15:35:44 GMT, Guido van Rossum <guido at python.org> wrote: >If there's anyone who believes the type/class unification should not >become a feature in Python 2.2, please speak up now or forever hold >your peace... (But I'd rather you speak up!) There's a risk that all you get is negative comments, so I'll add mypositive vote here - I love the new type/class stuff. I don't have a large body of code in existence, and in particular, I don't tend to do anything subtle which might be bitten by this, so I'm not a good test of backward compatibility issues, but I can see cases where I would use the new fetaures - so my vote is "yes". >I realize the PEPs aren't done yet, but I believe that the separate >introduction I wrote goes a long way towards explaining type/class >unification. Read it here: > > http://www.python.org/2.2/descrintro.html This is a good introduction, as it treats all of this as user-level features, and not as wizard-level "black magic". It encouraged me to try some of the features. One point - the "get/set method" stuff was quite a surprise to me. It's *not* something I would see as a consequence of class/type unification, but it is very welcome. It seems much nicer approach (in the cases where it's appropriate) than __getattr__ and __setattr__ hooks, in those cases where it's appropriate. >Any questions, don't hesitate to ask. Just DON'T CHANGE THE THREAD >TOPIC. I don't have time to read the entire newsgroup (I tried this >week, and I didn't get to anything else :). A "gentle introduction" to the metaclass stuff would also be nice. However, I suspect that this is an area which is too deep to allow much simplification... On the other hand, some relatively simple examples, maybe in the standard library, or alternatively in the distribution somewhere (and referenced in the documentation) would be good - maybe (meta)classes like the ones in the "Metaclasses in Python 1.5" article (enum.py, trace.py, etc). Hope this is useful feedback, Paul. From kragen at dnaco.net Mon Jul 2 12:56:36 2001 From: kragen at dnaco.net (Kragen Sitaker) Date: Mon, 02 Jul 2001 16:56:36 GMT Subject: Is this a true statement: Part II References: <9hiifr$sjs$1@taliesin.netcom.net.uk> <mailman.993843346.4433.python-list@python.org> <fFD%6.19908$zT1.1099537@e420r-atl3.usenetserver.com> <slrn9jvibr.is.grante@tuxtop.visi.com> Message-ID: <8J107.28607$zT1.1545790@e420r-atl3.usenetserver.com> In article <slrn9jvibr.is.grante at tuxtop.visi.com>, Grant Edwards <grante at visi.com> wrote: >On Sun, 01 Jul 2001 11:17:31 GMT, Kragen Sitaker <kragen at dnaco.net> wrote: > >>>You could write an operating system that could only be directly >>>programmed in Python. >> >>I'm not sure how. Nobody has yet come up with an operating system that >>could only be directly programmed in C, or Lisp, or Algol, or Java, >>despite implementing operating systems in all four. > >Weren't Symbolics machines circa 1980 directly programmable >in Lisp? No, they just had an instruction set that was well-suited to implementing Lisp, and a Lisp implementation with enough low-level features that you could write device drivers in it. -- <kragen at pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/> Perilous to all of us are the devices of an art deeper than we possess ourselves. -- Gandalf the White [J.R.R. Tolkien, "The Two Towers", Bk 3, Ch. XI] From guido at zope.com Tue Jul 31 19:09:43 2001 From: guido at zope.com (Guido van Rossum) Date: Tue, 31 Jul 2001 19:09:43 -0400 Subject: 2.2 features In-Reply-To: Your message of "Tue, 31 Jul 2001 14:28:05 CDT." <15207.1733.965818.91745@beluga.mojam.com> References: <mailman.996258542.15795.python-list@python.org> <cpwv4u16rx.fsf@cj20424-a.reston1.va.home.com> <mailman.996270412.11895.python-list@python.org> <cpofq524lr.fsf@cj20424-a.reston1.va.home.com> <slrn9m61bs.atb.quinn@retch.ugcs.caltech.edu> <slrn.pl.9m6a5m.kmu.qrczak@qrnik.zagroda> <cpae1lzio7.fsf@cj20424-a.reston1.va.home.com> <15206.48884.18637.676324@beluga.mojam.com> <200107311705.NAA16444@cj20424-a.reston1.va.home.com> <15206.61485.360973.566871@beluga.mojam.com> <200107311904.PAA17115@cj20424-a.reston1.va.home.com> <15207.1733.965818.91745@beluga.mojam.com> Message-ID: <200107312309.TAA17435@cj20424-a.reston1.va.home.com> > >> I guess I'm confused, but if isinstance(x, type) is true isn't > >> issubclass(x.__class__, type) also true? > > Guido> You are indeed confused. :) > > Guido> Seems you confuse isinstance(x, y) with issubclass(x, y). These > Guido> are very different. x in y can map to at most one of these (for > Guido> y a type object). > > Here's an example that makes concrete what I was thinking: > > >>> class Foo: > ... pass > ... > >>> class Bar(Foo): > ... pass > ... > >>> x = Bar() > >>> isinstance(x, Foo) > 1 > >>> issubclass(Bar, Foo) > 1 > >>> issubclass(x.__class__, Foo) > 1 > > Why can't the "in" operator grok all three of these possibilities? > > x in Foo same as isinstance(x, Foo) > Bar in Foo same as issubclass(Bar, Foo) > x.__class__ in Foo same as issubclass(x.__class__, Foo) > > I assume x can't be both an instance and a class at the same time. Ah, but there you're wrong. Classes are also instances (of the metaclass), and when we don't know anything about an object X, after knowing that "X in Foo" is true, we would still not know whether X was a Foo subclass or a Foo instance. Very different beasts. This kind of confusion comes up a long when you get too close to metaclasses (that's why explaining anything about metaclasses is so difficult). Languages with a prototype model instead of a class/instance model don't have this, but they have other issues... --Guido van Rossum (home page: http://www.python.org/~guido/) From tundra at tundraware.com Sun Jul 29 21:02:20 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 30 Jul 2001 01:02:20 GMT Subject: Timezone References: <3B64B098.2146ECEB@cs.utwente.nl> Message-ID: <3B64B1B7.A4EB7CB8@tundraware.com> Richard van de Stadt wrote: > > I run stuff on systems in various timezones. > I need to display when certain files have been updated. > ctime (time()) shows the current date and time, but without the timezone > that you get to see e.g. by Unix' date command. > > Is there a (Python) way to find out the timezone? > > Richard. import time time.tzname ...will return a tuple containing the strings which name the timezone time.timezone ...will return the offset from UTC in seconds -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From rnd at onego.ru Thu Jul 19 13:27:20 2001 From: rnd at onego.ru (Roman Suzi) Date: Thu, 19 Jul 2001 21:27:20 +0400 (MSD) Subject: PEP: Defining Python Source Code Encodings In-Reply-To: <3B56A4FB.104CBCBB@lemburg.com> Message-ID: <Pine.LNX.4.30.0107192125060.1335-100000@rnd.onego.ru> On Thu, 19 Jul 2001, M.-A. Lemburg wrote: >If the performance hit is noticable, we could look into optimizing >the setup for files which don't use the magic comment. I'd rather >leave this to after the implemenation. Maybe it is good idea to specify how much slow-down we allow for such things beforehand? Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Thursday, July 19, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "The bigger they are, the harder they hit you." _/ From tim at digicool.com Tue Jul 24 14:55:53 2001 From: tim at digicool.com (Tim Peters) Date: Tue, 24 Jul 2001 14:55:53 -0400 Subject: real-accurate, numpy...increased precision help In-Reply-To: <9jj0bl$9mq@dispatch.concentric.net> Message-ID: <BIEJKCLHCIOIHAGOKOLHOEJGCDAA.tim@digicool.com> [Bryan Webb] > I need to be able to work with numbers up to 2^800 in a floating point > envirnoment. I would like an increase of precision over std floats. ... Your best bet at this time is to look into Marc-Andre Lemburg's wrapping of GMP for Python: http://www.lemburg.com/files/python/eGenix-mx-Extensions.html#mxNumeric GMP supports arbitrary-precision floats. > ... > Should I use real-accurate, Probably not, but you'll find that out quick enough <wink>. > or numpy Not even relevant. From db3l at fitlinxx.com Thu Jul 5 22:35:04 2001 From: db3l at fitlinxx.com (David Bolen) Date: 05 Jul 2001 22:35:04 -0400 Subject: Is Python Dead? References: <MNS%6.355$Xs4.225014@news.pacbell.net> <458b194a.0107050711.72007607@posting.google.com> Message-ID: <u3d8awzs7.fsf@ctwd0143.fitlinxx.com> rcena at epcor.ca (Resty Cena) writes: > I, too, have been following Python since 1996, waiting all the while > to make it easy for me to do database programming. What I'd call good > database support is where I download a file or set of files into a > directory under my Python directory, perhaps run an install program, > then start Python, import a package, issue a command to connect to > Oracle, and start playing around with the scott/tiger database. I > don't want, nor do I have the time, to compile anything, nor muck > around with the Windows registry, nor manually set paths -- I just > want to try the product, not install it for production use. Ideally, > I'd like the IDE to do this for me. I'm a database programmer, and I > want to write applications right away. I'm also lazy and I expect much > from my tools. BTW, this doesn't cover the whole universe (which is complicated enough), but since you mentioned it - under Windows, what you want is pretty much how I perceive the state of affairs, using mxODBC. All I did was download it, unzip it (or install it for the newer versions) and I was done. I could connect to any of my existing data sources (via ODBC) just as with any of my other database access mechanisms in that environment. No recompiling, no special settings or anything. True, that's ODBC based, but that seems pretty standard for all the other access mechanisms I've used under Windows. I'm sure with other environments with direct client libraries per-database there's more complexity, and I can't directly address Python's state of affairs there. -- -- 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 bokr at accessone.com Sun Jul 1 20:58:34 2001 From: bokr at accessone.com (Bengt Richter) Date: Mon, 02 Jul 2001 00:58:34 GMT Subject: Is this a true statement: Part II References: <9hiifr$sjs$1@taliesin.netcom.net.uk> <mailman.993843346.4433.python-list@python.org> Message-ID: <3b3fb024.800984514@wa.news.verio.net> On Fri, 29 Jun 2001 12:33:48 -0700, Paul Prescod <paulp at ActiveState.com> wrote: [...] > >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). > I would add that programs have a life before coding (or generally should, though Python tempts mightily ;-). They first exist as a need, often in the mind of a non-programmer (who nevertheless may be pretty astute about needs IRL ;-) So part of the evaluation of a language, IMV, has to be in terms of how well it serves the process of conceiving and implementing a program serving the original needs, not to mention the usual about others (and yourself later) being able to understand and maintain the code. A programming language serves partly as a thinking language of sorts. If you've never heard of the STL, you're not likely to think of a solution using its features (except insofar as you might reinvent some independently). Python is a winner in providing a simple and powerful mix of capabilities, ISTM. As a (Python) newbie, I've yet to use Python for anything "real" but I find myself using it all the time now as a handy tool for Q&D stuff (which comes out less "D" ;-). And I'll actually do stuff I wouldn't have had the time to do in C or even C++. The development environment is also VERY important. E.g., I like Delphi for GUI development, MSVC++ IDE for debugging C++ (even when I am writing C++ for Linux or BSD and have to go to the extra trouble of #ifdef WIN32's etc.), Perl for its regular expressions (and surprising speed in that department), and flex for the ease of defining a text parser. Python is growing on me very fast, since it provides so much power so simply and safely. And the community seems friendly, which counts. Makes we want to contribute one of these days. I just wonder how people have time to read and post so much, especially the core people who must be insanely busy anyway. [...] From gerson.kurz at t-online.de Fri Jul 6 14:36:48 2001 From: gerson.kurz at t-online.de (Gerson Kurz) Date: Fri, 06 Jul 2001 18:36:48 GMT Subject: Here is howto: Exporting a Class from a .pyd References: <3b4474a8.4155281@news.t-online.de> <u66d6wzyk.fsf@ctwd0143.fitlinxx.com> Message-ID: <3b460288.6895812@news.t-online.de> Task: export a class from a .pyd 1) Forget about boost.org, it contains horrible C++ code like this: .... namespace boost { namespace python { namespace detail { struct function::type_object:singleton<function::type_object, callable<boost::python::detail::type_object<function>>>{ type_object() : singleton_base(&PyType_Type) {}}; ... And that was the readable bit of it. 2) In the initXYZ() routine, store a pointer to the module object returned, e.g. PyObject* my_module; my_module = Py_InitModule4( "SampleClass", SampleClass_methods, SampleClass_docstring, NULL, PYTHON_API_VERSION ); 3) Create some methods. Here is one: static PyObject* func_SampleMethod( PyObject* self, PyObject* args ) { return PyInt_FromLong(42); } 4) Create a class object. Its not documented, and the header says /* Revealing some structures (not for general use) */ but I'm not in the military so I guess it is for my use, anyway. static PyObject* func_SampleClass( PyObject* self, PyObject* args ) { // name of the class PyObject* pName = PyString_FromString( "SampleClass" ); // Create the __dict__ of the class. This example just adds a // single method copied from the global module dict. PyObject* pDict = PyDict_New(); PyObject* pModuleDict = PyModule_GetDict(my_module); PyDict_SetItemString(pDict,"SampleMethod", PyDict_GetItemString(pModuleDict,"SampleMethod")); return PyClass_New( NULL, pDict, pName ); } The NULL paramter could be replaced by a tuple of base classes. Note that this function will create a *class* object, not an instance object. 5) In Python, do things like import SampleClass s = SampleClass.SampleClass() print type(s), dir(s) o = s() print o.SampleMethod() Ah, I love python ! From new_name at mit.edu Mon Jul 16 10:46:54 2001 From: new_name at mit.edu (Alex) Date: 16 Jul 2001 10:46:54 -0400 Subject: Structuring packages References: <3B52CFF4.84AFD40D@ccsr.cam.ac.uk> Message-ID: <etdpub1q6ch.fsf@quiche-lorraine.mit.edu> Could you ask a more specific question? Alex. From jdavis at empires.org Wed Jul 25 21:24:22 2001 From: jdavis at empires.org (Jeff Davis) Date: Fri, 27 Jul 2001 00:52:22 +2328 Subject: weakref module in debian package Message-ID: <w2987.5367$tt4.249516@news.pacbell.net> I can't 'import weakref', I simply don't have the module. I don't really know why, since I just installed the debian package for python2.0. If someone knows why it's not bundled, let me know. Isn't it part of the standard python2 library? Thanks, Jeff Davis From sholden at holdenweb.com Wed Jul 11 15:58:10 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 11 Jul 2001 15:58:10 -0400 Subject: shortest match regexp operator anyone? References: <yv266cz4aom.fsf@lionsp093.lion-ag.de> Message-ID: <Za237.15199$vA6.833926@e420r-atl1.usenetserver.com> "Harald Kirsch" <kirschh at lionbioscience.com> wrote in ... > > SHORT STORY: > Does anyone know of a regular expression library which has an operator > that forces a subexpression to insist on its shortest match, even if > that ruins the overall match? > > LONG STORY: > > Look how different the following tasks are, although they look so > similar. > > 1) TASK: Find the first 'A' and match, if it is followed by a 'B'? > SOLUTION: '^[^A]+AB' > > 2) TASK: Find the first '<A>' and match, if it is followed by a 'B' > SOLUTION: ??? > > An approximation for (2) is '^[^<>A]+<A>B', but it does not match > 'A<A>B', which it should. > > With non-greedy matching, another approximation is '^.*?<A>B', however > this matches 'xx<A>y<A>B', although it should not. > > The third approximation is '^(.*<A>){1,1}?B' and the Tcl's manual page > `re_syntax' seems to indicate that '{1,1}?' forces a subexpression on > a shortest match. However the `?' indicates `non-greedy' which only > means that the `shortest match not ruining an overall match' is taken > and not the `shortest match!' > > The solution would in fact be a *shortest match operator*. For the > sake of discussion let it have postfix syntax like `*' and be written > as `%'. The solution for (2) would be '^(.*<A>)%B' which would *not* > match the string 'xx<A>y<A>B' since the shortest '.*<A>' found is not > followed by 'B'. > > Again the question: Is there a re-library with a true shortest match > operator? > > REMARK: The implementation would be rather simple since it suffices to > delete all outgoing transitions from stop states of the automaton > equivalent to the subexpression. > Had you thought about using lookahead assertions, which don't actually match anything, but fail unless the specified pattern is (or, for a negative lookahead assertion, is not) present? Combined with non-greedy matching this might get you where you want to be. regards Steve -- http://www.holdenweb.com/ From bsass at freenet.edmonton.ab.ca Wed Jul 4 14:42:48 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Wed, 4 Jul 2001 12:42:48 -0600 (MDT) Subject: Not enough Python library development [was PEP scepticism] (fwd) Message-ID: <Pine.LNX.4.33.0107041241390.7776-100000@bms> On Tue, 3 Jul 2001, Grant Griffin wrote: > Roman Suzi wrote: > > > ... > > CPyAN is much more complex task, because there are: > ... > > I think the problem here might be one of marketing, combined with a lack > of corporate sponsorship. To that end, I propose this resource be > called "Python Program Archive Network", or PyPAN, for short. That might > help it attract funding from Mrs. Smith's and Sara Lee. (Heck, if > nothing else, maybe those ladies can contribute something tasty to the > Python Cookbook.) > > <sorry> > > Seriously, folks, I never was a big fan of CPAN: in fact, for me, it was > just another part of my overall poor user-interface experience with Perl > <wink>. Although CPAN is impressive in terms of sheer girth, the CPAN > concept seemed to encourage large interdependencies between modules. > Although this seems like good thing in some ways (because it indicates a > lot of software reuse), I found it nightmarish to install even fairly > simple packages. (I never could get the automatic CPAN installer gizmo > to work well--at least without giving it a great deal of manual help.) This sounds like what I've heard about the RH `contributions' archive... I don't think it reflects on archives in general, just those that don't bother to maintain controls or enforce standards. If, on the other hand, you make contributors jump through some hoops, and do not allow submissions from anonymous contributors or those that do not meet strict standards... it might work, and be useful... even to those of us that already have a decent archive backing up our OS. > Having a very large standard library seems a better solution. (Of > course, Perl also comes with a large standard library.) I never seem to > have large cross-package dependency problems with Python; my experience > has been that nearly all packages require zero or one other packages. > Presumably, this is a fortunate aftertaste of the fact that PyPAN is > still just a half-baked idea. "seems" being the key word, one person's "large" is another's "huge and filled with stuff that don't run on my box". > But maybe an increasingly large standard library isn't totally > practical. An alternative that I think would be very helpful is > "application-targeted" distributions. For example, someone could make a > "Numeric" bundle of Python, including NumPy and related modules; > likewise, there could be a "webmaster" bundle. Of course, this takes a > lot of time and effort for somebody to create and maintain. > (ActiveState folks, are you listening?--given that you somehow make > money by giving away software, the more software you give away, the more > money you'll make <wink>.) ...the above paragraph describes what Debian's task packages do. It works because it is backed up by a well controlled archive of packages that meet a set of minimum standards... ...ANYTHING less is just asking, no - begging, for trouble. As much as I am in favour of turning Python into a packaged distribution -- if it is not top notch, don't bother. - Bruce From juergen.erhard at gmx.net Fri Jul 27 05:46:42 2001 From: juergen.erhard at gmx.net (=?ISO-8859-1?Q?=22J=FCrgen_A=2E_Erhard=22?=) Date: Fri, 27 Jul 2001 11:46:42 +0200 Subject: Future division patch available (PEP 238) In-Reply-To: <m15PKAC-000wcBC@swing.co.at> (tanzer@swing.co.at) References: <m15PKAC-000wcBC@swing.co.at> Message-ID: <27072001.2@wanderer.local.jae.dyndns.org> >>>>> "Christian" == Christian Tanzer <tanzer at swing.co.at> writes: [snipperoonio... lots of interesting stuff about real-life and seemingly highly dynamic Python deployments] Christian> To be honest, for TTTech design databases the change in Christian> division probably doesn't pose any problems. Due to Christian> user demand, the tools coerced divisions [in Christian> customer-written code] to floating point for a long Christian> time. "Due to customer demand"... well, seems to me you have given great support to PEP 238 with this. ;-) Bye, J PS: No, I'm not seeing you in the (raving) anti-PEP-238 camp, Christian. Your post was much too level-headed for this confusion to happen. ;-) -- J?rgen A. Erhard (juergen.erhard at gmx.net, jae at users.sourceforge.net) My WebHome: http://members.tripod.com/Juergen_Erhard "Those who would give up essential Liberty, to purchase a little temporary Safety, deserve neither Liberty nor Safety." -- B. Franklin -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 248 bytes Desc: not available URL: <http://mail.python.org/pipermail/python-list/attachments/20010727/f3355a9f/attachment.sig> From gerhard.nospam at bigfoot.de Tue Jul 17 17:20:47 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Tue, 17 Jul 2001 23:20:47 +0200 Subject: Python 2 times slower than Perl References: <8f41cfd.0107171238.6ff33b9b@posting.google.com> Message-ID: <slrn9l9930.95t.gerhard.nospam@lilith.hqd-internal> On 17 Jul 2001 13:38:12 -0700, Xu, C.S. <xucs007 at yahoo.com> wrote: >I just compared the speed of Python, Perl, Java, C >to do simple numerical calculations. Python is the >slowest: took 150 times of time than C, Perl about >60 times, Java is 4.5 times. > >The source code of Python is: (Other source are >similar, all use while loop): > >#!/usr/bin/env python >i = 2.5; >while i < 1e7: > j = 2.5 * 2.5 > i += 1 >print i, j A JIT will surely eliminate the line "j = 2.5 * 2.5", as it is just a no-operation. Perhaps Python doesn't, while Perl does? Gerhard -- mail: gerhard <at> bigfoot <dot> 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, [chr(ord(x)^42) for x in list('zS^BED\nX_FOY\x0b')]) From not.this at seebelow.org Fri Jul 6 15:31:29 2001 From: not.this at seebelow.org (Grant Griffin) Date: 6 Jul 2001 12:31:29 -0700 Subject: Comment on PEP-0238 References: <mailman.994427714.26169.python-list@python.org> <cpsngaja4g.fsf@cj20424-a.reston1.va.home.com> Message-ID: <9i53mh01c10@drn.newsguy.com> In article <cpsngaja4g.fsf at cj20424-a.reston1.va.home.com>, Guido says... > >I currently favor div(x, y) over x//y and x div y. Maybe also add >mod(x, y) for symmetry (that would also explain divmod() as a >messenger from the future :-). Messages from Guido's Time Machine sure are appealing, but I doubt that "divmod" is actually used much, so maybe symmetry of the others with that doesn't matter much. (Coincidentally, I just discovered "divmod" in "Python Pocket Reference" 10 minutes before reading this!--when I was enjoying special "small book daily reading time".) I guess I favor the operator format ("x div y", "x mod y") over the function format ("div(x, y)", "mod(x, y)"). The operator format seems to read better (more like "x / y"), and it matches other languages, like C, where these operator thingies are expressed in operator format (albiet by a symbol: "/" and "%".) If the operator style wins out, divmod might either be turned into an operator, or left alone. all-things-being-equal,-do-it-like-C-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 sill at optonline.net Sun Jul 29 09:14:36 2001 From: sill at optonline.net (Andrei Kulakov) Date: Sun, 29 Jul 2001 13:14:36 GMT Subject: Colon and underscores References: <39506f84.0107280205.1638011@posting.google.com> <slrn9m5r4n.2ue.sill@sill.silmarill.org> <L6H87.69279$Xr6.307583@news-server.bigpond.net.au> Message-ID: <slrn9m82pr.de.sill@sill.silmarill.org> On Sat, 28 Jul 2001 22:35:23 GMT, Neil Hodgson <nhodgson at bigpond.net.au> wrote: > Andrei Kulakov: > >> Besides, editors detect that : and autoindent for you. Imagine for > instance >> that you are 5 levels of indentation to the right, if there were no colons >> you'd have to hit enter and then <tab> 5 times! No thanks :P > > Editors can also detect that you started the line with a structuring > keyword (if, def, ...) and indent. The colon is really only needed when you > want to place the body on the same line: Well, it's easier for an editor to check if the line ends in ':' than check for several keywords and check if they're in a string or not.. If we had one editor everybody used, it wouldn't be a big deal, but with hundreds of editors out there, this is a consideration.. But I agree, readability is more important here. I didn't mention it because to the original inquirer, it doesn't seem more readable.. so I gave him a firm, objective reason instead :-). > > if a: b = 1 > > I'd be happy to see Python without the colons at the end of lines but its > no big deal. > > Neil def isn't absolutely required, either.. parser could detect difference between do_stuff() [...] and do_stuff() [...] But def is a good visual cue.. for me, at least. > > > -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: http://silmarill.org/cymbaline From s.ostring at ccsr.cam.ac.uk Tue Jul 17 07:57:13 2001 From: s.ostring at ccsr.cam.ac.uk (Sven =?iso-8859-1?Q?=D6string?=) Date: Tue, 17 Jul 2001 12:57:13 +0100 Subject: Calling C++ objects Message-ID: <3B542819.955186A2@ccsr.cam.ac.uk> Is there an interface for calling C++ classes in Python, with access to class members and methods? Thanks, Sven. From guido at python.org Sun Jul 1 09:49:30 2001 From: guido at python.org (Guido van Rossum) Date: Sun, 01 Jul 2001 13:49:30 GMT Subject: PEP scepticism References: <mailman.993747643.21070.python-list@python.org> <9hfqb5$dsllb$3@ID-89274.news.dfncis.de> <3dhex01n1m.fsf@ute.cnri.reston.va.us> <cphewzlbis.fsf@cj20424-a.reston1.va.home.com> <9hlcp4$eiphi$2@ID-89274.news.dfncis.de> Message-ID: <cppubkkbhf.fsf@cj20424-a.reston1.va.home.com> bernhard at intevation.de (Bernhard Reiter) writes: > Having started the topic I cannot remember the original point > having been made ever before. It sounded to me like the usual complaint that Python was acquiring too many new features. We've gone through endless rounds of that with Python 2.0 and 2.1. > And I explicitly wrote that I did not want to discuss the advantages > and disadvantages of certain features again. :) So I didn't. --Guido van Rossum (home page: http://www.python.org/~guido/) From 18k11tm001 at sneakemail.com Thu Jul 5 04:10:47 2001 From: 18k11tm001 at sneakemail.com (Russ) Date: 5 Jul 2001 01:10:47 -0700 Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> <bebbba07.0107021206.70a22aa8@posting.google.com> <20010702175245.A4092@node0.opengeometry.ca> <mailman.994201507.10872.python-list@python.org> Message-ID: <bebbba07.0107050010.8a47cf1@posting.google.com> "Ken Seehof" <kens at sightreader.com> wrote in message news:<mailman.994201507.10872.python-list at python.org>... > For liability reasons, I can't give you advice on whether or not to > use python for an air traffic control application :-) > > However, if I were (hypothetically, of course) to give you advice, > it would be the following, of which your reading constitutes an > agreement that I am not responsible for injury, deaths, and property > damage resulting from that which would be my advice, were it not, > if fact, hypothetical, which it is. If you hear something about an airplane crash in a few years, prepare for a call from my lawyer. :-) > Seems to me that python would be a good choice. You can write > bugs in any language, including python. However, python bugs > tend to be less subtle and easier to detect and fix than C/C++ bugs. > > The lack of type checking and function prototyping is not nearly as > big of a problem (if it's a problem at all) as C++ programmers tend > to fear. > > This fear is due to the fact that in some statically typed languages > such as C++, an undetected type mismatch is likely to cause rather > horrible bugs which are often intermittent and often corrupt unrelated > data. > > These kinds of type mismatch bugs that C++ programmers are > terrified of (memory overwrites, etc.) simply do not exist in python at > all. Python doesn't ever need to infer the addresses of bytes of data > from dubious type information at runtime (as C++ does). Type > information is always stored within the objects themselves. > > In python, data of the wrong type is not really any worse than data > of the wrong value, so these kinds of bugs tend to only have local > effects which are easily caught when tested. Not surprisingly, I have > found that I usually get fewer type related bugs in Python than in C++. > > Saying that python is unreliable because it lacks type checking is like > saying fish cause pollution because they lack bicycles. > > - Ken That's very interesting. Thanks for that perspective. I'd like to see you hash this out with Peter Milliken, who claims that type checking is essential for safety-critical applications. (Perhaps you did already. I'm using google groups, and I get very slow updates on this thread.) Russ From tim at digicool.com Thu Jul 5 14:27:20 2001 From: tim at digicool.com (Tim Peters) Date: Thu, 5 Jul 2001 14:27:20 -0400 Subject: There's got to be an easy way to do this In-Reply-To: <9i27i8$gd9bq$1@ID-11957.news.dfncis.de> Message-ID: <BIEJKCLHCIOIHAGOKOLHOEBGCCAA.tim@digicool.com> [Lindstrom Greg] > I am reading in a phone number field and would like to throw away > everything except the digits. Simplest: >>> def isdigit(c): ... return c in "0123456789" ... >>> filter(isdigit, "(555) 333.2221") '5553332221' >>> Fastest: Read the docs for string.translate(); set it to do identity (i.e., no) translation, and pass everthing *except* digits in its optional third ("delete these") argument. From mcherm at destiny.com Thu Jul 12 16:13:03 2001 From: mcherm at destiny.com (mcherm at destiny.com) Date: Thu, 12 Jul 2001 15:13:03 -0500 Subject: Version incomptabilities, code changes, __future__, etc Message-ID: <8479da10.da108479@destiny.com> > mcc> This "bon mot" needs more clarification. > I think the only clarification it needed was > ;-) > or > <wink> > <wink> Yes... I forget, sometimes, that you'll fool a few people (just by accident) if you're not careful. -- Michael Chermside From cjc26 at nospam.cornell.edu Tue Jul 31 21:46:35 2001 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Wed, 01 Aug 2001 01:46:35 GMT Subject: int() built-in and hex "0x..." strings References: <20010723.110751.1143408282.18374@troikanetworks.com> Message-ID: <%bJ97.180682$T97.21560301@typhoon.nyroc.rr.com> Ooops, sorry about the last post, my news reader is being funny and keeps showing me articles from July 22-23 as being new for some reason... * Bruce Edge <bedge at troikanetworks.com> menulis: | I can't believe this doesn't work: | | >>> int('0x80') -- Cliff Crawford http://www.sowrong.org/ A sign should be posted over every campus toilet: "This flush comes to you by courtesy of capitalism." -- Camille Paglia From aahz at panix.com Fri Jul 6 22:19:43 2001 From: aahz at panix.com (Aahz Maruch) Date: 6 Jul 2001 19:19:43 -0700 Subject: PEP: Procedure for Adding New Modules (please comment) References: <mailman.994278428.32719.python-list@python.org> <9i0231$c2e$1@newshost.accu.uu.nl> Message-ID: <9i5rjv$akf$1@panix3.panix.com> In article <9i0231$c2e$1 at newshost.accu.uu.nl>, Martijn Faassen <m.faassen at vet.uu.nl> wrote: > >This is here to make explicit a circumstance when depcrecation of >a module can be invoked; if there is no one willing to maintain it >anymore the interest is low. It is also a mild stick to be used so that >modules *will* be maintained; the integrators start mumbling about >deprecation may be a powerful incentive to any would-be maintainers (it >flushes out people motivated to maintain it :) I think this is one of the best parts of your PEP. It makes an excellent complement to PEP 4. -- --- 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 So much Astroglide. So little time. From tim.one at home.com Sun Jul 8 17:13:00 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 8 Jul 2001 17:13:00 -0400 Subject: Confusion about dictionaries - keys use value or identity? In-Reply-To: <Fk327.14800$i8.1312575@e420r-atl3.usenetserver.com> Message-ID: <LNBBLJKPBEHFEDALKOLCKEBEKNAA.tim.one@home.com> [Steve Holden] > ... > Key comparison of strings will test the lengths fisrt, and if the > lengths are the same will stop once two unequal characters are found... That's backwards. If it tested the lengths first, then e.g. "z" < "aaa" would be true. "perl"<"python"-is-true-either-way-though-ly y'rs - tim From tjenkins at nospiced.ham.devis.com Thu Jul 26 09:25:55 2001 From: tjenkins at nospiced.ham.devis.com (Tom Jenkins) Date: Thu, 26 Jul 2001 13:25:55 GMT Subject: SlightlyOffTopic: syntax-highlighting in XEmacs running on Windows References: <E%T77.147$bXi.169905152@news.telia.no> Message-ID: <3B601B45.4070107@nospiced.ham.devis.com> Thomas Weholt wrote: > Hi, > > I want to use X/Emacs to write Python-code on Windows too, but I have a > small problem with the python-mode.el. Where do I put the stuff that should > have gone into .emacs? Cannot create such a file on win32 filesystem. Why > aren't my code colorized in XEmacs 21.x using the python-mode like Emacs > under Linux, using the exact same python-mode.el-file? > > Any ideas? > > Thomas > > > Actually Thomas you can have a file named .emacs (at least under Win2k though I think you could do it in NT also) if you can't get your editor to save it as such you can always drop to the command line and do: copy con .emacs ^M <ctrl>-Z of-course-you-can-do-same-for-.vimrc<wink>-ly yours Tom From JamesL at Lugoj.Com Wed Jul 25 16:50:39 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Wed, 25 Jul 2001 13:50:39 -0700 Subject: Language change and code breaks References: <Pine.LNX.4.33.0107191316390.24983-100000@bms> <mailman.995571273.18192.python-list@python.org> <9j7gv8$9mg@dispatch.concentric.net> <cppuawfqbm.fsf@cj20424-a.reston1.va.home.com> <mailman.995734717.26373.python-list@python.org> <3B5DF101.9B2E4631@earthlink.net> <cpofq9a858.fsf@cj20424-a.reston1.va.home.com> <slrn9lubft.2qag.kamikaze@kuoi.asui.uidaho.edu> Message-ID: <3B5F311F.F09A3E32@Lugoj.Com> Mark 'Kamikaze' Hughes wrote: > > Wed, 25 Jul 2001 05:29:41 GMT in <cpofq9a858.fsf at cj20424-a.reston1.va.home.com>, > Guido van Rossum <guido at python.org> spake: > > But never mind, I'm giving up on making *Python* case-insensitive. > > The hostility of the user community is frightening. > > This baffles me; the division issue is IMO far more terrifying a > change, while case-insensitive is a mere quirk. The division issue has proven divisive. The case-insensitive issue has fostered insensitivity. <wink> From sh at ttsoftware.co.uk Fri Jul 20 11:31:34 2001 From: sh at ttsoftware.co.uk (Steve Horne) Date: Fri, 20 Jul 2001 16:31:34 +0100 Subject: Can I copy a generators state and then backtrack to it if necessary? Message-ID: <sdigltkmqv58ujun2b55jrgvbd5oec4okb@4ax.com> Can I copy a generators state and then backtrack to it if necessary? To explain what I mean, imagine the following... from __future__ import generators def test_gen (p) : for i in range (p) : yield i def use_gen (p) : i = p.copy () # or some equivalent # Do something that may accept values from p p = i # Backtrack # Do something that may accept values from p use_gen (test_gen (50)) I know that I could rewrite the use_gen function to accept a function rather than a generator, so that it would be called as... use_gen (test_gen, 50) ... and the function parameter could then be evaluated to rederive the initial generator state at any time, but this isn't really as flexible (you can't easily recreate any state other than the initial state), and it also seems less intuitive to me. A major use I could think of for this is in applications that need to balance searching by depth and by breadth according to some heuristic. In addition to the search tree so far, it would be easy to record generator states that have only identified some of the branches from a particular state - so you could explore this area of the tree depth-wise for a bit then nip-back to expand the breadth later. An obvious application would be for board games such as chess. -- Steve Horne Home : steve at lurking.demon.co.uk Work : sh at ttsoftware.co.uk From SBrunning at trisystems.co.uk Tue Jul 31 08:44:51 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Tue, 31 Jul 2001 13:44:51 +0100 Subject: simple question:the count of array Message-ID: <31575A892FF6D1118F5800600846864D78BF40@intrepid> > From: sdf [SMTP:wqh-2 at 263.net] > >>> a=['a','b','c'] > >>> b=a.count() > Traceback (most recent call last): > File "<pyshell#9>", line 1, in ? > b=a.count() > TypeError: count() takes exactly 1 argument (0 given) > >>> > > then how I get the number of a,I mean how much > values in a,in this case it should be 3 >>>b=len(a) >>>print b 3 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 loewis at informatik.hu-berlin.de Mon Jul 30 08:47:52 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 30 Jul 2001 14:47:52 +0200 Subject: Error on mimetools? References: <9k368v$a8q$1@news.uit.no> Message-ID: <j4puair3bb.fsf@informatik.hu-berlin.de> "Arnulf Heimsbakk" <arnulf at spirea.net> writes: > I'm trying to decode a mime64 message in python with mimetools. I have > tested the "body" with windows winzip. It decodes correctly. When I try to > decode it in python, it do not decode correctly. I get a file with slightly > increased size. The heading of the file seems the same, but when I test this > with a jpg file - the file gets corrupted when decoded with python's > mimetools. > > Is there a error in mimetools? Or is my approach entirly incorrect. My code > is below: > > out = StringIO() > mimetools.decode(StringIO(self.body), out, 'base64') > return out.getvalue() It very much depends on what self.body is in this context. To use mimetools.decode, you must be sure that it is the raw base64 bytes, i.e. without any headers and trailers. Regards, Martin From robin at jessikat.fsnet.co.uk Tue Jul 24 06:35:49 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Tue, 24 Jul 2001 11:35:49 +0100 Subject: Alternate numeric proposal, Take 2 References: <011901c11335$1a8c95e0$0101010a@local> <15196.29074.910090.697520@beluga.mojam.com> <mailman.995930043.12339.python-list@python.org> Message-ID: <gw7pr6AF+UX7Ewqe@jessikat.fsnet.co.uk> I'm afraid all these proposals for band aid type fixes to fundamental language changes are flawed. The danger is of copying code from one environment into the other which will silently cause problems at run time. We need to have a single well defined meaning for each element of a program. I think that Guido is utterly wrong to do this and similar changes against the expressed will of many of us. I believe that the current usage of / is 'hallowed by time' and is useful. I don't believe float division is more or less important than the truncating kind. I feel that the real problem is the lack of understanding of the great leader of the effect this will have on Python's reputation as a stable well thought out language. -- Robin Becker From smnordby at yahoo.com Fri Jul 27 21:33:54 2001 From: smnordby at yahoo.com (SteveN) Date: Fri, 27 Jul 2001 18:33:54 -0700 Subject: Language change and code breaks References: <Pine.LNX.4.33.0107191316390.24983-100000@bms> <mailman.995571273.18192.python-list@python.org> <9j7gv8$9mg@dispatch.concentric.net> <cppuawfqbm.fsf@cj20424-a.reston1.va.home.com> <mailman.995734717.26373.python-list@python.org> <3B5DF101.9B2E4631@earthlink.net> <cpofq9a858.fsf@cj20424-a.reston1.va.home.com> <A%287.1144$oc6.134253@e420r-atl3.usenetserver.com> <cpvgke2zf1.fsf@cj20424-a.reston1.va.home.com> Message-ID: <3B621682.11C08B66@yahoo.com> Guido van Rossum wrote: > Actually, it's been very tough. Years of therapy didn't prepare me > for the accusations of dictatorship. I also didn't see enough support But years of dictatorship will prepare you for ... the comfy chair! Seriously, thanks for a great language! -SteveN- From volucris at hotmail.com Mon Jul 16 04:44:37 2001 From: volucris at hotmail.com (Volucris) Date: Mon, 16 Jul 2001 03:44:37 -0500 Subject: Starting a Frame dependent on destruction of another Frame... References: <6f0b3be9.0107152232.21f297e6@posting.google.com> Message-ID: <3b52a90a$0$322$6e49188b@news.goldengate.net> "Rob Neely" <rneely at home.com> wrote in message news:6f0b3be9.0107152232.21f297e6 at posting.google.com... > I have a simple problem I'm trying to solve with Tkinter. > > When my application runs, I want a frame to pop up asking the user for > some info (a directory name). When they hit the "OK" button, I want > that frame to destroy itself, and start up another toplevel frame > which will be populated with some widgets based on what was entered in > the first frame. > > I've enclosed a very stripped down example below. If you run this > program in linux (under KDE), the only way to get to the second frame > is to close the window with the window manager (ie - clicking the "x" > in the KDE window decorations). When I run it from MS-windows - even > that doesn't work... > > Can anyone show me how I might configure the following applet so > clicking the "OK" button will destroy the frame and start up the next > frame? Or more generally - how should one set up an application where > one frame is started only after another has destroyed itself. > > I've tried as many combinations that I can think of - and this is the > closest I've gotten! > > Thanks in advance! > > --Rob > > from Tkinter import * > > class Splash(Frame): > def __init__(self, parent=None): > Frame.__init__(self, parent) > b = Button(self, text="OK", command=self.splash_done) > b.pack() > self.pack() > > def splash_done(self): > print "Clicked OK" > self.destroy() > > class Mainapp(Frame): > def __init__(self, parent=None): > Frame.__init__(self, parent) > l = Label(self, text="Main frame opened") > l.pack() > self.pack() > > Splash().mainloop() > Mainapp().mainloop() In this method, self refers to the button that called it, not the parent window. def splash_done(self): print "Clicked OK" self.destroy() All you have to do is destory the button's master (the parent window). def splash_done(self): print "Clicked OK" self.master.destroy() Cool? Cool. -- Volucris (a) hotmail.com "Eu n?o falo uma ?nica palavra do portugu?s." From cliechti at mails.ch Thu Jul 26 22:56:53 2001 From: cliechti at mails.ch (chris liechti) Date: 27 Jul 2001 04:56:53 +0200 Subject: Couple of newbie questions... References: <5a140c6d.0107261705.3a4f7db3@posting.google.com> Message-ID: <Xns90EB32FA37F9cliechtimailsch@62.2.32.50> time.sleep does give time bac to the system. just avoid value smaller that 0.03. my windows freaked out and showed processor usage on other processes when i used sleep(0.01) but larger values work as expected. chris foobarickknob at yahoo.com (Scott Taylor) wrote in news:5a140c6d.0107261705.3a4f7db3 at posting.google.com: > > 1) time.sleep doesn't seem to release time back to the Win32 > subsystem. I had a tight loop, and CPU was maxed out at 100% even if > I did a PumpWaitingMessages w/ a time.sleep. To actually get the loop > to return slices of time back to windows and not max out the CPU I had > to do a PumpWaitingMessages followed by a win32api.Sleep(0) call. My > question is - shouldn't time.sleep actually make the process sleep w/o > hogging CPU? > -- chris <cliechti at mails.ch> From JamesL at Lugoj.Com Fri Jul 20 13:18:32 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Fri, 20 Jul 2001 10:18:32 -0700 Subject: Case insensitivity References: <mailman.995647175.15752.python-list@python.org> Message-ID: <3B5867E8.6B8751F8@Lugoj.Com> Dan Bergan wrote: > (Declare the variable in mixed-case) > Dim myVariable as Integer > > (then I purposely type in the wrong case when I use 'myVariable') > myvaraible = 1 '<==TYPO! Well, if you "correct" that to myVaraible you would still be in error, because you accidentally exchanged "ia" with "ai" in addition to changing "V" to "v". Python will not inform you about about some typos, whether case-related, dropped characters, exchanged characters, or added characters. From gmcm at hypernet.com Tue Jul 31 18:51:21 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 31 Jul 2001 22:51:21 GMT Subject: importing win32com.client.Dispatch with embedded interpreter References: <fab90324.0107311204.2fffbfa4@posting.google.com> Message-ID: <Xns90EFBFDF131D1gmcmhypernetcom@199.171.54.154> [posted and mailed] Mike Haspert wrote: > The minimal function f1(), below in usecom.py, runs fine from the > command line, but when I use the C API for the interpreter, it runs > the first time and fails thereafter. Can anyone see what I'm doing > wrong? The error message "TypeError: this constructor takes no > arguments" has me stumped. [snip] > int minimal(char* modname) > { > bool success = false; > PyObject *mod,*func,*args,*rvals; > Py_Initialize(); [snip] It's got nothing to do with f1. You can't Py_Initialize() twice. - Gordon From aleaxit at yahoo.com Tue Jul 31 05:24:18 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 31 Jul 2001 11:24:18 +0200 Subject: case sensitivity redux (was Re: Language change and code breaks) References: <Pine.LNX.4.33.0107191316390.24983-100000@bms> <mailman.995571273.18192.python-list@python.org> <9j7gv8$9mg@dispatch.concentric.net> <cppuawfqbm.fsf@cj20424-a.reston1.va.home.com> <Pine.LNX.4.33.0107231434170.15565-100000@oliphant.ee.byu.edu> <532qlt453irrepptskcvp213d44r3so2e2@4ax.com> <cp4rs2qf6p.fsf@cj20424-a.reston1.va.home.com> <3B5DF282.87266DA2@earthlink.net> <cpr8v5a8h5.fsf@cj20424-a.reston1.va.home.com> Message-ID: <9k5tg301mn9@enews4.newsguy.com> (posted & mailed, just in case Guido is not following this thread any more, since this is fundamentally a message of support for his stated position...): "Guido van Rossum" <guido at python.org> wrote in message news:cpr8v5a8h5.fsf at cj20424-a.reston1.va.home.com... ... > I have changed my mind. I think that if I had to start over, I would > indeed try my hands at a case-insensitive language aimed at teaching > programming to beginners, with tools to enforce case consistency. > Given that nobody else who currently uses Python thinks this is a good > idea, Just for the record: I *am* "somebody else who currently uses Python", and I think that "this" (a case-insensitive language, with tools that enforce case consistency) is a *VERY GOOD* idea. Pity I was away during the hottest part of this debate, and even now am far from being caught up -- dislike for case sensitivity is clearly a minority position in the c.l.p community, but I'd like it to be just as clear that it's also *NOT* just you... I feel exactly the same way. One aspect I haven't seen mentioned in this huge thread is the issue of visually impaired programmers. Case sensitivity is an extra burden for such people (with whom I strongly empathize: my sight is still OK, sufficient to drive a car &c, but it's going downhill with time, and I must face the very real possibility that I'll be _seriously_ visually impaired a few years from now). Think of a useful tool for such an audience, a special-purpose 'screen reader' that will read out loud a snippet of Python code: what's the tool going to do about distinguishing upper and lower case? With case being significant, the tool will have to point out *every* case change -- a serious bother. Was case not thus significant, the tool could have two modes, a default "smoother" mode ignoring case, and a special mode pronouncing case to be used only (e.g.) within literal strings. For those of you who can't really empathize with other's issues and misfortunes, imagine being in a situation where you'd often need to have source code read out loud to you (e.g. over a phone), and/or you'd often want to dictate code (e.g. to some kind of voice-recognition, dictation-taking automatic system). What's case sensitivity giving you, that would compensate for the serious bother it causes in those situations? > I then settled on a case-sensitive language with case-preserving > tools. But now I think neither is worth fighting for. I guess that, as usual, you may well be right. But then, we're now talking basically about something like some minor changes to IDLE's source code editor, aren't we? Or to Emacs' python-mode, etc. Surely there would be no fight necessary to add a "case-preserving switch" to such tools for optional use. The only issue I can see is with modules (particularly in the standard libraries) that may _require_ a programmer to enter the same identifier in more than one different case-mix. Are there such cases today in Python's standard library? I'm not sure. Offhand, I can easily think of a few identifiers that do appear in different cases, e.g. fileinput (the module) vs FileInput (the class in module fileinput), but it would seem to me that those identifiers would not normally have to be entered with case being the *only* distinction (one would normally write fileinput.FileInput, so a reasonably smart tool might still be able to get the case right for each of the two identifiers - or is this requiring too much smarts from the tools?). Maybe, if a _small_ fight is needed to ENABLE (as opposed to FORCE:-) use of a semi-smart, case-preserving tool, it MIGHT be worth it, if the fight be small enough...? Alex From twanvds at xs4all.nl Mon Jul 9 10:57:56 2001 From: twanvds at xs4all.nl (Twan van der Schoot) Date: Mon, 9 Jul 2001 16:57:56 +0200 Subject: socket.connect timeout References: <9icas4$lvp$1@news1.xs4all.nl> <K9j27.20247$i8.1580848@e420r-atl3.usenetserver.com> Message-ID: <9icged$9a4$1@news1.xs4all.nl> Hi Steve, thanks, I've found it and I going to try it, kr Twan "Steve Holden" <sholden at holdenweb.com> wrote in message news:K9j27.20247$i8.1580848 at e420r-atl3.usenetserver.com... > "Twan van der Schoot" <twanvds at xs4all.nl> wrote in message > news:9icas4$lvp$1 at news1.xs4all.nl... > > Hi there, > > > > How do I increase the timeout period on a socket.connect()? > > A peek in the source code of the socket object does reveal anything > usefull. > > > > > > FWI: I'm using Python 2.1 from ActiveWare for WinNT (running on NT4.0SP6). > > > > thanks! > > > There's a module called timeoutsocket.py (take a look in the vaults of > Parnassus), which allows you much better control over the timeouts on your > sockets. Without this you can have problems. > > regards > Steve > -- > http://www.holdenweb.com/ > > > > > From rashotts at mn.rr.com Wed Jul 11 21:03:21 2001 From: rashotts at mn.rr.com (Russ Shotts) Date: Thu, 12 Jul 2001 01:03:21 GMT Subject: Developing Visual Studio add-ins in Python? Message-ID: <tH637.142074$R7.25090399@typhoon.kc.rr.com> Hi, Has anyone used Python to create a Visual Studio add-in? I need to perform some fairly complex processing, and their VBScript macros just cannot handle the task. Any pointers would be greatly appreciated. From cliechti at mails.ch Tue Jul 31 19:16:58 2001 From: cliechti at mails.ch (chris liechti) Date: 1 Aug 2001 01:16:58 +0200 Subject: FEEDBACK WANTED: Type/class unification References: <cp66cd12yp.fsf@cj20424-a.reston1.va.home.com> <Xns90EF5B77F1919duncanrcpcouk@127.0.0.1> <cp7kwpz6uh.fsf@cj20424-a.reston1.va.home.com> Message-ID: <Xns90F0DB45A38Bcliechtimailsch@62.2.32.50> Guido van Rossum <guido at python.org> wrote in news:cp7kwpz6uh.fsf at cj20424-a.reston1.va.home.com: > There's a missing section in PEP and tutorial on > "cooperation", a generalization of a "super" call that allows you to > spell "call the next method in the chain" without naming its class > explicitly. No time to explain that now. "super" interested me too. from your description, i think it's similar to Java's "super" keyword but extended to multiple inheritance. that would simplify writing class hierarchies because what one would not need to search the correct supperclass for a method and renaming a class is made much simpler. -- chris <cliechti at mails.ch> From jeffk at jdkoftinoff.com Fri Jul 13 01:48:17 2001 From: jeffk at jdkoftinoff.com (Jeff Koftinoff) Date: Thu, 12 Jul 2001 22:48:17 -0700 Subject: An unspeakable act References: <ib0lktkade28a9ci198b1jpn9jejqjbtlj@4ax.com> Message-ID: <3B4E8BA0.BD0A7A9F@jdkoftinoff.com> Daniel Klein wrote: > I did the unspeakable and got into a discussion (with another person on another usenet group) on > Python vs Java. This person says that dynamically typed languages produce bug-ridden programs and > that there are no reliable large applications (especially network apps) written in Python and that > it is just used for small to medium scripting. I know better but I don't have any proof. Can anyone > point me at a list of companies and the applications they have written (I already know about Zope > and I can't find the list of companies on the Python website since they moved the page to PSA). > > Thanks for any information you can provide (or point me to). > > Daniel Klein I used to think the same things with regards to dynamically typed languges versus statically type languages. The initial idea is that statically typed languages will tell you about the type errors when it compiles. Well, there is a bigger conceptual problem with the whole argument. My new realization is that unfortunately most C++ programmers have an attitude that if the program compiles and seems to work it is done! (it compiled! ship it!) - real testing of objects is rarely seen. How do you know your code is correct? You HAVE to test each part anyways. People who say 'statically typed languages are safer' must be relying on the compiler to tell them if their code is correct without fully testing their code! Yes, the compiler will complain if there is a type mismatch, but it won't tell you that the body of your function is doing the correct job as the specification says! heh, most c++ programmers don't even properly SPECIFY what each function/method is supposed to do. So, you have to properly test your code anyways to make sure it is robust. Any type errors in python code would be caught then. For people who do not make proper test code for their C++ objects, you will find that the bugs in their code are MUCH more insideous than a type error. And they creep in EVERYWHERE. So I would be inclined to say that static typing just gives you a false sense of security and makes it easier to overlook proper testing. For people who actually DO full testing on their C++ objects, I would be inclined to say that the static typing rules just make the code more complex. Have fun jeff koftinoff jeffk at jdkoftinoff.com From just at letterror.com Sat Jul 21 09:16:47 2001 From: just at letterror.com (Just van Rossum) Date: Sat, 21 Jul 2001 15:16:47 +0200 Subject: Help with PDF References: <mailman.995677535.12211.python-list@python.org> <20010721.071302.1704365084.1761@d150-169-166.home.cgocable.net> Message-ID: <3B5980BC.422232EC@letterror.com> Mark Nenadov wrote: > The best solution for Python and PDF that I have found is PDF-Lib > (www.pdflib.com). I have used it with Python, and it also work with a > wide variety of other languages. I haven't looked at PDFLib in a long time. Have you also looked at reportlab's pdfgen (www.reportlab.com)? If yes, how does it compare? Just From thomas at xs4all.net Mon Jul 2 15:22:38 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 2 Jul 2001 21:22:38 +0200 Subject: Augmented Assignement (was: Re: PEP scepticism) In-Reply-To: <oqlmm7tl6j.fsf@lin2.sram.qc.ca> References: <mailman.993952381.32699.python-list@python.org> <zbN%6.415855$oc7.58414702@news2.rdc2.tx.home.com> <q0avjto87p59hn7gv28r5cf1c84j2fb8c7@4ax.com> <naO%6.416271$oc7.58537852@news2.rdc2.tx.home.com> <vm40kt8knq3pplpv1rarjubl73vnl12ure@4ax.com> <20010702145211.M8098@xs4all.nl> <oqlmm7tl6j.fsf@lin2.sram.qc.ca> Message-ID: <20010702212238.Q32419@xs4all.nl> On Mon, Jul 02, 2001 at 11:17:24AM -0400, Fran?ois Pinard wrote: > Fuzziness in this area does not bring us anything, really. If you really > want a method to extend an mutable, spell it out as we always did, similar > to list.append(), say, but leave "+" and "+=" alone. I think you misunderstand. This is and always was *my* intent for augmented assignment, as well as *Guido*'s intent, as well as the intent of all but one of the people who reacted to the augmented assignment PEP back when it was written (for Python 2.0). I discussed this exact subject explicitly with Guido, and he was quite clear in what he wanted augmented assignment for. It works this way. It isn't going to change unless you come with arguments to convince Guido, and he has already heard all arguments in this thread -- from me, before the implementation was checked in. I doubt he would have gone for a pure syntactic sugar version of augmented assignment no matter what I'd have said :) Changing the implementation two releases *after* the fact is going to require a lot more arguments, and more than just arguments to boot. I have yet to find a case where the augmented assignment semantics trick newbies, even newbies that are baffled by the three-scope-rule (which we still have, despite nested scopes,) mutable-default-arguments, 'list.append()' (and 'list.sort()' and other mutating methods) not returning the list itself, and more. Once they grasp the difference between mutable and immutable values, and they need to do this at one time or another anyway, they also understand the exact semantics of augmented assignment. This thread reminds me a great deal about whether generators should be defined using 'def' or 'generate' -- it took me one (1) generator to realize how natural it was with def, and most (not all) counterarguments were basically trying to tell me I was wrong to feel that way :-) -- Thomas Wouters <thomas at xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From emile at fenx.com Thu Jul 12 11:42:35 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 12 Jul 2001 08:42:35 -0700 Subject: Can anyone offer a suggestion? Message-ID: <9ikgpq$j1cff$1@ID-11957.news.dfncis.de> I've been writing a business math class that allows for multiple precision accuracy, and in testing stumbled on this behavior: >>> from BNum import BNum as bn >>> ab = bn('1.2340000') >>> cb = bn('123.45') >>> ab 1.2340000 >>> ab * cb 152.3373000 >>> (ab*cb).disp(2) '152.34' >>> print '%8.2f' % ab*cb 151.84 +++++++++++++++++++++??????! >>> print 1.234 * 123.45 152.3373 >>> print ab*cb 152.3373000 >>> print float(ab*cb) 152.3373 >>> print '%8.2f' % float(ab*cb) 152.34 >>> print '%8.2f' % ab*cb 151.84 >>> print str(ab*cb) 152.3373000 How is the argument being coerced for inclusion? I would have thought float(), but apparently not. Any hints appreciated. (Otherwise I'll have to try to find it in the source! ;-0) -- Emile van Sebille emile at fenx.com --------- From loewis at informatik.hu-berlin.de Sun Jul 1 06:07:21 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 01 Jul 2001 12:07:21 +0200 Subject: Debugging reference count errors; PIL problem References: <3B37D3BC.5000304@erols.com> Message-ID: <j4lmm9ufmu.fsf@informatik.hu-berlin.de> "Edward C. Jones" <edcjones at erols.com> writes: > 1. What is currently the easiest way to track down reference > count errors? I recommend to use an advanced C debugger; gdb is good enough. There are actually two kinds of errors: too many decrefs, and too few decrefs. The former means that you will access memory that has already been freed; the latter means you have garbage. It would help immensely if you: a) already know what objects leak exactly, and b) have a small test cases that shows the leak. In gdb, set a breakpoint on allocation of your objects. The set a watchpoint on every change to the reference counter, and watch how it evolves. > 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? Not sure. Which objects in particular are left at the end? > Is there any documentation for using the reference count debugging > features? Not that I know of. Once you are through with your problem, you might consider writing up some stuff. > 3. I compiled PIL. "import _imaging" fails with the message: > > ImportError: ./_imaging.so: undefined symbol: Py_InitModule4 > > What's going on here? Py_InitModule4 is renamed when using --with-pydebug. You need to recompile PIL with the installation that you've configured --with-pydebug. Make sure you don't mix header files of both installations, nor sys.path; the renaming was introduced to detect errors with mixed installations. Regards, Martin From Pekka.Pessi at nokia.com Sat Jul 21 14:52:10 2001 From: Pekka.Pessi at nokia.com (Pekka Pessi) Date: 21 Jul 2001 21:52:10 +0300 Subject: Case insensitivity References: <mailman.995506711.21636.python-list@python.org> <cpvgkofyru.fsf@cj20424-a.reston1.va.home.com> Message-ID: <pvae1y2jz9.fsf@agni.research.nokia.com> In message <cpvgkofyru.fsf at cj20424-a.reston1.va.home.com> Guido van Rossum <guido at python.org> writes: >My own intuition and experience tells me that there seem to be two >kinds of people: some folks think case-sensitively, others think >case-insensitively. Myself, I am a case-sensitive person, but I can >easily learn to work with case-insensitive systems. It's possible >that most programmers have case-sensitive minds, but I think that most >non-programmers probably have case-insensitive minds. And >non-programmers are quite the majority. Most non-programmers like to use identifiers in their native language. Some people are happy with US-ASCII (like, Swahili, and perhaps Dutch), most Europeans are content with ISO Latin 1, but the vast majority would like to use Unicode. Currently Python supports ISO Latin 1, but I think that Unicode is the future. In my opinion, supporting Unicode is more valuable for more people than case-insensitivity. >*If* there is any hard scientific evidence that case-sensitivity is a >hindrance to learning to program (for most people), that would confirm my >hunch. I have some experience of teching programming with AmigaBASIC by Microsoft, which was both case-insensitive and had ISO-Latin-1 identifiers. So, one could write program like this: ?iti=32:is?=35 lapsi1=is?/7 lapsi2=?iti/4 LAPSI3=ABS(lapsi1-LAPSI2)+LAPSI2+ABS(IS?-?ITI) PRINT lapsi3 However, this would not work. The Microsoft programmers were not clever enough to extend case-insensitivity to ISO-Latin-1 characters: LAPSI2 is same as lapsi2, LAPSI1 is same as lapsi1 - but IS? is not the same thing as is?, nor ?ITI same as ?iti. Now *this* is nasty surprise. *Broken* case-insensitivity is not a minor wart. Calling it hindrance would be an understatement. It is a major pain. However, implementing the case-insensitivity properly is a real hurdle. With Latin1, one may argue that it is doable, but actually you would have to known the language in which the identifiers are written (because casing rules vary from language to language). Doing that with Unicode is next to impossible. Really. >To me, the only real important question is, how can we introduce >case-sensitivity for novices without breaking the millions of lines of >existing Python code. One option could be: forget it, it's too late. If you plan to do it *properly*, go for it. Otherwise, forget it. >Another: put the case-insensitivity in the tools. That would be easier, and much more valuable (the tools could fix typos and propose similar sounding indentifiers, as well). Pekka From bowman at acsu.buffalo.edu Tue Jul 17 15:47:26 2001 From: bowman at acsu.buffalo.edu (Charles L. Bowman, Ph.D.) Date: Tue, 17 Jul 2001 15:47:26 -0400 Subject: Installing NumPy on NT4 Message-ID: <3B54964E.223C19C6@acsu.buffalo.edu> Hello, The installer, Numeric-20.1.0.win32-py2.1.exe, fails to run from a DOS window, the "Start run" window, or simply clicking on the file. What am I missing? Thanks. Charles Bowman Python2.1.1c1 NT4, SP3 HP Vectra XU 5/90C From mcfletch at home.com Sat Jul 21 20:19:22 2001 From: mcfletch at home.com (Mike C. Fletcher) Date: Sat, 21 Jul 2001 20:19:22 -0400 Subject: VRML In-Reply-To: <3B59F747.837D36B7@olen.to> Message-ID: <000101c11243$f578ad80$a9807018@cr706570a> http://members.home.com/mcfletch/programming/mcf_vrml.htm That's in Python, though it requires the mxTextTools extension under the covers. HTH, Mike -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Joonas Paalasmaa Sent: July 21, 2001 17:43 To: python-list at python.org Subject: Re: VRML Jacek Pop?awski wrote: > > Hello. I am writing car game for Linux. To create 3D objects I use Blender, > save with alt+w which gives simple "videoscape format". I think VRML will be > much better. It will be great to create converter between VRML and my own > format. What I need is Python library which helps me read VRML. I searched > www.python.org, freshmeat and sourceforge. I found some projects, but one is > in C++ and not so easy (example app is huge!), seconds is in Python and I can't > find "download" section anywhere. Can you help me? Use wrlexport.py, that uses Blender/Python API for exporting. You can find it from http://www.janw.gothere.uk.com/exportmesh.html#vrml1 -- http://mail.python.org/mailman/listinfo/python-list From akuchlin at mems-exchange.org Fri Jul 6 10:52:11 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 06 Jul 2001 10:52:11 -0400 Subject: Time for a Python "distribution" ? References: <mailman.993826974.11013.python-list@python.org> <cp1yo3l0si.fsf@cj20424-a.reston1.va.home.com> <mailman.994046162.21135.python-list@python.org> <3B44B63A.BB507CBF@home.net> <mailman.994368791.9779.python-list@python.org> <Lsd17.8383$e5.1082989@newsb.telia.net> <3dlmm2qlcv.fsf@ute.cnri.reston.va.us> <mailman.994426392.22032.python-list@python.org> Message-ID: <3dith6qfdw.fsf_-_@ute.cnri.reston.va.us> Skip Montanaro <skip at pobox.com> writes: > Couldn't RPM do similar things? It's got a somewhat stronger relationship > to Python, so porting to Win/Mac might not be as difficult. Stronger relationship? There's a Python interface to the RPM C library, hiding undocumented inside Red Hat, but that's about the sum total of it. I don't think we'll be able to borrow anyone's implementation, apt or RPM or whatever. --amk From chrishbarker at home.net Thu Jul 5 13:49:01 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 05 Jul 2001 10:49:01 -0700 Subject: Python for air traffic control? References: <134704696.994123281122.JavaMail.root@boots> <mailman.994128604.28588.python-list@python.org> <bebbba07.0107022044.106d9da8@posting.google.com> <xll07.7615$B7.1404761@ruti.visi.com> <bebbba07.0107042305.114a9aab@posting.google.com> Message-ID: <3B44A88D.1AD69E29@home.net> Russ wrote: > I have done real-time programming in C++, and I used static or > start-up memory allocation almost exclusively to avoid memory > management overhead. It really helps execution efficiency, but it > really sucks up memory. Memory is cheap these days, however. I would > probably take the same approach in Python, if possible. (As I said, I > am a Python beginner.) I was waiting for someone with better understanding of Python internals to address this, but since no one has... Using static memory allocation with Python is impossible, and start-up allocation would be very difficult, if not imposible. This is because of Python's immutable types: a simple expression like: i = i+1 (or I += 1, but I don't want to get into that!) Creates a new number, and assigns it to the name, i. It does not change the data at the address refered to bye the original i. This means that you will be dynamically allocating memory almost constantly! You may want to consider looking into the Numeric module as well, the Numeric Array type gives you the option of storing a bunch of numbers in a pre-assigned array, so that: A[i] = A[i] + 1 does, in fact, change the value at the same address, but it also creates an intermediate value first. (A[i] += 1 does not) You can also use this kind of notation: add(A[i],1,A[i]) : the second A[i] tells the add function where you want to store the result. (python gurus: I suspect I have this at least a little wrong, please feel free to correct me) Anyway, what this tells you is that if you want statically allocated memory with Python, you will have a very hard time enforcing it (if it can be done at all) and, in fact, end up using a subset of Python, which is not really Python at all. In short: if you want a statically allocated, strongly typed language with type chaecking before run time, you don't want Python. I think many of us feel that those features are not required for mission critical applications, but if you do, you need to find another language! Another note, with all the disagrement in this thread, it's interesting that no one seems to think that c/C++ would be a good choice either! -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 emdpek at chron.com Fri Jul 27 18:29:34 2001 From: emdpek at chron.com (emdpek) Date: 27 Jul 2001 15:29:34 -0700 Subject: Static method and class method comments References: <9jn382$lqf$1@license1.unx.sas.com> <mailman.996103958.4468.python-list@python.org> <Xns90EA6710921D8duncanrcpcouk@127.0.0.1> <MdW77.10395$UB6.966994@e3500-atl1.usenetserver.com> <cxW77.10413$UB6.969993@e3500-atl1.usenetserver.com> Message-ID: <7fd99f9.0107271429.ad4d668@posting.google.com> > One more thing, the [funcmodifier] above might be changed to a > [funcmodifier_list] to allow 'protected classmethod' and the like. Hate to do a "me, too" posting, but... I really think this is a *damn* good idea, and would love to see it implemented! I did not know that class methods were now possible in 2.2, but I like the proposed method much better. More legible, more flexible, and would scale well with future enhancements! From flognat at flognat.myip.org Mon Jul 30 15:58:44 2001 From: flognat at flognat.myip.org (Andrew Markebo) Date: 30 Jul 2001 21:58:44 +0200 Subject: Debug your python code in emacs.. References: <m3zo9m9opq.fsf@localhost.localdomain> Message-ID: <m3vgka9ojv.fsf@localhost.localdomain> | Maybe something to try to squeeze into the python-mode.el?? Checking latets python-mode I see that it has functionality to follow execution when debugging, hmm dunno know if that is enough.. /Andy From db3l at fitlinxx.com Wed Jul 25 16:55:33 2001 From: db3l at fitlinxx.com (David Bolen) Date: 25 Jul 2001 16:55:33 -0400 Subject: Make it a major version number change (was Re: PEP0238 lament) References: <mailman.996013330.29136.python-list@python.org> <3B5E30CE.2901DED0@engcorp.com> <cp66ch9gfc.fsf@cj20424-a.reston1.va.home.com> Message-ID: <u3d7kenju.fsf@ctwd0143.fitlinxx.com> Guido van Rossum <guido at python.org> writes: > Unfortunately, all it seems to have done is spur this enormous > flamewar. It's really hard to remain calm when people start shouting > "the leadership is wrong because I say so." Those are definitely the messages to ignore and instead keep the blood pressure down :-) -- -- 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 thecalm at NOSPAM.btinternet.com Tue Jul 17 18:37:47 2001 From: thecalm at NOSPAM.btinternet.com (G. Willoughby) Date: Tue, 17 Jul 2001 23:37:47 +0100 Subject: Make an *.EXE Using Python. References: <oAI17.647550$166.13393459@news1.rdc1.bc.home.com> <E3K17.433170$eK2.87951585@news4.rdc1.on.home.com> Message-ID: <9j2en5$q15$1@uranium.btinternet.com> have you any examples on how to use py2exe??? Gary. "Nick Perkins" <nperkins7 at home.com> wrote in message news:E3K17.433170$eK2.87951585 at news4.rdc1.on.home.com... > You need py2exe: > > http://starship.python.net/crew/theller/py2exe/ > > > "EricIDLE" <grayson-wilson at home.com> wrote in message > news:oAI17.647550$166.13393459 at news1.rdc1.bc.home.com... > > Hello, > > I was wondering is there a way to make a exe using Python? > > I seem to remeber vagely that there was a "Make EXE" choice under the file > > menu but its no longer there (If it ever was) so if you can give me a hand > > with this it would be great. > > > > > > From rmacneil at interactdirect.com Fri Jul 20 12:19:41 2001 From: rmacneil at interactdirect.com (Rod MacNeil) Date: Fri, 20 Jul 2001 12:19:41 -0400 Subject: Large File Support References: <eiW57.266163$Z2.3224218@nnrp1.uunet.ca> <lru207zoqx.fsf@haasart1.dhcp.wg.waii.com> Message-ID: <cTY57.266206$Z2.3225457@nnrp1.uunet.ca> Thanks for your suggestion Art. I tried: $ CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" $ export CFLAGS $ ./configure OPT="-O2 ${CFLAGS}" But when I ran make I got: gcc -c -g -O2 -Wall -Wstrict-prototypes -I. -I./Include -DHAVE_CONFIG_H -o Obje cts/fileobject.o Objects/fileobject.c Objects/fileobject.c: In function `_portable_ftell': Objects/fileobject.c:267: incompatible types in return Objects/fileobject.c:275: warning: control reaches end of non-void function make: *** [Objects/fileobject.o] Error 1 I looked in the Makefile and the CFLAGS I specified were not there where I expected. The following seems to work but I'd like to know if it seems correct to you: 1. Run $ ./configure 2. Edit the Makefile and change the OPT= line near the top as follows: OPT= -g -O2 -Wall -Wstrict-prototypes -to- OPT= -g -O2 -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wal l -Wstrict-prototypes 3. Run make Its a bit of a pain to do this everytime ./configure is run but more important to me is finding out if there is something wrong with doing it this way? I am not a C programmer. BTW: The Python 2.1 docs specify -D_LARGEFILE64_SOURCE instead of -D_LARGEFILE_SOURCE. I tried the above method both ways and it seems to work. Thanx in Advance Here's the top section of the Makefile: # === Variables set by makesetup === MODOBJS= Modules/gcmodule.o Modules/threadmodule.o Modules/signalmodu le.o Modules/posixmodule.o Modules/_sre.o MODLIBS= $(LOCALMODLIBS) $(BASEMODLIBS) # === Variables set by configure VERSION= 2.1 srcdir= . CC= gcc CXX= c++ LINKCC= $(PURIFY) $(CC) AR= ar RANLIB= ranlib # Shell used by make (some versions default to the login shell, which is bad) SHELL= /bin/sh # Use this to make a link between python$(VERSION) and python in $(BINDIR) LN= ln # Portable install script (configure doesn't always guess right) INSTALL= /usr/bin/install -c INSTALL_PROGRAM=${INSTALL} INSTALL_SCRIPT= ${INSTALL_PROGRAM} INSTALL_DATA= ${INSTALL} -m 644 # Shared libraries must be installed with executable mode on some systems; # rather than figuring out exactly which, we always give them executable mode. # Also, making them read-only seems to be a good idea... INSTALL_SHARED= ${INSTALL} -m 555 MAKESETUP= $(srcdir)/Modules/makesetup # Compiler options OPT= -g -O2 -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W stri ct-prototypes DEFS= -DHAVE_CONFIG_H CFLAGS= $(OPT) -I. -I$(srcdir)/Include $(DEFS) LDFLAGS= LDLAST= SGI_ABI= CCSHARED= -fPIC LINKFORSHARED= -Xlinker -export-dynamic # Extra C flags added for building the interpreter object files. CFLAGSFORSHARED= # C flags used for building the interpreter object files PY_CFLAGS= $(CFLAGS) $(CFLAGSFORSHARED) "Art Haas" <arthur.haas at westgeo.com> wrote in message news:lru207zoqx.fsf at haasart1.dhcp.wg.waii.com... > "Rod MacNeil" <rmacneil at interactdirect.com> writes: > > > Hello NG, > > > > I need to build Python to include large file support on Redhat Linux 7.1. > > > > I tried the following instructions from section 8.1.1 in the Python docs but > > it doesn't work: > > > > On large-file-capable Linux systems, this might work: > > > > > > CC="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" > > export CC > > ./configure > > > > > > I think this fails because the variable CC is expected to have the compiler > > name (gcc). > > > > Does anyone have any alternative instructions? > > > > Don't set `CC', set `CFLAGS' ... > > $ CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" > $ export CFLAGS > $ ./configure > ... > > You'll probably have to go in and edit the Makefile, to set these same > flags for the `OPT' variable as well. Or, when you run `configure', > you could ... > > $ ./configure OPT="-O2 ${CFLAGS}" > > ... and things should work. If you want to have debug info in the > compiled program, add a `-g' to the OPT variable. Check the makefile > when configure finishes to ensure that the largefile flags are in the > OPT variable. > > -- > ############################### > # Art Haas > # (713) 689-2417 > ############################### From shredwheat at mediaone.net Wed Jul 11 12:50:48 2001 From: shredwheat at mediaone.net (Pete Shinners) Date: Wed, 11 Jul 2001 16:50:48 GMT Subject: Python speed References: <roG27.666914$166.13798179@news1.rdc1.bc.home.com> <pXG27.1312$M9.140003@typhoon.we.rr.com> <9ifjjh$1e3$1@news.mathworks.com> <3B4B562F.77C1B79@yahoo.com> <9ifo90$4hh$1@news.mathworks.com> Message-ID: <It%27.3828$M9.1040127@typhoon.we.rr.com> > Well, I say this because I've written a mud engine in Python and it's > slow. Using this engine on a PII 266 running RedHat 6.1, 400 > wandering monsters (with nothing else going on in the mud) will peg > the cpu. the following program will also peg the cpu ----------------------------------------------------------- while 1: pass ----------------------------------------------------------- does this mean the language isn't up to the task? now subtitute any function call for the pass. as long as your function is being called often enough for your programs needs, then there shouldn't be any trouble. so writing "while 1: move_monsters()" will peg the cpu, it is not an indication that the program or the language is not able to keep up. now of your loop was written something like this... interval = 1.0/30 #30fps while 1: start = time.time() move_monsters() diff = time.time() - start if diff < interval: time.sleep(interval - diff) ...and it still pegs the cpu, then you've got a problem. if the cpu is pegged it means the move_monsters is running slower than the desired 30fps. if the move_monsters() function runs quicker than each desired timeslice, then the program will sleep the remaining time, freeing up the cpu. anyways, my point is don't write python's speed off for burning 100% cpu. instead you should admire your OS for letting your app run as efficiently as it does :] From gergo.barany at gmx.net Wed Jul 11 17:20:02 2001 From: gergo.barany at gmx.net (Gergo Barany) Date: 11 Jul 2001 21:20:02 GMT Subject: How popular is Python, anyway? (was: Long Live Python!) References: <E566B020833BD311B6610008C791A39705CA5230@il93exm04.css.mot.com> <mailman.994804336.23495.python-list@python.org> <slrn9koofo.mjk.philh@comuno.freeserve.co.uk> Message-ID: <slrn9kpgtq.5ug.gergo.barany@hold.otthon.at> phil hunt <philh at comuno.freeserve.co.uk> wrote: > [snip flamebait crap] If anyone is going to to respond to this thread, *please* take comp.lang.c out of the Newsgroups: list. We don't do advocacy here. Followups set. Thanks, Gergo -- When in doubt, follow your heart. From sholden at holdenweb.com Tue Jul 3 21:50:26 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 3 Jul 2001 21:50:26 -0400 Subject: i'm trying to get user input from a Tkinter Entry field... References: <9htlpd$ki$1@plutonium.btinternet.com> Message-ID: <aAu07.20360$Lk6.1607969@e420r-atl2.usenetserver.com> "G. Willoughby" <thecalm at NOSPAM.btinternet.com> wrote in message news:9htlpd$ki$1 at plutonium.btinternet.com... > i'm trying to get user input from a Tkinter Entry field, this is the code i > am using: > > [snip...] > > def getNew(): > result1=str(newName.get()) > print result1 > > [snip...] > > Button(frame1, text="Add New Entry", command=getNew).grid(row=0,column=0) > newName=Entry(frame1).grid(row=1,column=0) > > [snip...] > > it somehow doesn't work, any ideas? > Yes. It's clear that something is wrong with your program. > P.S. no classes are used anywhere in this program. > Sorry to be unhelpful, but the exact nature of the error would require psychic Python debugging abilities beyond the range of this ordinary mortal. I presume the print statement doesn't print anything? Any other clues? Perhaps you posted snippets because it's a long program. If so, reduce it to essentials and post the whole thing (assuming it still exhibits the problem behavior). Good luck Steve -- http://www.holdenweb.com/ From jwbaxter at spamcop.com Sun Jul 22 13:19:31 2001 From: jwbaxter at spamcop.com (John W. Baxter) Date: Sun, 22 Jul 2001 10:19:31 -0700 Subject: Future division patch available (PEP 238) References: <mailman.995776716.24336.python-list@python.org> Message-ID: <220720011019310436%jwbaxter@spamcop.com> In article <mailman.995776716.24336.python-list at python.org>, Guido van Rossum <guido at digicool.com> wrote: > - unconditionally, there's a new operator // that will always do int > division (and an in-place companion //=). > > - by default, / is unchanged (and so is /=). > > - after "from __future__ import division", / is changed to return a > float result from int or long operands (and so is /=). Given that it is written in stone that 1 / 2 will someday produce 0.5, then the above seems to be the least bad way to get there. (And yes, I've used Pascal extensively for many years, but not recently...so div wouldn't shock me...but it's not now a keyword and // is a decent alternative.) I don't think 1 / 2 producing 0 is broken, so I don't think it needs to be fixed, but that view is unlikely to prevail. A note on both case-sensitive and integer division: if the language had started out case-insensitive and with / returning float (or rational) when not exact as integer, I would be against changing the language to the present rules. But neither set of rules is broken, and neither needs to be fixed. Ah, well...in 20 years it won't matter what happens now for either issue. --John From jm7potter at hotmail.com Thu Jul 5 06:30:29 2001 From: jm7potter at hotmail.com (Joe Potter) Date: Thu, 05 Jul 2001 06:30:29 -0400 Subject: a gadfly SQL question --- table creation References: <n237ktc10fithjhm8vj4pfkmrq7k4fjop8@4ax.com> <Xns90D5704F23F1Catodddexterpinioncom@203.2.194.51> <qlk7kto6lcqqsm2dslsmvrp5eeu3bhpdf7@4ax.com> <Xns90D59D0D33B09atodddexterpinioncom@203.2.194.51> Message-ID: <luf8kt4t8e5urfata61qfu9c90otqi9puv@4ax.com> On Thu, 05 Jul 2001 05:26:39 GMT, andy_todd at spam.free.yahoo.com (Andy Todd) wrote: >Joe Potter <jm7potter at hotmail.com> wrote in ><qlk7kto6lcqqsm2dslsmvrp5eeu3bhpdf7 at 4ax.com>: > >>On Thu, 05 Jul 2001 00:55:36 GMT, andy_todd at spam.free.yahoo.com (Andy >>Todd) wrote: >> >>>Joe Potter <jm7potter at hotmail.com> wrote in >>><n237ktc10fithjhm8vj4pfkmrq7k4fjop8 at 4ax.com>: >>> <snip> >> >>Thanks Andy. That really did help. >> >>Now, might I ask how one gets "1, Andy, Todd" out of Gadfly and back >>into a Python object for direct manipulation? >> >> >> >>Regards, Joe > >Blimey, hard questions now ;-) I haven't got gadfly on my machine so >apologies for any syntax errors, but try; > But easy for you, I see. :-) > >""" >>>> connection=gadfly.gadfly() >>>> connection.startup("jnso", ".\\ndata") >>>> cursor.execute("SELECT st_id, first_name, last_name FROM students WHERE >st_id='1' ") >>>> result=cursor.fetchone() >>>> result >( '1', 'Andy', 'Todd') >""" > >This is standard DB-API functionality. I highly recommend the 'stuff' at >http://www.python.org/topics/database/ for general Python database >information, and try googling for 'SQL' for resources on the lovely >language. I wouldn't recommend anything that focusses too heavily on SQL >Server or Oracle though as they have some non standard extensions which may >come back and bite you on the bum if you try them in gadfly. > I am reading a book on SQL that covers MySQL. But, in this one post you covered my main problem. I could not find where the magic words like "cursor.fetchall()" were coming from. I was reduced to looking at the Gadfly code and making a list of magic code. But, with DB-API spec I see where they are coming from. All praise to Andy on this fine morning. Thanks ever so much. >What the code does is establish a 'connection' to the database (I borrowed >this from your original post so I'm presuming it works ;-), executes an >arbitary SQL statement (I haven't used variable substitution but its really >easy, honest) and then returns the results into 'result'. Note that the >return of any cursor fetch is always a tuple, its up to you to muck about >with that tuple and use its elements to populate an object if thats what >you want to do. If you are changing data items and want to write these back >to gadfly you need to do that via another SQL update statement - which I >will leave as an exercise for the reader. > >A final note is that in my example above I have used the 'fetchone' method >and blithely carried on, this is because my query where predicate is >reducing the result set based on the primary key so that I *know* that I'm >going to return one and only one row. Most of the time you don't have this >luxury so you will find the following construct *slightly* more useful; > >""" >for i in cursor.fetchall() > <do something with i> >""" > >blimey-I-feel-like-I've-been-channeling-the-martellibot-ly y'rs, >Andy Thanks again. Regards, Joe From philh at comuno.freeserve.co.uk Thu Jul 19 07:36:49 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Thu, 19 Jul 2001 12:36:49 +0100 Subject: converting from perl: variable sized unpack References: <roy-B2459F.22112513072001@news1.panix.com> <mailman.995081424.8581.python-list@python.org> <slrn9l4esk.885.quinn@yak.ugcs.caltech.edu> <slrn9l5lc4.6ko.philh@comuno.freeserve.co.uk> <9j2dnn$ndm$0@216.39.144.220> <slrn9lavp6.v3.philh@comuno.freeserve.co.uk> <slrn9lbvbp.6o6.quinn@yak.ugcs.caltech.edu> Message-ID: <slrn9ldhif.488.philh@comuno.freeserve.co.uk> On 18 Jul 2001 21:19:54 GMT, Quinn Dunkan <quinn at yak.ugcs.caltech.edu> wrote: > >It's not just you, but I don't agree, and it's not just me either. >NameErrors, KeyErrors, and IndexErrors have saved me many times. One of the >things I didn't like about perl is how it magically created values on >reference, and then I had to go hunt down the bad reference that created it. >And I often store None in dicts and lists. It would be weird if d.has_key(x) >could be true or false while d[x] always evaluated to None. That means that >d[x] is implicitly creating a None when d.has_key(x) is false, It doesn't, it's just returning a value. Though I can see how that might be useful, e.g: for word in words: freq[word] += 1 instead of in current python: freq = {} for word in words: freq[word] = freq.get(word, 0) + 1 change to: for word in words: freq[word] += 1 Note this involves: (1) if you refer to a variable that doesn't exist, it creatres it giving it the value None (2) None.__getitem__() makes it into a Dictionary (3) Dict:__getitem__() on an item not found returns None (4) None + a number equals that number > >Perl has undef, and lua has nil, and in both those languages saying 'x = nil' >is equavalent to unbinding `x' That's not what I intend. > (I think that's true for perl, don't remember). >If python's None were to be consistent we should remove NameError and del and >have all unbound names evaluate to None. Nor that. X = None should be different than X not existing. >And lastly, and most importantly, that's the way the language works. Some >languages may work differently, but many languages also work this way. Since >obviously no one agrees, there is no "should". And there has to be a really >clear "should" to justify breaking code for it. Oh sure, I'm not suggesting changfing how Python behaves, merely suggesting that the other way of doing it is more productive. >For the circumstances when it's handy to have a 'default value' dict or list >that never raises, it's easy to subclass UserDict. Indeed. Except you'd have to say x = MyDict({'a':1, 'b':2}) instead of just x = {'a':1, 'b':2} -- #===== Philip Hunt == philh at comuno.freeserve.co.uk ======# Herbivore: effort-free public key encryption. See: <http://www.vision25.demon.co.uk/oss/herbivore/intro.html> ** First software release coming soon! ** From bokr at accessone.com Sat Jul 7 07:32:42 2001 From: bokr at accessone.com (Bengt Richter) Date: Sat, 07 Jul 2001 11:32:42 GMT Subject: Maintaining the Python FAQ References: <mailman.994428256.27172.python-list@python.org> <cpvgl6jbyz.fsf@cj20424-a.reston1.va.home.com> Message-ID: <3b46f35f.1276947673@wa.news.verio.net> On Fri, 06 Jul 2001 15:50:35 GMT, Guido van Rossum <guido at python.org> wrote: >Oleg Broytmann <phd at phd.fep.ru> writes: > >> On Fri, 6 Jul 2001, Guido van Rossum wrote: >> > Hm. To what extent is the current FAQ wizard a problem for its >> >> For me the biggest problem is not the FAQ Wizard, but FAQ.html - it is >> too big. 270K is too big for the Net. Let us split it intopages. > >Huh? The FAQ wizard gives you plenty of ways to access individual >items or sections. Why would you ever download the whole FAQ? > Make coffee while downloading, then when it's on disk, you can follow links _quickly_ and pleasantly (assuming separate html pages for topics, and downloading them as a zipped archive). Also, it's nice to be able to get to stuff even when the net is bogged down. You must have a good reliable fast link ;-) From matthewm at ihug.co.nz Mon Jul 9 23:54:58 2001 From: matthewm at ihug.co.nz (Matthew) Date: Tue, 10 Jul 2001 15:54:58 +1200 Subject: PythonCOM and Office. Arrgh! Message-ID: <3B4A7C91.44680652@ihug.co.nz> Hi everyone, A few more hours and my mind will be gone; burnt to a frazzle by this most annoying, frustarting problem. No matter what I try, I CAN NEVER get named keyword arguments to do anything via PythonCOM Excel automation. xlapp.Workbooks.Open("D:\\Fred.xls", Password='fred') profers no error. The xcel window opens with Password Dialog opem. Type in 'fred' and s/s loads up. Named arg passed in call apparently ignored. xlapp.Workbooks.Open("D:\\Fred.xls", password='fred') generates error - Open got unexpected keyword argument 'password', so it seems to me that somethings going on with passed named args I've tried 10s of different xcel functions but with identical results. Named args do zippo. Spell a keyword arg incorrectly and you get reprimanded. I've tried under NT4/2000 with both ActiveState2.0 build 203 & ActiveState21.- build 210. What am I overllooking/missing? Please help before it's too late... Thanks, matthew. From vvainio at karhu.tp.spt.fi Mon Jul 23 01:32:27 2001 From: vvainio at karhu.tp.spt.fi (Ville Vainio) Date: 23 Jul 2001 08:32:27 +0300 Subject: TK + cmd.cmdloop() in threads (was Re: howdoI: Exception in thread - terminating the program? References: <yox7kx83xzf.fsf@karhu.tp.spt.fi> <u7kx74dmd.fsf@ctwd0143.fitlinxx.com> <yox1yneojvi.fsf_-_@karhu.tp.spt.fi> <9j5lq9$jl7$1@panix2.panix.com> Message-ID: <yox3d7o1a8k.fsf@karhu.tp.spt.fi> aahz at panix.com (Aahz Maruch) writes: > I don't know what cmd.cmdloop() does, but if it's a TK thingie, what No, cmd is a module that provides a line-oriented command interpreter for console, nothing to do with TK. http://www.python.org/doc/current/lib/module-cmd.html > you're suggesting is a Bad Idea. Generally speaking, it's safest to > have only one thread accessing any external resource (GUI, file handle, > DB connection, etc). But one would think it's reasonably safe to access a resource one thread at a time, via mutexes etc. (and some external resource, such as sockets, almost *have to* be accessed in multiple threads). Is TK really such a beast that all the access to TK widgets have to be called via it's own event loop? -- 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 quinn at yak.ugcs.caltech.edu Sun Jul 15 20:55:48 2001 From: quinn at yak.ugcs.caltech.edu (Quinn Dunkan) Date: 16 Jul 2001 00:55:48 GMT Subject: converting from perl: variable sized unpack References: <roy-B2459F.22112513072001@news1.panix.com> <mailman.995081424.8581.python-list@python.org> Message-ID: <slrn9l4esk.885.quinn@yak.ugcs.caltech.edu> On Fri, 13 Jul 2001 23:28:39 -0400, Barry A. Warsaw <barry at digicool.com> wrote: > RS> [f1, f2, f3, f4, f5, f6] = string.split (line) > > RS> but the problem is that line may have fewer than 6 fields on > RS> it. Perl handles this smoothly by leaving the "extra" > RS> variables undefined, whereas python raises a ValueError > RS> exception. What I'd like to do is have the extra field > RS> variables left as null strings. > >Python doesn't work this way, but I've been thinking about writing a >PEP to make sequence unpacking less strict. Please don't. Or if you do, I hope it "lays the issue to rest". I often use unpacking from log files, with the assumption that the wrong number of fields is a parsing error, and should be reported as one, not silently "fixed". If you are relying on your log files having the same number of fields, it is an error if they don't. If your log files have a variable number of fields, you should split into a list and pick it apart more carefully. And that's just for log files, I use this often to unpack tuples, and if I pass in a non-conformant tuple, that's bad data and should break sooner rather than later. But mostly, it's a change that doesn't fix something which is clearly broken (you could argue either way), but breaks existing code. Even without that, I argue that a bad pattern match should throw an exception and not assign None, just like a bad array index should throw an exception and not assign None. It's more consistent with the language. Ruby allows * notation: a, b, *c = sequence # `c' gets the rest of the sequence which is cute, but I don't like it. Just another random "convenient" little trick to remember. It's not half as useful as the 1.6 * apply trick. Let's go easy on the syntax gimmicks. From tundra at tundraware.com Tue Jul 17 17:50:07 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 17 Jul 2001 21:50:07 GMT Subject: ANN: HB - Learn Python A Little Faster References: <3B4FE9A6.DBBF3919@tundraware.com> Message-ID: <3B54B0F2.CC6300F5@tundraware.com> For those of you following along with my "training wheels" python program, I just updated it at: http://www.tundraware.com/Software/hb/HB.tar.gz This should be it for a while. ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From desai at mcs.anl.gov Thu Jul 26 12:46:45 2001 From: desai at mcs.anl.gov (Narayan Desai) Date: 26 Jul 2001 11:46:45 -0500 Subject: PYTHONPATH Message-ID: <yrxk80vhc3u.fsf@catbert.mcs.anl.gov> Hi. I have tried to set PYTHONPATH from inside of an already executing program and it reliably fails, ie import os os.environ["PYTHONPATH"]="/path" import module_located_in_path fails, while if I set this variable outside of the script in the parent environment it works as expected. Is this not allowed? Am I doing this wrong? Is there an alternative way to achieve the same effect? thanks.. -nld From stevewilliams at wwc.com Sun Jul 22 22:49:52 2001 From: stevewilliams at wwc.com (Steve Williams) Date: Mon, 23 Jul 2001 02:49:52 GMT Subject: PEP0238 lament References: <mailman.995832157.30385.python-list@python.org> Message-ID: <3B5B9185.810ED4C8@wwc.com> Tim Peters wrote: > [snip] > > > i-always-blamed-cauchy-and-weirstrass-for-tormenting-the-world- > > with-epsilons-and-deltas-ly y'rs, Z. > > i-personally-blame-guido-for-letting-it-stand<wink>-ly y'rs - tim Yes, yes. Let's stop nattering about wedging division into the ring of integers (1/2 is undefined, not 0, right?) and get on with adding the hyperreals to Python. From xyzmats at laplaza.org Fri Jul 20 10:02:39 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Fri, 20 Jul 2001 14:02:39 GMT Subject: How to run codeobjects in Python? References: <mailman.995024902.7812.python-list@python.org> <9imphr015u5@enews1.newsguy.com> <3B4FBBD8.45F56742@engcorp.com> <9iorv60pj2@enews4.newsguy.com> Message-ID: <3b5839c3.147469179@news.laplaza.org> On Sat, 14 Jul 2001 09:24:00 +0200, "Alex Martelli" <aleaxit at yahoo.com> wrote: :"Peter Hansen" <peter at engcorp.com> wrote in message :news:3B4FBBD8.45F56742 at engcorp.com... : ... :> Alex, please consider moving closer to the Eastern Standard timezone :> so that you may answer my questions more quickly. What's so special :> about Italy anyway? : :Pasta, of course. You guys can claim your pizza is as good as Italy's :(I'd disagree, but there IS space for debate) I don't think there's /much/ space for debate. Some of the specialty pizza shops are producing nearly-comparable stuff, but the run-of-the-mill stuff is, umm, let's say "different". Best pizza I've ever eaten was in France, actually...at a totally unassuming restaurant in Cannes (not many miles from the border, so it's almost Italy). Oops, this appears to be badly off-topic (but tasty). Mats Wichmann (Anti-spam stuff: to reply remove the "xyz" from the address xyzmats at laplaza.org. Not that it helps much...) From rcameszREMOVETHIS at dds.removethistoo.nl Mon Jul 23 14:14:10 2001 From: rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz) Date: Mon, 23 Jul 2001 18:14:10 GMT Subject: Sybase module 0.28 (Brown Paper Bag) released References: <m3pubqd3i7.fsf@vole.object-craft.com.au> <m3bsmd1try.fsf@vole.object-craft.com.au> Message-ID: <Xns90E7CC126BADArcamesz@127.0.0.1> Dave Cole wrote: > I didn't post that (I posted the original a long time ago - but > this isn't it). >> Message-ID: <m3pubqd3i7.fsf at vole.object-craft.com.au> Well, if it's a forgery, it's a pretty good one. Even the message-ID seems authentic. That is to say, it matches the form of the ID in your message closely. You might want to check if it's identical to the message-ID of your original message: if so, onlynews.com shouldn't have allowed it to be posted under that ID. Also, keepers of usenet-archives will _not_ be amused. (This might give you some leverage if onlynews isn't too helpful.) Note carefully: if it *is* a duplicate message-ID, cancelling the message may not do what you expect. > Looking at the path, who are onlynews.com? > > Path: vic.nntp.telstra.net!intgwlon.nntp.telstra.net > !newsfeeds.ihug.co.nz!news.xtra.co.nz!nntp-relay.ihug.net > !ihug.co.nz!news-out.nibble.net!hub1.nntpserver.com > !cyclone-sjo1.usenetserver.com!news-out-sjo.usenetserver.com > !newsin.onlynews.com!newsout.onlynews.com!news1.onlynews.com.POSTED > !not-for-mail This is the same Path: header as it showed up on my server: > Path: news.demon.nl!demon!bullseye.news.demon.net > !dispose.news.demon.net!demon!feed2.news.rcn.net!rcn > !dca6-feed2.news.digex.net!intermedia!newsfeed1.cidera.com > !cyclone-sjo1.usenetserver.com!news-out-sjo.usenetserver.com > !newsin.onlynews.com!newsout.onlynews.com!news1.onlynews.com.POSTED > !not-for-mail Theoretically, the Path: header could be forged too, but that wouldn't prevent the originating server from appearing somewhere in that line. Presumably, modern news servers wouldn't accept such a header form a normal client. Looking at the common servers in the path, the posting must have entered the network at one of these servers: - cyclone-sjo1.usenetserver.com - news-out-sjo.usenetserver.com - newsin.onlynews.com - newsout.onlynews.com - news1.onlynews.com Mind you, that's just a theoretical possibility: there's no evidence that header has been forged. The following headers were added by the NNTP-sever, or so it would seem: >> NNTP-Posting-Host: onlyNews customer >> X-Complaints-To: abuse at onlynews.com >> X-Trace: onlyNews customer >> NNTP-Posting-Date: Sat, 21 Jul 2001 16:18:41 PDT >> Organization: www.onlynews.com >> Date: Sat, 21 Jul 2001 23:18:41 GMT >> Lines: 56 Not too helpful, I'm afraid: - It seems to confirm onlynews.com is the originating server of the message. - We now know the timezone the news server is in. (PDT, isn't that Pacific Daylight saving Time?) - In all probability the sever inserted the Date: header, not the newsclient. So it's a deliberate fake, it's highly unlikely that a newsreader was used to produce it, as those (AFAIK) never allow such detailed control over the generation of the headers. You could get close by using the same newsreader as the victim, but "Gnus/5.0807 (Gnus v5.8.7) Emacs/20.5" isn't very popular [*], and it seems to insert it's own Date: header. Of course, using Python and the nntplib-module you could be producing your own fake messages in about half an hour or less, and that includes the time to read the documentation, so that makes _everybody_ in this ng a suspect... ;-) Mind you, this may be just a newsadmin trying to be helpful by re- distributing messages s/he thought had been lost due to a crash or something like that. Malicious forgeries are usually pretty crude, both with regard to technical skill as contents. Robert Amesz -- [*] Which is probably a good thing, as I really *hate* what the supercite function does to quoted text. Ugh! This might also be a convenient opportunity to point out that the latest userfor-draft *strongly* suggest you should use '>' for quoted text, and nothing else. From nde at comp.leeds.ac.uk Wed Jul 18 07:44:27 2001 From: nde at comp.leeds.ac.uk (Nick Efford) Date: Wed, 18 Jul 2001 11:44:27 GMT Subject: Language change and code breaks (fwd) References: <mailman.995415330.32301.python-list@python.org> Message-ID: <GGo3A8.CzM@leeds.ac.uk> On Tue, 17 Jul 2001 20:09:05 -0400, Lulu of the Lotus-Eaters <mertz at gnosis.cx> wrote: > I--one of those professional programmers--write a Python script for > someone who runs a business, or a non-profit, or an agency, to run on > their CGI webserver. This client knows not the first thing about Python > or about programming, nor do they maintain the webserver, just rent > space on it. But still, this script does something useful for users of > the website--order products, or request documents, or send data to a > database. > > I go away, no longer available. The client's web hosting company > upgrades the Python installation to Python 3.7 (this is in the future > :-)). Client's scripts break. Interesting scenario. Of course, this could happen with other s/w, too. This really says more about the policy of the web hosting company w.r.t. upgrades than it does about the wisdom or otherwise of breaking compatibility in a future version of Python. Any web hoster worth its salt should at least run old and new versions of the s/w in parallel and provide clients with the opportunity to test programs in the new environment before migrating. Nick From com-nospam at ccraig.org Sat Jul 21 10:21:59 2001 From: com-nospam at ccraig.org (Christopher A. Craig) Date: 21 Jul 2001 10:21:59 -0400 Subject: interpreter improvements In-Reply-To: <5e8bd451.0107210040.2e2d9a0e@posting.google.com> References: <5e8bd451.0107190224.7171e61@posting.google.com> <mailman.995692716.8559.python-list@python.org> <5e8bd451.0107210040.2e2d9a0e@posting.google.com> Message-ID: <87ofqe1hx4.fsf@elbereth.ccraig.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 kp87 at lycos.com (kevin parks) writes: > Anyway, i spend all day in the interpreter and i was > hoping to make it a more pleasant experience. I can't > believe you can't do: > > >>> foo(somereallylongbitofcodegoeshere, > itsrealllybothersomeifyoumistype) [change a bunch of crap here] > >>> !foo You can't do this in Unix either. With readline support you can use emacs keybindings to go back, forward, search, etc., but no Python interpreter that I know of messes with the syntax of the language to enhance command history or expansion. I think this is a good thing. In shell these history and expansion tricks are part of the language, that is "!foo" in shell means "run the last command starting with the string 'foo'". This is not part of the Python language and I don't think you should be able to type something into the interpreter which is not part of the language. Now porting zsh's ZLE to Python is another matter entirely ;-) - -- Christopher A. Craig <com-nospam at ccraig.org> "May the source be with you." -- Open Source Software mantra -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: Processed by Mailcrypt iEYEARECAAYFAjtZkAYACgkQjVztv3T8pzv/rACgs+o6Uva6bPpPP6INC6aYxJ/r qBoAn2ZgZoiQQbfTbC1YOAHtfZd0e6SG =HAOx -----END PGP SIGNATURE----- From fleet at teachout.org Thu Jul 19 13:33:21 2001 From: fleet at teachout.org (fleet at teachout.org) Date: Thu, 19 Jul 2001 13:33:21 -0400 (EDT) Subject: VariableSubstitution in commands or funtion names? Message-ID: <Pine.LNX.4.30.0107191323200.25339-100000@fleet1> Beautiful - Thank you! - fleet - > Date: Thu, 19 Jul 2001 16:36:58 GMT > From: "Terry Reedy" <tjreedy at home.com> Subject: > >> Parsing the csv output of a spreadsheet allows me to assign "smith" >> to a variable - CurCust. >> >> Now I want to do something like: >> from cust import CurCust >> print cust.CurCust["street"] > >If I understand correctly, try (not tested) > >import cust >current = getattr(cust, CurCust) >print current['street'] > >etc > >Terry J. Reedy From JamesL at Lugoj.Com Wed Jul 25 23:21:59 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Wed, 25 Jul 2001 20:21:59 -0700 Subject: Deposing Dictators References: <9jmjne$q54$1@wisteria.csv.warwick.ac.uk> <B784EAB7.14F50%dgoodger@bigfoot.com> Message-ID: <3B5F8CD7.E8BD38B6@Lugoj.Com> David Goodger wrote: > Go ahead, keep Python the way you like it. Nobody's forcing you to upgrade. True. No one is threatening anyone's physical well being. If someone uses augmented assignment or list comprehensions in a module or an application, and I find that might be a useful module or application, that technically isn't *forcing* me to upgrade from 1.5.2. I could edit it. I could write my own module or application. If I come on and complain about some bug or problem in 1.4 and am told to upgrade to fix it, there is no force involved there. So technically you are correct. From peter at engcorp.com Sat Jul 14 12:43:16 2001 From: peter at engcorp.com (Peter Hansen) Date: Sat, 14 Jul 2001 12:43:16 -0400 Subject: parallel port?!? References: <3B513D42.933A0445@iinet.net.au> Message-ID: <3B5076A4.AD309756@engcorp.com> Richard B wrote: > > I would like to know how to communicate with the parallel port under > python. Is this possible? If so can it be done under all operating > systems that support python. No. There is no such thing as a truly cross-platform parallel port solution, much as there is no cross-platform serial port support. > I need to interface with the parallel port to send commands to a board > connected to it. I have just come to grips with python, it is my first > language, so I think this is what I should use to communicate with the > parallel port so that I can implement new features latter on. You might consider reducing the scope of what you are trying to do, or at least breaking it into phases. You are apparently in the difficult position of: 1. Being new to programming, in general. 2. Being new to Python. 3. Needing a cross-platform solution (do you really?). 4. Needing a solution, bad ("this is kind of important") 5. Not having access to other resources nearby to help. You have at least one thing in your favour: your fine taste in a first language to learn. :) Python is definitely capable of doing this, but I suggest you learn to walk before you run. In this case, start by walking through the Python tutorial, if you haven't already. Also spend some time clarifying your specific requirements. Parallel port communication can take many forms. For one thing, are you trying to control individual data pins directly? Do you need handshaking? Are you trying to stream data through the port the way you might with, say, a parallel port tape drive? Do you need bidirectional communications? EPP or ECP? Special timing considerations? The latter thing might be something which actually *prevents* you from using Python, as it might not be high-performance enough to provide you with the necessary signal timing. I'm guessing you need to be able to set up the data pins as outputs, then place a particular bit pattern on them, then toggle a handshaking line active then inactive. If this is the case, what you could do under DOS would probably be suitable here. That means finding a way of talking directly to the control registers of the parallel port, at 0x378 for LPT1 for example. A quick search on google.com didn't produce any useful results for me, so my only other suggestion at the moment is to look into the win32all extensions produced by Mark Hammond and available by following the links at http://www.python.org/2.1 . These provide direct access to the Win32 API which doubtless has some routines that could provide direct access. I know this is probably not a big help at the moment, and if I'd done this myself I'd send you something more useful. I've generally tried to avoid using the parallel port to communicate with things because it is generally unreliable and complicated to use compared to a serial port... And I know *that* doesn't help when you don't have control over the nature of the other device... -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From treaves at silverfields.com Fri Jul 13 09:18:33 2001 From: treaves at silverfields.com (Timothy Reaves) Date: Fri, 13 Jul 2001 09:18:33 -0400 Subject: Compile 2.1 problem In-Reply-To: <20010712231559.Q5396@xs4all.nl> References: <20010712133304.3415243d.treaves@silverfields.com> <20010712231559.Q5396@xs4all.nl> Message-ID: <20010713091833.1906590d.treaves@silverfields.com> On Thu, 12 Jul 2001 23:15:59 +0200 Thomas Wouters <thomas at xs4all.net> wrote: > On Thu, Jul 12, 2001 at 01:33:04PM -0400, Timothy Reaves wrote: > > On 12 Jul 2001 13:18:35 -0400 > > Alex <new_name at mit.edu> wrote: > > > > > > > > What output do you get when you run the last command, > > > with the -v flag? > > Please re-read Alex's posting, and compare it with yours. You are using '>'s > where he typed '\'s. There is an important difference :) That was because I copied it from the e-mail. Live and learn. This is the output, which is a bit long. -------------- next part -------------- A non-text attachment was scrubbed... Name: py.out Type: application/octet-stream Size: 3919 bytes Desc: not available URL: <http://mail.python.org/pipermail/python-list/attachments/20010713/e46bc075/attachment.obj> From guido at python.org Thu Jul 26 17:59:40 2001 From: guido at python.org (Guido van Rossum) Date: Thu, 26 Jul 2001 21:59:40 GMT Subject: Opcode compatible division References: <mailman.996084400.32614.python-list@python.org> <cpae1s935l.fsf@cj20424-a.reston1.va.home.com> <3b603e72.476839078@wa.news.verio.net> Message-ID: <cpae1r5p31.fsf@cj20424-a.reston1.va.home.com> bokr at accessone.com (Bengt Richter) writes: > Is from future a one-way effect for the rest of the interpreter's execution? It is done on a per-module basis -- each module that wants the effect must contain a future statement. Read PEP 236, it spells it out in nauseating detail: http://python.sourceforge.net/peps/pep-0236.html --Guido van Rossum (home page: http://www.python.org/~guido/) From tim.leeuwvander at nl.unisys.com Tue Jul 17 17:27:18 2001 From: tim.leeuwvander at nl.unisys.com (Leeuw van der, Tim) Date: Tue, 17 Jul 2001 16:27:18 -0500 Subject: Binary ZODB packages for Win95? Message-ID: <DD0DC14935B1D211981A00105A1B28DB033ED364@NL-ASD-EXCH-1> Hello, Does anyone know of any download-location for binary packages of standalone ZODB for Win95? I don't have a compiler for Windows, so I depend on binary packages for this OS! With thanks, --Tim From web2ed at yahoo.com Fri Jul 6 14:58:58 2001 From: web2ed at yahoo.com (Edward Wilson) Date: 6 Jul 2001 11:58:58 -0700 Subject: Postgres support References: <gul1kts5l6aolk55o7vguk97uorjd08j9f@4ax.com> Message-ID: <5174eed0.0107061058.5446dac9@posting.google.com> This is exactly what I have been talking about for *years* now. Python will only appeal to scientific developers researching the "impossible to do" until it handles databases on a first class scale. Oh, and another point, ODBC is dead. Microsoft has already abandand it for OLEDB a COM based library. References to ODBC need not apply. What is needed are RAW Native Drivers at the C/C++ level. Python needs a ready to use cross database module which handles Oracle, DB2, SQL-Server, Sybase, and Informix. If it handles Postgres and MsSQL that would be a bonus, however, most $$ gigs don't use the last two db's much so most of the focus should be on the "big five" or at least on the big three (Oracle, DB2, and SQL_Server). In my opinion, what has held Python back from going primetime virtical is it's lack of commercial grade db support, and I beleive it will continue to do so until a tribe of Python-developers gathers to accomplish this end. I have for a long time felt that this has warranted the support of the General himself """_GV_""" if for nothing else than for moral support and inspiration to see this call to it's end. The Python cummunity should throw it's best resources at this void until this call is answered. Once a baseline is established, many intermediate developers could mantain such a platform. The main need of the hour is to draw a crowd, once the crowd exists--it will self-sustain. -zERO From piet at cs.uu.nl Thu Jul 12 18:20:39 2001 From: piet at cs.uu.nl (Piet van Oostrum) Date: 13 Jul 2001 00:20:39 +0200 Subject: Problems getting mod_python up n' running References: <4e2ddb70.0107121317.4c883f6c@posting.google.com> Message-ID: <wz1ynlrdqg.fsf@sunshine.cs.uu.nl> >>>>> "Jonas Bengtsson" <jonas.b at home.se> (JB) writes: JB> Furthermore I have put following files under JB> e:\program\python21\libs\mod_python: That should be in e:\program\python21\mod_python JB> And my environment path contains: JB> E:\Program\Python21;e:\Program\Python21\libs You mean PATH? The last part is not necessary. JB> What can be the problem? See above. -- Piet van Oostrum <piet at cs.uu.nl> URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From jeff at ccvcorp.com Mon Jul 2 12:43:36 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Mon, 02 Jul 2001 09:43:36 -0700 Subject: PEP scepticism References: <mailman.993747643.21070.python-list@python.org> <9hfqb5$dsllb$3@ID-89274.news.dfncis.de> <3dhex01n1m.fsf@ute.cnri.reston.va.us> <roy-900E5D.10061401072001@news1.panix.com> Message-ID: <3B40A4B8.E8F3DC04@ccvcorp.com> Roy Smith wrote: > Having now used python for about 4 years, I still think > indentation-for-grouping was a dumb idea. The problem is that it is just > too easy to add or delete whitespace by accident (and without noticing), > especially when cutting and pasting hunks of code from one place to > another. When such whitespace munging makes the code look ugly, it's > simply a minor annoyance. When it changes the meaning of the code, it's a > language design mistake. Not to say that your opinion isn't considered, but... It seems to me, that it's just as likely that cut-and-paste is as likely to result a missed bracket as it is to result in munged whitespace. And I, personally, find it a lot easier to track indent levels than I do to search out brackets or whatnot within large code blocks. I imagine that it eventually boils down to a personal-taste distinction... Jeff Shannon Technician/Programmer Credit International From pobrien at orbtech.com Sun Jul 15 13:35:24 2001 From: pobrien at orbtech.com (Patrick K. O'Brien) Date: Sun, 15 Jul 2001 17:35:24 GMT Subject: Naked function call syntax References: <3b4fa037.1845423078@wa.news.verio.net> Message-ID: <wvk47.45349$J91.2359350@bgtnsc06-news.ops.worldnet.att.net> Here is a class that might give you some ideas. If you combined this with raw_input('What do you want to pd?') as the method you might get something close to what you want. I haven't actually used this class with something that needed a parameter but it should be doable. class PseudoKeyword: '''A callable class that implements a method that is passed as a parameter. Good for creating a pseudo keyword in the python runtime environment. The keyword is really an object that has a repr() that calls itself which calls the method that was passed in the init of the object. All this just to avoid having to type in the closing parens on a method. So, for example: >>> quit = PseudoKeyword(SomeObject.someMethod) >>> quit SomeObject.someMethod gets executed as if it had been called directly and the user didn't have to type the parens, like "quit()". This technique is most applicable for pseudo keywords like quit, exit and help. ''' def __init__(self, method): # XXX Should probably check that this is a callable object. self.method = method def __call__(self): self.method() def __repr__(self): self() return '' --- Patrick K. O'Brien Orbtech "I am, therefore I think." "Bengt Richter" <bokr at accessone.com> wrote in message news:3b4fa037.1845423078 at wa.news.verio.net... > Interactively, I find myself writing little things like: > > def pd(x): > try: > print x.__doc__ > except: > print '(no doc string)' > > so that, e.g., I can type > > pd(vars) > > and get formatted info. But I'm lazy enough that > I would like to to type just > pd vars > > Is there an existing pythonic way to do this? > > If not, would there be breakage if python were modified to make > > foo whatever-up-to-EOL > > equivalent to > > foo(whatever-up-to-EOL) > > when it would be a syntax error otherwise? I.e., I'm wondering > if the grammar could be modified to do this by changing trailer > to accept arglist NEWLINE if _all_ else fails, and treat a match > as if it was an arglist. Leading '(' or '[' ambiguity would be > resolved in favor of normal arglist or subscriptlist. > > From tim at digicool.com Mon Jul 23 15:52:31 2001 From: tim at digicool.com (Tim Peters) Date: Mon, 23 Jul 2001 15:52:31 -0400 Subject: PEP0238 lament In-Reply-To: <15196.17040.65029.654718@beluga.mojam.com> Message-ID: <BIEJKCLHCIOIHAGOKOLHAEFPCDAA.tim@digicool.com> [Skip Montanaro] > I'm not a denizen of the edu-sig list, but Guido has mentioned the > Alice folks (I think they are the ancestors of the VPython folks) > before as a significant influence on his ideas about this subject. > Perhaps you would class them as educators and not numeric people, but > I would throw them in the numeric camp. Does it make one whit of difference to anything here? If so, I read Matt Conway's doctoral dissertation when this issue was still new, and it's far more about pedagogy than numerics in Alice. From aahz at panix.com Mon Jul 16 09:33:00 2001 From: aahz at panix.com (Aahz Maruch) Date: 16 Jul 2001 06:33:00 -0700 Subject: Boolean idioms (was Re: re Challenge: More Compact?) References: <mailman.995247446.16415.python-list@python.org> Message-ID: <9iuqec$1bh$1@panix2.panix.com> In article <mailman.995247446.16415.python-list at python.org>, Tim Peters <tim.one at home.com> wrote: > >Well, it's un-Pythonic to try to emulate Perl undef via Python None; it's >idiomatic to return 0 for false and 1 for true, [...] I know that it's a frequent Python idiom to use 0/1, but where is it specifically un-Pythonic to use 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 "How come we choose from just two people for President but more than 50 for Miss America?" --AEN From grayson-wilson at home.com Wed Jul 11 19:48:07 2001 From: grayson-wilson at home.com (EricIDLE) Date: Wed, 11 Jul 2001 23:48:07 GMT Subject: Help With filter(). Message-ID: <XA537.678643$166.13965187@news1.rdc1.bc.home.com> What does filter do? I don't understand when I read it other places. From guido at python.org Fri Jul 13 15:26:58 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 13 Jul 2001 19:26:58 GMT Subject: Language change and code breaks References: <mailman.994958301.16016.python-list@python.org> <3B4E586D.35460F68@engcorp.com> Message-ID: <cpelrk39t9.fsf@cj20424-a.reston1.va.home.com> Peter Hansen <peter at engcorp.com> writes: > Unfortunately, while code a chemist writes is very likely never > going to rely on the current integer division behaviour, code > written by those of us in computers who tend to work closely > with the hardware (where we are constantly thinking in terms > of bytes, words, signed and unsigned, memory locations, bits > and nybbles, etc.) will fairly often write code which depends > on the current behaviour. Ah, but you professional programmers can easily be trained. Just the fact that you can already juggle all those concepts in your head means that you won't have much trouble learning the additional fact that i/j returns a float and that integer division must be spelled as i div j. > I can't see a simple answer to this. It looks as though there > are two camps, to both of whom it is absolutely essential that > Python act in a specific way. And the two ways are completely > incompatible. No, that's not it. The problem is that you have written much more Python code than the chemists of the world, and if I were to change the language, you would have to go through all that code to find out which slashes to replace with 'div'. > Doesn't that mean that the only solution that can be accepted > without causing serious complications is to make the change, > but clearly support a command line option (or some other > configuration setting) to enable the current behaviour, > so those who have depended on integer division can continue > to run old code under the new engine without fear of > breakage? This has been said many times in other contexts: command line options to change a particular behavior are evil. It would mean that library modules could't depend on either behavior. If we're going to give users a choice, it's going to be some kind of per-module switch. > (I know, it's not perfect, but with a little more design > thought it can probably come pretty close. For example, > code that might have to run on someone else's system, which > might not have the correct setting for integer division, > can use a sys.setIntegerDivision(1) call to force the > desired behaviour. Or does this have to be on a module- > by-module basis? Yes, this has to be on a per-module basis. > Anyway, that's not my problem. :-) Yes it is! Unless we find a solution that *works* you will be affected. > So, O' BDFL, why not take the most Pythonic approach > and use a solution which *pragmatically* achieves a good > practical balance but which causes purists always to feel > a little uneasy and which can lead to perpetual discussion > about "warts" and why other languages are better and.... ;) Believe me, I'm trying. --Guido van Rossum (home page: http://www.python.org/~guido/) From david at boddie.net Wed Jul 25 13:01:24 2001 From: david at boddie.net (David Boddie) Date: 25 Jul 2001 10:01:24 -0700 Subject: Future division patch available (PEP 238) References: <mailman.996052189.14819.python-list@python.org> Message-ID: <18289ee4.0107250901.3910d4e1@posting.google.com> tanzer at swing.co.at (Christian Tanzer) wrote in message news:<mailman.996052189.14819.python-list at python.org>... > Guido, > > I deeply respect your language design skills and I appreciate your > ongoing improvements. I'm impatiently looking forward to using many of > the features new in 2.2. I'd like to echo these sentiments. One of the things I like about Python is its pragmatism. For example: although it provides classes and objects, it is forgiving to those of us who were raised without them. [Problems associated with backwards compatibility snipped.] > What if `/` applied to two integer values returned neither an > integer nor a float but an object carrying the float result but > behaving like an integer if used in an integer context? > > For instance: > > >>> x = 1/2 > >>> type(x) > <type 'Ratio'> > >>> print "%d %f %s" % (x, x, x) > 0 0.5 0.5 > >>> 2 * x > 0 > >>> 2. * x > 1.0 > > The difficult issue here is how `integer context` is defined. > Should multiplication by an integer be considered an integer > context? Pro: would preserve correctness of existing code like > `(size / 8) * 8`. Con: is incompatible with Rationals which might > be added in the future. A problem arises if the type of the result (x in this example) is not immediately resolved, requiring this context to be carried forward. A "neutral" operation immediately following the assignment above, such as a print statement (for want of a better example) or even another division would further complicate the issue by leaving the interpretation of the result until later when the original context is unavailable. [...] > - If there is a possibility of specifying division semantics on a > per module case (via a directive or the file extension), it should > also be possible to specify the semantics for thingies like > `compile`, `execfile`, `exec`, and `eval`. > > This only works if absence of a semantics indicator means old-style > division. This has to be the best way to go. A substantial change to the behaviour of the language should require the module author's explicit intent. > I think this would go the farthest to alleviate compatibility > problems. I understand your desire to avoid dragging the past around > with you wherever you go and I like Python for its cleanliness. But > in this case, it might be worthwhile to carry the ballast. If the behaviour of the / operator can be assigned on a per module basis, and it is made explicit where changes to the default behaviour occur, then what is the harm of carrying the old (standard) behaviour forward? Without wanting to detract from Christian's points above, I'd like to make a few observations. I apologise in advance if you've read these too many times already: I migrated to Python from RLaB (a Matlab-like language) and was surprised by the behaviour of integer division. However, reading the tutorial made it clear that the / operator performed "integer division" and that the % operator gave the modulus(?) of the result. Since this is the main (most convenient) way to perform integer division on current versions of Python, one would expect that to change the behaviour of / would be to break most code which previously performed integer division. Introducing // for int/int -> *float* (as has been suggested as a counter-measure to // for int/int -> int) isn't going to help since it will either be a special case operator, or it will have to be extended to work with float/float and mixed type operations. Otherwise programmers will have to explicitly check for two integer arguments and apply a different operator in that case. I expect that under other circumstances there would be an outcry over introducing // at all, as it going against the general preference for readability in Python. In my opinion, PEP 238 is something of a half measure. It takes away / for integer division yet doesn't introduce the "div" keyword (or the "mod" keyword for that matter). However, if it did include these then I suspect that it would attract even more criticism. Since one outcome of the PEP is to have int/int -> rational, then shouldn't we wait until rationals have become standard issue, or have they already? Otherwise we'll have to go through this all over again, and nobody wants that. One solution to the problem that / doesn't do what is expected, at least during interactive mode, is to retain the standard behaviour by default with the option to change this on a per module basis. However, in interactive mode, the default would be to have the new division behaviour switched *on* with a suitable warning reminding the user that this is the case. Therefore, nobody is surprised at the command line, and old modules continue to work as normal. Although I expect that there creatures that are immune to this particular magic bullet. <wink> pragmatism-always-wins-ly y'rs - David From aleaxit at yahoo.com Mon Jul 16 11:58:11 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 16 Jul 2001 17:58:11 +0200 Subject: timed event?? References: <tl5t1fprkuobd@corp.supernews.com> Message-ID: <9iv2uk0pcu@enews2.newsguy.com> "NJM" <njm at rectec.net> wrote in message news:tl5t1fprkuobd at corp.supernews.com... > I want to write a program that does things on a timed basis. Can someone > tell me where is the best place to start? I can't seem to find any modules > that will help me. Maybe standard module sched...? Alex From skip at pobox.com Sun Jul 8 11:38:22 2001 From: skip at pobox.com (Skip Montanaro) Date: Sun, 8 Jul 2001 10:38:22 -0500 Subject: csv to XML converter crash and burn In-Reply-To: <tkgnj6feescc0d@xo.supernews.co.uk> References: <tkgnj6feescc0d@xo.supernews.co.uk> Message-ID: <15176.32366.287906.974092@beluga.mojam.com> >>>>> "Julius" == Julius Welby <jwelby at waitrose.com> writes: Julius> I just got all public spirited and posted this: Julius> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66003 Julius> It's a module for transforming csv to XML. It works fine for cvs Julius> strings where no escaped commas or "" appear but..... Julius> Unfortunately I now realise I didn't have a sufficient grasp of Julius> the csv format. Julius, You might want to take a look at Dave Cole's recently announced CSV parser: http://groups.google.com/groups?q=CSV&hl=en&group=comp.lang.python.*&safe=off&rnum=3&ic=1&selm=mailman.992813221.29993.clpa-moderators%40python.org Use that for parsing, then restrict your code to generating XML. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From sill at optonline.net Tue Jul 17 21:20:30 2001 From: sill at optonline.net (Rainy) Date: Wed, 18 Jul 2001 01:20:30 GMT Subject: How popular is Python, anyway? (was: Long Live Python!) References: <E566B020833BD311B6610008C791A39705CA5230@il93exm04.css.mot.com> <mailman.994804336.23495.python-list@python.org> <slrn9koofo.mjk.philh@comuno.freeserve.co.uk> <slrn9kpr3e.527.sill@sill.silmarill.org> <Gzj37.13006$B7.2564502@ruti.visi.com> <slrn9ks0mh.9oi.sill@sill.silmarill.org> <23891c90.0107170315.36f571e9@posting.google.com> Message-ID: <slrn9l9p15.cm.sill@sill.silmarill.org> On 17 Jul 2001 04:15:40 -0700, Paul Boddie <paul at boddie.net> wrote: > sill at optonline.net (Rainy) wrote in message news:<slrn9ks0mh.9oi.sill at sill.silmarill.org>... >> >> "I meant more like sending somewhere my resume saying I know python and did >> this and that, and getting hired. I actually did use some python at my >> previous job (some cgi/image manipulation). I was then asked to redo it >> in perl :-/." > > I can't stand it when that kind of thing happens. In your case, you > were using a language with some pretty potent tools available for it > to get the job done. A similar kind of idiocy was once imposed on me, > forcing me to rewrite various CGI-based programs in C++ of all > horrors. Insane! That's just bizarre! Good thing they haven't heard that assembly is the fastest, they'd have you do CGI stuff in it ;-). > > Paul -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: http://silmarill.org/cymbaline From guido at zope.com Mon Jul 30 08:36:22 2001 From: guido at zope.com (Guido van Rossum) Date: Mon, 30 Jul 2001 08:36:22 -0400 Subject: proposed language change to int/int==float (was: PEP0238 lament) In-Reply-To: Your message of "Mon, 30 Jul 2001 02:22:21 EDT." <LNBBLJKPBEHFEDALKOLCAEDILCAA.tim.one@home.com> References: <LNBBLJKPBEHFEDALKOLCAEDILCAA.tim.one@home.com> Message-ID: <200107301236.IAA09315@cj20424-a.reston1.va.home.com> [Tim Peters] > Scheme says and reveals nothing about internal representations. Neither does Python, IMO. --Guido van Rossum (home page: http://www.python.org/~guido/) From gerhard.nospam at bigfoot.de Tue Jul 3 10:37:43 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Tue, 3 Jul 2001 16:37:43 +0200 Subject: MS "bans" GPL References: <7iq1ktcmslo24kbr8qvob2g3hpgleuf025@4ax.com> <9hshbp$oqv$2@216.39.170.247> Message-ID: <slrn9k3ji4.49l.gerhard.nospam@lilith.hqd-internal> On 3 Jul 2001 13:29:29 GMT, David LeBlanc <whisper at oz.nospamnet> wrote: >In article <7iq1ktcmslo24kbr8qvob2g3hpgleuf025 at 4ax.com>, mkx at excite.com >says... >> Do the folks at MS _want_ us to find them unreasonable? >> >> http://dailynews.yahoo.com/h/zd/20010702/tc/ms_attacks_open_source_1.html >> >> "The license for Microsoft's Mobile Internet Toolkit, which is in its >> second beta release to developers, says that it may not be used with >> any software under the Free Software Foundation's General Public >> License (GPL) and six other forms of "potentially viral software." >> That language refers to open source code's freely available and shared >> code licensing agreements. The wording of the license cites the Linux >> OS and the Perl scripting language as examples." >> >> >> >Now that Microsoft has bought their way out of most of the anti-trust >suit (cheap too! nationa news reported only a few hundred thousand >dollars contributed to Bush's campaign and his inaugral ball), it's only >a matter of time before the license for the OS prohibits installation of >open source 3rd party software. After all, you only pay for the computer >- MS seems to think they own it otherwise. (One can only hope that the >states attornies general go forward with their anti-trust suit and so >does the EU.) > >I wonder how much they paid for the UK government with it's de-facto "MS >all the way" policy? You have to wonder what was going through the Blair >government's mind when they flew government ministers to Redmond to kick- >off the UK government services on the web project. There's a wee bit of >excitement over there right now since the services that are already up >can only be accessed by Internet Explorer due to reliance on propietary >certificates. > >XP: the coming evil - you thought it was bad now? Just wait. You don't try to spread FUD, do you? No matter what MS or any other company writes into their "license agreements", not everything is compatible with German or US or whatever laws. Gerhard -- mail: gerhard <at> bigfoot <dot> 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 flognat at flognat.myip.org Wed Jul 25 17:21:12 2001 From: flognat at flognat.myip.org (Andrew Markebo) Date: Wed, 25 Jul 2001 21:21:12 GMT Subject: Redirecting broswers in Py References: <3B5F0AC8.BF54029C@telocity.com> Message-ID: <m3vgkgaemy.fsf@localhost.localdomain> First of all, a hint.. you can use """ or ''' or ' to surround strings, so you could do: c.send("""<META HTTP-EQUIV="Refresh"Content=0;Host="http://www.someurl.com">""") Hmm reading this example you seem to be missing a ; between refresh and content, could be a 'news' bugg. Are you only sending this answer?? as reply? You know that you need to send status back also with headers and so on, like HTTP/1.0 200 ok [headers] [empty line] [HTML containting your redirection] An alternative could be to send a "HTTP/1.0 302 Redirect" answer to the browser, including as header the location to move to. /Andy / Adonis Vargas <deltapigz at telocity.com> wrote: | the script accepts the connection then processes information once that | is done i want to be able to send the broswer to X page. i have found | something and used it in the line below: | | c.send("<META | HTTP-EQUIV=\"Refresh\"Content=0;Host=\"http://www.someurl.com\">") | | but i think im going at this completely wrong. | | any help would greatly be appreciated. | | Adonis From tim.hochberg at ieee.org Thu Jul 26 16:35:15 2001 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Thu, 26 Jul 2001 20:35:15 GMT Subject: Numeric.transpose (incorrect documentation) References: <3B6076D4.68B6840C@bioeng.ucsd.edu> Message-ID: <7a%77.49685$Cy.6379277@news1.rdc1.az.home.com> "Curtis Jensen" <cjensen at bioeng.ucsd.edu> wrote in message news:3B6076D4.68B6840C at bioeng.ucsd.edu... > the documenation for the "transpose" function for the "Numeric" module > seems to be incoorect, or at least missleading. The correct place for this is probably the numpy-discussion list, so I'm cc'ing it there. Perhaps the Paul Dubois will see it and have some ideas for clearing of the docs. > It says that transpose is suppose to return a "new" array. In fact it > does not. It returns a pointer to the same array, only with transposed > indicies. It's been a while since I looked at the NumPy docs, so I don't recall what conventions they use here. However, transpose does return a new array, it just points to the same data as the original. If a=transpose(b), "a is b" is false and "a.shape == b.shape" is false, so clearly they are different objects (i.e., different arrays). You know most of this, as you demonstrate down below, I just wanted to make the point that there is a difference between a new array and new data. Note that nearly every operation that can return a reference rather than a copy does so. Even slicing, if b=a[3:5], then 'b' holds a reference to the same data as 'a'. Some functions go so far to return a reference when they can, but otherwise copy. See ravel for example -- it copies the data if its argument is not contiguous, otherwise it uses a reference. Now _that_ can be confusing! Useful though. -tim > consider the example: > > Python 1.5.2 (#4, Sep 5 2000, 10:29:12) [C] on irix646 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> from Numeric import * > >>> foo = zeros([5,10]) > >>> bar = transpose( foo ) > >>> foo > array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], > [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], > [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], > [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], > [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) > >>> bar > array([[0, 0, 0, 0, 0], > [0, 0, 0, 0, 0], > [0, 0, 0, 0, 0], > [0, 0, 0, 0, 0], > [0, 0, 0, 0, 0], > [0, 0, 0, 0, 0], > [0, 0, 0, 0, 0], > [0, 0, 0, 0, 0], > [0, 0, 0, 0, 0], > [0, 0, 0, 0, 0]]) > >>> foo[0,2] = 1 > >>> foo > array([[0, 0, 1, 0, 0, 0, 0, 0, 0, 0], > [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], > [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], > [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], > [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) > >>> bar > array([[0, 0, 0, 0, 0], > [0, 0, 0, 0, 0], > [1, 0, 0, 0, 0], > [0, 0, 0, 0, 0], > [0, 0, 0, 0, 0], > [0, 0, 0, 0, 0], > [0, 0, 0, 0, 0], > [0, 0, 0, 0, 0], > [0, 0, 0, 0, 0], > [0, 0, 0, 0, 0]]) > >>> > > > if bar was truely a new array, then changes to foo would not affect > bar. In the example above, it does. This way actualy works better for > my purposes, however, the documentation is missleading. > > -- > Curtis Jensen > cjensen at bioeng.ucsd.edu > http://www-bioeng.ucsd.edu/~cjensen/ > FAX (425) 740-1451 From donn at drizzle.com Tue Jul 3 03:43:17 2001 From: donn at drizzle.com (Donn Cave) Date: Tue, 03 Jul 2001 07:43:17 -0000 Subject: Augmented Assignement (was: Re: PEP scepticism) References: <oqlmm7tl6j.fsf@lin2.sram.qc.ca> <mailman.993952381.32699.python-list@python.org> <zbN%6.415855$oc7.58414702@news2.rdc2.tx.home.com> <q0avjto87p59hn7gv28r5cf1c84j2fb8c7@4ax.com> <naO%6.416271$oc7.58537852@news2.rdc2.tx.home.com> <vm40kt8knq3pplpv1rarjubl73vnl12ure@4ax.com> <20010702145211.M8098@xs4all.nl> <oqlmm7tl6j.fsf@lin2.sram.qc.ca> <mailman.994135685.10748.python-list@python.org> Message-ID: <994146195.807921@yabetcha.drizzle.com> Quoth Courageous <jkraska1 at san.rr.com>: | Expecting the change of something is one thing and observing it's | incorrectness is another. Be what may about the current implementation | and future of Python, it is simply wrong that a = a + 1 is evaluated | differently than a += 1. | | I'm not sure that this will matter much in the scheme of things; | however, I do know that this behavior will likely always be surprising | to the uninitiated. The equivalency of a = a + 1 to a +=1 is | something that I'd wager is the first instinct of programmers | approaching the form. Probably, though that might just mean programmers approach from C. The thing that I like about all this, it's good to hear what sounds like a consensus that Python programmers need to have some appreciation of the object/reference/binding/namespace thing that happens when we assign. We can't reasonably say "don't worry, it will just work", we can't pass it off as an esoteric internal detail, you need to get this model from the start. Left to your own devices you might not get it. If you don't, you can't accurately predict what your code will do. If augmented assignments confuse a few people, but the potential for confusion leads authors and teachers to take more pains early on, to firm up these notions before += can lead folks astray, I predict a net gain. Donn Cave, donn at drizzle.com From cfelling at iae.nl Thu Jul 26 20:45:14 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 27 Jul 2001 02:45:14 +0200 Subject: Python equivalent of two Perl statements References: <mailman.995644438.3940.python-list@python.org> Message-ID: <9jqdiq$ppb$1@animus.fel.iae.nl> Kemp Randy-W18971 <Randy.L.Kemp at motorola.com> wrote: ... > On 20-Jul-2001 Kemp Randy-W18971 wrote: >> What is the equivalent of these Perl statements in Python? >> >> $time = scalar(localtime); >> print "This FTP request started on $time \n"; >> > import time > now = time.ctime(time.time()) > print now or any of these fine printing lines: print "This FTP request started on %(time)s \n" % locals() print "This FTP request started on %(time)s \n" % {"time": time} print "This FTP request started on %s \n" % time -- groetjes, carel From lomax at pumpichank.com Tue Jul 10 01:12:01 2001 From: lomax at pumpichank.com (Frank "Swelterpie" Lomax) Date: Tue, 10 Jul 2001 01:12:01 -0400 Subject: Bug in rfc822 References: <slrn9khcjv.c7q.philh@comuno.freeserve.co.uk> <QFc27.8798$e5.1167735@newsb.telia.net> <2ih27.49242$he.3402812@e420r-atl1.usenetserver.com> <cp66d2i59b.fsf@cj20424-a.reston1.va.home.com> <15177.50705.483826.728871@beluga.mojam.com> <mailman.994696935.26488.python-list@python.org> <090720011856254589%jwbaxter@spamcop.com> Message-ID: <15178.36513.530758.627272@anthem.wooz.org> >>>>> "JWB" == John W Baxter <jwbaxter at spamcop.com> writes: >> bass tech JWB> Sorry, but my not so nimble mind wondered why a technician is JWB> needed to deal with those passing fish on a musical tour. JWB> Probably a union thing. ;-) No, it is because they emit the most harmonious sub-200Hz fundamentals when stroked just right, i.e. behind the gills, and with a vigorous circular motion. They are tricky beasts to handle, but so much more cooperative than your average contrabasso guitarist. which-in-my-experience-you-never-want-to-stroke-especially-not-vigorous-ly y'rs, - frank From michael at stroeder.com Thu Jul 19 14:32:32 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Thu, 19 Jul 2001 20:32:32 +0200 Subject: dnslib license? References: <3B56DCCB.6EF0DEED@stroeder.com> <3dlmlkyj8p.fsf@ute.cnri.reston.va.us> Message-ID: <3B5727C0.79B8DCAC@stroeder.com> Andrew Kuchling wrote: > > BTW, personally I'd vote for extending the DNS code and adding it as > dnslib.py to the standard library, rather than having it be a separate > project. Since Guido suggested the same this seems to be the master plan... Ciao, Michael. From peter at engcorp.com Sat Jul 7 10:14:52 2001 From: peter at engcorp.com (Peter Hansen) Date: Sat, 07 Jul 2001 10:14:52 -0400 Subject: Comment on PEP-0238 References: <mailman.994427714.26169.python-list@python.org> <cpsngaja4g.fsf@cj20424-a.reston1.va.home.com> <FFv17.1178$Y6.656565@news1.rdc2.pa.home.com> Message-ID: <3B47195C.E5E48F8F@engcorp.com> Terry Reedy wrote: > > GvR: > > I currently favor div(x, y) over x//y and x div y. Maybe also add > > mod(x, y) for symmetry (that would also explain divmod() as a > > messenger from the future :-). > > I suspect that some newbies and > CP4E people would find *that* (div()) strange. I suspect that newbiews and CP4E people rarely need the integer division behaviour and wouldn't care or even realize about div(). In my mind integer division is usually related to operations I think about in terms of the processor (maybe by picturing the assembly code or something). From this point of view, div() is actually probably more reasonable than // or x div y. I think // could actually be the worst as from a readability point of view it looks too much like just / and could lead to tricky bugs. If div() is used, then mod() and divmod() should also both be present, again thinking from the point of view of the way processors work and the assembly code (producing the remainder in other registers simultaneously with the quotient). -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From shalehperry at home.com Fri Jul 20 13:07:21 2001 From: shalehperry at home.com (Sean 'Shaleh' Perry) Date: Fri, 20 Jul 2001 10:07:21 -0700 (PDT) Subject: Python equivalent of two Perl statements In-Reply-To: <E566B020833BD311B6610008C791A39705CA526F@il93exm04.css.mot.com> Message-ID: <XFMail.20010720100721.shalehperry@home.com> On 20-Jul-2001 Kemp Randy-W18971 wrote: > Thanks! I will try that. > FYI, the python time module is essentially a wrapper around the POSIX time functions. do a 'man ctime' and you will be on the right track. From johnroth at ameritech.net Fri Jul 27 11:31:03 2001 From: johnroth at ameritech.net (John Roth) Date: Fri, 27 Jul 2001 08:31:03 -0700 Subject: Eliminating upgrade risk References: <mailman.996105586.6334.python-list@python.org> Message-ID: <tm3298o5hut5d1@news.supernews.com> "Tim Peters" <tim.one at home.com> wrote in message news:mailman.996105586.6334.python-list at python.org... > [John Roth] > > After enduring the PEP 238 threads for far too long, as well as other > > threads, I've come to the conclusion that Python is simply too unstable > > for real use. > > Hmm. That suggests to me you haven't really used it. I'm currently writing a major application. > > Now, I've got a slightly different background here. Much of my > > professional life was in IBM mainframe shops, > > Did IBM invite you to their internal bitch sessions? This is Open Source, > John: it's *all* out in plain view. Heck, I'm the closest thing Guido has > to a PR department <yikes!>, and PEP 238 in particular is talking about > something that may change in 2 years. I've attended Guide, and occasionally Share, for close to a decade. That's an invitation only (users of IBM computers only) session that goes way back. Yes, I do know exactly what I'm talking about here. Release to release compatibility is one of IBM's selling points at the executive management level. > > > where installing a new version of the operating system, major utilities > > and language processors was essentially **guaranteed** not to break > > running applications. > > I have no idea what "essentially **guaranteed**" means. Was this a clause > in a legally binding contract? Or a hyperbolic way of saying you usually > didn't have much trouble? If it was legally binding, how much would you pay > to get the same kind of clause in a Python contract? The community's > aggregate commitment to that cause so far is $0.00 <wink>. See the previous comment about "legally binding." Those promises were made as conditions of sale. Consult your lawyer about ramifications. > > I can remember numerous upgrades where I had to do absolutely > > nothing on the applications side. > > ... > > Believe it or not, most Python upgrades are like that too -- although we > don't currently charge you Big Bux for the opportunity to be locked to IBM > iron, I'm sure we could set a price for that too <wink>. > > an-ibm-mainframe-shop-this-ain't-ly y'rs - tim I see you've totally missed the point, Tim. The watchword in large, successful sites is management of risk. Lots of people like to sneer at IBM, but they got where they are by presenting a low-risk alternative. Some people like to live on the edge, some don't. John Roth > > > From lomax at pumpichank.com Fri Jul 20 13:36:42 2001 From: lomax at pumpichank.com (Frank "Time's Up!" Lomax) Date: Fri, 20 Jul 2001 13:36:42 -0400 Subject: All computers in the world MUST sync with ATOMIC clock before 12:00 AM 21 July 2001!!! References: <E566B020833BD311B6610008C791A39705CA526D@il93exm04.css.mot.com> Message-ID: <15192.27690.424252.623624@anthem.wooz.org> If all Python users do not sync with the atomic clock before midnight tomorrow, Guido's time machine will automatically revert all temporally backported patches. This means bye bye "class", "def", and "yield". We'll be left with Guido's original dream for Python (ca 0.8.3) as an Import Calculus Language. Gordon would have to be voted LFDB and imputils become central to the language (in fact, it would become the only core module). There isn't anything that Guido can do to stop this; as it is clearly stated in the owners manual, tinkering with the machine's internals in this way will cause Universal Chaos and Havoc. You really don't want all Python programs ever written to suddenly start un-executing in reverse do you? I can't de-bear the thought of IEEE 754 support being re-un-added, but without the least most unsignificant digits on the anti-left. cornering-the-market-on-Python-driven-personal-atomic-watches-ly y'rs, - frank From paulsid at home.com Sat Jul 7 18:10:44 2001 From: paulsid at home.com (Paul Sidorsky) Date: Sat, 07 Jul 2001 16:10:44 -0600 Subject: "has" Operator References: <Pine.LNX.4.30.0107080115240.17775-100000@rnd.onego.ru> Message-ID: <3B4788E4.175ACBFC@home.com> Roman Suzi wrote: > if hasattr(myobject, "someattribute"): > foo() > else: > bar() > is clean enough, IMHO... Oops, I didn't know about hasattr(). Yes, that certainly does the trick. Though I have to say the syntax is a little odd (what with the quotes), but it's certainly sufficient. Thanks! Sorry to bother everyone. -- ====================================================================== Paul Sidorsky Calgary, Canada paulsid at home.com http://members.home.net/paulsid/ From tomh at optiscan.com Wed Jul 25 21:57:08 2001 From: tomh at optiscan.com (Tom Harris) Date: Thu, 26 Jul 2001 11:57:08 +1000 Subject: Auto Building MS VC6 Projects Message-ID: <AA94BA487AE0D411829300D0B7A7A95F079501@uluru2.optiscan.com.au> All, I do this in Python using the os.system() command to run MSDEV, but I acknowledge that using COM is probably the better solution. This man has done a lot of the work already in Perl, so porting it should be minimal effort. There are a number of gotchas though, my favourite being MSDEV bringing up random dialog boxes, halting the build until someone comes in and clicks them. http://www.alumni.caltech.edu/~dank/msdev.htm 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 > -----Original Message----- > From: Olaf Meding [SMTP:OlafMeding at noSpam.CompuServe.com] > Sent: Thursday, 26 July 2001 3:35 > To: python-list at python.org > Subject: Auto Building MS VC6 Projects > > Microsoft Visual C++ can be automated (COM, OLE) and I would like to use > Python to automate nightly VC6 builds. > > Has anyone does this and is willing/able to share ideas or code? > Is there any documenation on this somewhere? > > > Olaf > TomoTherapy > > Please remove "noSpam" to get my email address > > From eli-wallach at ugly.com Sun Jul 1 17:06:50 2001 From: eli-wallach at ugly.com (Mexican Bandit) Date: Sun, 01 Jul 2001 21:06:50 GMT Subject: Python cgi script - outputting images References: <pjgujtkkdihrjfelc5qo0acabavvuu5mvo@4ax.com> <5hmujt89383m9n4o044aknd2a0f5d5h0re@4ax.com> <kuels07don.fsf@lasipalatsi.fi> Message-ID: <oj3vjt4mb86e39q6bv1vsf85a62icfa9f9@4ax.com> >windows has separate "text mode" and "binary mode". text mode >means windows does some translation when you write to a file. >this breaks for binary data. stdout also happens to be in >text mode by default. you need to run python with the -u command >line option to get stdout in binary mode. Thanks, problem solved. I tried the same little script in Perl and had the same problem. But the Perl documentation does mention this text/binary mode problem when serving up images on Windows. Regards From aleaxit at yahoo.com Thu Jul 5 16:40:40 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 5 Jul 2001 22:40:40 +0200 Subject: There's got to be an easy way to do this (fwd) References: <mailman.994355168.2401.python-list@python.org> Message-ID: <9i2jv703cm@enews2.newsguy.com> "Lulu of the Lotus-Eaters" <mertz at gnosis.cx> wrote in message news:mailman.994355168.2401.python-list at python.org... ... > filter(lambda c:c.isdigit(), '(123)/456-7890') > > Thirteen characters shorter than Emile's, and still no [re] :-). > > Personally, I even find it easier to read. YMMV. filter(string.isdigit, '(123)/456-7890') is six fewer characters and IMHO more readable still. A few more characters (because you need some preparation, once, outside of the inner loop), but blazingly fast in the inner loop: nondigits = ''.join([chr(x) for x in range(0,256) if not chr(x).isdigit()]) identity = string.maketrans('','') and then in the inner loop '(123)/456-7890'.translate(identity, nondigits) Alex From akuchlin at mems-exchange.org Wed Jul 18 10:32:39 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 18 Jul 2001 10:32:39 -0400 Subject: distutils and python2.1 References: <slrn9lafnl.1on.alf@leo.logilab.fr> Message-ID: <3dzoa2pat4.fsf@ute.cnri.reston.va.us> alf at leo.logilab.fr (Alexandre Fayolle) writes: > python2 setup.py bdist_rpm > the rpm I get will install in /usr/lib/python1.5/site-packages. > > Is there something I can tweak in the setup.cfg, maybe ? There's a --python option to specify the path of the interpreter to use. >From the output of 'python setup.py bdist_rpm --help': --python path to Python interpreter to hard-code in the .spec file (default: "python") --fix-python hard-code the exact path to the current Python interpreter in the .spec file I think in your case --python=python2 would be sufficient. --amk From paul at boddie.net Wed Jul 25 05:50:10 2001 From: paul at boddie.net (Paul Boddie) Date: 25 Jul 2001 02:50:10 -0700 Subject: Future division patch available (PEP 238) References: <GNZwEiAJepW7Ew0F@jessikat.fsnet.co.uk> <mailman.995776716.24336.python-list@python.org> <mailman.995825018.9832.python-list@python.org> <9jfjd6$ad4$2@newshost.accu.uu.nl> <7u6nltoqdnqjjdiquu6ngtaruflhvbvdl5@4ax.com> <j4g0bof3jv.fsf@informatik.hu-berlin.de> <p8unltsi5qda8rpdavja4iemj6r1s2ak4a@4ax.com> <j48zhfgbny.fsf@informatik.hu-berlin.de> <23891c90.0107230531.4fb02b12@posting.google.com> <cpd76qqfow.fsf@cj20424-a.reston1.va.home.com> Message-ID: <23891c90.0107250150.2930f827@posting.google.com> Guido van Rossum <guido at python.org> wrote in message news:<cpd76qqfow.fsf at cj20424-a.reston1.va.home.com>... > paul at boddie.net (Paul Boddie) writes: > > > But over a few releases, which seem to be quite frequent these days, > > one may find oneself with quite a collection of "legacy" programs [...] > I think it will be inevitable for many Pythons to come to provide a > way to turn off the new division rules. I am currently working on a > command line option for this. But a command line option isn't nearly as fine-grained as may be demanded in this case: different modules may use different / operator semantics. Then, some kind of directive is needed, and I can see the "one true division operator" code authors not wanting to pollute their code with such "vulgarity", whilst old code may not be conveniently modified. So how do you manage this? [...] > > "connect", is hardly going to help. Several people are talking about > > clever tools: perhaps once they are written, the authors will then > > give us the type inferencing system people have been wanting for so > > long. <1/2 wink> > > That's not a bad idea. Maybe the race for the best division upgrade > tool will have practical type inference as a side effect. > Traditionally, "mostly correct" type inference has been rejected as > too dangerous; but in a conversion tool, it would be much better than > nothing. Given that satisfactory Python type inference has been hanging around unsolved for years, I think you'll need to put off this change for quite some time. Anyway, if anyone is going to put that amount of effort in, they might as well end up with a new language where they decide the rules. In other words, what is the motivation for devising a comprehensive type inference system for Python without deciding to take such a project along a different path of development from Python itself? (See Vyper for an example of this.) Paul From mcherm at destiny.com Mon Jul 9 16:10:29 2001 From: mcherm at destiny.com (Michael Chermside) Date: Mon, 09 Jul 2001 15:10:29 -0500 Subject: 2.2+ == 3000? (was Re: Comment on PEP-0238) Message-ID: <3B4A0FB5.1D843495@destiny.com> First, thanks for the excellent background. I'd like to address some of your points. Terry J. Reedy wrote: > Conclusion: The proposed/planned change *is* unprecedented. Okay, that seems to be true. > It does not > have a consensus of support, and I believe a vote would go against. This HAS happened before. It's a useful point to make, but not necessarily a good principle for designing a language. Consensus should be listened to, but not kowtowed to. > Theoretical math and CS considerations are mixed if not against it. Mixed. > It > will, I believe, break more lines of code than all other upgrades so far > put together. It does not add any functionality whatsoever. This is true, and is a very good point. It will BREAK CODE, and it DOESN'T ADD FUNCTIONALITY. This is a strong strike against, and must be balanced by other advantages. > It hardly > adds to net clarity, and maybe detracts, depending on the reader and > balance of i/i->i versus i/i->f constructions used. Maybe it clarifies, maybe not. As you point out, there is no consensus. > It makes Python less > intuitive for programmers coming to Python from languages, such as C, that > use the same syntax. I disagree. Coming to Python from C, I would not ASSUME that integer "/" worked the same in Python as in C. Neither would I expect "^" to do XOR. In each case I'd look it up in the manual the first time I tried it. > The reason for it is to cater to the expectations of > current-non-user, hoped-for new users who will not read the grammar, > manuals, or even the tutorials enough to change their expectations. [Note, > for instance, that this consideration hardly entered the recent discussion > on syntax for generators.] Oh come on. Python *IS* attracting new users on a regular basis, and it clearly (to me!) has the possibility to attract beginners. This is a GOOD THING. > Finally, this change was defined years ago as > one that would only happen in a new series of Python releases. > Guido... I happen to think you are right, that div is not the best interpretation of int/int. I'm not sure what IS the right answer, though. If everyone said, "this will break too much code", then I'd have to be understanding. But as a fairly new user, without large existing scripts to maintain, I don't really mind. Others are not as lucky (or are MORE lucky since they got to use Python sooner than I did). Gotta-let-Guido-know-that-not-EVERYONE-disagrees-ALL-the-time-ly yours, Michael Chermside From google.com at wizemail1.cjb.net Tue Jul 24 20:39:50 2001 From: google.com at wizemail1.cjb.net (Ricardo Correia) Date: 24 Jul 2001 17:39:50 -0700 Subject: Bug? Message-ID: <4835e825.0107241639.bbf438e@posting.google.com> Hi --------------------------------------------------- mainlist = [1, 2, 3, 4, 5] copy = mainlist for item in copy: print item, mainlist.remove(item) --------------------------------------------------- Shouldn't this produce '1 2 3 4 5'? I only get '1 3 5' and unfortunately because of this my program doesn't work. I'm using python 2.0 (the one that comes with Mandrake 8.0) Thanks Ricardo Correia From phrxy at csv.warwick.ac.uk Wed Jul 18 15:26:30 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Wed, 18 Jul 2001 20:26:30 +0100 Subject: Python 2 times slower than Perl In-Reply-To: <3B559B30.61A90EA@jam.rr.com> References: <8f41cfd.0107171238.6ff33b9b@posting.google.com> <9j3rvk$26bt$1@norfair.nerim.net> <3B559B30.61A90EA@jam.rr.com> Message-ID: <Pine.SOL.4.30.0107182025300.21247-100000@mimosa.csv.warwick.ac.uk> On Wed, 18 Jul 2001, Rob Andrews wrote: > Gilles Lenfant wrote: > > > > Seriously, compare 2 languages with really useful features (Genrate PDF > > report, extract XML data...). > > You can find useless stuffs that run much faster in Python than in Perl. > > > > I'd love to see some comparisons in which people who are good at their > respective languages are given the same task considered reasonably > programmable in each of the given languages. [...] may be of interest: http://www.twistedmatrix.com/users/jh.twistd/python/moin.cgi/IcfpPythonTeam John From tbryan at python.net Sat Jul 21 22:02:31 2001 From: tbryan at python.net (Tom Bryan) Date: Sun, 22 Jul 2001 07:02:31 +0500 Subject: Python embebbed with Oracle SQL*Plus References: <eef39a63.0106270501.4865aeab@posting.google.com> Message-ID: <9jebjm$m4l$1@slb6.atl.mindspring.net> 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? Yes, as others have stated, you can probably do something similar with sqlplus and the popen functions. > 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?). I can recommend DCOracle. You won't need to make a special Python, but you will need to install an extension module (which may include compiling it from sources). If you're using Jython, I've heard that you can also use Java's JDBC, but I've never tried it. > Generally, what is the best way to script Oracle with > Python, and how does it compare to the two above? I'd say DCOracle is the way to go. At least give it a try. http://www.zope.org/Products/DCOracle/ http://www.zope.org/Members/matt/dco2 See also http://www.python.org/sigs/db-sig/ http://www.python.org/topics/database/ more-fun-than-a-terabyte-of-data-ly yours ---Tom From bill-bell at bill-bell.hamilton.on.ca Mon Jul 16 15:06:27 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Mon, 16 Jul 2001 15:06:27 -0400 Subject: timed event?? In-Reply-To: <995307592.350.37802.l7@yahoogroups.com> Message-ID: <3B5302F3.29092.45A4363@localhost> "NJM" <njm at rectec.net> wrote: > I want to write a program that does things on a timed basis. Can > someone tell me where is the best place to start? I can't seem to > find any modules that will help me. If you mean "at intervals" then you might consider wxTimer in wxPython (www.wxpython.org). I haven't used it; however, the documentation says it can be used in Python. Bill Bell, Software Developer From nhodgson at bigpond.net.au Wed Jul 18 02:26:11 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Wed, 18 Jul 2001 06:26:11 GMT Subject: PEP: Defining Python Source Code Encodings References: <mailman.995435490.11996.python-list@python.org> Message-ID: <7_957.12503$Xr6.103094@news-server.bigpond.net.au> Roman Suzi: > ...Neil Hodgson wrote: > > Allowing non-ASCII characters in names enhances interoperaility with Java > > and .NET which allow this. > > Why every vapor MS introduces triggers such a chain reaction in IT > circles? That everything must conform or die?! Java has been around for more than 5 years now and is hardly vapour. > Who in his right mind uses non-ASCII names for identifiers? People who wish to be able to understand their own code and for their code to be understood by colleagues. Despite having little skill in the language, I would prefer to read code with sensibly chosen Japanese identifiers rather than repeated meaningless ASCII identifiers. These are all too common when non-ASCII characters are disallowed. Neil From stevewilliams at wwc.com Tue Jul 24 00:16:07 2001 From: stevewilliams at wwc.com (Steve Williams) Date: Tue, 24 Jul 2001 04:16:07 GMT Subject: FTP win32 program References: <1m477.55371$rt.8243308@typhoon.tampabay.rr.com> Message-ID: <3B5CF72B.E810465F@wwc.com> Acid wrote: > I am trying to write simple program with Python to connect to an ftp, > list, download a file(s) etc... > > I am running this under Win2K professional with Python 2.1: > > [snip] > I start the Python Gui, then New Window, put the above script in, then > save, then Run Script. It returns: > > File "C:/Python21/download.py", line 2 > from ftplib import FTP > ^ > SyntaxError: invalid syntax > > What's the trick to get this working under Win32? > That caret is in a suspicious place. How are you putting the script in the New Window? Cut and paste? Check for random leading whitespace. Anyway, don't use 'from ftplib import FTP' even though the code itself and Beasley give that as their example, because you'll have trouble catching exceptions. And you will definitely want to catch exceptions with ftp. Use something like #============================= import ftplib #Connect to host try: ftp = ftplib.FTP('x,y,z') except ftplib.all_errors, e: print e . . . #punt #Change working directory try: ftp.sendcmd('CWD /misc')) except ftplib.all_errors, e: print e . . . #punt #List the directory try: ftp.retrlines('LIST') except ftplib.all_errors, e: print e . . . #punt #========================= instead. I know the verb 'catch' is not Pythonic, but . . . From bh at intevation.de Thu Jul 26 14:22:14 2001 From: bh at intevation.de (Bernhard Herzog) Date: 26 Jul 2001 20:22:14 +0200 Subject: Exceptions' Behaviour References: <mailman.995459309.19355.python-list@python.org> <ac677656.0107181058.71f62494@posting.google.com> <mailman.995526636.21726.python-list@python.org> <ac677656.0107191006.28da887e@posting.google.com> <slrn9m0mjj.l0b.quinn@yak.ugcs.caltech.edu> Message-ID: <6qsnfjczzd.fsf@abnoba.intevation.de> quinn at yak.ugcs.caltech.edu (Quinn Dunkan) writes: > On 19 Jul 2001 11:06:02 -0700, Tom Good <Tom_Good1 at excite.com> wrote: > >Martin Sj?ren <martin at strakt.com> wrote in message news:<mailman.995526636.21726.python-list at python.org>... > >> Yes I know that, but that's not what I'm asking. What I'm asking is why i > >> n > >> > >> >>> raise ("a","b") > >> > >> the "b" disappears? IMO that's a pretty weird behaviour. Yes anybody usin > >> g > >> non-class exceptions derived from Exception in a real-world program are > >> insane, but this is a puristic thing of mine. :-) > >> > >> Martin > > > >I agree, it is kind of weird, and I don't know why it works that way. > >I would probably expect trying to raise a tuple to generate an error. > > I expect it's backwards compatibility. Many moons ago there were no > user-defined classes, and hence no instance exceptions. Ever notice > the __getitem__ trickiness IOError does so it can be unpacked like > like a 2-tuple? I have a feeling that once upon a time it was. AFAIK, these are different things, actually, although they both have to do with string-based exceptions. With string exceptions, the exception type is a string and when it is raised it may have an associated value. For IOError, the value was a 2-tuple. With class-based exceptions, the value is always an instance of the exception class (or a derived class), but for backwards compatibility it has to behave like a 1-tuple in some cases. The raise behavior is related to the trick used to simulated base-classes for string-based exceptions. If you want to have a common 'baseclass' for exceptions E1 and E2, you simply use the tuple (E1, E2). You can use that tuple both in except clauses and in raise statements. Now since exceptions are really strings the raise statement if the exception type is a tuple takes the first item recursively until it finds a string. Bernhard -- Intevation GmbH http://intevation.de/ Sketch http://sketch.sourceforge.net/ MapIt! http://mapit.de/ From philh at comuno.freeserve.co.uk Mon Jul 9 17:21:59 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Mon, 9 Jul 2001 22:21:59 +0100 Subject: A modest proposal (was: Comment on PEP-0238) References: <mailman.994427714.26169.python-list@python.org> <cpsngaja4g.fsf@cj20424-a.reston1.va.home.com> <hdgcktgn4eksejt01vqa8k0g7k69ov1isj@4ax.com> <9icndo$loe$1@nntp6.u.washington.edu> Message-ID: <slrn9kk83m.gh1.philh@comuno.freeserve.co.uk> On 9 Jul 2001 16:51:04 GMT, Donn Cave <donn at u.washington.edu> wrote: >Quoth Courageous <jkraska1 at san.rr.com>: >... >| [Snip: Guido's plan] >| >| This seems to me to be reasonable. While backward compatibility >| is important in computer languages, the real problem occurs when >| changes are abrupt. And in any case, we always have older versions >| of the interpreter around. > >Sure. For me, it looks like older versions is all we're going to >have around. Python is getting too complicated, has always been >too slow (mainly startup cost), and now it's going to start breaking >existing code in a serious way, for the sake of notions that are >very debatable. It seems to me that two forces are at work here. One force, concerned about existing Python code, wants Python to maintain as much backward compatibility as possible. This is an entirely sensible concern, rooted in a pragmatism torward software design. Another force, concerned about possible flaws in Python as it stands, wants to improve the language. Thus we have new operators such as +=, and other changes for the good. Thus also we have a PEP regarding integer division, which Guido thinks is a flaw in the current version of Python. This attitude of wanting to make the most elegant possible programming language is also entirely sensible, not least because if Guido didn't think that way, Python wouldn't exist and we'd all be using P**l or something like it. So, how do we reconcile the two? I suggest we continue to name the existing language "Python" and the new developments by called under a different name ("SuperPython" or "CP4A" possibly). That way, everyone gets what they want. The new SuperPython would be free to experiment with radical new ideas -- including changing the case-sensitivity, for example. And the old, exisiting Python would be guaranteed to evolve in a way that doesn't break existing code, without a very very good reason. Futhermore, SuperPython could compile to the same bytecode format as Python. This would mean that existing Python libraries would work with SuperPython. -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From urner at alumni.princeton.edu Wed Jul 25 03:19:24 2001 From: urner at alumni.princeton.edu (Kirby Urner) Date: Wed, 25 Jul 2001 00:19:24 -0700 Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <eppstein-03540D.13070222072001@news.service.uci.edu> <LNBBLJKPBEHFEDALKOLCOECNLAAA.tim.one@home.com> <mailman.995899647.346.python-list@python.org> <tclolt053o18f8q0ntb7n4aggitdkmeg4h@4ax.com> <Io_67.23543$B7.3779351@ruti.visi.com> <slrn9lp2m5.vp.Gareth.McCaughan@g.local> <p56plt8q4rs3bgcqbepk61q2r3g0tr2vhe@4ax.com> <slrn9ls3ae.2fm.Gareth.McCaughan@g.local> <cpitghbq05.fsf@cj20424-a.reston1.va.home.com> <9jlo4v$rhbl$1@sky.inp.nsk.su> Message-ID: <9lsslt4gst61qal99c5n3oj74ievl2i6tp@4ax.com> "Andy Salnikov" <salnikov at inp.nsk.su> wrote: > Would not it be better to have rationals first and than change meaning of >int/int->rational, than changing first to int/int->float and then to >int/int->rational? > >Cheers, >Andy. > This echoes my sentiments over on edu-sig at python.org: Were I in charge, I might have preferred that / remain the way it is, until/unless a more Scheme-like inclusion of the rational number type (different from float) came along, which would happen when the "long" type melted away, and became part of "int" (seamless i.e. no difference from the user's point of view). This might have happened in 3.xx. I think it's somewhat premature to fiddle with / in 2.x. More context: http://mail.python.org/pipermail/edu-sig/2001-July/001543.html where I admit it: I'm not in charge :-D Kirby From rnd at onego.ru Wed Jul 18 16:45:02 2001 From: rnd at onego.ru (Roman Suzi) Date: Thu, 19 Jul 2001 00:45:02 +0400 (MSD) Subject: Python 2 times slower than Perl In-Reply-To: <Pine.SOL.4.30.0107182005070.21247-100000@mimosa.csv.warwick.ac.uk> Message-ID: <Pine.LNX.4.30.0107190021260.6530-100000@rnd.onego.ru> On Wed, 18 Jul 2001, John J. Lee wrote: >On 18 Jul 2001, Johann Hibschman wrote: >[...] >> cc -O2 0.28 >> cc 0.62 >> ocamlopt 1.26 (compiled) >> ocaml 9.42 (interpreted) >> perl 28.9 >> python 66.8 >> >> Hm. I'm beginning to wonder if I compiled python with -O2 or not. >> Plus, I'm becoming more and more fond of ocaml. I have 65.67user 0.07system 1:05.90elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (253major+163minor)pagefaults 0swaps with Python 2.1.1c1 (on AMD K6-225) Other Python versions on the same machine: $ time python1.5 tst.py 10000000.500000 6.250000 61.95user 0.03system 1:02.43elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (345major+76minor)pagefaults 0swaps $ time python2.0 tst.py 10000000.500000 6.250000 61.68user 0.03system 1:02.40elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (419major+95minor)pagefaults 0swaps $ time python2.1 tst.py 10000000.500000 6.250000 63.72user 0.02system 1:04.00elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (290major+108minor)pagefaults 0swaps (these results are not strictly correct, because I have not done reruns to eliminate startup times differences properly. >> >> The python function I used was the basic >> >> def test (): >> i = 2.5 >> j = 2.5 >> while i < 1e7: >> j = 2.5 * 2.5 >>> i = i + 1.0 >> print "%f %f\n" % (i, j) >> >> if __name__ == '__main__': >> test () > >When do you ever write Python code that does this kind of thing?? For >example, if you're doing lots of fp work, don't you use Numeric? > >Must try OCaml, though (and Haskell)... That is my observation too after I saw language shootout results. (URL appeared here many times). But in my applications speed is not the main virtue. The top thing is express logic in a plain language and this is Python great at. However, my collegues noticed that Python is too slow to be Squid redirector (to stop ads) while Perl is great at the same task (because Perl was designed for such application). This doesn't make Python worse! If you rewrite the test above in Assembly, you will get it even faster than in C, but does the effort spent worth it? That is why I do not understand why Java is so popular: it is not large enough improvement over C/C++ in terms of source readability but still poses serious overhead in execution speed... I have the feeling it stalled at the middle between C++ and Python... Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Wednesday, July 18, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Hard work never killed anyone, but why chance it?" _/ From thomas at xs4all.net Tue Jul 3 10:26:25 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 3 Jul 2001 16:26:25 +0200 Subject: New PEP: Quality Guidelines For Standard Modules In-Reply-To: <5.0.2.1.0.20010703080216.026f3ab0@mail.inet.com.br> References: <5.0.2.1.0.20010703080216.026f3ab0@mail.inet.com.br> Message-ID: <20010703162625.U8098@xs4all.nl> On Tue, Jul 03, 2001 at 08:07:27AM -0300, Carlos Ribeiro wrote: > now, I'm still waiting for Martin's proposed PEP2 text - it seems that he That's Martijn, not Martin :) 'Martijn' has the emphasis on the 'ij', which is pronounced not unlike the 'ai' in "aiieeeee! *splat*" I-wont-go-into-how-Thomas-is-supposed-to-be-pronounced-ly y'rs ;) -- Thomas Wouters <thomas at xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From tjreedy at home.com Fri Jul 27 11:44:22 2001 From: tjreedy at home.com (Terry Reedy) Date: Fri, 27 Jul 2001 15:44:22 GMT Subject: PEP 238 (revised) References: <cp4rrz5onj.fsf@cj20424-a.reston1.va.home.com> Message-ID: <q%f87.34136$EP6.8735302@news1.rdc2.pa.home.com> "> PEP: 238 > Title: Non-integer Division Now that I look at it, the title seems rather odd, given that at least half of the PEP and the discussion is/has been about integer division. How about Revising Division or even better Splitting the Division Operator. Terry J. Reedy From nperkins7 at home.com Tue Jul 24 14:08:35 2001 From: nperkins7 at home.com (Nick Perkins) Date: Tue, 24 Jul 2001 18:08:35 GMT Subject: Auto sort in Dictionaries??? References: <74cc9702.0107222235.78bd9d35@posting.google.com> <LeR67.534528$eK2.111965964@news4.rdc1.on.home.com> <iL477.106891$T97.14984550@typhoon.nyroc.rr.com> Message-ID: <DQi77.544106$eK2.114143459@news4.rdc1.on.home.com> "Cliff Crawford" <cjc26 at nospam.cornell.edu> wrote in message news:iL477.106891 ... > I don't think the above line will work... ... Quite right. My original code suffered from 4am syndrome. Thanks for the help. Here is the fixed up version: class order_dict(dictionary): """Dictionary which returns contents in order of insertion""" def __init__(self): dictionary.__init__(self) self.n = 0 def __setitem__(self, key, value): dictionary.__setitem__(self, key, (self.n, value)) self.n += 1 def __getitem__(self, key): return dictionary.__getitem__(self, key)[1] def keys(self): ks = [(n, key) for (key, (n, _)) in dictionary.items(self)] ks.sort() return [key for (n, key) in ks] def values(self): vals = dictionary.values(self) vals.sort() return [ value for (n,value) in vals ] def items(self): return [(key, self.__getitem__(key)) for key in self.keys()] From skip at pobox.com Tue Jul 31 15:28:05 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 31 Jul 2001 14:28:05 -0500 Subject: 2.2 features In-Reply-To: <200107311904.PAA17115@cj20424-a.reston1.va.home.com> References: <mailman.996258542.15795.python-list@python.org> <cpwv4u16rx.fsf@cj20424-a.reston1.va.home.com> <mailman.996270412.11895.python-list@python.org> <cpofq524lr.fsf@cj20424-a.reston1.va.home.com> <slrn9m61bs.atb.quinn@retch.ugcs.caltech.edu> <slrn.pl.9m6a5m.kmu.qrczak@qrnik.zagroda> <cpae1lzio7.fsf@cj20424-a.reston1.va.home.com> <15206.48884.18637.676324@beluga.mojam.com> <200107311705.NAA16444@cj20424-a.reston1.va.home.com> <15206.61485.360973.566871@beluga.mojam.com> <200107311904.PAA17115@cj20424-a.reston1.va.home.com> Message-ID: <15207.1733.965818.91745@beluga.mojam.com> >> I guess I'm confused, but if isinstance(x, type) is true isn't >> issubclass(x.__class__, type) also true? Guido> You are indeed confused. :) Guido> Seems you confuse isinstance(x, y) with issubclass(x, y). These Guido> are very different. x in y can map to at most one of these (for Guido> y a type object). Here's an example that makes concrete what I was thinking: >>> class Foo: ... pass ... >>> class Bar(Foo): ... pass ... >>> x = Bar() >>> isinstance(x, Foo) 1 >>> issubclass(Bar, Foo) 1 >>> issubclass(x.__class__, Foo) 1 Why can't the "in" operator grok all three of these possibilities? x in Foo same as isinstance(x, Foo) Bar in Foo same as issubclass(Bar, Foo) x.__class__ in Foo same as issubclass(x.__class__, Foo) I assume x can't be both an instance and a class at the same time. Skip From skip at pobox.com Wed Jul 25 09:23:25 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 25 Jul 2001 08:23:25 -0500 Subject: Future division patch available (PEP 238) In-Reply-To: <0ilsltgmrc2eg39jf8cg2i4tam5ujqld0f@4ax.com> References: <GNZwEiAJepW7Ew0F@jessikat.fsnet.co.uk> <mailman.995776716.24336.python-list@python.org> <mailman.995825018.9832.python-list@python.org> <9jfjd6$ad4$2@newshost.accu.uu.nl> <7u6nltoqdnqjjdiquu6ngtaruflhvbvdl5@4ax.com> <j4g0bof3jv.fsf@informatik.hu-berlin.de> <p8unltsi5qda8rpdavja4iemj6r1s2ak4a@4ax.com> <j48zhfgbny.fsf@informatik.hu-berlin.de> <23891c90.0107230531.4fb02b12@posting.google.com> <cpd76qqfow.fsf@cj20424-a.reston1.va.home.com> <0ilsltgmrc2eg39jf8cg2i4tam5ujqld0f@4ax.com> Message-ID: <15198.51277.172557.468104@beluga.mojam.com> Stephen> I assume some applications ignore the standard *.py filename Stephen> convention - hopefully rare enough to handle other ways, or Stephen> maybe a case for allowing a command line option in addition. When I install a script into /usr/local/bin it loses its extension altogether. So, while I edit fmail.py in my development directory, it's installed as /usr/local/bin/fmail. I assume that's fairly common practice. It certainly is outside the Python community. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From eppstein at ics.uci.edu Mon Jul 30 02:38:45 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Sun, 29 Jul 2001 23:38:45 -0700 Subject: Language Niches (long) References: <8beb91f5.0107280407.5a30341d@posting.google.com> <3B62FAFF.BB987077@Lugoj.Com> <mailman.996347633.4448.python-list@python.org> <8beb91f5.0107282158.4785ae5e@posting.google.com> <UK2E1VAMB+Y7EwX$@jessikat.fsnet.co.uk> <mailman.996429234.13926.python-list@python.org> <vko8mtotv7s6mopits06ntammk5ibe4905@4ax.com> <mailman.996437578.30803.python-list@python.org> <sln9mtgfkd0mdrjbj6vtlihitollc1f4ka@4ax.com> Message-ID: <eppstein-2999C5.23384429072001@news.service.uci.edu> In article <sln9mtgfkd0mdrjbj6vtlihitollc1f4ka at 4ax.com>, Courageous <jkraska1 at san.rr.com> wrote: > Why would anyone ever write anything in C or other standard compiled > languages? I'm not sure you were serious here, but I'll answer anyway: Because it runs quickly and you have very good control of memory. E.g. a student here has been working on a program which needs to store a small amount of information for a half-billion objects -- easy in C to allocate a byte per object in a big array, harder if each object has multiple bytes of overhead. Of course most other languages will let you allocate byte arrays but then you lose their object oriented advantages. And, the program currently runs in around 16 hours -- imagine how much more time it might take if written in an interpreted language. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From bsass at freenet.edmonton.ab.ca Thu Jul 12 14:31:45 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Thu, 12 Jul 2001 12:31:45 -0600 (MDT) Subject: Long Live Python! In-Reply-To: <9ijpfk02a67@enews4.newsguy.com> Message-ID: <Pine.LNX.4.33.0107121131290.21768-100000@bms> On Thu, 12 Jul 2001, Alex Martelli wrote: <...> > How anybody could deduce from that thread that Python is not > suitable to typical scripting operations is the real mystery > to me here. You guys are way too sensitive, and must not have read past the "horrible scripting..." part of the message (and I probably should have put a <wink> or <grin> in there someplace, <sigh>). The point was that python and sh operate on different levels. e.g., $ cat file*1 file*2 file*3 | tee file4 | wc -cwl >> file5 (i.e., concatenate some unknown number of files whose names match one of three patterns, write the result to a file and count the characters, lines and words, appending that result to a different file) is what in Python.... ...2 lines, 3, 4, an explicit loop, a function or two, or maybe a program (i.e., some imports, assignments, blocks of code, ...)? Ya, I know, for some... "script" == "interpreted", for the rest of us... "script" == "automating a sequence of command line operations". I guess it was a mistake to play off that bit of ambiguousness as an introduction to the point. - Bruce From paulp at ActiveState.com Mon Jul 2 14:33:12 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Mon, 02 Jul 2001 11:33:12 -0700 Subject: Augmented Assignement (was: Re: PEP scepticism) References: <mailman.993952381.32699.python-list@python.org> <zbN%6.415855$oc7.58414702@news2.rdc2.tx.home.com> <q0avjto87p59hn7gv28r5cf1c84j2fb8c7@4ax.com> <naO%6.416271$oc7.58537852@news2.rdc2.tx.home.com> <vm40kt8knq3pplpv1rarjubl73vnl12ure@4ax.com> <20010702145211.M8098@xs4all.nl> <mailman.994083124.18397.python-list@python.org> <uN107.141431$L4.17198481@news1.rdc1.az.home.com> <3B40B551.5A554148@ActiveState.com> <15168.47771.528688.531809@beluga.mojam.com> Message-ID: <3B40BE68.C33815D7@ActiveState.com> Skip Montanaro wrote: > > Paul> "Advanced" types could have "smart" behaviour and simple types > Paul> could have x=x+y behaviour. > > Let's ignore lists, tuples and numbers for a moment because most people know > how they are supposed to work (or will figure it out with a simple script). > Suppose I see code like this > > import mumble > x = mumble.Mumble() > ... > x += 1 > > How am I supposed to know without digging around in the code or docs for the > mumble module if it is a "simple" or "advanced" type? You won't know. But there is a lot you don't know about modules without reading the docs. What this does: print mumble It could open a socket and download Quake for all you know. > You haven't solved > any problems, just added a new protocol for programmers to implement that > will be done so in a haphazard fashion. Making a problem so rare that very few people ever run into it is progress. The way I see it, 95% of all types will be non-mutating. The exceptions will be types that are used primarily by speed freaks. I can't actually recall the last third-party type that I've used that used serious mathematical operator overloading. (obviously I'm not a Numpy user) The average user will simply not run into the issue, just as they don't have to spend much effort worrying about whether "print" will do something weird and wonderful. And yes, I've actually run into a "__repr__" that opened a socket -- but it didn't download Quake. If we can restrict the problem to math-type people then that's better than confusing *everybody*. Especially since the math-type people asked for the confusing behaviour. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From claird at starbase.neosoft.com Wed Jul 25 15:06:22 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 25 Jul 2001 14:06:22 -0500 Subject: Distributed computing using SOAP. What about speed ? References: <LBA77.58$bXi.175168000@news.telia.no> Message-ID: <48F88F43C9842AD9.1E631B0D03856868.6FDBB21E772A6CB3@lp.airnews.net> In article <LBA77.58$bXi.175168000 at news.telia.no>, Thomas Weholt <thomas at gatsoft.no> wrote: >hi, > >( In relation to my previous post about user authentication using SOAP, I >got another simple question. ) > >Does anybody have any thoughts about SOAP, especially SOAPpy ( it looks very >nice, simple to use ), and potential speed issues? I'm thinking of >implementing a distributed system where nodes communicate using SOAP. >There's a clear potential of much traffic among the nodes and I just >wondered if SOAP is the right protocoll/technology for the job. In my >project each node will register with a nodemaster ( holds info about running >nodes, nothing else, will check for availability of registered nodes with a >given interval too, remove dead ones from list ) and get a list of running >nodes in return. It will then proceed to query these running nodes in a >serial manner ( at least to begin with, maybe use a async. approach later ) >about information and parse the result. > >Is SOAP suitable for something like this? It seems like it would be very >easy to get a system like this up and running. My goal is to make a >distributed system ala Gnutella, with no central server, just a bunch of >nodemasters and nodes. I'm interested in other users experience with SOAP, >with focus on speed of communcation ( speed of network disregarded. I'm only >interested in impact on speed caused by SOAP itself. ). > >It's also clear that some problems might occur cuz the BaseHTTPServer which >is used for the most part, have performance issues. Perhaps implementing the >server using asyncchat etc. would increase performance ?? Why aren't the >modules allready implemented with these tools available in the standard >python lib allready, if that's the case? . . . SOAP can be a pig. I'm very fond of SOAP. I use it a bunch, and look forward to doing more. It's gross, though, compared to, say, CORBA (and my favorite is what this century calls "T-spaces"). On the other hand, lots of people are using SOAP, it'll get better, and, if performance annoys enough capable people, someone will invent a reworked transport layer that solves these problems. I summarize my answer: design and implement your project intelligently, and with SOAP. If performance turns out to be a problem--and you're unlikely to be certain until it's *quite* a problem--be prepared to move to a different technology. As unsatisfying as I imagine you find that answer, it's the best one I know. -- Cameron Laird <claird at NeoSoft.com> Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From cubicle584 at mailandnews.com Mon Jul 16 20:23:36 2001 From: cubicle584 at mailandnews.com (Software Scavenger) Date: 16 Jul 2001 17:23:36 -0700 Subject: Is Python Dead? Long Live Python! References: <mailman.994713616.26838.python-list@python.org> <3B4A66D3.AD4B29D9@engcorp.com> <c250fb6e.0107100431.8a46d83@posting.google.com> Message-ID: <a6789134.0107161623.3ee0081c@posting.google.com> ajp at fudokai.org.uk (CyberKat) wrote in message news:<c250fb6e.0107100431.8a46d83 at posting.google.com>... > Nice - I just have to find the _time_ to learn Python well enough to > point out where and how it's better - I like the look and concepts of Until you know it well you aren't ready to introduce it into your workplace. Then it will be easy. Just write some apps your coworkers need urgently, and once the importance of those apps starts to become clear to your whole company, some months later, the programming language they are written in will become one of your company's main programming languages. Being an evangelist is hard work, but, as hard work goes, it's easy hard work. From James_Althoff at i2.com Thu Jul 12 16:21:44 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Thu, 12 Jul 2001 13:21:44 -0700 Subject: Long Live Python! Message-ID: <OF42A8DC70.9CE6B4AC-ON88256A87.006FA432@i2.com> Phil Hunt wrote: >On Wed, 11 Jul 2001 17:47:50 -0400, Peter Hansen <peter at engcorp.com> wrote: >>I tend to think of Python more as an extremely effective and maintainable >>general-purpose programming language, which happens also to work >>very well when applied as a "scripting language" (whatever that means). > >To me it means "good for short programs <100 lines". Bear in mind >that 100 lines of Python is equivalent to 300 lines of Java or 400 >lines of C++. We are shipping a successful product that comprises more than 100,000 lines of Jython. What is it about Python that would, in your experience, make it only "good for short programs <100 lines". Jim From mikeb at mitre.org Thu Jul 5 12:20:52 2001 From: mikeb at mitre.org (Mike Brenner) Date: Thu, 05 Jul 2001 12:20:52 -0400 Subject: FTP program works -- now how do I send the directory over? Message-ID: <3B4493E4.BCFC985@mitre.org> Randy > ... And Python has another edge over Perl. With Python, the ... client is build in, while with Perl, you need to obtain and install ... I agree. The main reason Java took off was its very large, integrated run time library. Python's library is a great asset, but Python would spread faster if more parts were built in. My ideal build would include the following: (I realize the political reality that this cannot be done.) (a) Numerics (b) wxPython (c) py2exe (d) TADS, pygame (e) odbs, ftp, mysql (f) the windows extentsions & its editor in wxpython so it works under linux (g) midi2wav, wav2midi, wav2cd, cd2wav, microphone2wav, wav2speaker (h) wxpython2gif (i) etc. From 18k11tm001 at sneakemail.com Mon Jul 2 20:38:04 2001 From: 18k11tm001 at sneakemail.com (Russ) Date: 2 Jul 2001 17:38:04 -0700 Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> <bebbba07.0107021206.70a22aa8@posting.google.com> <mailman.994111084.403.python-list@python.org> Message-ID: <bebbba07.0107021638.3dc5429f@posting.google.com> William Park <opengeometry at yahoo.ca> wrote in message news:<mailman.994111084.403.python-list at python.org>... > > From: Russ (18k11tm001 at sneakemail.com) > > Subject: Python for air traffic control? > > Date: 2001-06-29 17:42:45 PST > > > > 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. > > Of course, you idiot... It depends how well you did in high school > math. If there are N airplanes whose positions are given by > (x,y,z)_i, i=1,2,...N > then you have to calculate distance from an airplane at to every other > airplanes. > > You would be maintaining NxN table to see > - if any position is outside the assigned trajectory, or > - distance (between any two position) is too close > > Am I missing something? Yes, you are missing something: my question. I asked about the feasibility of using Python for a safety-critical application. I didn't ask for a fifth-grade-level analysis of the problem. Trust me: you don't have a clue. BTW, I scored in the top 1% in the math section of the Graduate Records Exam. How did you do? From aleaxit at yahoo.com Fri Jul 13 07:20:57 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 13 Jul 2001 13:20:57 +0200 Subject: How can I run precompiled code objects? References: <mailman.995002401.30502.python-list@python.org> Message-ID: <9imliq0112b@enews1.newsguy.com> "Vesselin Peev" <vesselinpeev at hotmail.com> wrote in message news:mailman.995002401.30502.python-list at python.org... > Hello, > > Can anyone tell me how to use the so called "code objects" in Python, for > example the ones created via > > PyObject* Py_CompileString(char *str, char *filename, int start) > > There's no explanation on the matter that I can find. In Python, you can pass a code object to the exec statement or to the eval built-in function, > All I want to do is to execute different precompiled python code blocks from > a C program (I have already embedded Python). I could make do without > bytecode but then the speed would be much les. A "code block" is not suitable for eval(), so exec it will have to be, if you're working in Python as you said at the start. If you're working in C as you say now, the C API function you have to call is PyEval_EvalCode. It takes 3 arguments -- a code object, then two dictionaries to use as local and global namespaces -- the last arg can be 0, but not the 2nd one. So anyway, a typical usage pattern might be: PyObject *globals, *code, *result; /* prepare an innocuous 'globals' dictionary */ globals = PyDict_New(); PyDict_SetItemString(globals, "__builtins__", PyEval_GetBuiltins()); /* compile your string of statements into a code object */ code = Py_CompileString(statements, "<stmts>", Py_file_input); if(!code) { PyErr_Print(); return 0; } /* execute the compiled statement */ result = PyEval_EvalCode((PyCodeObject *)code, globals, 0); Py_DECREF(code); if(!result) { PyErr_Print(); return 0; } else { Py_DECREF(result); return 1; } Season to taste if, as it seems, you may want to keep the code objects around, reuse a globals dictionary, etc, etc. Alex From kragen at dnaco.net Thu Jul 19 16:09:05 2001 From: kragen at dnaco.net (Kragen Sitaker) Date: Thu, 19 Jul 2001 20:09:05 GMT Subject: =?big5?B?W1FdIEZpbGUgT2JqZWN0IC0tIGZ1bmN0aW9uICdyZWFkJw==?= References: <mailman.995560073.30389.python-list@python.org> Message-ID: <B7H57.239$nq6.19822@e420r-atl3.usenetserver.com> In article <mailman.995560073.30389.python-list at python.org>, jackyci <jackyci at sinamail.com> wrote: >In Windows. "\n" equal "\x0d\x0a" >But in function "read" of File Object, "\x0d\x0a" equal 1 byte. Actually "\n" still equals "\x0a". It's just that "\x0d\x0a" gets translated to "\x0a" on input from a file, and the reverse translation happens on output to a file, unless you opened the file with "b" binary mode. This is brain-damage Python inherited from C; the C standard specifies that this translation has to happen by default on systems that represent their line endings in a non-Unix way, so that text-manipulating C programs written on Unix will Just Work. (At the time that this was established, this was nearly all C programs.) -- <kragen at pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/> Perilous to all of us are the devices of an art deeper than we possess ourselves. -- Gandalf the White [J.R.R. Tolkien, "The Two Towers", Bk 3, Ch. XI] From prem at engr.uky.edu Fri Jul 20 15:59:18 2001 From: prem at engr.uky.edu (Prem Rachakonda) Date: 20 Jul 2001 12:59:18 -0700 Subject: Probems with IDLE References: <Pine.LNX.4.21.0107171601020.12906-100000@seahawk.ecc.engr.uky.edu> Message-ID: <e56d8da7.0107201159.53d688d6@posting.google.com> Hi, I am working with Python 2.1 on Windows 2000. The situations are not anything specific. Prem. Prem Rachakonda <prem at engr.uky.edu> wrote in message news:<Pine.LNX.4.21.0107171601020.12906-100000 at seahawk.ecc.engr.uky.edu>... > Hi, > I am not sure if anyone of you have found this problem, but the regular > exit commands 'CTRL+C', 'CTRL+A', 'CTRL+X', 'CTRL+V' don't work all the > time. But if you go to EDIT>COPY OR EDIT>CUT etc. they work fine. Can > somebody fix this?? > > 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 From gbreed at cix.compulink.co.uk Tue Jul 10 11:36:05 2001 From: gbreed at cix.compulink.co.uk (gbreed at cix.compulink.co.uk) Date: 10 Jul 2001 15:36:05 GMT Subject: Language Shootout References: <3B4B1BE7.1483F292@yahoo.com> Message-ID: <9if7d5$ss1$1@plutonium.compulink.co.uk> In article <3B4B1BE7.1483F292 at yahoo.com>, slinkp23 at yahoo.com (Paul Winkler) wrote: > For the mathematically challenged, what is matmult? > Pointer to a FM to R would be fine. Ooh! I've got one of them! <http://www.microtonal.co.uk/matritut.htm> Graham From gregj at pdxperts.com Sun Jul 15 00:54:39 2001 From: gregj at pdxperts.com (Greg Jorgensen) Date: Sun, 15 Jul 2001 04:54:39 GMT Subject: not safe at all References: <mm8tkt4te3qnbpv3nh5nhsi591o1osln73@4ax.com> <m030ltord2kgp98mb7a397rl1bgtgar0en@4ax.com> <kr81ltkck185fba69ukgvn5hf1ivtosvar@4ax.com> Message-ID: <jm947.348493$p33.7096844@news1.sttls1.wa.home.com> "Dennis Roark" <denro at earthlink.net> wrote in message news:kr81ltkck185fba69ukgvn5hf1ivtosvar at 4ax.com... > Dynamic typing, or binding, reference variables that can > change the type pointed to, are to me still part of a weaker > type safety than if they were not there. Typing and binding are not the same thing. In C, C++, Pascal, etc. the name and type of a variable are attributes of the variable name. The variable's content (or what it points to) doesn't have any name or type--it's just a chunk of memory that is interpreted and manipulated according to the type of the variable name used to refer to it. The most obvious example of this is the C/C++ union: union { int ival; float fval; } u; u.ival and u.fval are different variables with different types referring to the same (untyped) chunk of memory. In statically-typed languages like C, variables can't change their types. A cast only tells the compiler to use different rules to manipulate the memory the cast expression refers to; it doesn't change the type of any variables. The contents of a typed variable can be changed, but the variable can't be rebound to another chunk of memory. C and C++ simulate binding through the indirection of pointers. But because the compiler can't detect rebinding a pointer, the programmer has to deal with memory management (C, C++), and all the problems that ensue, or the language can simply disallow pointers (Java). Python doesn't have variables. Python has typed objects, references to objects, and names that are bound to objects. The binding is dynamic: a name may be bound to different objects of different types at run-time (as your example code demonstrates). The type is a property of the object, not of the name. Note that Python doesn't have or need pointers. Dangling pointers and undisposed objects and chunks of memory are the biggest problems for C/C++ programmers. The language type enforcement does nothing to deal with these subtle and hard to find problems. An industry of debugging and testing tools developed alongside C++ to help programmers find and fix memory management problems. Java is one solution: a typed language with name binding rather than pointers. Java's C-derived syntax and complexity are a lot for new programmers to master, and buggy and incompatible JVMs plague more experienced programmers. Python is another solution. Python's simpler syntax, rich built-in objects and standard library, and vastly simpler runtime environment make it a good choice where Java is too bulky or complicated. I've been programming professionally for 25 years and I've mastered a lot of languages. I still usually "think" in C, but Python is now my language of choice for almost everything. My current day job involves building a huge logistics system for an auto manufacturer. We're using Oracle PL/SQL and Java. I can say without exagerration that if we were using Python we'd be done by now, and our bug list would be one-tenth of what it is now. The biggest problem we face is the multitude of programmers at widely varying skill levels, trying to master complicated and subtle languages and tools, and get their code to work with all the rest. If we were using Python the skill gaps would be narrower, and easier to see and fix. > So let's hold back the ad hominem > attacks and help each other progress. I agree--some of the postings are out of line. > Originally [in Visual Basic], there was not a way to > force declaration of variables. It was programmer pressure > that forced MS to introduce the "option explicit" code > directive which requires declaration. The OPTION EXPLICIT feature of VB does the same thing as Fortran's IMPLICIT NONE. VB has typed variables and the VARIANT type, which is just a UNION with a "current type" attribute. I don't know when OPTION EXPLICIT was introduced, but I'm pretty sure stronger typing and avoidance of the VARIANT type was pushed so VB could play nice in the COM/DCOM world, and not in response to programmer pressure. Greg Jorgensen PDXperts LLC Portland, Oregon, USA gregj at pdxperts.com From duncan at NOSPAMrcp.co.uk Wed Jul 4 08:47:53 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Wed, 4 Jul 2001 12:47:53 +0000 (UTC) Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> <9hrj3q$cj1@news1.gtech.com> <bebbba07.0107031040.593143f8@posting.google.com> <20010704013238.2DC8A00.NOFFLE@niccolo.ke4.de> Message-ID: <Xns90D489E9982B4duncanrcpcouk@127.0.0.1> Mirko Liss <mirko.liss at web.de> wrote in news:20010704013238.2DC8A00.NOFFLE at niccolo.ke4.de: > An example in C: > > typedef plane_t int ; /* plane no */ > typedef lane_t int ; /* lane no */ > typedef go_down_in_pieces_t bool ; > go_down_in_pieces_t dispatch( plane_t flightno, \ > lane_t neigboring_highway ) ; > > If the arguments get swapped, the compiler gets angry. > Is this what you wanted to have in C ? > No wonder the compiler gets angry, you can't rename your own types as 'int'. Also there is no type called 'bool' in C. Perhaps you meant: typedef int plane_t; typedef int lane_t; typedef int bool; typedef bool go_down_in_pieces_t; go_down_in_pieces_t dispatch(plane_t flightno, lane_t neighboring_highway); int main() { plane_t plane = 5; lane_t lane = 3; dispatch(plane, lane); dispatch(lane, plane); dispatch(dispatch(lane, plane), dispatch(lane, plane)); return 0; } Now the compiler is completely happy. All calls to dispatch give it two integers so there is nothing to complain about. C's 'typedef' only defines an alias for a type, it doesn't define a new type, and any programmer that thinks it does should be locked in a cupboard with a copy of the standard and not let out until they have translated it into readable English. Please tell me you don't do air traffic control for a living. -- 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 bokr at accessone.com Mon Jul 9 23:48:42 2001 From: bokr at accessone.com (Bengt Richter) Date: Tue, 10 Jul 2001 03:48:42 GMT Subject: Language Shootout References: <mailman.994689198.3317.python-list@python.org> <3B49F724.1F3DF6B3@yahoo.com> <3B4A0C34.C64202C2@Lugoj.Com> <3B4A185D.7C9EC4A5@yahoo.com> <3b4a468d.1494788532@wa.news.verio.net> Message-ID: <3b4a6782.1503226134@wa.news.verio.net> On Tue, 10 Jul 2001 01:01:23 GMT, bokr at accessone.com (Bengt Richter) wrote: >I just did a python recursive fib(100000) in >just over 15 seconds, including startup and >printing to screen, by my watch. (Not a typo, >that was 100k). Of course, it might not be the >usual recursive solution (see below) ;-) [...] >I haven't fine tuned this. It's a close translation of Oops, several things: - That 15 seconds was mostly conversion for printing. Actual calculation time was more like 0.8 sec ;-) - I should have eliminated an expression Changes --- #eliminated this > fkm1 = fkp1 - fk > if n&1: > return fkp1*fkp1 + fk*fk, fkp1*( fkp1+fk+fk) > else: #changed this > return fk*(fk+fkm1+fkm1), fkp1*fkp1 + fk*fk return fk*(fkp1+fkp1-fk), fkp1*fkp1 + fk*fk --- Sheesh. I also changed the a+a things above to a<<1 but it's in the noise. Wonder if a**2 is much different from a*a for big longs... I put in a clock() timer for calculation and printing. This gives about 380 microseconds +- a few for N=32, and for N=100000: That took 0.796213 seconds to calculate, and 15.226808 to print. That took 0.797725 seconds to calculate, and 15.006354 to print. That took 0.804495 seconds to calculate, and 14.893308 to print. That took 0.800631 seconds to calculate, and 14.624085 to print. is representative, again on (300mhz P2, 320MB ram, NT4sp3) Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 Given the print time, apparently this recursion beat iteration by 0.8 vs about 15 seconds ((~32 hand timed load, calc, print) -15). Never say never ;-) Revised version: ______________________________________________________________ # fibpx.py - fast recursive fibonacci algorithm using pairs # Copyright (c) 2001, Bengt Richter. All rights reserved. # Use is governed by the GNU GENERAL PUBLIC LICENSE -- see http://gnu.org # NO WARRANTY EXPRESS OR IMPLIED IS GIVEN AS TO CORRECTNESS # OR SUITABLILITY FOR ANY PURPOSE. USE AT YOUR OWN RISK. # # Updated 2001-07-09 bokr # import sys def pfib(n): if n < 2: return 1L,1L if n == 2: return 1L,2L k = n / 2L # this makes the log effect fk,fkp1 = pfib(k) # recursion here if n&1: return fkp1*fkp1+fk*fk, fkp1*(fkp1+(fk<<1)) else: return fk*((fkp1<<1)-fk), fkp1*fkp1+fk*fk def ffib(x): if x < 3: return 1 else: fxm2,fxm1 = pfib( x - 2L ) return fxm2+fxm1 import time def main(): if len(sys.argv) != 2: sys.stderr.write("usage: %s number\n" % sys.argv[0]) sys.exit(2) tStart = time.clock() answer = ffib( long(sys.argv[1]) ) tEnd = time.clock() print 'fib(',sys.argv[1],') =\n', answer tEndPrint = time.clock() print "\nThat took %10.6f seconds to calculate," \ " and %8.6f to print." % (tEnd-tStart, tEndPrint-tEnd) if __name__ == "__main__": main() ______________________________________________________________ From jdavis at empires.org Mon Jul 23 04:33:43 2001 From: jdavis at empires.org (Jeff Davis) Date: Mon, 23 Jul 2001 01:33:43 -0700 Subject: Auto sort in Dictionaries??? References: <74cc9702.0107222235.78bd9d35@posting.google.com> Message-ID: <_gR67.5001$LR1.270732@news.pacbell.net> phillip wrote: > Hi, > > I put 'name,values' into a dictionary. > But when I get the keys and display the values they come out in a > different order that the order I inserted them in. > > Is there a way maintain the oringinal order? > > Phill > I don't think dictionaries are designed that way in python, but here is what you can do: each new value you insert, push() the key onto a list. Then when you need to access them in order just traverse the list. The reason you most likely didn't get the values back in order is that the DB in which the values were inserted used an algorithm for data management that didn't preserve the order. I am not sure this is the best solution, but it will work. Hope it helps. Jeff Davis From greg at cosc.canterbury.ac.nz Thu Jul 19 01:23:36 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Thu, 19 Jul 2001 17:23:36 +1200 Subject: Language change and code breaks References: <mailman.995378792.16515.python-list@python.org> <cpvgkq1f2b.fsf@cj20424-a.reston1.va.home.com> <_bh57.32695$d4.1090608@e420r-atl1.usenetserver.com> <9j4a6e0cpu@enews4.newsguy.com> Message-ID: <3B566ED8.E14732F8@cosc.canterbury.ac.nz> Alex Martelli wrote: > > having a recently-invented typographic prettiness, such as > letter-cd tcase, affect meaning, has always struck me as a deeply > flawed idea. If you asked a mathematician, I doubt he'd regard it as either "recent" or "flawed". Mathematicians have been using case-, font-, style- and alphabet- sensitive identifiers for centuries... -- 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 idot at vt.edu Fri Jul 27 20:53:54 2001 From: idot at vt.edu (Carl Banks) Date: Fri, 27 Jul 2001 20:53:54 -0400 Subject: Radical Suggestion for Integer Division Migration Message-ID: <2f2tj9.ejt.ln@10.0.0.1> Basically, have all integer division using the "/" operator throw an exception during the transition period, unless "from __future__ import division" appears in the module. A little PEPish explanation follows. (Only the abstract is much too baroque....) Abstract Many people do not like the new division semantics introduced in PEP 238, for it bears the curse of a backward-incompatible language change, shrouded by the cold repression of Silence. It is Silence that people fear most about this transition, for Silence harbors the subtle code breaks that shall arise, lurking in unconscious shadow, waiting in ambush. Thus, it is suggested that Python save us from this pernicious evil by vanquishing Silence. For then, the program that attempts to divide two integers shall invoke the great and terrible wrath of Python, and lo! Python shall raise an IntegerDivisionError exception, casting light upon the shadow in which tomorrow's subtle bugs hide. And only by switching to the integer division operator "//", or by including "from __future__ import division" atop the module, can the programmer abate Python's fury. Yet it is written: Upon the change of the major version number, Python's tenacious wrath shall relent, and thenceforth all shall live peacefully in the fertile land of consistent division. Motivation PEP 238 proposes a rather controversial language change to Python, namely a change in the semantics of the division operator. But, as Tim Reedy pointed out in the c.l.py post introducing the "Language Change and Code Breaks" thread, a change in semantics that does not produce an error (like PEP 238) can lead to subtle breakages in code. PEP 238 does include a provision to produce a warning when integer division occurs. Warnings, however, are often too easy to ignore. It goes without saying that we would like all Python code to be ready when Python 3.0, and the new semantics, arrive. It seems that, as long as the classical semantics for integer division remain the default, much code will continue to use it, right up to the release of 3.0. This, of course, could lead to subtle bugs. This proposes that, in the transition period, there be *no default semantics at all* for integer division. Integer division using "/" would become illegal, throwing an IntegerDivisionError exception, unless the programmer explicitly requests the new semantics with "from __future__ import division." Because of this exception, the subtle errors that might have resulted would instead manifest themselves as glaring exceptions, easy to see, and easy to fix. Older code would not fail silently during the transition period, but fail resoundingly. Hopefully, by the advent of Python 3.0, all Python code will account for the new semantics. Specification Starting with Python 2.3, an attempt to divide two integers (including long integers) would result in an exception, IntegerDivisionError, being raised. The IntegerDivisionError exception would display a helpful message, such as: Integer division is in a transition period in Python, and is currently disabled. You can use the new integer division operator "//" instead, or you can put "from __future__ import division" at the beginning of the module to request the new division semantics. Note that modules designed for Python versions before 2.3 may no longer work. It is suggested that you upgrade any modules you are running, and review any uses of division in your programs. For more information, see http://blah.blah/blah/blah.html Although the above message is much longer than the typical one-line messages for most exceptions, in this case it is justified because of the potential for code break that can result if one ignores it, and the possibility that someone running Python 2.3 for the first time might not be aware of the upcoming changes. And, as the helpful error message says, one can use the new integer division operator to perform integer division. Or, one could request the new division semantics by including 'from __future__ import division' atop the module. Non-integer division would not throw an exception. The IntegerDivisionError would only exist in the transition period. In Python 3.0, the new division semantics would become the default, and IntegerDivisionError would disappear. P.S. If this seems to have any chance at all, I'll write up a real PEP. P.P.S. I'd like to vote for "quotient" as a substitute for integer division, even though it's wrong. P.P.P.S. Also, may I request that, since we've already decided we're going to break division in 3.0, we might as well break everything else, too. Let's figure out everything that needs fixed (type/class dichotomy, heterogenous comparison, ";".join, etc.), and get it out of the way all at once. -- CARL BANKS From peter at engcorp.com Thu Jul 26 19:39:16 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 26 Jul 2001 19:39:16 -0400 Subject: Eliminating upgrade risk References: <tlu596rosgngd9@news.supernews.com> <mailman.996105586.6334.python-list@python.org> <biDHvIAmJ2X7Ewtm@jessikat.fsnet.co.uk> <3B601811.4B68578B@interet.com> Message-ID: <3B60AA24.B26F6B76@engcorp.com> "James C. Ahlstrom" wrote: > > Robin Becker wrote: > > > If the advice from the Gods is that Python is a 'research' language then > > I'll know better what to do. [...] > The problem is that the new Python features, as wonderful as they are, > are chosen for Computer Science Purity, not day-to-working-day > importance to someone actually trying to write a widely used bullet > proof program. The current rate of language change is fine for a > student or casual programmer I'm sure, but I don't have that luxury. I agree the rate of change is enough to make many of us nervous (perhaps especially in industry). And I agree some of the new features appear (from my particular point of view) unnecessary and more like CS playthings than anything else. That said, I have to say that at least one change is likely to improve my ability to produce bullet-proof programs. The surgery on the way division works will almost certainly reduce the risk of my accidentally (and quietly) truncating a result when I really meant to say float(x)/y and forgot, since this is an idiom I rarely need to use. (This is leaving aside the issue of code breakage, but I'm talking only about new code here, and in my case I don't need to maintain backwards compatibility.) Another thing I'm going to like is the generators, which are very likely going to help me write readable, elegant code for several coding patterns where I now have to write cumbersome and relatively unreadable code. So these two things will help a lot with bullet-proof programming. And list comprehensions. I suspect list comprehensions will also let me write more readable code (after I get past the ebullient phase many seem to go through, and tone it back a little). There are therefore at least three things that will help. Since readability is the single biggest item which will contribute to bullet-proof programs (after testing!), and since many of the new items should tend to increase readability, I have to disagree with your claim. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From tom-list at home.com Mon Jul 30 11:21:38 2001 From: tom-list at home.com (Tom) Date: Mon, 30 Jul 2001 11:21:38 -0400 Subject: mistake in Python 2.1.1 debug download References: <mailman.996467575.12375.python-list@python.org> Message-ID: <3b657b7b$1_1@Usenet.com> Ok. Thanks. Tom. "Tim Peters" <tim.one at home.com> wrote in message news:mailman.996467575.12375.python-list at python.org... > [Tom] > > I just downloaded the following: > > Python-2.1.1-Debug.zip > > > > It includes Python22 files. I assume this is a mistake. > > So it does! My mistake. Ignore the *22.* files, or think of them as > fascinating freebies. > > > Also, where do the .pdb files go? Aren't .pdb files compiler > > specific? Is this debug download platform/compiler specific? > > Nothing in that zip file is of any use to you unless you're writing Python > extensions in C or C++, on Windows, and using MSVC 6. Even then it's of > limited use, and probably more trouble to download than it's worth. > > > A readme file would be helpful. > > I bet you downloaded it from SourceForge. python.org explains the > uselessness of this file on its download page. You just convinced me to > stop shipping this file <wink>, so rest assured it won't happen again. > > If you're not used to Python, download 2.1.1 from > > http://www.python.org/2.1.1/ > > instead. It's got better instructions. Unfortunately, there's no way to > add explanatory text to the Files download page on SourceForge. > > Posted Via Usenet.com Premium Usenet Newsgroup Services ---------------------------------------------------------- ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY ** ---------------------------------------------------------- http://www.usenet.com From rnd at onego.ru Sun Jul 1 04:43:47 2001 From: rnd at onego.ru (Roman Suzi) Date: Sun, 1 Jul 2001 12:43:47 +0400 (MSD) Subject: Unix Scripting Host In-Reply-To: <slrn9jt7s3.a56.gerhard.nospam@lilith.hqd-internal> Message-ID: <Pine.LNX.4.30.0107011229210.21581-100000@rnd.onego.ru> On Sun, 1 Jul 2001, Gerhard [iso-8859-1] H?ring wrote: >Please excuse this off-topicish post. I was looking for something similar to >the Windows Scripting Host in the Unix world: a library where an application >can register functions and types that can then be used by any scripting >language that bothers to implement the "Unix Scripting Host" interface. The >application language should not be limited to C or C++. AFAIK, there is no Scripting host in UNIX. UNIX itself is a large scriptitng host where miriads of tasks are done by using scripts which process text files. You can do os.system("yourprogram args") from almost any language. You can also pipe thru standard stderr, stdin and stdout files or communicate via UNIX sockets or by other means. But you can't register functions, you can make very compact and fast standalone programs which do 1 task well and call them. This is how UNIX does it and this is a point in which UNIX is different from Windows. (I do not know about all Unices out there). You can think about scripts in UNIX as functions and you will have your Unix Scripting Host for free ;-) For example, there is a nice Python script by Remco Gerlich at Useless Python which allows you to write things like this: for i in `range 1 51 2 file%03d` do mv $i MyFiles done How is it different from registering functions somewhere in the deeps of the proprietary Windows system? >The closest thing I could find was XPCOM from the Mozilla project. I >thought that KDE2 or GNOME might offer this already, but I didn't find >anything (except the relatively heavyweight CORBA approach). >Any suggestions/pointers? Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Sunday, July 01, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "DEVICE=EXXON.SYS may mess up your environment" _/ From greg at cosc.canterbury.ac.nz Mon Jul 30 01:00:05 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Mon, 30 Jul 2001 17:00:05 +1200 Subject: Language change and code breaks References: <mailman.995378792.16515.python-list@python.org> <cpvgkq1f2b.fsf@cj20424-a.reston1.va.home.com> <ud76rn4p8.fsf@cs.uu.nl> <3B5D88B1.774A4D70@Bibliothek.Uni-Augsburg.de> <wzhew2gm27.fsf@sunshine.cs.uu.nl> <3B601CBE.627D3D22@Bibliothek.Uni-Augsburg.de> <9jpbi8$32v$1@samos.cs.uu.nl> <3b61c8f0.577829094@wa.news.verio.net> Message-ID: <3B64E9D5.82A7B3E9@cosc.canterbury.ac.nz> Bengt Richter wrote: > > You may know the significance of fgjqkw then ;-) > If not, google for it. Burning with curiosity, I just tried that, but didn't get anything. -- 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 skip at pobox.com Sat Jul 7 14:51:21 2001 From: skip at pobox.com (Skip Montanaro) Date: Sat, 7 Jul 2001 13:51:21 -0500 Subject: Comment on PEP-0238 In-Reply-To: <cp4rsok3i7.fsf@cj20424-a.reston1.va.home.com> References: <mailman.994427714.26169.python-list@python.org> <cpsngaja4g.fsf@cj20424-a.reston1.va.home.com> <FFv17.1178$Y6.656565@news1.rdc2.pa.home.com> <cpelrskgrr.fsf@cj20424-a.reston1.va.home.com> <9i7a7k$h9ks6$1@ID-11957.news.dfncis.de> <cp4rsok3i7.fsf@cj20424-a.reston1.va.home.com> Message-ID: <15175.23081.888138.584693@beluga.mojam.com> Guido> "Emile van Sebille" <emile at fenx.com> writes: >> If you're going to add keywords, why not add precision and allow >> those who want non-integer division to set it to the level of >> precision they require. That breaks no more code (presumably) than >> adding div or yield does. Guido> I'm not sure what you're asking about. If you're serious, please Guido> submit a PEP! This is the time to do it. Posting to the Guido> newsgroup is *not* sufficient to let an idea be heard by me -- Guido> you *have* to mail it to me directly or to python-dev. (While I Guido> like to read c.l.py sometimes, I cannot guarantee that I see Guido> every post.) Isn't this similar to Paul DuBois' floating point ideas? Skip From mogmios at mlug.missouri.edu Tue Jul 10 12:53:03 2001 From: mogmios at mlug.missouri.edu (Michael) Date: Tue, 10 Jul 2001 11:53:03 -0500 Subject: guessing mime type without extension? Message-ID: <Pine.LNX.4.21.0107101150400.13716-100000@mlug.missouri.edu> Is there a way to guess a files mime type by content rather than extension similar to the way the Unix 'file' command works? ('file -bi <filename>' on my RedHat box) I know I could call the Unix one using exec() or something like that but I am always worried about calling external programs. Thanks. *^*^*^* Michael McGlothlin <mogmios at mlug.missouri.edu> http://www.kavlon.com From peter at engcorp.com Sun Jul 15 20:00:24 2001 From: peter at engcorp.com (Peter Hansen) Date: Sun, 15 Jul 2001 20:00:24 -0400 Subject: windows port access References: <3b520bcb@news.cybertours.com> Message-ID: <3B522E98.BAAA9E93@engcorp.com> If you look back through the last two days' worth of postings for subject "parallel port?!?" you should find something to help. Yes, it is possible, no the result is not compatible (but you could always write a higher level wrapper to make it so). Bryan Brannigan wrote: > > I am looking for a way to send data to certain ports on a custom ISA card. > The card is addressed as 280h. Is this possible with Python? Is the code > compatible with Linux as well? > > Bryan -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From rnd at onego.ru Tue Jul 3 09:46:20 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 3 Jul 2001 17:46:20 +0400 (MSD) Subject: Python and DB support (was: Re: Is Python Dead?) In-Reply-To: <9hsds501vk3@enews1.newsguy.com> Message-ID: <Pine.LNX.4.30.0107031739570.26398-100000@rnd.onego.ru> On Tue, 3 Jul 2001, Alex Martelli wrote: >"Roman Suzi" <rnd at onego.ru> wrote in message >news:mailman.994155184.16109.python-list at python.org... > ... >> Anyway, I wanted to say that some generic (!=Windows only) ADO >> could help for those who consider Python for tasks usually >> done with PHP or ASP. > >We seem to keep hitting a brickwall here. Let's try an analogy. -skip Python vs. ASP - I have not used ASP. (I must confess, I have not even looked into ASP deeply and had no knowledge ASP could be used with other languages than Basic (or whatever). My assumption was that ASP is like PHP. Thanks for lesson! >http://phplib.netuse.de/documentation/documentation-3.html#ss3.1 >After studying that page a bit, unless I'm missing something, >it appears to me that this interface is *VASTLY* inferior to >the Python DB API. I do not believe it. PHP is so widely used with databases that I cant believe it's database connectivity is that bad! >It may very well be that it's worthwhile designing a higher >level, somewhat ADOlike superstructure on top of the DB API, >but, if so, then it DEFINITELY cannot be because of some >kind of "competition" between Python and PHP -- much less, >of course, "between Python and ASP", which is as peculiar a >"competition" as "between Python and Unix" or "between >Python and the JVM"...!!! Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Tuesday, July 03, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Paranoia is nothing to be afraid of!!" _/ From andreas at andreas-jung.com Fri Jul 13 12:30:11 2001 From: andreas at andreas-jung.com (Andreas Jung) Date: Fri, 13 Jul 2001 11:30:11 -0500 Subject: Book count test References: <E566B020833BD311B6610008C791A39705CA5242@il93exm04.css.mot.com> Message-ID: <02ad01c10bb9$195dfd90$9865fea9@SUXLAP> And what do we learn from these numbers ? Andreas From: "Kemp Randy-W18971" <Randy.L.Kemp at motorola.com> To: <python-list at python.org> Sent: Freitag, 13. Juli 2001 10:22 Subject: Book count test > I went to www.amazon.com and counted the number of books in these categories > Python - 136 (including snake books) > Java - 1621 > Perl - 430 > C++ - 1341 > PHP - 38 > ASP - 172 > Oracle - 682 > > > -- > http://mail.python.org/mailman/listinfo/python-list From Sibylle.Koczian at Bibliothek.Uni-Augsburg.de Thu Jul 26 09:35:58 2001 From: Sibylle.Koczian at Bibliothek.Uni-Augsburg.de (Sibylle Koczian) Date: Thu, 26 Jul 2001 15:35:58 +0200 Subject: Language change and code breaks References: <mailman.995378792.16515.python-list@python.org> <cpvgkq1f2b.fsf@cj20424-a.reston1.va.home.com> <ud76rn4p8.fsf@cs.uu.nl> <3B5D88B1.774A4D70@Bibliothek.Uni-Augsburg.de> <wzhew2gm27.fsf@sunshine.cs.uu.nl> Message-ID: <3B601CBE.627D3D22@Bibliothek.Uni-Augsburg.de> Piet van Oostrum wrote: > > >>>>> Sibylle Koczian <Sibylle.Koczian at Bibliothek.Uni-Augsburg.de> (SK) writes: > > SK> But that's exactly what he says! Algol 60 was before C, as far as I > SK> know, and case-insensitive as was normal at the time. > > Sorry, I meant to say that Algol 60 was case sensitive. > -- Really? Must have overlooked that: we used teletype machines, no lowercase letters anyway (where all the keywords uppercase or what?). Wish I'd kept those yellow punched tapes, they'd look nice on my pinboard ... -- ---- 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 eppstein at ics.uci.edu Fri Jul 13 12:05:26 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Fri, 13 Jul 2001 09:05:26 -0700 Subject: Cross-platform GUI app -- Tkinter? References: <3b4e211f$1@news.blarg.net> <9imq3s$jv3c9$1@ID-89274.news.dfncis.de> Message-ID: <eppstein-8FB212.09052613072001@news.service.uci.edu> In article <9imq3s$jv3c9$1 at ID-89274.news.dfncis.de>, bernhard at intevation.de (Bernhard Reiter) wrote: > > If I want to make a GUI application with menus and such, and I want it to > > be easily portable to multiple platforms, what is the best way to do it? > > www.wxpython.org (IMO) Doesn't seem to run on a Mac. tkInter has some problems (clunky appearance, and I couldn't get PIL to work with it) but at least a Mac port exists. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From guido at python.org Fri Jul 27 13:27:41 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 27 Jul 2001 17:27:41 GMT Subject: Deposing Dictators References: <9jmjne$q54$1@wisteria.csv.warwick.ac.uk> <3b602daf.1623450@nntp.sprynet.com> <slrn9m111q.e6f.Gareth.McCaughan@g.local> <dOoGUKA3PKY7EwWa@jessikat.fsnet.co.uk> <cpsnfi2z9w.fsf@cj20424-a.reston1.va.home.com> <$dK+wKA$tZY7Ewin@jessikat.demon.co.uk> Message-ID: <cpn15q2sg0.fsf@cj20424-a.reston1.va.home.com> Robin Becker <robin at jessikat.fsnet.co.uk> writes: > In article <cpsnfi2z9w.fsf at cj20424-a.reston1.va.home.com>, Guido van > Rossum <guido at python.org> writes > >Robin Becker <robin at jessikat.fsnet.co.uk> writes: > > > >> We all know lightning is God's way of telling us to shut up. Of course > >> God is benevolent no matter how appalling the universe gets. The > >> opposite of benevolent is malevolent. When our quick-sorts go wrong it > >> will be as a result of a benevolent act by a caring designer. > > > >I sincerely wish you would be struck by lightning. Your attitude > >disgusts me. > > > >--Guido van Rossum (home page: http://www.python.org/~guido/) > > Oh dear I sense a humour deficit :( Touche. There was no smileys in your comments about dictators either. --Guido van Rossum (home page: http://www.python.org/~guido/) From qrczak at knm.org.pl Mon Jul 30 02:30:49 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 30 Jul 2001 06:30:49 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <mailman.995989601.30748.python-list@python.org> <cp3d7lbo89.fsf@cj20424-a.reston1.va.home.com> <ubsm8epr5.fsf@ctwd0143.fitlinxx.com> <cp7kww92ph.fsf@cj20424-a.reston1.va.home.com> <m266cg73ig.fsf@mycroft.actrix.gen.nz> <3b60d65e.219212588@news.eircom.net> <cpy9pa4hnh.fsf@cj20424-a.reston1.va.home.com> <slrn.pl.9m4s03.f3g.qrczak@qrnik.zagroda> <3b64e984.782776733@wa.news.verio.net> Message-ID: <slrn.pl.9m9voo.gs8.qrczak@qrnik.zagroda> Mon, 30 Jul 2001 05:30:37 GMT, Bengt Richter <bokr at accessone.com> pisze: >>result depends on the value of the argument (x**y returns at least >>a float when y is a rational, but may return an integer when y is > ^^^^^-inexact vs. exact--^^^^^^^ >>a nonnegative integer) and turns some TypeErrors into ValueErrors > Actually, with rationals, could't you return the inverse rational > for negative y integers ;-) Surely rational**negative_integer should return a rational - this case "lies between" cases considered in this example. The reason of the unusual behavior of ** is simple: there are about four operations artificially folded into one operator. It could be done because it happens that they give equal results on equal inputs, and it's commonly done in mathematics and programming languages. These operations are the following (generally each time it's statically known which is meant): - Raising an element of a ring (or even associative group) to a nonnegative integer exponent. It means: multiply the given number of times (with 0 giving the unit). - Raising an element of a field to an integer exponent. If the exponent is negative, the number must be non-zero. It means: if the exponent is nonnegative, multiply the given number of times, otherwise multiply inverses. - Raising a real or complex number to a rational exponent. If the exponent is negative, the number must be non-zero. If we are not considering complexes and the exponent has an even denominator, the number must be nonnegative. The meaning is well known, I won't repeat the full definition. - Raising a positive real number to a real exponent, or raising a complex number to a complex exponent. It means: x**y == exp(y*log(x)), for suitably overloaded exp and log. Each time you give a more general exponent, you demand more from the domain of the base, and sometimes previously valid results no longer exist (e.g. (-1)**(1/3) is defined, but (-1)**float(1/3) is not). -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From oliver at rutherfurd.net Tue Jul 24 12:17:00 2001 From: oliver at rutherfurd.net (Ollie Rutherfurd) Date: Tue, 24 Jul 2001 11:17:00 -0500 Subject: ANN: winreg module (_winreg wrapper) Message-ID: <20010724111700.A27412@loki> Hello, I've written an object-oriented wrapper for _winreg. It's a little higher level than _winreg, and it allows you to access the sub keys and values of a key, via a key object. I remember seeing a similar post a while back, but as I couldn't find the post or the module... Anyway, I'm learning Python, and this seemed like a good little project. Here's a little code snippet showing how it can be used: >>> from winreg import * >>> key = Key(HKCR) >>> len(key.keys) 3940 >>> print key[0].name * >>> '.py' in key.keys 1 >>> print key['.py'].values[None] Python.File >>> pyfile = key['Python.File'] >>> print pyfile['Shell\\Open\\Command'].values[None] "C:\\Python21\\python.exe" %1" %* >>> There's not really any external documentation, but I used DocTest (which is really cool!), so there are a bunch of usage examples in the code. You can find winreg here: http://www.newtonsplace.net/winreg.html If you check it out, I'd love feedback! -Ollie Rutherfurd oliver at rutherfurd.net From brakedon at hotmail.com Sat Jul 7 12:56:31 2001 From: brakedon at hotmail.com (eric_brake) Date: 7 Jul 2001 09:56:31 -0700 Subject: Tying a GUI to a another module Message-ID: <7b515e0f.0107070856.3466e4a1@posting.google.com> Does anyone know how to link a module containing the gui (first_gui) and a another one containing the code to run the program (fibonaccii_gui). Using the "Fib Calc" button to execute the process. I want the program to take input from the Entry field process it through "fibonaccii_gui" and then print the fibonaccii sequence in the Label field. Here's the involved modules, Thank you for any help. "first_gui" module import fibonaccii_gui from Tkinter import * class fibon_gui: def __init__(self, master): frame_entry = Frame(master) frame_entry.pack() input = Entry(frame_entry, width=30) input.pack() output = Label(frame_entry, text="Output goes here") output.pack(side=TOP) frame_button = Frame(master) frame_button.pack() button_fibcalc = Button(frame_button, text="Fib Calc") button_fibcalc.pack(side=LEFT) button_quit = Button(frame_button, text="QUIT", fg="red", command=master.quit) button_quit.pack(side=RIGHT) root = Tk() root.title('Fibonaccii') fibgui = fibon_gui(root) root.mainloop() Here's "fibonaccii_gui" module class fibonaccii: def fib(self): a, b = 0, 1 while b < fibnumber: #print b, fibonaccii sequence is saved in variable "b" a, b = b, a+b fibinstance = fibonaccii() From db3l at fitlinxx.com Thu Jul 5 22:31:15 2001 From: db3l at fitlinxx.com (David Bolen) Date: 05 Jul 2001 22:31:15 -0400 Subject: Exporting a Class from a .pyd References: <3b4474a8.4155281@news.t-online.de> Message-ID: <u66d6wzyk.fsf@ctwd0143.fitlinxx.com> gerson.kurz at t-online.de (Gerson Kurz) writes: > It is quite easy to export methods, and constants, and even datatypes > from a .pyd (Python Extension DLL, .so in #?nix). However, how do you > export a class ? Is it just a special way of exporting datatypes ? > (But then, I cannot yet see how to add methods to such a datatype). > I've looked up google but in vain. New objects in extensions are formed by initializing an appropriate structure with entry points (determined by Python and the basic type of object you implement) for your object and then letting Python know about it. Methods are handled through the getattr slot (e.g., you just look up the entry point for your method and return it as the result). That's one of the weaker sections of the existing documentation (what information there is can be found mostly in the Python C/API document), so you're best set to refer to either sample sources for extensions or to the Python source itself. There is an xxobject.c file in the objects directory of the Python source that can be a good starting point (as can be any of the other object implementation files in that directory). Note that these methods will actually give you a new type, but not something that you can subclass from within your Python code. If you want that do some google searching on extension classes, which can provide a way to do that, or - probably easier - try working with a library such as Boost to make some of that work easier. -- -- 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 Randy.L.Kemp at motorola.com Tue Jul 3 16:07:33 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Tue, 3 Jul 2001 16:07:33 -0400 Subject: Calculus Message-ID: <E566B020833BD311B6610008C791A39705CA51F8@il93exm04.css.mot.com> And if you want a good contrast to Leibnitz, try Authur Schopenhauer. -----Original Message----- From: pinard at iro.umontreal.ca [mailto:pinard at iro.umontreal.ca] Sent: Tuesday, July 03, 2001 3:02 PM To: tundra at tundraware.com Cc: python-list at python.org Subject: Re: Calculus [Tim Daneliuk] > I thought it was Voltaire who said we live in the best of all possible > world (in 'Candide')... Panglos, Candide's teacher and philosopher, was repeating that sentence at every turn of the page, indeed. But Voltaire's intent was laughing at Leibnitz philosophy, making it look ridiculous. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From aleaxit at yahoo.com Tue Jul 3 08:29:54 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 3 Jul 2001 14:29:54 +0200 Subject: Python and DB support (was: Re: Is Python Dead?) References: <mailman.994155184.16109.python-list@python.org> Message-ID: <9hsds501vk3@enews1.newsguy.com> "Roman Suzi" <rnd at onego.ru> wrote in message news:mailman.994155184.16109.python-list at python.org... ... > Anyway, I wanted to say that some generic (!=Windows only) ADO > could help for those who consider Python for tasks usually > done with PHP or ASP. We seem to keep hitting a brickwall here. Let's try an analogy. It's exactly as if somebody said "consider Fortran for tasks usually done with Lisp or Unix". This is not an "alternative". Fortran is a language. It runs within environments. Unix is an environment within which some languages run. You do not *CHOOSE BETWEEN* Fortran and Unix. You choose your language and your environment, and it could, if you want, be Fortran under Unix. If you like Fortran and you like Unix, go for it. Of course Fortran also runs on many other environments (not all) and Unix also runs many other languages (not all), but that doesn't make them ALTERNATIVE to each other!!! Now, it's EXACTLY the same situation: you say "consider Python for tasks usually done with PHP or APS". This is not an "alternative". Python is a language. It runs within environments. ASP is an environment within which some languages run. You do not *CHOOSE BETWEEN* Python and ASP. You choose your language and your environment, and it could, if you want, be Python under ASP. If you like Python and you like ASP, go for it. Of course Python also runs on many other environments (not all) and ASP also runs many other languages (not all), but that doesn't make them ALTERNATIVE to each other!!! *WHY* is it apparently so durned HARD?! Why do people keep saying "ASP" as if it somehow IMPLIED a language choice when one can perfectly well run any number of languages even on the *SAME SINGLE* Active Server Page?! Microsoft brainwashing? Anti-Microsoft brainwashing? I don't really understand. It's clearer why people may believe that taking advantage of the JVM and the huge amount of libraries for it somehow requires coding in Java (it doesn't, of course - Python is a possible alternative!), since Sun has done their best to blur the key distinction between language and environment. But Microsoft HAS been highlighting in glow-in-the-dark bright orance that THEIR environments are FULLY multi-language, since day one. Is Microsoft marketing really SO feeble that they still have not been able to get THIS single VERY simple point across?! If you're considering deploying Python on IIS, it really makes no difference whether Python duplicates much of the powerful infrastructure that you get on IIS anyway -- it's crucial that Python lets you fully exploit that existing infrastructure, but any duplications are mostly wasted effort. If you're considering deploying Python or PHP on Apache in a cross-platform way, or on some specific target system where ADO is not available, then what you need to compare is not either language vs ADO, but the languages and their libraries with each other. I'm no PHP expert, but it appears to me that the closest you get on PHP to a DB-independent interface is as a part of PHPLib, e.g. cfr http://phplib.netuse.de/documentation/documentation-3.html#ss3.1 After studying that page a bit, unless I'm missing something, it appears to me that this interface is *VASTLY* inferior to the Python DB API. In particular, there's nothing even vaguely approaching the nice convenience functionality that ADO supplies. So *what* makes you think people are choosing PHP rather than Python because of DB connectivity issues? Apparently they're so choosing DESPITE Php's _inferiority_ in DB connectivity. So, further enhancing the DB functionality of Python seems unlikely to have any important effect in this regard. It may very well be that it's worthwhile designing a higher level, somewhat ADOlike superstructure on top of the DB API, but, if so, then it DEFINITELY cannot be because of some kind of "competition" between Python and PHP -- much less, of course, "between Python and ASP", which is as peculiar a "competition" as "between Python and Unix" or "between Python and the JVM"...!!! Alex From paulp at ActiveState.com Sun Jul 1 15:33:41 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sun, 01 Jul 2001 12:33:41 -0700 Subject: Comment on PEP-0238 References: <3B3BE855.A6223E70@3-cities.com> <cp7kxvlake.fsf@cj20424-a.reston1.va.home.com> <Y4J%6.4084$Z6.2010194@news1.rdc2.pa.home.com> Message-ID: <3B3F7B15.5E3C2BD6@ActiveState.com> I really don't want to go through this whole argument again (after all, that's the point of PEPs) but when you were a child, you "just knew" whether you meant truncating or float division. Python guesses based on the types of the operands which is a poor choice in a dynamically typed language that otherwise treats "5.0" as a more verbose alternate syntax for "5": for i in range(5.0): print i If Python were to always disallow integer/float coercion then users would learn that and life would go on. Instead, it coerces in some places and not others. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From michael at stroeder.com Mon Jul 23 04:56:44 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Mon, 23 Jul 2001 10:56:44 +0200 Subject: web sessions support References: <O8R67.2110$De6.330884@news.pacbell.net> Message-ID: <3B5BE6CC.9B71B87E@stroeder.com> Jeff Davis wrote: > > I have been looking around and I have not been able to find a session > module for python (for the web). Basically I just need a normal session > manager that can work somewhat like the one in PHP. I have recently been > moving away from PHP to python for web stuff and I need a session manager. > If no such module exists, I would write my own. You might wanna borrow some ideas from http://www.stroeder.com/pylib/PyWebLib/ I'm the author => take it with a grain of salt. ;-) There are other modules too: http://thor.prohosting.com/~pboddie/Python/web_modules.html Ciao, Michael. From nperkins7 at home.com Tue Jul 24 11:48:52 2001 From: nperkins7 at home.com (Nick Perkins) Date: Tue, 24 Jul 2001 15:48:52 GMT Subject: function while true - list function? References: <88f77.300$e%3.6743@news.lhr.globix.net> Message-ID: <ENg77.543485$eK2.113992779@news4.rdc1.on.home.com> "Giles Constant" <giles at spacepigs.com> wrote in message news:88f77.300$e%3.6743 at news.lhr.globix.net... > Hi there, > > is there a function in python which will populate a list with the results > of a function while the function returns something other than 'None'? I've > looked for something but can't find much, but it's something I'm doing so > often (especially while processing SQL databases) that I'm wondering if, if > it doesn't already exist, it could be a good idea for future versions. > > eg: > > def GrabSomeData: > somecursor.execute("SELECT x,y FROM z") > return unroll(somecursor.fetchone) * > > * I figured "unroll" would be a good name for it :-) > Here's a version of unroll which can take extra args: def unroll(fn,*args,**kwds): results = [] x = fn(*args,**kwds) while x != None: results.append(x) x = fn(*args,**kwds) return results for record in unroll(cursor.fetchone): process(record) This will create a list of all results of your function, up to, but not including the first 'None' result. ... Here's another way to do it, using generators: (in python 2.2) from __future__ import generators def gen_unroll(fn, *args, **kwds): x = fn(*args,**kwds) while x != None: yield x x = fn(*args,**kwds) for record in gen_unroll(cursor.fetchone): process(record) if somecondition(): break The difference, with the generator version, is that results are not all computed and put in a list, as with the first version of unroll; they are generated only as they are needed. With the generator version, if you decide to break out of processing records before all are done, you will have saved the time needed to fetch all records in advance. From yuba at cyberback.com Fri Jul 20 21:05:02 2001 From: yuba at cyberback.com (Greg & Janet LINDSTROM) Date: Fri, 20 Jul 2001 20:05:02 -0500 Subject: Help with PDF Message-ID: <000801c11181$3145dcc0$2cde3dd8@glindshome> Greetings- What is available in Python to produce Portable Document Format (PDF) files? I have read through the "Python Programming on Win32" book and searched the web-site, with little result (the book is good, but eluded that new tools might be available by the time the book had been published). What is the state-of-the-python on pdf? Is it considered "the method of choice" for "pretty" documents? Thanks, Greg Lindstrom Vilonia, Arkansas -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-list/attachments/20010720/a94f521f/attachment.html> From ullrich at math.okstate.edu Sat Jul 14 09:13:57 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sat, 14 Jul 2001 13:13:57 GMT Subject: Language Shootout References: <mailman.995051543.19976.python-list@python.org> Message-ID: <3b5042e3.1229234@nntp.sprynet.com> On Fri, 13 Jul 2001 15:11:52 -0400, "Tim Peters" <tim.one at home.com> wrote: >[Tim] >> Here's another fun one: you can also write a long-int multiplication >> routine in Python that runs significantly faster than the builtin >> long *! Hint: recursion <wink>. > >[David C. Ullrich] >> I give up, howdaya do that? >> >> (When I read this I said aha, you're getting at something like >> using >> >> [*] (a*2**k+b)*(c*2**k+d) = a*c*2**(2*k) + (a*d+b*c)*2**k + b*d. >> >> But when I think about it I don't see why that would give any >> improvement - it _seems_ to me that vanilla long multiplication >> should be quadratic (a*b takes time "len"(a) * "len"(b), where >> "len" is the number of "digits".) If that's correct then using >> [*] wouldn't improve things at all as far as I can see. > >Right, it's not "clever" enough: that reduces an NxN mult to four >(N/2)x(N/2) mults. NxN takes N**2 "elementary" (1x1->2) mults, and >(N/2)x(N/2) N**2/4, so four of the latter is no savings over the former. > >The trick is to reduce it to three (N/2)x(N/2) multiplications That would do it all right... >(and >recursively too for those in turn). Then the overall complexity drops from >O(N**2) to O(N**log2(3)) ~= O(N**1.58). > >> Can't decide: >> >> You're hinting at [*] and I'm analyzing it wrong? (Like >> if vanilla multiplication is actually worse than quadratic >> in the sense above then [*] will speed things up...) > >You'll figure it out <wink>. Thanks. (Too late, Emmanuel already gave it away.) > "An answer" is spelled out in Knuth vol 2, or >search for "Karatsuba multiplication" on the web. > >> You're hinting at something kinda like [*] but with clever >> rearrangents that does give improvement, like that >> Strassen(?) thing for matrix multiplcation? > >Yes, but not nearly *that* clever. > >> You're talking about using an FFT-based multiplication? >> (One can certainly write a recursive FFT. But surely if >> _this_ is what you meant then the hint would be "FFT" >> instead of "recursion"...) > >I'm not sure you can write one of those *in Python* that's actually faster >than the builtin long *, unless the longs are so large nobody would care. Doesn't seem likely to me either, wasn't sure what you were getting at. (Just for giggles I made a few Python FFT's yesterday; one of them is only about 100 times slower than the same algorithm in Object Pascal...) >See > > http://groups.yahoo.com/group/python-list/message/63188 > >and followups for Christian Tismer's last known stab at implementing >Karatsuba in Python. It pays for ints short enough that somebody *might* >care. OTOH, anyone who cares a lot should be using one of the GMP wrappers >(GMP also uses this trick, but in excruciatingly long-winded and >platform-optimized C). Right - wasn't meaning to suggest that this was the right solution for serious work, just wanted to know what the algorithm in question was. Lemme write this down: Karatsuba. David C. Ullrich From gmcm at hypernet.com Wed Jul 18 09:18:35 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 18 Jul 2001 13:18:35 GMT Subject: Importing XML modules in py2exe or Installer? References: <Xns90DE9C2957BDgustaflalgonetse@194.213.69.152> <Xns90DE68B66343Agmcmhypernetcom@199.171.54.154> <Xns90DEC227B102Cgustaflalgonetse@194.213.69.148> <mailman.995419232.8951.python-list@python.org> Message-ID: <Xns90E25ECA4BBFEgmcmhypernetcom@199.171.54.154> "Gregory P. Smith" wrote: > I hack that I don't really recommend, but that does work: rename the > _xmlplus subdirectory from the pyxml installation to xml. (move any > old tiny xml directory that python came with out of the way). We've > been doing this to package mojo nation successfully with both gordons > and py2exe. [we did that for other historical reasons unrelated to > packaging but it worked for packaging as a side effect] I looked into this and discovered a problem with imputil (which both Thomas & I rely on). Your hack neatly avoids the problem. When you have _xmlplus installed, importing xml causes code in xml/__init__.py to run which imports _xmlplus, then swaps itself in sys.modules with _xmlplus. Under the regular import mechanism, an import of, say, xml.sax will cause _xmlplus.sax to be imported, but it will show up as xml.sax in sys.modules, and it will have the __name__ "xml.sax". Under imputil, _xmlplus.sax will be imported (and become an attribute of xml), but it will show in sys.modules as _xmlplus.sax (and have a __name__ of _xmlplus.sax). Normally, this is not a problem. Once imported, a reference to xml.sax will be resolved by looking for the name "sax" within xml, and this succeeds. But there are quite a few places in _xmlplus where it searches sys.modules, and these cases fail. I've posted a patch to the import SIG for comment. If no one complains, I'll send it on to Pythonlabs. - Gordon From heikowu at ceosg.de Mon Jul 16 17:58:13 2001 From: heikowu at ceosg.de (Heiko Wundram) Date: Mon, 16 Jul 2001 23:58:13 +0200 Subject: CGI-Problem with Refresh Header Message-ID: <9ivnss$csl$01$1@news.t-online.com> Hello fellow Pythonistas! I have a small problem with my CGI-script; I need to do a refresh (to some other page) after a certain amount of time, but I can't remember the exact syntax of the "Refresh:"-HTTP-Header... Anybody out there who can help me? :) Yours, Heiko W. From sailwong at alumni.cuhk.edu.hk Tue Jul 10 13:50:52 2001 From: sailwong at alumni.cuhk.edu.hk (Steve S.L. Wong) Date: Wed, 11 Jul 2001 01:50:52 +0800 Subject: Newbie asks(2): How to do this line of C in Py? Message-ID: <tkmfvla7npuqfd@news.supernews.com> if sscanf(command,"%c%d",&c,&d) != 2 { } From aahz at panix.com Thu Jul 12 00:26:04 2001 From: aahz at panix.com (Aahz Maruch) Date: 11 Jul 2001 21:26:04 -0700 Subject: Tuple Semantics - Rationale'? References: <3B4CA0A8.20B53230@tundraware.com> Message-ID: <9ij8ss$puj$1@panix2.panix.com> In article <3B4CA0A8.20B53230 at tundraware.com>, Tim Daneliuk <tundra at tundraware.com> wrote: > >Supposed I did want 0 argument pairs in that tuple, but I wanted to prepare >the way for adding some later. Would I use: > > (()), (), ((,)) ??? Um. Tuples are immutable. How do you add more later? -- --- 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 "How come we choose from just two people for President but more than 50 for Miss America?" --AEN From bill-bell at bill-bell.hamilton.on.ca Wed Jul 25 20:31:11 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Wed, 25 Jul 2001 20:31:11 -0400 Subject: Threads in Python version 1.5, thread doesn't start until calling process dies In-Reply-To: <996072078.378.91641.l9@yahoogroups.com> Message-ID: <3B5F2C8F.4085.28B422@localhost> kentabacchi at excite.com (Ken Tabacchi) wrote, in part: > I am having some trouble with a threadded process in Python version > 1.5. It seems that the thread does not start until the calling > process has died. The thread starts immediately when the following > program is run under Python version 2.1. Interesting one (for me, anyways). Please forgive my ignorance: would I be correct to surmise that 1.5 lacks 'threading' and locks? From sholden at holdenweb.com Thu Jul 12 12:55:57 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 12 Jul 2001 12:55:57 -0400 Subject: Light Speed Socket Connections References: <d01baf67.0107112132.34e70d03@posting.google.com> <3b4d6184.1698299906@wa.news.verio.net> <mailman.994949372.17704.python-list@python.org> Message-ID: <NCk37.1777$u76.55241@e420r-atl3.usenetserver.com> "Skip Montanaro" <skip at pobox.com> wrote in message news:mailman.994949372.17704.python-list at python.org... > > Bengt> On 11 Jul 2001 22:32:16 -0700, tangell at kicker.com (T Angell) wrote: > >> I wrote some code to test how long it takes to make socket connections > >> and ran it against several hosts around the world, here are some > >> sample times: > >> > >> socket time: 0.0047459602356 > >> socket time: 0.00469899177551 > >> socket time: 0.00404000282288 > >> socket time: 0.00537407398224 > >> > Bengt> [...] > >> t1 = time.time() > Bengt> For accurate timing, time.clock() is recommended, I believe: > ... > > Not in this case. He wants to know how long it takes the socket to be > connected between the two machines. That is an elapsed time sort of thing, > what you measure with time.time. It has little or nothing to do with the > CPU time used by the client process making the connection. > Well, after this little experiment on PythonWin 2.0/Win95 I'm no longer sure what is going on: >>> for i in range(10): ... time.sleep(2.5) ... print time.time(), time.clock() ... 994956779.3 5.86667560636e-006 994956781.88 2.55270956603 994956784.41 5.0637313733 994956786.94 7.58865720176 994956789.41 10.1181121038 994956791.99 12.6327050403 994956794.46 15.1421897786 994956796.99 17.6518547076 994956799.51 20.1890552976 994956802.04 22.7061055331 Is my CPU usage really ~100% during those sleeps? regards Steve -- http://www.holdenweb.com/ From eduard.hiti at t-online.de Mon Jul 2 16:01:08 2001 From: eduard.hiti at t-online.de (Eduard Hiti) Date: Mon, 2 Jul 2001 22:01:08 +0200 Subject: Is Python Dead? References: <9hq6900kqt@enews4.newsguy.com> Message-ID: <9hqjvf$f4i$01$1@news.t-online.com> | Oh, and, what about http://sourceforge.net/projects/xdb/? Now | renamed to XBase, I'm told, but apparently the URL still has | XDB in it. Haven't checked it, but they claim support for C++, | Perl and Python. Unfortunately support for various scripting languages, including Python, is still on the To Do-list (at least on their home page) From jeff at ccvcorp.com Mon Jul 2 12:33:53 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Mon, 02 Jul 2001 09:33:53 -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> <9hjeg8$dtrpr$1@ID-11957.news.dfncis.de> Message-ID: <3B40A271.F48D39ED@ccvcorp.com> Either that, or use double \'s, eg: >>>os.system("c:\\Program Files\\KeyNote\\keynote.exe") The likely problem here being that \ indicates escape codes in python strings; in order to represent \ itself, you either need to escape it (which is what \\ does), or specify that the string not use escape codes (which is what the raw string does). Jeff Shannon Technician/Programmer Credit International Emile van Sebille wrote: > Maybe you need a raw string? eg: > >>> system(r"C:\Program Files\KeyNote\keynote.exe") > > -- > > Emile van Sebille > emile at fenx.com > > --------- > "MDK" <no at spam.com> wrote in message > news:9hil2h$3qa$1 at taliesin.netcom.net.uk... > > > > "Franz GEIGER" <fgeiger at datec.at> 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 rnd at onego.ru Tue Jul 3 00:50:46 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 3 Jul 2001 08:50:46 +0400 (MSD) Subject: Python and DB support (was: Re: Is Python Dead?) In-Reply-To: <ug0cfdo2k.fsf@ctwd0143.fitlinxx.com> Message-ID: <Pine.LNX.4.30.0107030844250.15928-100000@rnd.onego.ru> On 2 Jul 2001, David Bolen wrote: >Roman Suzi <rnd at onego.ru> writes: > >> However, my collegues were not satisfied with it. One somplain was that in >> ASP/IIS it is "very easy" to receive a "recordset" from database and then >> apply it in different situations in the ASP-page, because recordset is an >> object and even subqueries could be made without quering DB again. > >Just curious, but did your colleagues try using Python's COM interface >to ADO to retrieve an actual recordset object that they could >manipulate the same in Python as in other ASP languages? Aha! Now I could understand what is the brake of Python library development. Most of Python users are Windows users. And they have COM for whatever is in their system. >At least under Windows, it would seem that having solid ODBC and COM >support should pretty much cover in Python anything you'd do elsewhere. > >On other environments, direct support for a particular database is >likely to be more desirable, as it's more typical in those >environments, but as you've noted, there's a plethora of support >modules for various databases - some at various levels. We mostly have Linux servers, so COM+ADO is no option. The point was not to choose between Windows and Linux, ASP was choosen to serve particular purpose, for the database already implemented in Microsoft land. >-- >-- David Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Tuesday, July 03, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Paranoia is nothing to be afraid of!!" _/ From sandysj at asme.org Fri Jul 6 11:42:12 2001 From: sandysj at asme.org (Jeff Sandys) Date: Fri, 6 Jul 2001 15:42:12 GMT Subject: Is there a K&R on Python? References: <3B42EEAD.9EE4E7A7@divalsim.it> <l8e6kt415rispcte0qbaj1qhq33hq270bk@4ax.com> Message-ID: <3B45DC54.F8E703A2@asme.org> > >I'm looking for a Python book to use as a desktop reference > > _Python Essential Reference_ did it for me. There is a reason it is called essential. First 100 pages, everything essential about the language, next 200 pages, short descriptions of all the essential modules included in the distribution. Get the 2nd version for Python 2.1, or the first version for Python 1.5. Thanks, Jeff Sandys From roy at panix.com Thu Jul 19 21:17:35 2001 From: roy at panix.com (Roy Smith) Date: Thu, 19 Jul 2001 21:17:35 -0400 Subject: Parsing TCL? Message-ID: <roy-8EF99A.21173519072001@news1.panix.com> I know this is probably a strange request, but does anybody know of a python module which parses TCL files? From tjenkins at nospiced.ham.devis.com Tue Jul 24 16:52:31 2001 From: tjenkins at nospiced.ham.devis.com (Tom Jenkins) Date: Tue, 24 Jul 2001 20:52:31 GMT Subject: PEP238 and zope Message-ID: <3B5DE0F7.9070001@nospiced.ham.devis.com> We're a zope shop. Its quite possible that the work we do now will be still in use for many years (not guaranteed but we still use code now that we wrote 2 years ago - before it was zope ;) ) We use Python Methods in Zope... python snippets stored directly in zope's zodb. grepping *.py won't find any of these snippets. I don't believe zope will surface any warnings that PEP238 stipulates (tho I may be wrong). How do we code _now_ so as to minimize our pain? Tom From kp87 at lycos.com Fri Jul 27 04:42:07 2001 From: kp87 at lycos.com (kevin parks) Date: 27 Jul 2001 01:42:07 -0700 Subject: interpreter improvements References: <5e8bd451.0107190224.7171e61@posting.google.com> <slrn9m0nbf.l0b.quinn@yak.ugcs.caltech.edu> <mailman.996177532.9490.python-list@python.org> <cpd76n5p7q.fsf@cj20424-a.reston1.va.home.com> Message-ID: <5e8bd451.0107270042.691bf6f0@posting.google.com> Thanks everyone. I am learning a lot by this discussion, but i should point out that the main reason why i am so unhappy with the interpreter is that i am ON A MACINTOSH!!! The forgotten platform of the python world. (thanks god for Jack and Just!) which means that IDLE, we don't really have! (it's broken, i think and has been for a while as there are problems with tkinter. Unless i am, as always, wrong) And our Mac IDE is, uhm... (forgive me please)...uhmm.... Not fully-featured as IDLE is. Compound this with the move to OS X and the fact that our text engine (WASTE) is not yet ready for prime time X wise... Well. I guess i should be used to it by now and just realize that macintosh is the runt of the litter and that we will never have the niceties that other *nix and Windoze users have. I'll die of old age before we get syntax coloring! Anyway i hate to send this post because it makes me seem ungrateful for all that Python and the Python Community has given me. That is not the case. I am still very much in love with both, but i would be thrilled, if, just once, the Macintosh was given a bit more Python love. The Mac is a legit machine, and an affordable one. Lot's of folks use them. They should all come with Python Pre-installed :-) and a pretty IDE to make us all happy Pythonites. I mean, don't you pity us?! What do we have? Awesome hardware and ... Applescript!? The Apple couldn't even hang on to Smalltalk for us! I've had to wait 10 years to get back the NeXT machine i had! Guido! Please release the dogs! The Mac world is on a respirator! Ok, i am done getting carried away. cheers, kevin parks seoul, korea kp87 at lycos.com Guido van Rossum <guido at python.org> wrote in message news:<cpd76n5p7q.fsf at cj20424-a.reston1.va.home.com>... > Skip Montanaro <skip at pobox.com> writes: > > > As others (including Guido) have observed, having a line editing subsystem > Creating an editing subsystem is a lot of work. I created one that > knows the structure of the language, and it is distributed for free > with Python. The only downside is that it uses a GUI, so it's not for > everyone. Its name? IDLE. > > BTW, IDLE's rules are almost the same as those used by Emacs > python-mode.el. Emacs *does* run in a classic TTY window. > > --Guido van Rossum (home page: http://www.python.org/~guido/) From volucris at hotmail.com Thu Jul 12 14:23:56 2001 From: volucris at hotmail.com (Volucris) Date: Thu, 12 Jul 2001 13:23:56 -0500 Subject: Newbie Question: Regular Expressions References: <mailman.994953021.32263.python-list@python.org> Message-ID: <3b4deab3$0$329$6e49188b@news.goldengate.net> I'm not too confortable with with regular expressions, so I can't help you there. But, I did write a program for my father that might help you out a little bit. It downloads winning Powerball numbers (It's a lottery if you didn't know.) and grabs the numbers for a chosen date. PBallAgent: http://volucris.8m.com/PBallAgent/pballagent.pyw.txt -- Volucris (a) hotmail.com "Eu n?o falo uma ?nica palavra do portugu?s." <fett at tradersdata.com> wrote in message news:mailman.994953021.32263.python-list at python.org... > I have a really dumb program that i would like to make smarter. I need > to take a file on my hard drive and filter out everything except for the > standings which are written in it. I have tried to use regular > expressions with no success, but i still think that they are probably > the best way. I created the following simple fix, but it is unreliable > if the data changed posistions. > > > input = open('rawdata', 'r') > S = input.read() > print S[4021:6095] > > Output : > League Standings > American League > EAST W L PCT GB HOME ROAD EAST CENT WEST NL L10 STRK > Red Sox 43 29 .597 - 23-15 20-14 23-13 8-7 6-6 6-3 6-4 L2 > Yankees 41 31 .569 2.0 21-15 20-16 19-11 12-9 5-7 5-4 6-3 W2 > Blue Jays 35 38 .479 8.5 18-20 17-18 14-13 6-7 11-13 4-5 5-5 W3 > Orioles 34 39 .466 9.5 20-20 14-19 15-17 9-12 6-5 4-5 5-5 L1 > ........( it continues with all the standings) > > > Also could you tell me if its possible to download the data from the > web-page in python so that it doesnt even have to deal with opening the > file. > > > > > > > > -- > Daniel Hammond Get your free e-mail account today @ > Raleigh NC http://sabacctable.zzn.com > The United States of America > ------------------------------------------------------------------- > > > From rhcassel at yahoo.com Wed Jul 18 09:43:35 2001 From: rhcassel at yahoo.com (rh cassel) Date: Wed, 18 Jul 2001 13:43:35 GMT Subject: OO misconceptions // Learning curve geometry/ References: <mailman.994969462.27792.python-list@python.org> <hevsktcrnpckttnkgi1arcue5kjjsbrrb5@4ax.com> <mailman.995046506.2514.python-list@python.org> <9ir1l7$3ja$1@panix2.panix.com> <9irfbc11jaq@enews1.newsguy.com> <slrn9l49me.p58.tim@vegeta.ath.cx> <mailman.995268208.1394.python-list@python.org> <slrn9l6kci.qqs.tim@vegeta.ath.cx> <3B538E16.65394C9D@engcorp.com> <slrn9l7a8r.rpe.tim@vegeta.ath.cx> <9j0rko025gf@enews3.newsguy.com> <slrn9l9k6t.va1.tim@vegeta.ath.cx> Message-ID: <bog57.219$Ax5.5503@news3.voicenet.com> > Granted, Perl had the longest and steepest learning curve since C++ for > me. But after grasping the concept of "context" and learning to use > Perl's m// and s/// operators to my advantage, I find I can just > accomplish more faster than with most other languages, even (so far) > with Python. Off topic but if one looks at the definition, a "steep" learning curve means quick and easy to learn. It is an accumulated knowledge versus time function. The marketing folks have totally corrupted the meaning. Here is a nice reference. http://www.computerworld.com/cwi/stories/0,1199,NAV63-1356_STO61762,00.html Bob From bokr at accessone.com Sat Jul 28 20:58:10 2001 From: bokr at accessone.com (Bengt Richter) Date: Sun, 29 Jul 2001 00:58:10 GMT Subject: PEP 238 (revised) References: <cp4rrz5onj.fsf@cj20424-a.reston1.va.home.com> <slrn9m3bt8.114.sill@sill.silmarill.org> <3B61B7E4.5C6DFF01@Lugoj.Com> <cpzo9q16ux.fsf@cj20424-a.reston1.va.home.com> <3b622f18.603981038@wa.news.verio.net> Message-ID: <3b633eda.673551235@wa.news.verio.net> Update: Scheme's 'wart' was a beauty spot after all ;-) On Sat, 28 Jul 2001 04:51:08 GMT, bokr at accessone.com (Bengt Richter) wrote: >On Fri, 27 Jul 2001 19:59:16 GMT, Guido van Rossum <guido at python.org> wrote: >[...] >> >>IEEE 754, the floating point standard in use in virtually all current >>hardware, mandates that -0.0 be distinguishable from 0.0, in order to >>be able to represent the sign of degenerated underflow results. (Or >>so I understand, having been educated in IEEE 754 through numerous >>discussions with Tim Peters, but not by reading the standard. If I'm >>wrong, Tim will surely correct me. :-) >> >>I don't know of a portable way to generate -0.0 in Python; on my Linux >>box, simply writing -0.0 does it, but not on my Windows box. >> >My gut feeling is that the symmetry of sign,magnitude numbers in IEEE754 is not good >when you are dealing with a mapping of the real axis to the unit circle. It doesn't >feel right to me, though probably it's not of much practical consequence. > I still feel that way ;-) >But, speaking of the unit circle, UIAM Scheme has what appears to me to be a wart. >Functions that return angles apparently do so as values in (-pi,pi] rather than >[-pi,pi). To me that is a wart. Apparently Scheme got it from APL, and I still haven't >got to the local U library to see the referenced paper with the rationale. Mathematically, >you can't translate the interval by exactly pi and get a 2pi interval that includes zero! >It strikes me as weird to exclude zero and include 2pi. [1] Well, it's also weird to translate that interval by pi ;-/ I wasn't looking at what it really means. I.e., the interval (-pi,pi] is really effectively two intervals, (-pi,0) and [0,pi], which you can separate out from (-pi,pi] and rearrange with the ususal if angle < 0: angle += twopi getting [0,pi],(pi,2pi) with the pi's merging for [0,2pi) as I wanted. I've programmed that a zillion times. I just wasn't looking at (-pi,pi] in terms of the two intervals :-/ But I think the real truth is that IEEE754 returns [-pi,-0][0,pi]. "if angle < 0" can separate that into [-pi,-0) and [-0][0,pi] and then adding 2pi to [-pi,-0) gives [pi,2pi) to combine with [-0][0,pi] for [-0][0,2pi). The -0 will probably disappear benignly at some point if ignored, but I wonder if the function is relying on that always happening in the caller's code. You can ignore the following paragraph, after the intervals have been fixed as above ;-/ > >And look what that interval does if you want to turn it into a Python index range >for k steps of 2*pi/k. Adding pi to an angle puts it in (0,2pi] -- and unless you >turn 2pi into zero before doing angle*k//twopi, you will have an out of range index >when an arctangent returns pi instead of -pi. > I wonder if (angle*k//twopi)<k is always true if angle<twopi. Seems like it should be for positive numbers anyway. >My intel book says the pentium FPATAN instruction returns radians with a magnitude >*less than* pi, so whatever constant is defined as pi for purposes of returning it >from software, the choice must have been made there between +pi and -pi, or they just >return whatever the hardware provides, which would make the scheme documentation wrong >about the interval. It could either be called (-pi,pi) or [-pi,pi], but not half open. > Well, looking in another part of the book, it uses the pi symbol and says inclusive as well as specifying the signed zero cases. So I conclude [-pi,-0][0,pi] is coming from the hardware. Which is not half open until splitting off and translating the negative piece by 2pi, as above. >Is this something that might be given a clean resolution in Python? >I.e., [-pi,pi) , IMHO ;-) > Never mind, Scheme's interval is fine (just that it's really two for some purposes). I can make what I wanted after all *<8-p I wonder if Scheme actually returns the hardware result or forces -pi to +pi specially to make (-pi,pi] their actual result range per their spec. I'll post this before looking. ;-) From ruckc at yahoo.com Mon Jul 16 21:23:13 2001 From: ruckc at yahoo.com (ruckc) Date: 16 Jul 2001 18:23:13 -0700 Subject: [ZOPE] External Method process limits? bug fix! References: <9i9rmn$kc6$1@node21.cwnet.roc.gblx.net> <detgkt4tbklojg2lothn6jm6ak0pnls874@4ax.com> <9iajn0$rvm$1@node21.cwnet.roc.gblx.net> <9iicpa$9ju$1@node21.cwnet.roc.gblx.net> Message-ID: <a9a946b.0107161723.5554a9a8@posting.google.com> I tried this change, and i still only get a 15 byte Image Object in Zope. missive at frontiernet.net (Lee Harr) wrote in message news:<9iicpa$9ju$1 at node21.cwnet.roc.gblx.net>... > Hi: > > Thanks for your help. I finally broke down and joined the zope mailing list. > It was not so difficult, really, just fill out the form at: > > http://lists.zope.org/mailman/listinfo/zope > > and reply to the confirmation message that goes out to you. > > > Turns out there is a bug in the PIL External Method example in the Zope > Book. Once the image.data attribute gets to a certain size, it is no > longer pushed around as a string, but gets wrapped up in its own > different kind of object. PIL or cStringIO was objecting to that. > > The fix is to wrap image.data in str() to force stringiness. > Here is the corrected code... > > (mostly from http://www.zope.org/Members/michel/ZB/ScriptingZope.dtml) > > > def makeThumbnail(self, original_id, size=128): > """ > Makes a thumbnail image given an image Id when called on a Zope > folder. > > The thumbnail is a Zope image object that is a small JPG > representation of the original image. The thumbnail has a > 'original_id' property set to the id of the full size image > object. > """ > > from PIL import Image > from cStringIO import StringIO > import os.path > > # create a thumbnail image file > original_image=getattr(self, original_id) > original_file=StringIO(str(original_image.data)) # bug fix here > image=Image.open(original_file) > image=image.convert('RGB') > image.thumbnail((size,size)) > thumbnail_file=StringIO() > image.save(thumbnail_file, "JPEG") > thumbnail_file.seek(0) > > # create an id for the thumbnail > path, ext=os.path.splitext(original_id) > thumbnail_id=path + '.thumb.jpg' > > # if there's and old thumbnail, delete it > if thumbnail_id in self.objectIds(): > self.manage_delObjects(thumbnail_id) > > # create the Zope image object > self.manage_addProduct['OFSP'].manage_addImage(thumbnail_id, > thumbnail_file, > 'thumbnail image') > thumbnail_image=getattr(self, thumbnail_id) > > # set the 'originial_id' property > thumbnail_image.manage_addProperty('original_id', > original_id, > 'string') From Randy.L.Kemp at motorola.com Tue Jul 3 11:50:37 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Tue, 3 Jul 2001 10:50:37 -0500 Subject: What's wrong with this program Message-ID: <E566B020833BD311B6610008C791A39705CA51EB@il93exm04.css.mot.com> I am writing a short Python program to FTP data in my windows directory to a windows machine. Here is the program (with IP, name., and password changed to protect the innocent, along with the trace. What do I need to modify to ftp all the files in my particular windows directory to a directory on a Unix machine, using a user account with name and password provided? import string, os from ftplib import FTP print string.join(os.listdir('d:\programsPerl'),',') ftp = FTP('144.144.144.144',21) #connect to host, default port ftp.login(user='Goofy',passwd='elmer',acct='fudd') # default, i.e.: user name, passwd hostname ftp.cwd('/usr2/ecadtesting/tarbackups/') ftp.retrlines('LIST') # list directory contents ftp.quit() Here is the trace raceback (most recent call last): File "D:\Python20\Pythonwin\pywin\framework\scriptutils.py", line 301, in RunScript exec codeObject in __main__.__dict__ File "D:\programsPython\ftpdata.py", line 4, in ? ftp = FTP('144.144.144.144',21) #connect to host, default port File "D:\Python20\lib\ftplib.py", line 108, in __init__ if user: resp = self.login(user, passwd, acct) File "D:\Python20\lib\ftplib.py", line 318, in login resp = self.sendcmd('USER ' + user) TypeError: cannot add type "int" to string >>> From opengeometry at yahoo.ca Fri Jul 13 14:12:29 2001 From: opengeometry at yahoo.ca (William Park) Date: Fri, 13 Jul 2001 14:12:29 -0400 Subject: apply problems In-Reply-To: <3B4F3501.E1469159@bioeng.ucsd.edu>; from cjensen@bioeng.ucsd.edu on Fri, Jul 13, 2001 at 10:50:57AM -0700 References: <3B4F3501.E1469159@bioeng.ucsd.edu> Message-ID: <20010713141229.A422@node0.opengeometry.ca> On Fri, Jul 13, 2001 at 10:50:57AM -0700, Curtis Jensen wrote: > apply( self.ren.Elements, cmd[1], additional_kwds ) > def Elements( self, at, deformed, iact, normal, xi, nelist, nodes, > elements, *args, **kwds ): > However, if I replace the apply command with: > self.ren.Elements( cmd[1][0], cmd[1][1], cmd[1][2], cmd[1][3], > cmd[1][4], cmd[1][5], additional_kwds ) > > It works fine. I can't figure why the apply line doesn't work. There Try apply( self.ren.Elements, (self, cmd[1]), additional_kwds ) There is subtle difference between calling Elements() as regular function and as class method within an object, namely 'self' argument. -- William Park, Open Geometry Consulting, <opengeometry at yahoo.ca> 8 CPUs cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc. From aahz at panix.com Fri Jul 27 16:26:39 2001 From: aahz at panix.com (Aahz Maruch) Date: 27 Jul 2001 13:26:39 -0700 Subject: Case insensitivity References: <mailman.995506711.21636.python-list@python.org> <cpvgkofyru.fsf@cj20424-a.reston1.va.home.com> Message-ID: <9jsipv$d2h$1@panix2.panix.com> [Okay, I posted one silly response to Guido before OSCON; now that I'm back home, let's try for a more considered one.] In article <cpvgkofyru.fsf at cj20424-a.reston1.va.home.com>, Guido van Rossum <guido at python.org> wrote: > >Anyway, I wasn't trying to do anything of the sort -- I was indicating >I have a right to be torn over this issue, since strong arguments can >be made for both cases. > >Several people whom I respect have strongly suggested that if Python >wants to appeal to non-programmers, it should be case-insensitive. >(Leaving apart details of how to implement that; I agree that it >should be case-preserving.) Others, whome I respect just as much, >feel that it should be case-sensitive. For users who start with case-sensitive languages such as English (or are at least familiar with English or another case-sensitive language), I believe that case sensitivity as a concept is easy to learn. I think that for such users, case sensitivity is ultimately a benefit to literate programming; at the very least, I've never heard anyone complain about case-sensitivity once it was pointed out that language works the same way. OTOH, I can see that someone who is familiar only with languages that do not possess case might face some difficulty. On the gripping hand, given that Python is already case-sensitive and that there are reasonable arguments in favor of case-sensitivity, I think the burden should lie on those who want to remove case-sensitivity to produce an especially powerful argument to change Python's behavior, particularly given the (IMO) reasonable suggestion that we can create tools that emulate case-insensitivity for beginning programmers if we wish. -- --- 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 Fortune cookie: Watch your relations with other people carefully, be reserved. From tanzer at swing.co.at Tue Jul 24 03:20:01 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Tue, 24 Jul 2001 09:20:01 +0200 Subject: A use for integer quotients In-Reply-To: Your message of "Mon, 23 Jul 2001 16:39:15 +0200." <3B5C3713.A5201C5A@letterror.com> Message-ID: <m15OwU5-000wcEC@swing.co.at> Just van Rossum <just at letterror.com> wrote: > > As for the second line: do you really think > > int(float(bytes)/float(k)+.5) is signigicantly better for rounding? > > 1) only one of the / operands need to be a float to force a float > outcome, and 2) there is a round() builtin function. Now, if we > initialize k to a float, we can write it like so: > > int(round(bytes/k)) My version of the Python Library Reference Manual (Release 2.1, 15 April 2001) says: Conversion from floating point to (long or plain) integer may round or truncate as in C; see functions floor() and ceil() in the math module for well-defined conversions. That means that one should not use `int` to convert from float to integer. No using `int (math.floor (a/b))` is quite a mouthful but everybody caring about version compatibility will have to use such abominations for a long time. (For instance, my main customer will ship based products on 1.5.2 for several month to come, the shift to 2.x *may* happen with the next major release which is planned for the last quarter of the year). -- 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 loewis at informatik.hu-berlin.de Tue Jul 24 05:30:50 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 24 Jul 2001 11:30:50 +0200 Subject: Python 2.2 dictionary question. References: <Xns90E76819BC1F6duncanrcpcouk@127.0.0.1> <j4bsmbgbxs.fsf@informatik.hu-berlin.de> <Xns90E7787B441D5duncanrcpcouk@127.0.0.1> Message-ID: <j44rs2ishh.fsf@informatik.hu-berlin.de> Duncan Booth <duncan at NOSPAMrcp.co.uk> writes: > > Also note that much of this has been discussed before in > > > which is precisely why I didn't just post a bug report to sourceforge since > I was sure it must have been discussed *somewhere*, I just couldn't find > the discussion. That should never stop you from reporting a bug when you think you found one. It may be that it is quickly closed if it was fixed, or if it was not considered a bug; this should not worry you. I doubt that the bug would be closed if there was still the intention to do something about the problem. Anyway, since there is an SF report on this now, we can sit back and wait what Guido decides :-) Regards, Martin From chris at voodooland.net Mon Jul 9 09:36:55 2001 From: chris at voodooland.net (Chris Watson) Date: Mon, 9 Jul 2001 08:36:55 -0500 (CDT) Subject: license suggestions? In-Reply-To: <slrn9kj2cf.el0.scarblac@pino.selwerd.nl> Message-ID: <20010709083440.U93525-100000@open-systems.net> On 9 Jul 2001, Remco Gerlich wrote: > The typical binary only product would usually be under a license other than > your license. And your clause 3 doesn't allow that. Oh come on if the author of the binary only work is to LAZY to even follow clause 3.. # 3. No changes are made to this license and/or additional terms of use # are placed "without prior written permission from Chris Watson." ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ There is no problem asking me to license it to you for any license you wish. This just gives me control to prevent GPL'ing it. It takes 30 seconds to shoot me an email to license it they way you want. > Your license is a sort of ultra-GPL. s/ultra-GPL/anti-GPL/ Chris From rnd at onego.ru Tue Jul 17 16:57:39 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 18 Jul 2001 00:57:39 +0400 (MSD) Subject: PEP: Defining Python Source Code Encodings In-Reply-To: <3b549622.2170522105@wa.news.verio.net> Message-ID: <Pine.LNX.4.30.0107180052360.15217-100000@rnd.onego.ru> On Tue, 17 Jul 2001, Bengt Richter wrote: >I think you're right about #! triggering confusion, but I think a fixed keyword >as a prefix is helpful when e.g., grepping for files with directives. > >I withdraw my #!pragma (or #!pythma ;-) suggestion and propose >r'^\s*#pragma\s' as the magic line prefix regular expression. I think, this has no chance to be included into Python. Or Python will be messier than C++ is now. I do not believe pre-tokenizer directives are required... .spy things could be handled even now, so the overhead will be only for those who need it: --- file.spy --- #!/usr/bin/prepython #!pragma $!pythma #!pyth on #!pyth off ... ... ---------------- Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Tuesday, July 17, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "...put knot yore trust inn spel chequers." _/ From tatiana at exatas.unisinos.br Tue Jul 17 17:24:59 2001 From: tatiana at exatas.unisinos.br (Tatiana Evers) Date: Tue, 17 Jul 2001 18:24:59 -0300 Subject: Python and C++ Message-ID: <00de01c10f06$ef192ef0$39a5100a@cg22898> Hi, I'm a new python user. I would like to know how can I extend Python ? I read documents in www.python.org, but I didn't found anything about class in C++. Anyone knows something about it ? One example or site or tutorial ?Please, I need some help. Thanks ;o) Tatiana Evers --------------------------------------------------------------- Tatiana Figueiredo Evers Mestranda em Computa??o Aplicada (Computa??o Gr?fica) UNISINOS - S?o Leopoldo - RS tatiana at exatas.unisinos.br www.inf.unisinos.br/~tatiana From bokr at accessone.com Tue Jul 17 01:47:48 2001 From: bokr at accessone.com (Bengt Richter) Date: Tue, 17 Jul 2001 05:47:48 GMT Subject: Boolean idioms (was Re: re Challenge: More Compact?) References: <mailman.995247446.16415.python-list@python.org> <9iuqec$1bh$1@panix2.panix.com> Message-ID: <3b53d21f.2120342641@wa.news.verio.net> On 16 Jul 2001 06:33:00 -0700, aahz at panix.com (Aahz Maruch) wrote: >In article <mailman.995247446.16415.python-list at python.org>, >Tim Peters <tim.one at home.com> wrote: >> >>Well, it's un-Pythonic to try to emulate Perl undef via Python None; it's >>idiomatic to return 0 for false and 1 for true, [...] > >I know that it's a frequent Python idiom to use 0/1, but where is it >specifically un-Pythonic to use None/1? >-- >>> ['zero','one'][0==1] 'zero' >>> ['zero','one'][0==0] 'one' >>> ['zero','one'][None] Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: sequence index must be integer I don't know about Pythonic or not, but maybe a reason, in case it gets passed symbolically and used raw instead of as [sym==1]? Or is it really not dependable even for boolean expressions? From skip at pobox.com Wed Jul 18 12:18:58 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 18 Jul 2001 11:18:58 -0500 Subject: how saving/retreiving python code from DB ? In-Reply-To: <9j457f07jv@enews4.newsguy.com> References: <3B559274.6B66A372@yahoo.com> <9j457f07jv@enews4.newsguy.com> Message-ID: <15189.46834.424888.145730@beluga.mojam.com> vincent> I'm looking for a module that allow us to store/import python vincent> code into DB (bsddb for example) instead of a file. Alex> You can write your own version of __import__ ... I believe there was a custom __import__ floating around at one time that allowed imports from zipfiles (part of some sort of freeze tool that Fredrik Lundh wrote, perhaps?). If that code can be located, it would probably serve as a useful template for importing code from other structured files. Sorry, my memory is foggy on the details. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From 18k11tm001 at sneakemail.com Tue Jul 3 14:40:31 2001 From: 18k11tm001 at sneakemail.com (Russ) Date: 3 Jul 2001 11:40:31 -0700 Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> <9hrj3q$cj1@news1.gtech.com> Message-ID: <bebbba07.0107031040.593143f8@posting.google.com> "Peter Milliken" <peter.milliken at gtech.com> wrote in message news:<9hrj3q$cj1 at news1.gtech.com>... > Funny, I thought all of the April Fool jokes were out on the 1st April, did > this one get delayed (badly) somewhere along the line? > > Python is a fine language for quick and dirty prototyping. For banging out > applications that are going to run in an environment where it isn't going to > matter if the program crashes, but it is certainly not something I would put > forward for something like Air Traffic Control. > > This is a joke, right? If that's your idea of a joke, you have a strange sense of humor, but I appreciate your post anyway. If your claims about Python are even close to the truth, I need to know. <cut> > Based upon Gerrit's observations, which I fully endorse, anybody who doesn't > use the most strongly typed language they can find for an application like > Air Traffic Control, has to put it mildly, rocks in their head :-). As I indicated in my original post, the lack of type checking does concern me. However, as I wrote in a later post, I also suspect that this concern is overblown. I am not a computer scientist or even a full-time programmer, so I don't pretend to be an expert in this area. I am an aerospace engineer, and I do some programming in support of my own research (but I am a Python beginner). Consider the type checking in C or C++, for example. Suppose that a function takes several ints (or any other type) as arguments, and suppose the calls of the function all pass ints in the correct slots. The compiler will be perfectly happy. Does that assure that the arguments are passed correctly? Of course not. It is a necessary but not sufficient condition for correctness. The arguments could be completely out of order, and the compiler wouldn't have a clue. Now consider argument passing by keyword in Python. The order of the arguments no longer matters. Sure, the wrong type of arguments could still be passed in, but it seems to me the probability is less than getting the wrong object of the right type in C++. In C++, the complier only checks the type of the argument, but Python checks the actual NAME of the argument. The name is more specific than the type. In C++, the function calls all get checked automatically at compile time, but Python doesn't check them until run time. That is a valid concern, but hardly a show-stopper. I understand that PyChecker can be used for static checking. I actually think the core Python language should have an option to do static checking, but as long as some product is available to do it, the issue is not major. > Don't get me wrong, Python is a nice language and you could probably do the > job with it with enough time and effort. But as an earlier respondent said, > you would literally have to test it to death and then some! i.e. because of > the lack of type checking there could be a single line of code somewhere > that has never been run that could cause catastrophic failure of the > application (architectural design *might* mitigate this but it gets back to > the people factor - something I don't trust :-)). At least with a strongly > typed language, even if a line of code has never been run, you are > reasonably assured that when it does run it won't crash due to a variable > being mispelled or mis-used. As I said, static type checking is a must, but it can already be done in Python. So I think your concerns, although valid, are way overblown. By the way, people in the commercial software industry have no idea about the amount of testing that will go into the ATC application we are talking about. Their concerns are completely different, of course. If they tested their software even one-tenth as much as this application will be tested, they'd go out of business. I get a kick out of people who think that a few programmers can hack out some code and just slap it into an operational ATC system (not to imply you think that, of course). > Of course, I could at this point say I would never venture into air space > controlled by such as system, but I know it would never get off the ground > (so to speak :-)) because to do it in Python would mean it would never pass > acceptance testing - sure you could code it just as fast (if not faster) > than most other languages used for this application area but you would be in > the test phase forever - or at least until the customer cancelled the > contract :-). So keep dreaming :-) You may be right that Python is not the right language, but I don't think you've made a convincing case. Russ From gmcm at hypernet.com Sun Jul 29 14:01:36 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 29 Jul 2001 18:01:36 GMT Subject: Slightly off-topic... (sending HTML data through a Python socket) References: <3B643B5D.E62C6669@telocity.com> Message-ID: <Xns90ED8EBEB65A6gmcmhypernetcom@199.171.54.154> Adonis Vargas wrote: > I am attempting to send HTML data back to a browser which connected to X > port. I have goen over the the HTML RFC and just can not get it to work. > What I am attempting to do is send a redirect back to the browser. So > far I have something as follows: > > c.send(""" > <HTML> > <HEAD> > <META HTTP-EQUIV=\"Refresh\" > Content=0;Host=\"http://www.python.org/\">" > </HEAD> > </HTML> > """) Eric already pointed out the correct format of the http-equiv line. You're not telling us how this is being sent. Is the browser first getting a line like "HTTP/1.0 200 OK\r\n"? In other words, you need to follow the HTTP protocol before HTML does you any good. If you're using one of the standard HTTP Servers, this is getting taken care of for you. But if 'c' is a socket, you'll need to do the HTTP stuff yourself. (No need to escape a quote in a triple-quoted string.) - Gordon From guido at python.org Thu Jul 26 17:48:08 2001 From: guido at python.org (Guido van Rossum) Date: Thu, 26 Jul 2001 21:48:08 GMT Subject: PEP0238 lament References: <5sdnlt072hm6hp17nluu6f0fqq4bvr6mj8@4ax.com> <mailman.995873261.11975.python-list@python.org> <916olt0p3kciv0evmotdg6jev9bl29l57i@4ax.com> <Xns90E77C7A1776Cjimpublishingresourc@207.126.101.100> <3B5C52EA.9430255E@alcyone.com> <cpofqaova7.fsf@cj20424-a.reston1.va.home.com> <Xns90E99AC16C87Bduncanrcpcouk@127.0.0.1> <cpzo9t80l7.fsf@cj20424-a.reston1.va.home.com> <Xns90EA6386D25CFduncanrcpcouk@127.0.0.1> <cp4rrz95iu.fsf@cj20424-a.reston1.va.home.com> <p5_77.30678$EP6.7893929@news1.rdc2.pa.home.com> Message-ID: <cpitgf5pma.fsf@cj20424-a.reston1.va.home.com> "Terry Reedy" <tjreedy at home.com> writes: > *My* worry, based on some of your expressed views, is that you might > someday decide to *unify* ints and floats by eliminating ints |-( There would always be some kind of difference between an int (exact) and a float with the same value (inexact). --Guido van Rossum (home page: http://www.python.org/~guido/) From cpsu at larc.ee.nthu.edu.tw Fri Jul 6 02:31:57 2001 From: cpsu at larc.ee.nthu.edu.tw (Chyr-Pyng Su) Date: Fri, 06 Jul 2001 14:31:57 +0800 Subject: Tkinter and printf in C ... Message-ID: <3B455B5D.544A2EF5@larc.ee.nthu.edu.tw> Recently I have wrote a program in C, and start to write the GUI for it. I want to capture the message dump by the C program and show them on a text window. Does anyone have some idea to do that??? redirect the stdout??? BR cp. From maiertur at zwallet.com Mon Jul 16 22:25:31 2001 From: maiertur at zwallet.com (maiertur at zwallet.com) Date: Tue, 17 Jul 2001 04:25:31 +0200 (MEST) Subject: JOIN FREE!!! Guaranteed Downline & Income... Message-ID: <UTC200107170225.EAA00534@bacchus.cwi.nl> Have Your Downline Built BEFORE You Spend Any Money! This program even offers you a Monthly Guaranteed Minimum Income!! GUARANTEED DOWNLINE, GUARANTEED INCOME!!! Don't miss out on this Great Opportunity to secure yourself a Guaranteed Monthly Minimum Income!!! It's FREE to join Post Launch Program!!! Your FREE membership # will also be entered into a Lucky Draw to WIN $100 to shop online!! ALL new members that join after you will be placed in ONE Straight Line directly UNDER you. YOU can easily get 500-1,000 members under YOU in a month!! There is absolutely NO RISK to get involved and NO COST to join Post Launch Program.For information,mail to:clubmail at postmaster-email.com REMEMBER....You have NOTHING to lose and potentially A LOT TO GAIN. Join Today!!! ======================================================== Disclaimer: This is a ONE TIME MAILING ! You are not in our mailing list. You can contact us about it at mailto:maier at zwallet.com Your address was bought from a professional and you can request him to stop selling your address at mailto:sign4removal at yahoo.com Both of us want to keep your privacy and your address will be immediately removed!!! ========================================================= From sill at optonline.net Thu Jul 19 21:41:51 2001 From: sill at optonline.net (Rainy) Date: Fri, 20 Jul 2001 01:41:51 GMT Subject: Conway's Life References: <3B57AF54.F909FD36@.com> Message-ID: <slrn9lf317.2pp.sill@sill.silmarill.org> On Fri, 20 Jul 2001 01:10:56 GMT, Doug Newhouse <n at .com> wrote: > I'm a recreational programmer with some pretty basic experience in > Python and I'm looking for a good way to implement the grid needed for > Life (or other cellular automata) in Python. > This would be in win98. > I should be able to figure out the algorithms and stuff, it's just that > I have no idea how to do graphics. (Would this be TK? Perhaps someone > could recommend a web site or book?) Oh, and keep it simple please, no > need for anything super efficient just yet. > (I did this once in Turbo Pascal using ascii symbols and EGA screen > settings on a VGA monitor, that's not ideal ;) > There's example curses conway's game of life in standard distribution under Demo/curses/life.py . -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: http://silmarill.org/cymbaline From python at lee-morgan.net Tue Jul 10 20:34:23 2001 From: python at lee-morgan.net (Lee Morgan) Date: Wed, 11 Jul 2001 00:34:23 GMT Subject: Newbie asks(2): How to do this line of C in Py? References: <tkmfvla7npuqfd@news.supernews.com> <uzoaci9zw.fsf@ctwd0143.fitlinxx.com> Message-ID: <wkd778qos7.fsf@lee-morgan.net> "Steve S.L. Wong" <sailwong at alumni.cuhk.edu.hk> writes: > if (sscanf(command, "%d", &num) != 1 ) { > } One method could be try: num = int( command ) except: pass # or perhaps num = 0 else: # contents of if statement > > -- Lee Morgan From twofingersalute at atl.mediaone.net Thu Jul 5 22:14:56 2001 From: twofingersalute at atl.mediaone.net (myself) Date: Thu, 05 Jul 2001 22:14:56 -0400 Subject: Changing default font in idle/linux References: <tk55clhbjjrfd@corp.supernews.com> <tk5di6614baj06@corp.supernews.com> Message-ID: <9i3702$g5cmc$1@ID-87965.news.dfncis.de> In article <tk5di6614baj06 at corp.supernews.com>, "Stephen Boulet" <spboulet at speakeasy.net> wrote: > To reply to my own post, I found out about: > > /usr/lib/python2.1/site-packages/idle/config-unix.txt > > but my fonts still look bad. Maybe it's an issue with kde and > anti-aliasing, but the letters look jagged. Any help appreciated. > > Stephen Boulet wrote: > all I can suggest is a search on fonts in Google Groups, particularly alt.os.linux.mandrake- for posts on font issues; mine look OK (not great) w/ LM7.2, python2.1-5, AA enabled (of course AA only applies to KDE apps, but having it enabled seems to cause some probs. for non-kde apps). Also, try similar search comp.windows.x.kde and: http://www.mail-archive.com/expert at linux-mandrake.com/ http://www.mail-archive.com/cooker at linux-mandrake.com/ http://www.mail-archive.com/newbie%40linux-mandrake.com/ http://lists.kde.org/ you'll find a ton of posts, hopefully one will apply to your particular setup- LM ver, vid card, KDE/QT ver, etc. How do fonts look in other non-kde apps?? Sorry this is best I can do, hope it helps..... >> Anyone know how to change the default font in idle in linux? I've >> looked at the file "EditorWindow.py" but found no "text['font'] = >> ("lucida console", 8)" line. >> >> Here are my versions: >> >> # rpm -q python tkinter >> python-2.1-1mdk >> tkinter-2.1-1mdk >> >> Thanks. >> >> -- Stephen >> >> From tjenkins at nospiced.ham.devis.com Thu Jul 26 11:01:52 2001 From: tjenkins at nospiced.ham.devis.com (Tom Jenkins) Date: Thu, 26 Jul 2001 15:01:52 GMT Subject: a break for comprehensions References: <9jpadd$s5k$1@news.duke.edu> Message-ID: <3B6031C3.6010707@nospiced.ham.devis.com> Kevin Lacker wrote: > Can you do this: > > answer = [] > for x in my_list: > if not is_good(x): > break > answer.append(process(x)) > > with a list comprehension somehow? I'm starting to dislike explicit for > loops just for the purposes of constructing another list from a current one. do you mean like this? >>> def even(x): ... return int(divmod(x,2)[1]) == 0 ... >>> a = [1, 2, 3, 4, 5, 6, 7] >>> b = [z for z in a if not even(z)] >>> print b [1, 3, 5, 7] >>> c = [z for z in a if even(z)] >>> print c [2, 4, 6] >>> oops sorry just saw that you had process(x) in there... lets try it: >>> def process(x): ... return str(x) ... >>> process(1) '1' >>> c = [process(z) for z in a if even(z)] >>> print c ['2', '4', '6'] >>> hmmm, seems to work for me (python 2.1) From chrishbarker at home.net Wed Jul 25 13:36:04 2001 From: chrishbarker at home.net (Chris Barker) Date: Wed, 25 Jul 2001 10:36:04 -0700 Subject: A modest PEP0238 suggestion References: <3b5c6e08.27535083@aplnews> <9jjk9g$8tk$1@newsy.ifm.liu.se> <cpu201a8y7.fsf@cj20424-a.reston1.va.home.com> Message-ID: <3B5F0384.3086D19E@home.net> Guido van Rossum wrote: >Changing 1/2 > from returning a float to returning a rational won't have to break > code, since the mathematical value of the result is the same. No, it's not. We should all be aware now that 1/10 as a rational is not the same value as 1/10 stored as binary floating point. After all, how many times does someone post a question about why a loop like the following doesn't terminate? >>> i = 0. >>> while i <> 1: ... i+=0.1 Anyway, while the difference is far more subtle, and far less likely to break code, a rational is NOT a float (nor is a float a real, so I'm glad you didn't name them that). And there are a few of us that occasionally make use of or at least accomodate the difference (not to mention performance issues!) -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 Greg.Lindstrom at acxiom.com Thu Jul 5 12:15:38 2001 From: Greg.Lindstrom at acxiom.com (Lindstrom Greg - glinds) Date: Thu, 5 Jul 2001 11:15:38 -0500 Subject: There's got to be an easy way to do this Message-ID: <ABEE81BE08ADD311B6A1009027DE908D0BD87D90@conmsx03.conway.acxiom.com> I am reading in a phone number field and would like to throw away everything except the digits. Being an old C programmer, I know how I would do this. Even with my limited knowledge of Python, I know how I would do it: stripped_phone='' for c in phone_number: if c in digits: stripped_phone += c but with all of the data structure support native to Python, I'm sure there is "an obvious way" to do it (perhaps it's because I'm not Dutch:-). Greg Lindstrom Acxiom Corporation, mail: CWY10011149 InfoBase Products Development office: (501) 342-1626 301 Industrial Blvd, Conway, AR, 72032 fax: (501) 336-3911 email: Greg.Lindstrom at acxiom.com "When the solution is simple, God has spoken" Albert Einstein From quinn at yak.ugcs.caltech.edu Fri Jul 13 15:12:51 2001 From: quinn at yak.ugcs.caltech.edu (Quinn Dunkan) Date: 13 Jul 2001 19:12:51 GMT Subject: not safe at all References: <mm8tkt4te3qnbpv3nh5nhsi591o1osln73@4ax.com> <slrn9ku3c3.mrk.9nick9m@localhost.localdomain> <u26ukt4vot7b1qu02hkp8l1pnmdi0sfp3l@4ax.com> Message-ID: <slrn9kui1i.orp.quinn@yak.ugcs.caltech.edu> On Fri, 13 Jul 2001 16:00:22 GMT, Dennis Roark <denro at earthlink.net> wrote: >I appreciate those who replied, particularly Nick's >informative reply. I would still argue that "dynamic" >typing is a weaker and less safe sort of typing than the That's always a popular argument, naturally from people who have never written a large program in a dynamic language. The argument is "which method produces 'more correct' programs?". The static people talk about rigorously enforced interfaces, correctness proofs, contracts, etc. The dynamic people talk about rigorously enforced testing and say that types only catch a small portion of possible errors. The static people retort that they don't trust tests to cover everything or not have bugs and why write tests for stuff the compiler should test for you, so you shouldn't rely on *only* tests, and besides static types don't catch a small portion, but a large portion of errors. The dynamic people say no program or test is perfect and static typing is not worth the cost in language complexity and design difficulty for the gain in eliminating a few tests that would have been easy to write anyway, since static types catch a small portion of errors, not a large portion. The static people say static types don't add that much language complexity, and it's not design "difficulty" but an essential part of the process, and they catch a large portion, not a small portion. The dynamic people say they add enormous complexity, and they catch a small portion, and point out that the static people have bad breath. The static people assert that the dynamic people must be too stupid to cope with a real language and rigorous requirements, and are ugly besides. This is when both sides start throwing rocks. >typing is a weaker and less safe sort of typing than the >static typing of C++. Nick brings up the C++ example of But if all you know is the C idea of "static typing" and "type safety" you don't even know your own camp. To view this debate in earnest, go to wherever the Eiffel and Ada people do battle against Smalltalkers, Lispers, & co. There's good arguments on both sides. I've never seen a formal study, but even if there is one it probably wouldn't be difficult for either side to poke holes in it. From barry at zope.com Tue Jul 24 18:16:54 2001 From: barry at zope.com (Barry A. Warsaw) Date: Tue, 24 Jul 2001 18:16:54 -0400 Subject: PEP238 and zope References: <3B5DE0F7.9070001@nospiced.ham.devis.com> Message-ID: <15197.62422.841114.343701@anthem.wooz.org> >>>>> "TJ" == Tom Jenkins <tjenkins at nospiced.ham.devis.com> writes: TJ> these snippets. I don't believe zope will surface any TJ> warnings that PEP238 stipulates (tho I may be wrong). How do TJ> we code _now_ so as to minimize our pain? >>> must_be_int = 1 / 2 >>> must_be_int 0 >>> must_be_int = int(1.0 / 2.0) >>> must_be_int 0 -Barry From thomas at xs4all.net Tue Jul 24 11:18:38 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 24 Jul 2001 17:18:38 +0200 Subject: re bad leadership In-Reply-To: <0+yM4IAgmKX7EwIQ@jessikat.fsnet.co.uk> References: <0+yM4IAgmKX7EwIQ@jessikat.fsnet.co.uk> Message-ID: <20010724171838.A21770@xs4all.nl> On Mon, Jul 23, 2001 at 11:48:00PM +0100, Robin Becker wrote: > it doesn't matter what the leadership says is right. The popular vote is > against the stupid float '/' operator. Really ? I don't see a popular vote. I just see a very long and very heated discussion with a small group of repeat offenders (oops, did I say offenders ? I meant posters) that just keep on proclaiming their righteousness with little in the way of new arguments (either way, for that matter.) > MDFL you are wrong! Give up gracefully now! I don't believe the BDFL is wrong, either. I did, but I changed my mind. I gave up gracefully after long and careful (and un-heated) consideration, and admitted I was wrong before :) I strongly suspect the change will actually *fix* more code that was relying on float inputs than it will break code that depended on int/int being special-cased. Robin, sorry, but you are wrong <wink>. -- Thomas Wouters <thomas at xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From sheila at spamcop.net Tue Jul 10 15:17:26 2001 From: sheila at spamcop.net (Sheila King) Date: Tue, 10 Jul 2001 19:17:26 GMT Subject: SMTP server class ?? References: <d0alktgu1k5qvlt2bqdmb8l0k1rlmqm6ie@4ax.com> <mailman.994773686.29026.python-list@python.org> Message-ID: <04lmktc7dhd9glgskkdmm5u8r5dcubdsf4@4ax.com> On Tue, 10 Jul 2001 10:00:17 -0400, barry at digicool.com (Barry A. Warsaw) wrote in comp.lang.python in article <mailman.994773686.29026.python-list at python.org>: : :>>>>> "SK" == Sheila King <sheila at spamcop.net> writes: : : SK> Actually, I found what Barry Warsaw calls his "experimental" : SK> smtp server (RFC821 compliant) at the Vaults at : SK> Parnassus. I've downloaded it. : :It's actually now in the standard library as smtpd.py. It's :asyncore/asynchat based, and it's not perfect, but at least one other :person than me has found it useful <wink>. : :It implements the minimal required RFC 821 SMTP server interface, and :no, it hasn't been checked against RFC 2821 yet either. ;) I looked at the current 2.1 Module docs online here http://www.python.org/doc/current/modindex.html and see no mention of it? I've taken a cursory glance from the code I downloaded off of your site last night. It seems to be heavy on the Unix-isms. Does it run on win32 platforms? Heh...I'm not expecting something extremely standards compliant. Actually, all I really want, is something to act as smtp.localhost so that I can set my mail client up to send mail to 127.0.0.1, and have the raw messages written to a file. Then I will take a script to pipe them to this smtp server I'm having to use temporarily (I want to set the >From on the SMTP envelope, so that I can use my usual "from" address...ISPs can be so restrictive...been without my usual DSL for over 60 hours now, and using temporary dialup with port 25 blocked. :( If I have time this afternoon, I might try a hand at writing myself something simple. I'm just being cautious, as I've not done any sockets programming up to this point. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From shredwheat at mediaone.net Wed Jul 11 12:54:58 2001 From: shredwheat at mediaone.net (Pete Shinners) Date: Wed, 11 Jul 2001 16:54:58 GMT Subject: 'Blade of Darkness' demo has open Python source References: <cNP27.13552$Y6.4409459@news1.rdc2.pa.home.com> Message-ID: <Cx%27.3830$M9.1041990@typhoon.we.rr.com> "Terry Reedy" <tjreedy at home.com> wrote > In a recent thread on game programming in Python, someone mentioned that > the commercial game Severance: Blade of Darkness is scripted in Python. I > recently installed it off a demo CD. While I could not play too far due to > having only half the required video memory, I was surprised and pleased to > discover that it included open Python source: not frozen .exe, not > compiled .pyc, but notepad-readable .py files. yeah, i've looked at this too. try downloading some of the MODS too. same thing. .PY files and perhaps some graphic resources with them. From new_name at mit.edu Mon Jul 9 09:25:32 2001 From: new_name at mit.edu (Alex) Date: 09 Jul 2001 09:25:32 -0400 Subject: How to 'from package import module; from module import variable'? Message-ID: <etdn16e1bg3.fsf@pickled-herring.mit.edu> Hi. I've recently switched to using packages. Because I use reload a lot during testing, it'd be helpful to be able to do this sort of thing successfully: >>> from mouse.tools import queues >>> from queues import Cyclic_queue Traceback (most recent call last): File "<stdin>", line 1, in ? ImportError: No module named queues My understanding of the package import routine is still sort of sketchy, but I was wondering if there's a way to convince the import function that queues is actually a module it can import from. I could just make assignments, but that seems kludgey. Alex. From grante at visi.com Tue Jul 24 14:47:55 2001 From: grante at visi.com (Grant Edwards) Date: Tue, 24 Jul 2001 18:47:55 GMT Subject: PEP0238 lament References: <mailman.995839419.19134.python-list@python.org> <9jgvbc$dos$1@newshost.accu.uu.nl> <slrn.pl.9lopjh.308.qrczak@qrnik.zagroda> <Yg_67.23542$B7.3778752@ruti.visi.com> <slrn.pl.9lovfr.4na.qrczak@qrnik.zagroda> <buqqltkne23s66b27rn31p6e9ip2a3m53q@4ax.com> <slrn.pl.9lqvmg.n1b.qrczak@qrnik.zagroda> <k_h77.23757$B7.3910692@ruti.visi.com> <slrn.pl.9lrdst.k2v.qrczak@qrnik.zagroda> Message-ID: <vpj77.24033$B7.3921711@ruti.visi.com> In article <slrn.pl.9lrdst.k2v.qrczak at qrnik.zagroda>, Marcin 'Qrczak' Kowalczyk wrote: >Tue, 24 Jul 2001 17:10:40 GMT, Grant Edwards <grante at visi.com> pisze: > >>>as long as a literal is an expression with type independent >>>from the context. This implies that implicit conversions from >>>int to float and rational are unavoidable in Python. >> >> Why? > >Because you can't express operations like "add one", "multiply by ten" >or "take the reciprocal (when complex numbers are considered too)". I don't understand, but it's a moot point. If DFL wants it, it will happen. There's no point in arguing about it any more. -- Grant Edwards grante Yow! RELATIVES!! at visi.com From guido at python.org Thu Jul 26 17:58:00 2001 From: guido at python.org (Guido van Rossum) Date: Thu, 26 Jul 2001 21:58:00 GMT Subject: interpreter improvements References: <5e8bd451.0107190224.7171e61@posting.google.com> <slrn9m0nbf.l0b.quinn@yak.ugcs.caltech.edu> <mailman.996177532.9490.python-list@python.org> Message-ID: <cpd76n5p7q.fsf@cj20424-a.reston1.va.home.com> Skip Montanaro <skip at pobox.com> writes: > As others (including Guido) have observed, having a line editing subsystem > that knows about the structure of the language you are using can be a boon. > With readline support I can recall individual lines I've typed at the > interpreter, however readline knows nothing about Python's block structure, > so I can't recall entire blocks that correspond to (for instance) "if", > "for", or "while" statements. Creating an editing subsystem is a lot of work. I created one that knows the structure of the language, and it is distributed for free with Python. The only downside is that it uses a GUI, so it's not for everyone. Its name? IDLE. BTW, IDLE's rules are almost the same as those used by Emacs python-mode.el. Emacs *does* run in a classic TTY window. --Guido van Rossum (home page: http://www.python.org/~guido/) From s713221 at student.gu.edu.au Thu Jul 26 07:26:24 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Thu, 26 Jul 2001 21:26:24 +1000 Subject: Language change and code breaks References: <mailman.996120946.2459.python-list@python.org> Message-ID: <3B5FFE60.4D871094@student.gu.edu.au> Tim Peters wrote: > I have a good grasp of what it takes to undertake a major optimization > project (I made my living for 15 years writing optimizing compilers), and > the only way we have enough resource to tackle that successfully is in my > dreams. We could certainly spend more time than we do making solid small > (localized and modest) performance improvements -- but only by dropping > other work. IOW, the plate's already overflowing, Joe, and I'm sure you > have your ideas of what we should drop to work on what you want instead, but > everyone else does too, and the bulk of the pressures don't push in the > "faster" direction. Tim, Guido and others, thank you for your effort and dilligence in developing Python. Once you get past the crys of anguish and outrage, I think most people in this group appreciate your efforts *grins* or we wouldn't be so interested in python's future. I only wish I knew enough C/C++ or had the proper time to learn it so that I could become a solid contributor, rather than an occasional user. > heck-just-look-at-this-week's-outcry-to-break-division-instead<wink>-ly > y'rs - tim Yes. Things got heated, didn't they? *evil grin* Anyone would think that you'd been talking about forcing ourselves on the poster's virgin daughters. *Hmmm* Maybe that could become a PEP proposal? -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From BPettersen at NAREX.com Fri Jul 20 13:09:55 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Fri, 20 Jul 2001 11:09:55 -0600 Subject: string random generator (Sorry if too stupid, but i am a beginner) Message-ID: <6957F6A694B49A4096F7CFD0D900042F27D563@admin56.narex.com> > From: Gustavo Vieira Goncalves Coelho Rios > > Hi folks! > > I am in need for a function that return a string of len x > random generated, like > > strrnd(5) > 'Df%d^' > > strrnd(2) > '&@' > > > I have the following code: The problem is that i don't known > how to map a int to a char. > > import random > def strrnd(n = 24) : > result = [] > while n : > n = n - 1 > result.append(random.randrange(1,255,1)) > return result > > How may i get what i want. (Sorry if too basic, but i am a > python beginner). > Another problem: This functins will be called thousands of > time a minute, so performance is a definitive requirement. Something along these lines should work: import random, string def randomWord(length): res = '' for i in range(length): res += random.choice(string.letters) return res -- bjorn From erno-news at erno.iki.fi Tue Jul 3 21:43:33 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 04 Jul 2001 04:43:33 +0300 Subject: problem with sending email References: <mailman.994139704.17222.python-list@python.org> Message-ID: <ku3d8d31ve.fsf@lasipalatsi.fi> In article <mailman.994139704.17222.python-list at python.org>, Haris Lekatsas <lekatsas at EE.Princeton.EDU> writes: | Unfortunately it makes my scripts less portable as the path to | sendmail has to be specified (not always at /usr/sbin/sendmail) | but this seems to be the only solution I have so far. i'm under the impression that /usr/lib/sendmail is pretty universal. with smtplib you have to configure the hostname of the smtp server. | I wonder if python's smtplib is broken. works for me... -- erno From pedro at athlet.de Thu Jul 12 02:58:24 2001 From: pedro at athlet.de (pedro) Date: Thu, 12 Jul 2001 06:58:24 GMT Subject: catch empty sys.argv Message-ID: <3b4d491b.56611422@news.isis.de> hi, my scripts gets a variable from .sys.argv[1] (a filename). when the filename is not entered the scripts is completely useless, so i thought i'd do a basic check like: if sys.argv[1] == '' exit('enter something, stupid') but the script just fails if nothing is entered (it also fails without the check of course): Traceback (most recent call last): File "lm4l.py", line 118, in ? obj = argv[1] IndexError: list index out of range what can i do ? thx, pedro From bill-bell at bill-bell.hamilton.on.ca Mon Jul 16 10:09:01 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Mon, 16 Jul 2001 10:09:01 -0400 Subject: Challenge: More Compact? In-Reply-To: <995266132.1201.24550.l8@yahoogroups.com> Message-ID: <3B52BD3D.4482.349EB09@localhost> "Tim Peters" <tim.one at home.com> wrote, in part: > BTW, does it bother anyone that all of these solutions accept an IP > ending with a newline? This reminds me of a thread of a few months ago on one of the Perl lists. Someone (it might have been me :o) wanted a regex that matches the collection of (syntactically correct) URLs exactly. How do we know that the junk that we write in this quite low-level context is correct? How would one check that an IPv4 IP address, or a URL for that matter, is correct as specified in an RFC somewhere? (This summer I'm working with one of Parnas' s/e students. Maybe that's why my conscience is giving me such grief.) Can't-think-of-a-way-of-signing-this-ly yours, etc From BPettersen at NAREX.com Mon Jul 16 12:48:42 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Mon, 16 Jul 2001 10:48:42 -0600 Subject: Language change and code breaks Message-ID: <6957F6A694B49A4096F7CFD0D900042F27DB99@admin56.narex.com> > From: Peter Hansen [mailto:peter at engcorp.com] > > Bjorn Pettersen wrote: > > [snip] > > > > Well, I for one wrote several thousands of lines of Python > code in my > > last job, and I obviously have no influence on when they're going to > > upgrade to a newer version of Python. You can probably safely assume > > that they're not going to put a programmer on fixing > programs that are > > running without any problems. More likely they would upgrade Python, > > realize that "a bunch" of Python scripts stopped working, and either > > roll back the Python upgrade, rewrite them in Perl/Java, or > find someone > > with enough Python skills to fix the problems. Neither > solution would be > > good PR for Python... > > I agree it wouldn't be good PR for Python, but presumably neither > is having division which doesn't behave as newcomers expect. > We're trying to choose the lesser of two evils. Yes, we're chosing between people who currently doesn't use Python (but might in the future), and people who have significant investments in Python... > Anyway, if your previous employer upgrades Python for no good > reason and without checking the Change History where they will > see all the warnings in BIG PRINT about how existing code might > break and that they should run "divscan.py" to see if their code > is safe or not, how can we protect them against themselves? What if they change because some package they use is no longer supported with the older version (or has a bugfix that isn't backported, etc.)? In theory it's always possible to remain with an earlier version, but in practice it ain't always so <wink>. "divscan.py" would be a good idea, but since Python is a dynamic language, all it could do would be to point out all occurrences of division in your code. You would still have to manually examine each and every one of them to figure out whether it needed change or not... > I'm trying to point out that this kind of hypothetical example, > where some group might upgrade (but not be aware of this issue > even after lengthy publicity during the transition period) > even though they will not actively maintain their code, is > not likely, or not worth worrying about for long. I would hardly call it hypothetical. I'm sure a lot of companies are in this boat, and most probably don't read c.l.py (the volume is just too great). The first warning they're probably going to get that a new version of Python is available is when they call the developer of foo.py with a problem and he says: "yeah, that's fixed in the latest version -- but it requires Python 2.x". Besides, a minor point change would in most context indicate minor, source-compatible changes only. > And that's where the contingency plans come into play: we've > provided adequate notice, tools, etc., and yet somebody chose > to ignore us and got punished. Big deal. Getting Python accepted in an organization as a viable alternative to Perl requires a lot of hard work. Once you've got a foothold it seems stupid to shoot yourself in the foot by introducing random incompatibilities that may or may not provide better traction for non-users (not to mention the hackish solutions to long division that would be introduced). I'm not against making this change per se, however, I think it should be in the context of an overhaul of the entire numerical system, and it definitely deserves a 3.0 labelling since that would indicate that there are incompatible changes involved with upgrading. -- bjorn From gnb at itga.com.au Wed Jul 25 03:49:46 2001 From: gnb at itga.com.au (Gregory Bond) Date: 25 Jul 2001 17:49:46 +1000 Subject: PEP0238 lament References: <5sdnlt072hm6hp17nluu6f0fqq4bvr6mj8@4ax.com> <mailman.995873261.11975.python-list@python.org> <916olt0p3kciv0evmotdg6jev9bl29l57i@4ax.com> <Xns90E77C7A1776Cjimpublishingresourc@207.126.101.100> <3B5C52EA.9430255E@alcyone.com> <cpofqaova7.fsf@cj20424-a.reston1.va.home.com> Message-ID: <868zhdo3c5.fsf@hellcat.itga.com.au> Guido van Rossum <guido at python.org> writes: > Anything else? Some sort of semi-automated help to discover problem code. E.g -Dwarn => msg to stderr each time a division is done that would have different meanings under -Dold and -Dnew. From othello at javanet.com Fri Jul 20 13:27:58 2001 From: othello at javanet.com (Raymond Hettinger) Date: Fri, 20 Jul 2001 13:27:58 -0400 Subject: The unPEP: List-Tuple Unification Message-ID: <3B586A1E.B037349D@javanet.com> It looks like types and classes are heading toward unification in 2.2a (oh yeah). Now, I want to offer an idea that is sure to attract a few flames: 1. Give lists an assignable property called 'immutable' which defaults to zero. 2. If the property gets set to one (i.e. mylist.immutable=1), then the list disables future assignments. For example, mylist[3]='three' generates: TypeError: object doesn't support item assignment 3. Immutable lists can never be converted back to mutable. For example, mylist.immutable=0 generates: TypeError: immutable objects cannot be changed 4. Immutable lists can be copied to mutable lists just like tuples can. For example, mynewlist=list(mylist) makes a new mutable list. 5. If a list is used as a dictionary key, then the immutable property gets set to one automatically. 6. Deprecate tuples. Simplify the tutorials. Get on with life. Hiding behind asbestos, Raymond From steve at lurking.demon.co.uk Mon Jul 23 00:34:58 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Mon, 23 Jul 2001 05:34:58 +0100 Subject: Future division patch available (PEP 238) References: <mailman.995776716.24336.python-list@python.org> <220720011019310436%jwbaxter@spamcop.com> <9jfj2t$ad4$1@newshost.accu.uu.nl> Message-ID: <2l5nlt01l0mge3to8jb5413to2npq2u6lb@4ax.com> On 22 Jul 2001 22:11:41 GMT, m.faassen at vet.uu.nl (Martijn Faassen) wrote: >John W. Baxter <jwbaxter at spamcop.com> wrote: >[snip] >> I don't think 1 / 2 producing 0 is broken, so I don't think it needs to >> be fixed, but that view is unlikely to prevail. > >I believe there'll be a huge outcry once it actually looks like >this is going to be in Python for real, when the people who don't track >the Python development discover what's up with this. Of course - there are a *huge* number of algorithms that make use of integer division, not to mention all the code that simply does arithmetic using integers and expects an integer result. If this happens, the Perl community will be laughing at us big time - and for years to come - as one by one all those Python versions get upgraded (all those 1.5.2 versions are bound to get changed some time, even if it takes a while) and Pythons reputation for being a stable language slowly turns into a joke. You think red hat looks stupid for including non-release versions of the compilers in two separate red hat releases - despite the problems and outcry after the first! - Just wait see what this does to Pythons reputation! The thing about the happy majority is that they aren't writing in all the time. They seem invisible. When they give up on Python because their working programs turn into seething piles of hard-to-trace bugs just because they updated the compiler to a new version, and they figure line-by-line searches of thousands of lines of code would be hardly more effort than to convert to a *stable* language where they don't need to worry about the next update, I guess they'll stay silent. But I'm sure there'll be an outcry at the start. And if Python changes and *then* the mistake is acknowledged and reversed - hah! I probably won't drop Python because of this. I'll certainly argue for standardising on the version immediately before the change. My Python scripts may not be that big in general, but there are a lot of them and I don't even know for sure who is using them. Having dozens of people screaming at me that their scripts are suddenly giving stupid results, or hanging (because using float division in the algorithm not only screws the results up, it prevents termination too) or whatever is not something I'd like to have to deal with. Maybe it's time to download the source - and get ready to release my PythonThatStillWorks version. From tjreedy at home.com Thu Jul 26 14:17:47 2001 From: tjreedy at home.com (Terry Reedy) Date: Thu, 26 Jul 2001 18:17:47 GMT Subject: byte compiled files References: <3B602FA0.6030809@herts.ac.uk> Message-ID: <f9Z77.30582$EP6.7867864@news1.rdc2.pa.home.com> "Mark Robinson" <m.1.robinson at herts.ac.uk> wrote in message news:3B602FA0.6030809 at herts.ac.uk... > can anyone shed some light on the mysterious behaviour of my byte > compiled files. I am currently working on a python script which analyses > patterns in a DNA sequence. I have a function which checks a pattern (a > substring of approx 6 chars) to ensure only valid charactors are > present. When I first run this program it runs fine, but if I > immediately rerun the program (i.e using the pre-byte compiled file) it > finds all patterns non-valid. If I delete the .pyc file between runs > this problem does not occur. Can anyone explain what is happening here > to me and how to prevent it? > > blobby [Always say which version of the interpreter you are having such problems with] There is a known bug, whose details I forget, in the writing/rereading of .pyc files that changes the arithmetic or representation of floats, and which exhibits the re-run/delete behavior you describe. I believe it has been or will be fixed in 2.2. Maybe the same (try 2.2a1 if you can), maybe related. To pin it down, put print statements in your 'is_valid()' function, or before, to find the statement that gets altered. Good luck. Terry J. Reedy From duncan at NOSPAMrcp.co.uk Wed Jul 25 07:13:13 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Wed, 25 Jul 2001 11:13:13 +0000 (UTC) Subject: Language change and code breaks References: <Pine.LNX.4.33.0107191316390.24983-100000@bms> <mailman.995571273.18192.python-list@python.org> <9j7gv8$9mg@dispatch.concentric.net> <cppuawfqbm.fsf@cj20424-a.reston1.va.home.com> <mailman.995734717.26373.python-list@python.org> <3B5DF101.9B2E4631@earthlink.net> <cpofq9a858.fsf@cj20424-a.reston1.va.home.com> <23891c90.0107250210.2e37ca61@posting.google.com> Message-ID: <Xns90E97A202990duncanrcpcouk@127.0.0.1> paul at boddie.net (Paul Boddie) wrote in news:23891c90.0107250210.2e37ca61 at posting.google.com: >> You would be very surprised if email to JKnapka at EarthLink.Net was sent >> to a different user than email to jknapka at earthlink.net. There are > > I'm fairly sure that I don't get personal e-mails (going via my > particular mail provider) when the capitalisation of parts of my > address is changed. Not that I regard this as desirable, but I no > longer regard it as surprising. > If I remember correctly, the domain name (after the '@') is not case sensitive. The user name (before the '@') *may* be case sensitive, but it varies from system to system. -- 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 just at letterror.com Mon Jul 23 10:39:15 2001 From: just at letterror.com (Just van Rossum) Date: Mon, 23 Jul 2001 16:39:15 +0200 Subject: A use for integer quotients References: <mailman.995866298.23496.python-list@python.org> <eppstein-E19F08.00451323072001@news.service.uci.edu> <3B5BDCB4.A2010560@letterror.com> <GbW67.19921$EP6.4914854@news1.rdc2.pa.home.com> Message-ID: <3B5C3713.A5201C5A@letterror.com> > [Just van Rossum] > > Do you really want 2047 bytes to be shown as 1 kbyte? > > Integer division is a lousy tool in this particular example... [Terry Reedy] > Just, this is stupid, wrong, and gratuitously insulting, > and therefore, in my opinion, ugly and nasty. I think you're terribly overreacting. Sorry if I offended anyone, I admit that first line of mine is a dumb assumption. To put it more subtly: *I* would never use int arithmetic for this sort of thing in Python. > As for the second line: do you really think > int(float(bytes)/float(k)+.5) is signigicantly better for rounding? 1) only one of the / operands need to be a float to force a float outcome, and 2) there is a round() builtin function. Now, if we initialize k to a float, we can write it like so: int(round(bytes/k)) I really don't see how the int examples you gave are in any way superior. > If so, that is a statement of anti-integer float-religion preference, > not fact. Maybe. Integer arithmetic like may be a lot more natural if you have a strong C background, and if not wasting cycles is a priority. To me (no strong math background, no computer science education) it simply looks like "showing off" to do a simple thing like this with ints. But I'm sure you'll see an insult in that line, too. > I am beginning to think that there is something wrong with a proposal > that apparently has to be promoted by bulldozing away reasonable > skepticism. Look, all I did was point out that for *this* particular example *I* think it's not appropriate to use int division. I have not taken postition either way, in fact I'm afraid of this change, too. All I know is that I would've preferred the proposed behavior in the first place, but I'm not so sure about adding it now, so late in the game. Just From steve at lurking.demon.co.uk Fri Jul 27 19:15:42 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Sat, 28 Jul 2001 00:15:42 +0100 Subject: Deposing Dictators References: <9jmjne$q54$1@wisteria.csv.warwick.ac.uk> <3b602daf.1623450@nntp.sprynet.com> <slrn9m111q.e6f.Gareth.McCaughan@g.local> <dOoGUKA3PKY7EwWa@jessikat.fsnet.co.uk> <cpsnfi2z9w.fsf@cj20424-a.reston1.va.home.com> <$dK+wKA$tZY7Ewin@jessikat.demon.co.uk> <3b61a98d$0$11917@wodc7nh0.news.uu.net> <3B61B01F.6C6B2B5D@Lugoj.Com> <6c8b7eb9.0107271358.4783d9c1@posting.google.com> Message-ID: <fls3mt0ofg36qek58fjm4ebqgnd7bcbuek@4ax.com> On 27 Jul 2001 14:58:35 -0700, dirck at pacbell.net (Dirck Blaskey) wrote: >Inertia should always be taken into account, but it should never >be the single deciding factor - or we'd all be working legacy COBOL. A couple of years ago, you may remember a major panic caused by peoples realisation that a hell of a lot of COBOL code was going to stop working. The developers were long since retired. In many cases, the source code was long since lost. That COBOL program was still there and working, though, some 20 or 30 years after it was written. Useful programs aren't discarded so fast as development fashions and religions. The trouble is that Python programs - and libraries much more so - are quite often shared in source form. >I think this is where most of the reactionary responses come from. >C is deeply ingrained in the programming culture, because in a lot >of ways it was, and in some ways still is, The Programming Language. >Anything you do, day in and day out, year after year, no matter how >odd or perverse or inconsequential, becomes 'the natural order of things'. >The more deeply ingrained, the harder it is to actually see. If that was true, we wouldn't be using Python at all. After all, it is a dynamically typed language that stores its identifiers in a hash table - it provides a keyword to say 'a function definition is coming' rather than leaving it to issues that often depend on the semantics (rather than simply grammar rules) of what has happened in the past. And it doesn't even allow you to use braces for block structures. How not-like-C can you get? From clspence at one.net Fri Jul 27 09:53:14 2001 From: clspence at one.net (Chris Spencer) Date: 27 Jul 2001 08:53:14 -0500 Subject: The error of building Python on HP UX References: <9jobt0$nh7$1@mail.cn99.com> <cpofq77phl.fsf@cj20424-a.reston1.va.home.com> <3B60BC42.8C790BCE@yahoo.com> <23891c90.0107270222.7856bec2@posting.google.com> Message-ID: <fds2mtkf6l2ttli8e7tgts6mtgn22p3bd0@4ax.com> Note that the compiled version they provide does NOT have threading enabled. <grumble> Chris. On 27 Jul 2001 03:22:13 -0700, paul at boddie.net (Paul Boddie) wrote: >SteveN <smnordby at yahoo.com> wrote in message news:<3B60BC42.8C790BCE at yahoo.com>... >> Guido van Rossum wrote: >> > >> > (Couldn't resist. :-) >> > >> > It is indeed an error to attempt to build Python on HP UX. (See the >> > endless laments in the SF bug database.) >> >> And yet HP makes it available: >> http://hpux.connect.org.uk/hppd/hpux/Languages/python-2.1/ > >It's a fearsome experience to run Python on HP-UX too - see the >screenshot they provide. ;-) From JamesL at Lugoj.Com Sun Jul 29 02:43:17 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Sat, 28 Jul 2001 23:43:17 -0700 Subject: Problem with timing, again: References: <%QM87.438$k9.52157@e3500-atl1.usenetserver.com> Message-ID: <3B63B085.3B3E897F@Lugoj.Com> Jeremy Moles wrote: > > I had an earlier post about timing in a program. Well, this is what I have > so far - exactly. It works, but it won't respond, and it won't let the > button go. What am I doing wrong? You should have the dostuff function return, not enter an infinite loop. Instead of going into an infinite loop, you should look into using the "after" widget method. That would allow you to schedule future actions. So if you delete the 3 line starting at "while 1" and insert instead the lines: domorestuff() self.hi_there.after(15000, domorestuff) you might have better luck. However, if domorestuff get shung up for any reason (such as taking a long time to resolve a host name or to transfer data) then things will hang a while. Other options include using threads or look into creative use of the "createfilehandler" mainloop hook. One reference on these techniques is chapter 18 of "Python and Tkinter Programming" by John E. Grayson. This is an "okay" book that should be worth investing in if you keep running into other Tkinter development issues. > > ____________________________________________ > > from Tkinter import * > > class App: > > def __init__(self, master): > > frame = Frame(master) > frame.pack() > > self.hi_there = Button(frame, text='Upload', > command=self.dostuff).pack() > > def dostuff(self): > import socket,ftplib,time > x=socket.gethostbyname(socket.gethostname()) > y=open('D:\\Python\\IP.html','w') > y.write(x) > y.close() > def domorestuff(): > z=ftplib.FTP(host='ahost') > z.login(user='asuer',passwd='apassword') > z.cwd('public_html') > z.storlines('STOR IP.html',open('D:\\Python\\IP.html','r')) > z.close() > while 1: > domorestuff() > time.sleep(15) > > root = Tk() > root.title('IPUL') > > app = App(root) > > root.mainloop() > > _______________________________________________ > > Anyways, the program works - but the gui itself freezes up - it's as if the > button is stuck. You guys were so helpful last time, any advice this time? From skip at pobox.com Mon Jul 23 10:46:20 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 23 Jul 2001 09:46:20 -0500 Subject: proposed language change to int/int==float (was: PEP0238 lament) In-Reply-To: <LNBBLJKPBEHFEDALKOLCOECNLAAA.tim.one@home.com> References: <eppstein-03540D.13070222072001@news.service.uci.edu> <LNBBLJKPBEHFEDALKOLCOECNLAAA.tim.one@home.com> Message-ID: <15196.14524.979058.576152@beluga.mojam.com> (I changed the subject to make sure that people reading c.l.py are aware of the ramifications of PEP 238 in case they haven't read it or this thread.) >> but float is just ugly. It is turning exact values (integers) into >> approximate ones (float) when I didn't tell it to. Tim> If the language defines "/" as returning a float, then you told it Tim> to. The problem is all those places in my existing code I already told it to divide two integers and return another integer. It's like George Bush changing personal translators and starting to get subtly different meanings from the statements Vladimir Putin makes. At first blush they may seem the same, but every once in awhile the message comes out wrong. I really don't understand the problem with teaching people new to Python right from the get-go that when you divide two ints it works like grade school long division. Unless my kids' educations were aberrant in some way (they weren't raised on Mars), I think long division is still taught to everyone in school somewhere along the way. It's not like it's a concept completely foreign to people. After years of bit rot in their brains due to calculator crutches they may need a minute to refresh, that should be all. If Python had int/int==float from day one, nobody would be bitching about it. It's just that there's all this code out there that already assumes int/int==int that will have to be picked over if people are to upgrade to a Python that says int/int==float. Probably nobody new to the language will bitch about it, because they haven't got a lot of code to maintain that makes the int/int==int assumption. To those of us who have to go back and fiddle all our code, the proposed change seems very much like gratuitous breakage. It's a bird-in-the-hand sort of thing. You're pissing off a fairly significant fraction of the language's existing constituency in hopes of attracting some non-programmers to the language who may not come anyway for various other reasons. Moshe, please make sure that when you update PEP 238 it includes this problem and that it seems to be shared by many opponents to this change. Skip From owen at astrono.junkwashington.emu Wed Jul 25 11:46:36 2001 From: owen at astrono.junkwashington.emu (Russell E. Owen) Date: Wed, 25 Jul 2001 08:46:36 -0700 Subject: Question: handling buffers of data in C extensions Message-ID: <9jmpkt$ktk$1@nntp4.u.washington.edu> In a C extension module, I am trying to implement a read function (something that passes back a buffer of data that Python should own and dispose of when it's ready to). I'm a bit confused about the best way to go about this. I've appended what I have so far. I suspect it *might* work, but that there is a better way. My main concern is that PyString_AsString returns a null-terminated string, which is inappropriate and perhaps wrong; if the PyString is expecting the final buffer to be null-terminated I'm in trouble. The documentation mentions buffer functions that sound much more appropriate, but I've not been able to figure out how they work. Any advice would be appreciated. -- Russell static PyObject *read (PyObject *self, PyObject *args) { PyObject *py_edt_p; EdtDev *edt_p; int size; PyObject *py_buf_p; /* parse arguments */ if (!PyArg_ParseTuple(args, "Ni", &py_edt_p, &size){ return NULL; } edt_p = (EdtDev *) PyLong_AsVoidPtr(py_edt_p); if (edt_p == NULL{ return NULL; } /* create a new Python string of the appropriate size and get a pointer to its internal buffer */ py_buf_p = PyString_FromStringAndSize(NULL, size); buf_p = PyString_AsString(py_buf_p); /* fill the internal buffer and return the string */ if (0 != edt_read((EdtDev *) edt_p, buf_p, size){ PyErr_SetString(PyExc_RuntimeError, edt_errStr); return NULL; } return py_buf_p; } From tundra at tundraware.com Sun Jul 8 20:14:12 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 09 Jul 2001 00:14:12 GMT Subject: Good Newbie Books References: <Cp427.655296$166.13566993@news1.rdc1.bc.home.com> Message-ID: <3B48F70B.33801776@tundraware.com> EricIDLE wrote: > > Hello, > Does anybody know of some good newbie books for me to read? I have already > read Ian Van Laningham's "Teach yourself Python in 24 Hours" are there any > good books that kind of step me up (from the book mentioned before). > > Thanks. I've bought several, but I like what you'll find at this URL best: http://www.diveintopython.org -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From deokhwankim at hotmail.com Thu Jul 5 21:23:59 2001 From: deokhwankim at hotmail.com (Deokhwan Kim) Date: 5 Jul 2001 18:23:59 -0700 Subject: Private variable Message-ID: <320bded.0107051723.489bc869@posting.google.com> In 9.6 Private Variables, Python Tutorial: Notice that code passed to exec, eval() or evalfile() does not consider the classname of the invoking class to be the current class; this is similar to the effect of the global statement, the effect of which is likewise restricted to code that is byte-compiled together. The same restriction applies to getattr(), setattr() and delattr(), as well as when referencing __dict__ directly. I have found an explanation of the second statement in Language Reference. the global is a directive to the parser. It applies only to code parsed at the same time as the global statement. In particular, a global statement contained in an exec statement does not affect the code block containing the exec statement, and code contained in an exec statement is unaffected by global statements in the code containing the exec statement. The same applies to the eval(), execfile() and compile() functions. But I don't know what the first and third statements mean in regard to private variables. Can you explain them as examples if possible? From guido at python.org Tue Jul 24 16:42:28 2001 From: guido at python.org (Guido van Rossum) Date: Tue, 24 Jul 2001 20:42:28 GMT Subject: PEP0238 lament References: <mailman.995873261.11975.python-list@python.org> <3B5C4BB5.932C041D@alcyone.com> Message-ID: <cpu202oy8i.fsf@cj20424-a.reston1.va.home.com> Erik Max Francis <max at alcyone.com> writes: > > By the way, 1/2 is also > > 0.5 in standard JavaScript: > > I wouldn't think how JavaScript does things would be a valid defense in > any case. This attitude is hurtful to your position. Just because JavaScript has a bad rep doesn't mean its designers were morons. Of course, pointing to JavaScript without motivation doesn't help. But trying to understand why JavaScript (a language that is in many ways very similar to Python, with a more conventional C-like syntax) does things a particular way may shed light on the issue in a more general context. --Guido van Rossum (home page: http://www.python.org/~guido/) From aahz at panix.com Wed Jul 18 23:56:57 2001 From: aahz at panix.com (Aahz Maruch) Date: 18 Jul 2001 20:56:57 -0700 Subject: TK + cmd.cmdloop() in threads (was Re: howdoI: Exception in thread - terminating the program? References: <yox7kx83xzf.fsf@karhu.tp.spt.fi> <u7kx74dmd.fsf@ctwd0143.fitlinxx.com> <yox1yneojvi.fsf_-_@karhu.tp.spt.fi> Message-ID: <9j5lq9$jl7$1@panix2.panix.com> In article <yox1yneojvi.fsf_-_ at karhu.tp.spt.fi>, Ville Vainio <vvainio at karhu.tp.spt.fi> wrote: > >I haven't done any UI stuff (apart from cmd and toy GTK/TK examples) >in python yet, is it ok to have TK mainloop running in one thread and >still perform normal cmd.cmdloop() operation in another? I can't >quickly think of any reason why it wouldn't be, but I can't figure out >why it hasn't been explicitly suggested... Having a TK window doing >the data browsing/drawing while still having a straightforward, >versatile cmd.cmdloop() running on a console sounds like an extremely >potent combination. Anyone done it? Are there some subtle gotchas that >make it a bad idea? I don't know what cmd.cmdloop() does, but if it's a TK thingie, what you're suggesting is a Bad Idea. Generally speaking, it's safest to have only one thread accessing any external resource (GUI, file handle, DB connection, etc). -- --- 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 Fortune cookie: Watch your relations with other people carefully, be reserved. From sholden at holdenweb.com Mon Jul 16 08:51:29 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 16 Jul 2001 08:51:29 -0400 Subject: Need help with socket server code References: <mailman.995132124.31082.python-list@python.org> Message-ID: <VnB47.1585$PF1.117925@e420r-atl2.usenetserver.com> "Shane Anglin" <shane.anglin at mtni.net> wrote in message news:mailman.995132124.31082.python-list at python.org... > Here's the basics of what I want to do with my new app: > Main loop is: > 1 - check socket for any incoming data > 1a - if no data on socket, go to 2, else get the data and place it into a list > 2 - print out list > 3 - go to 1 and do it all over again > > Currently, I can create a TCP socket server app using examples that will sit and wait (idle 99% of the time) and accepts the incoming data just fine, my 'print list' part is not processing at all until I get any new data in... for example, 1-wait on a client connect on socket, when a connection happens, get data, 2- place new data into list, print list, 3 -go to 1 and do it all over again... in this scenario, #1 has the rest of my code 'hostage' until a client connection is made and closed. > Shane: I'm unsure from your description as to whether you want the list to *only* contain the data from the last submission, or whether you want it to grow as individual submissions are added. However, your pseudo-code is rather unstructured. I presume you must have some reason for not using a structure like: while 1: l = listfrom(socket) print list where the listfrom() function simply waits for a connection on a socket and returns data. Do you need to do other computations while the socket code is running in the background? You might want to take a look at two framework module which do most of the work for you, and which are quite easy to use: SocketServer allows you to build synchronous servers (where nothing happens when there's no work coming in o ver network sockets), and asyncore builds asynchronous servers, where interactions can easily happen with several different clients on several different connections concurrently. regards STeve -- http://www.holdenweb.com/ From aycock at cpsc.ucalgary.ca Thu Jul 26 12:32:33 2001 From: aycock at cpsc.ucalgary.ca (John Aycock) Date: Thu, 26 Jul 2001 10:32:33 -0600 Subject: perl2py - In progress! :-) In-Reply-To: <15200.17588.34980.217940@beluga.mojam.com>; from skip@pobox.com on Thu, Jul 26, 2001 at 11:26:28AM -0500 References: <oqae1rg432.fsf@lin2.sram.qc.ca> <15200.17588.34980.217940@beluga.mojam.com> Message-ID: <20010726103233.B9810@cpsc.ucalgary.ca> On Thu, Jul 26, 2001 at 11:26:28AM -0500, Skip Montanaro wrote: > Raise and catch exceptions at the appropriate places? > > raise == goto > except == target of goto Unfortunately that doesn't work in the general case, only when the goto is used in a "structured" fashion. There are some papers on automatic removal of gotos; I can dig up the references if anyone wants them. John From dennis at dennis-voss.de Mon Jul 9 12:21:27 2001 From: dennis at dennis-voss.de (Dennis Voss) Date: Mon, 09 Jul 2001 18:21:27 +0200 Subject: ICQ module for Python? References: <3B488B04.B9753A7A@alcyone.com> Message-ID: <3B49DA07.EA6DCCF9@dennis-voss.de> > Is there an ICQ module available for Python which supports sending and > receiving of messages? Don't want to reinvent the wheel if I don't have > to. There's a command-line tool available for Linux systems. You could call that or implement the protocoll in Python. I *think* ICQ's protocoll is documented. Happy hacking (that's what ESR wrote in my book) Dennis From vvainio at karhu.tp.spt.fi Tue Jul 17 03:33:01 2001 From: vvainio at karhu.tp.spt.fi (Ville Vainio) Date: 17 Jul 2001 10:33:01 +0300 Subject: Python vs. Perl sockets (was Re: OO misconceptions References: <mailman.994969462.27792.python-list@python.org> <hevsktcrnpckttnkgi1arcue5kjjsbrrb5@4ax.com> <mailman.995046506.2514.python-list@python.org> <9ir1l7$3ja$1@panix2.panix.com> <9irfbc11jaq@enews1.newsguy.com> <slrn9l49me.p58.tim@vegeta.ath.cx> <mailman.995268208.1394.python-list@python.org> <slrn9l6kci.qqs.tim@vegeta.ath.cx> <3B538E16.65394C9D@engcorp.com> <slrn9l7a8r.rpe.tim@vegeta.ath.cx> <3B53B339.B6698858@engcorp.com> <slrn9l7lfm.t2g.tim@vegeta.ath.cx> Message-ID: <yoxsnfwggcy.fsf_-_@karhu.tp.spt.fi> tim at vegeta.ath.cx (Tim Hammerquist) writes: > Fair enough. =) Python does sound like a good choice in this case, > despite Perl's strength in sockets. What do perl sockets have that python sockets don't? I'm doing logistics/socket stuff in Python also, and haven't had any problems with Python sockets and threads. A lot more goes into socket programming than bind& accept: concurrency, queues... *cough* Bareword file handles *cough* -- 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 gervaserules at yahoo.com Mon Jul 16 17:57:06 2001 From: gervaserules at yahoo.com (eAndroid) Date: 16 Jul 2001 14:57:06 -0700 Subject: String Splice Assignment Message-ID: <4e3a8319.0107161357.690b5120@posting.google.com> Why don't strings support splice assignment, and what are some alternatives? I would expect it would work like this: >>> a = 'asdf' >>> a[1:2] = "EFGH" >>> a 'aEFGHf' I have a long string (~1000 chars) that I would like to do multiple splice assignments on. I am now interested alternatives to do this, especially efficient ones. Thanks, nathan From tjreedy at home.com Mon Jul 16 13:11:10 2001 From: tjreedy at home.com (Terry Reedy) Date: Mon, 16 Jul 2001 17:11:10 GMT Subject: Most efficient solution? References: <mailman.995289809.28477.python-list@python.org> <slrn9l5urp.nto.alf@leo.logilab.fr> Message-ID: <OeF47.11959$p7.3571067@news1.rdc2.pa.home.com> > C = {} > for item in B: > C[item]=None This sort of makes me wish we had dict comprehensions to match list comprehensions: C = {item:None for item in B} or C = {item:1 for item in B} as revised and then discarded From gregor at mediasupervision.de Tue Jul 3 09:20:01 2001 From: gregor at mediasupervision.de (Gregor Hoffleit) Date: Tue, 3 Jul 2001 15:20:01 +0200 Subject: Writing xbase .dbf files with Python ? Message-ID: <20010703152001.D12350@mediasupervision.de> Just for confirmation: There is no Python module available that's able to write/modify xbase .dbf files, right ? (I'm not interested in pointers to the various read-only modules ;-) Gregor From guido at python.org Fri Jul 27 10:57:03 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 27 Jul 2001 14:57:03 GMT Subject: Language change and code breaks References: <Pine.LNX.4.33.0107191316390.24983-100000@bms> <mailman.995571273.18192.python-list@python.org> <9j7gv8$9mg@dispatch.concentric.net> <cppuawfqbm.fsf@cj20424-a.reston1.va.home.com> <mailman.995734717.26373.python-list@python.org> <3B5DF101.9B2E4631@earthlink.net> <cpofq9a858.fsf@cj20424-a.reston1.va.home.com> <A%287.1144$oc6.134253@e420r-atl3.usenetserver.com> Message-ID: <cpvgke2zf1.fsf@cj20424-a.reston1.va.home.com> "Steve Holden" <sholden at holdenweb.com> writes: > [posted & mailed] > > "Guido van Rossum" <guido at python.org> wrote ... > > > > But never mind, I'm giving up on making *Python* case-insensitive. > > The hostility of the user community is frightening. > > > I find this a saddening remark. Perhaps the vehemence of some of the > reactions is an indication of how much users value your language. I'm sure > you are quite capable of ignoring personal abuse and ill-informed comment > that suggests you do not have the best interests of the Python community at > heart. Actually, it's been very tough. Years of therapy didn't prepare me for the accusations of dictatorship. I also didn't see enough support *for* my position to want to continue. > I comment on your proposals, as do many others, to offer an > alternative point of view (though I'm sure many times my comments have > already been thought about). > > Do I take the emphasis to mean that you are thinking about making *some > other language* case-insensitive? Only dreaming, for now. --Guido van Rossum (home page: http://www.python.org/~guido/) From hcsgss at texlife.com Tue Jul 24 16:01:28 2001 From: hcsgss at texlife.com (Galen Swint) Date: Tue, 24 Jul 2001 15:01:28 -0500 Subject: Making AIX happy using dynamic linking Message-ID: <1010724150128.ZM79448@anson.hcs.tl> This outlines how to: - build python as a shared lib on AIX - build dyanmic modules that use shared libs on AIX I posted a couple of weeks ago asking about problems with Python, shared libraries and AIX. Basically what we wanted to do was this: have Python load a C extension module which was a shared lib, which in turn relied upon another shared lib which also needed embedded Python. It looks like this: Python -> imdpdfmodule -> libimagedoc.so -> embedded python Naturally, we wanted the embedded python to be the same code as the top-level interpreter, so that meant libimagedoc.so had to link back up to the the Python level. It took a long time to get it all right because neither one of us working on the project has much experience with shared libs, and AIX doesn't make things easy. Here are the build statements we ended up using (the .o files are built with plain old gcc -c -g). ### libimagedoc.so: libimagedoc.o xmtframe_backend.o rm -f libimagedoc.so /usr/local/Python-2.1/Modules/makexp_aix libimagedoc.exp "libimagedoc.so" libimagedoc.o xmtframe_backend.o $(IMAGEMAGICKHOME)/magick/.libs/libMagick.a $(PCLOBJS) /usr/local/lib/libt1.a $(CC) -shared -Wl,-G -Wl,-bE:libimagedoc.exp -Wl,-bloadmap:libimagedoc.map -Wl,-H512 -Wl,-T512 -o libimagedoc.so libimagedoc.o xmtframe_backend.o $(PCLOBJS) $(IMAGEMAGICKHOME)/magick/.libs/libMagick.a /usr/local/lib/libt1.a -ljbig -ljpeg -lmpeg -ltiff -lpng -lz -lXm -lXt -lX11 -lXext -lm imdpdfmodule.so: imdpdfmodule.o libimagedoc.so libimagedocpdf.o pcl_pdf_render.o rm -f imdpdfmodule.so ./ld_so_aix gcc -Wl,-brtl -o imdpdfmodule.so -einitimdpdf imdpdfmodule.o libimagedocpdf.o pcl_pdf_render.o -L/usr1/hcsgss/libimagedoc -limagedoc -L$(PDFLIBHOME)/lib -lpdf ### Notice that we ended up wrapping some of our static libraries (really just libt1 and libMagick) in libimagedoc.so and exporting them so that other shared libs (like imdpdfmodule.so) could use them. Also, we linked with the -G flag. This left all unresovled symbols at link time to be resolved by the run-time linker. Some explanations of some flags we used: -Wl,-brtl --- this places the linker in 'dynamic' mode so that it also --- recognizes .so libraries -Wl,-G --- leaves symbols unresolved at link time to be resolved at --- load time Once we had done this, we ended up with a error message that __eprintf could not be resolved. I (admittedly rather hackishly), dodged this problem by re-making the python executable to export __eprintf. __eprintf is in libgcc and is normally added to executables, but for some reason python is not built with it. It must be exported before libimagedoc could use it, also. I created the export file by hacking python's makefile to do the following upon building the interpreter: ### # Build the interpreter $(PYTHON): Modules/$(MAINOBJ) $(LDLIBRARY) cp Modules/python.exp pythoneprintf.exp; echo "__eprintf" >> pythoneprintf.exp; $(LINKCC) $(LDFLAGS) $(PYLINKFORSHARED) -o $@ \ Modules/$(MAINOBJ) \ $(LDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST) ### This allows the run-time loader (rtl) find __eprintf in the interpreter. Python as a shared lib: Since we weren't always using libimagedoc with a python interpreter, and since it relied upon embedded python, we also wanted a copy of python to be dynamically linked to it. We again hacked python's Makefile and added the following to the 'libpython$(VERSION).so' rule: ### aix*) \ $(CC) -shared -Wl,-T512 -Wl,-H512 -Wl,-bE:Modules/python.exp -o $@ $(LIBRARY_OBJS) -lpthread -lm -lgcc \ ;; \ ### We then copied this to our (prefix)/lib/config directory and were able to easily use it by using the standard -Wl,-brtl, -L, and -l flags. One final note, we always had duplicate symbol errors for some functions included by -lm when we were using ld_so_aix, I did a little hack on this so that -lm was included as part of CCARGS instead of CCOPT in lines 171 and 170 respectively. I don't know if this was the *best* way to do this, but dang it, it works so we're gonna use it! :-) Galen Swint From yeahoo at yeehaa.com Mon Jul 9 00:13:02 2001 From: yeahoo at yeehaa.com (Drake) Date: 8 Jul 2001 21:13:02 -0700 Subject: Newbie... Help with Dates/Times Message-ID: <11f492f.0107082013.e9845f4@posting.google.com> I'm an expert VB programmer by profession. I believe VB is on the way out due to .NET, C#, python, etc. As such, I've begun a mid-life transition away from VB. Python seems like a logical, fun place to start. Here's my first py project... - Multiple network drives to search - Pattern match directory names (200-1000 matched per drive) - Pattern match file names within matched dir - Compare file dates (time is irrelevant) of matching files to a target date determined by user. - If filedate is >= (equal to or after) the target date, the fully qualified path prints to a file. Currently, I'm using an os.path.walk routine to gather the files per drive. Here's my problem... Im lost on the date stuff. 1) I'm thinking of comparing seconds... os.path.getmtime('myfile'). How do I strip off the time and get the seconds based on only the date? 2) How do I get the seconds for the target date. The user is entering a date. Do I create a time tuple and then convert that to seconds? This turned out to be a rather complex first project. And I haven't put on a GUI yet. In VB this thing took me less than 45 mins with a GUI, and complete error trapping, including network errors! The user even chooses which drives to search based on the available mappings. But it's time to move on. I'm open to any tips, comments, performance recommendations, etc regarding this project and my transition. Drake From rcameszREMOVETHIS at dds.removethistoo.nl Wed Jul 18 19:01:18 2001 From: rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz) Date: Wed, 18 Jul 2001 23:01:18 GMT Subject: [Q] Python, GUI, and Java References: <sAj57.1758$oz3.22749@vixen.cso.uiuc.edu> Message-ID: <Xns90E3A3D23905rcamesz@127.0.0.1> Young-Jin Lee wrote: > Can I use Pythong to develop a client application with a GUI? Pythong, unfortunately, is single threaded. It's a pretty thick thread, though. For multithreading, use Snackless: its threads are painfully thin indeed.[*] <g> > It looks like I should you Tkinter. How powerful is it? Or wxPython. That's pretty powerful, powerful enough to program a Delphi-lookalike in. (Just look for Boa Constructor, it's on Sourceforge, IIRC.) > How easy is it? And is there any way to connect Python application > and Java application? For Jython it shouldn't too be hard. For CPython, though... it all depends on what you mean by 'connect'. But, unless I'm very mistaken, you can't use Tkinter or wxPython in Jython programs. You'll have to use Java's 'native' GUI, i.e. the AWT or Swing. Robert Amesz -- [*] For any newbies out there: the entire first paragraph is just a bit of facetious disinformation. From guido at python.org Sat Jul 28 18:10:23 2001 From: guido at python.org (Guido van Rossum) Date: Sat, 28 Jul 2001 22:10:23 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <mailman.995989601.30748.python-list@python.org> <cp3d7lbo89.fsf@cj20424-a.reston1.va.home.com> <ubsm8epr5.fsf@ctwd0143.fitlinxx.com> <cp7kww92ph.fsf@cj20424-a.reston1.va.home.com> <m266cg73ig.fsf@mycroft.actrix.gen.nz> <3b60d65e.219212588@news.eircom.net> <cpy9pa4hnh.fsf@cj20424-a.reston1.va.home.com> <slrn.pl.9m4s03.f3g.qrczak@qrnik.zagroda> Message-ID: <cpzo9ozow4.fsf@cj20424-a.reston1.va.home.com> Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl> writes: > Fri, 27 Jul 2001 13:37:51 GMT, Guido van Rossum <guido at python.org> pisze: > > > If we have rationals in our numeric tower, I definitely want (5/2 - 3/2) > > to be usable as a sequence index, > > This doesn't work in my model. The simplest way to let it work is to > treat ints (with longs) and rationals as representation details of > the same concept (no matter if it's the same Python's type or not). > > This is not nice IMHO and it leads to more cases when the type of the > result depends on the value of the argument (x**y returns at least > a float when y is a rational, but may return an integer when y is > a nonnegative integer) and turns some TypeErrors into ValueErrors > (e.g. s[1/2]). > > I would not make 5/2-3/2 usable as a sequence index. My style is more > "typeful". But you decide. I am not at all sure! This should definitely be added as an open issue to the rationals PEP. --Guido van Rossum (home page: http://www.python.org/~guido/) From robin at jessikat.fsnet.co.uk Sun Jul 22 05:08:29 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sun, 22 Jul 2001 10:08:29 +0100 Subject: Any Suggestions for an Editor with MS-Windows ? References: <92757716C8BFF476.D432477A795DB759.E2FB05E062137965@lp.airnews.net> Message-ID: <7NI$UuANgpW7Ewz+@jessikat.fsnet.co.uk> In article <92757716C8BFF476.D432477A795DB759.E2FB05E062137965 at lp.airnew s.net>, zeke <Zeke at xyz.net> writes >Am almost half way through the manual and getting ready for the easy >job of bringing over some basic files (yea, right). Currently using >Ultra Edit but having doubts about it. >zeke > vim & gvim bot work under winxx -- Robin Becker From Gareth.McCaughan at pobox.com Fri Jul 27 18:55:37 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Fri, 27 Jul 2001 23:55:37 +0100 Subject: PEP 238 (revised) References: <cp4rrz5onj.fsf@cj20424-a.reston1.va.home.com> Message-ID: <slrn9m3sb9.1c5.Gareth.McCaughan@g.local> Guido van Rossum wrote: > Here's a completely revised version of PEP 238. [...] +0.9. Quibbles: - "analized" should be "analysed" (NB not "analyzed", please) - I cannot bring myself to like 2/1 -> 2.0 - putting "-Dold" and "-Dnew" in the language until version 3.000 [:-)] feels bad; something more extensible would be better - "many contexts ... don't have a clear float or integer context" is nasty. Replace the end with "... can't sensibly be classified as preferring either integers or floats", maybe. - the reasoning behind rejecting "/ = classical, // = float" is broken. Maybe something like: | - Let / keep its classic semantics; introduce // for | true division. This does not solve the problem that | the operator written as "/" has semantics very | different from those of mathematical division. | Furthermore, we believe that true division is needed | more often than floor division, and it should therefore | have the more familiar and shorter name. This is | also likely to be less confusing for newcomers to | Python. - Something is strained about the grammar of the last sentence of the answer to the first question in the FAQ. I suggest replacing it with something like | Note that for both positive and negative integers, | classic and floor division round towards negative | infinity, whereas the int() function rounds | towards zero. (divmod() rounds towards negative | infinity.) I don't like "quotient" for the result of floor-division; to me, "quotient" means the result of "true division". "True division" is better than "real division" and you should not be deterred from using it by the fact that some people think it prejudges the question. Since so many people are asking about conversion tools, the matter should be addressed briefly in the FAQ at the end. -- Gareth McCaughan Gareth.McCaughan at pobox.com .sig under construc From michael at stroeder.com Wed Jul 4 11:02:45 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Wed, 04 Jul 2001 17:02:45 +0200 Subject: Two problems with backslashes References: <Xns90D4A141E71CDgustaflalgonetse@194.213.69.148> Message-ID: <3B433015.D056EEA@stroeder.com> Gustaf Liljegren wrote: > > I have two problems with backslashes in DOS path strings: > > >>> path = 'e:\test\test.txt' I guess that's already the error. You did not specify a correct DOS path name. \t is a tab character. Hence your problems with string.split(). Try instead: >>> path = 'e:\\test\\test.txt' >>> path 'e:\\test\\test.txt' >>> print path e:\test\test.txt >>> # or as an alternative >>> path = r'e:\test\test.txt' >>> path 'e:\\test\\test.txt' >>> print path e:\test\test.txt > Alternative ways would be much appreciated. You should dig into module os.path. Ciao, Michael. From tim.one at home.com Tue Jul 3 21:48:53 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 3 Jul 2001 21:48:53 -0400 Subject: Is Python Dead? In-Reply-To: <OTj07.179491$ff.1395689@news-server.bigpond.net.au> Message-ID: <LNBBLJKPBEHFEDALKOLCOEEFKMAA.tim.one@home.com> [Paul Prescod] > Is anybody else suspicious about the sudden uptick of troll-like > behavior on comp.lang.python? Keep an eye out and don't bother > responding to anything inflammatory. But, Paul! We *like* talking with you! some-people-are-just-inflammatory-by-nature-ly y'rs - tim From reageer.in at de.nieuwsgroep Tue Jul 3 13:04:13 2001 From: reageer.in at de.nieuwsgroep (Rene Pijlman) Date: Tue, 03 Jul 2001 19:04:13 +0200 Subject: zope's acquisition inheritance References: <3B41E221.CE23D83E@home.com> Message-ID: <sju3kto9lgcmhfv3eeh63o6and87iv8bpv@4ax.com> Wostenberg <pwos at home.com> schreef: >Anybody heard of acquisition outside Zope This is a (more or less) scientific publication about acquisition: http://www.ccs.neu.edu/home/lorenz/papers/oopsla96/ More links on acquisition in Zope on: http://www.zope.org/Members/rpijlman/acquisition Regards, -- Ren? Pijlman From brakedon at hotmail.com Tue Jul 3 22:45:28 2001 From: brakedon at hotmail.com (eric_brake) Date: 3 Jul 2001 19:45:28 -0700 Subject: object - oriented programming Help!! References: <mailman.994164970.2845.python-list@python.org> Message-ID: <7b515e0f.0107031845.51c2183b@posting.google.com> Simon Brunning <SBrunning at trisystems.co.uk> wrote in message news:<mailman.994164970.2845.python-list at python.org>... > > From: brakedon at hotmail.com [SMTP:brakedon at hotmail.com] > > What am I doing wrong? I am trying to learn object oriented > > programming, but I don't know what I'm doing wrong. > > > > >>> import fibonaccii_gui > > >>> fibonaccii.fib(fibinstance, 100) > > Traceback (most recent call last): > > File "<pyshell#2>", line 1, in ? > > fibonaccii.fib(fibinstance, 100) > > NameError: name 'fibonaccii' is not defined > > You are importing a module called fibonaccii_gui, then referring to just > fibonaccii. Replace your 2nd line with: > > fibonaccii_gui.fib(fibinstance, 100) > > And it just might work. Thank you it finally worked! This is how it evened out. Thank you again! "fibonaccii_gui" module class fibonaccii: def fib(self, fibnumber): a, b = 0, 1 while b < fibnumber: print b, a, b = b, a+b fibinstance = fibonaccii() Call it from the interpreter: >>> import fibonaccii_gui >>> fibonaccii_gui.fibinstance.fib(100) 1 1 2 3 5 8 13 21 34 55 89 From reageer.in at de.nieuwsgroep Fri Jul 6 17:13:26 2001 From: reageer.in at de.nieuwsgroep (Rene Pijlman) Date: Fri, 06 Jul 2001 23:13:26 +0200 Subject: Postgres support References: <gul1kts5l6aolk55o7vguk97uorjd08j9f@4ax.com> <5174eed0.0107061058.5446dac9@posting.google.com> <mailman.994448787.15987.python-list@python.org> Message-ID: <o5acktc6ot7upcu01eh3hul6e8mtu9qqnn@4ax.com> Skip Montanaro <skip at pobox.com> schreef: >I'm not sure there are many Python programmers with the discretionary funds >necessary to buy any of the commercial databases you want supported. Oracle is almost free for development purposes. "Technology Tracks are a tremendous value at US$200 each... How do we do this? By providing a developer license with each product. Why do we do it? Because we want to make it as easy as possible for you to develop your applications using Oracle technology." http://technet.oracle.com/software/htdocs/track_benefits.htm Just put your production data in PostgreSQL and Oracle is quite affordable. >Next question? What do you mean with 42? -- Vriendelijke groet, Ren? Pijlman <rpijlman at spamcop.net> Wat wil jij leren? http://www.leren.nl/ From msimpson at ioindustries.com Thu Jul 12 08:32:52 2001 From: msimpson at ioindustries.com (Mike Simpson) Date: 12 Jul 2001 05:32:52 -0700 Subject: Freeing memory from Python lists! References: <cdd0bc89.0107111041.c3f8209@posting.google.com> <qebpktoe7n33altfhpar744nhak7hf4b6u@4ax.com> <slrn9kpj0n.mi0.chat@linuxsupreme.homeip.net> Message-ID: <cdd0bc89.0107120432.67439872@posting.google.com> chat at linuxsupreme.homeip.net (Chad Everett) wrote in message news:<slrn9kpj0n.mi0.chat at linuxsupreme.homeip.net>... Thanks for the helpful response Chad! Mike > Nothing has been lost. As other responses have pointed out, you are seeing > a manifestation of the OS memory management algorithms. To show you that > nothing has been "lost" do the following: > > 1. run python and get a python prompt > > 2. look at your memory allocation > > 3. do your: > > result = [] > for count in xrange(510*478): > result.append(count) > > 4. look at memory usage > > 5. delete the result list > > del result > > 6. look at memory usage > > 7. now build the list again > > result = [] > for count in xrange(510*478): > result.append(count) > > 8. look at memory usage and you'll see it has only gone back up to the same > amount of memory at step 4. > > > > > > -----= 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 tim.one at home.com Fri Jul 20 21:54:32 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 20 Jul 2001 21:54:32 -0400 Subject: trouble installing Python-2.2a1.exe In-Reply-To: <ac677656.0107191230.767b041d@posting.google.com> Message-ID: <LNBBLJKPBEHFEDALKOLCMEOJKPAA.tim.one@home.com> [Tom Good] > I downloaded the Python-2.2a1.exe installer from SourceForge, and > verified that the MD5 sum is correct. When I run it under Windows > 2000 Professional [Version 5.00.2195], I get an error dialog that > says: > > 16 bit Windows Subsystem > > The NTVDM CPU has encountered an illegal instruction. > CS:020c IP:0115 OP:0f 00 00 00 00 Choose 'Close' to terminate the > application. > > > Any ideas? Just general ones: Reboot. Use Windows Update to make sure you've got all the critical MS fixes. Like the splash screen says, close *all* other programs before trying to install. Especially make sure to disable virus checkers (no, Python isn't a virus, but virus checkers work at very low levels and often interfere with normal operation). Don't try to install from a network (copy the installer to your boot drive first). Make sure you have enough disk space. Install from an account with Admin privileges. You didn't say how far it got (if it got anywhere at all), but if you're being "creative", try accepting the defaults. There was even one case (but on Win98SE) where the install didn't work until the user hit the ENTER key instead of clicking with the mouse, presumably due to some machine-specific conflict with the video and/or mouse drivers. Try a different machine. Cheer up: you're the only person it doesn't work for <wink>. business-as-usual-for-windows-ly y'rs - tim From machin_john_888 at hotmail.com Mon Jul 16 18:01:02 2001 From: machin_john_888 at hotmail.com (John Machin) Date: 16 Jul 2001 15:01:02 -0700 Subject: Most efficient solution? References: <mailman.995289809.28477.python-list@python.org> Message-ID: <92ae279c.0107161401.4d51778d@posting.google.com> Jay Parlar <jparlar at home.com> wrote in message news:<mailman.995289809.28477.python-list at python.org>... > I have a simple problem, but one that, without some optimization, might hurt the performance of my project. To sum it up, I > have two lists, we'll call them list A and list B, both lists contain only one-word strings (ie. both were generated by string.split() > performed on a large amount of text) > > List B consists of my "stopwords", meaning, the words I don't want included in my final version of list A. So what I need to > do is check every item in list A, and if it occurs in list B, then I want to remove it from the final version of A. My first thought > would be: > > for eachItem in A: > if eachItem in B: > A.remove(eachItem) > > Now, this will work fine, however, the size of list A varies, and while list B is constant, it is quite large (more than 750 items). > List A can also, should the situation warrant, become quite huge as well. The main problem is that I have no idea of the > efficiency of "in" for large lists like this. Can anyone think of a possibly quicker way, or is this the best? A Python list is a sequence. Thus the "in" and "remove" operations must be O(n). Thus what you propose will be O(m*n**2), where n = len(A) and m = len(B). Thus for non-trivial sizes you may well have a problem. This question seems to have little to do with Python and lots to do with (a) data structures and (b) common sense and (c) looking at prior work in the field. Some clues: (a) (1) B should not be a sequence-like data structure. In whatever language you use, try a dictionary aka hashed look-up table. If the language doesn't have such an ADT built in, or available in a standard library, or it's not fast and robust, abandon the language [Don't panic -- Python is just fine]. (2) Iterating over a collection from which you are removing items needs to be undertaken with care. (3) Don't forget to concern yourself about how much memory your data structures will occupy. Your project could run very fast until it runs out of real memory and then become painfully slow. Hint: at least one of the solutions proposed by other posters involved a copy of your A list. (b) Why are you putting noise words into A and then ripping them out again? To quote Jon Bentley: "Do nothing gracefully". Even more graceful than do(nothing) is do_not_do(anything)! Consider this: Here is the loop that you didn't mention: for word in A_source: # or something similar ... A.append(word) Try changing that to: for word in A_source: if not B.has_key(word): A.append(word) cue_the_fat_lady() (c) Your school library should have copies of things like: W. B. Frakes and R. Baeza-Yates eds., Information Retrieval : Data Structures and Algorithms, Englewood Cliffs, N.J. : Prentice-Hall. You could also try dipping into the a few of the 150 papers that cite it; see http://citeseer.nj.nec.com/context/36679/0 If you are worried about how your project will be effected by len(A), there is a book called "Managing Gigabytes". [snip] > "Though there are many paths > At the foot of the mountain > All those who reach the top > See the same moon." Those using an O(n**3) mountain_top_search algorithm may find the moon crumbled with age when and if they get to see it :-) From mnenadov at stclairc.on.ca Tue Jul 24 08:03:45 2001 From: mnenadov at stclairc.on.ca (Mark Nenadov) Date: Tue, 24 Jul 2001 12:03:45 GMT Subject: constructor chaining? Message-ID: <20010724.081619.1139901474.1751@d150-169-166.home.cgocable.net> I am wondering how I can do constructor chaining with Python. For example, if I had a base class called "Media" and a child class called "Book", how would I call the Media's __init__ constructor from within the Book's __init_constructor? In PHP I know you can just refer to the name of the parent's constructor. In Java I believe you can call "super()". How can I do this in Python? Thanks in advance. -- ~Mark Nenadov (author/editor for http://www.coffeecode.com) From peter at engcorp.com Tue Jul 24 23:41:21 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 24 Jul 2001 23:41:21 -0400 Subject: PEP0238 lament AND Re: Case (In)sensitivity References: <00867F2E.N22121@rsmi.com> <3B5CAED2.80B9CF3C@ActiveState.com> <mailman.995930982.17575.python-list@python.org> <acppltstdl0oo692su8e9c4fhm6cf14kt9@4ax.com> Message-ID: <3B5E3FE1.1C1ABBA4@engcorp.com> Stephen Horne wrote: > > On Mon, 23 Jul 2001 18:35:35 -0500, "Chris Gonnerman" > <chris.gonnerman at newcenturycomputers.net> wrote: > > >Both of these changes fall in the same group IMHO... they > >break a lot of code. > > Case insenstitivity is also a serious issue for me - it might even > bite me for adopting a case-based naming convention as an apparently > sensible way to avoid future identifier conflicts - [...] > > Anyway, it's probably less an issue for me than division - I use > integer division a lot, whereas defining different identifiers with > only case-changes to distinguish them is a definite no-no. This last item should always be said in conjunction with an "in my opinion"... We *frequently* use identifiers which differ only in case from their class name. We also use identifiers which are identical to other identifiers except for case, primarily when we have a large series of CONSTANTS defined somewhere. In this case, it is even supported directly by advice in our Coding Conventions document. The code is readable, logical, consistant, and *would break* of course if case-sensitivity ever became an issue. (Which, apparently, it won't, according to a posting of Guido's within the last day or two. Thankfully.) (This appears to be a religious issue, and I'm not sure anyone can have an argument other than "it's bad" to attempt to convince me that this is not a perfectly valid use of case sensitivity, on which I've counted for years.) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From DavidLnonospammy at raqia.com Tue Jul 31 16:56:03 2001 From: DavidLnonospammy at raqia.com (David Lees) Date: Tue, 31 Jul 2001 16:56:03 -0400 Subject: Python Threads on Linux References: <d396b814.0107302239.6341a93@posting.google.com> <3dsnfdjg1w.fsf@ute.cnri.reston.va.us> <akuchlin@mems-exchange.org> <mailman.996596704.6347.python-list@python.org> <ojqdmtguukc4ju3d8k7gvivqdfksd8e6dg@4ax.com> <qf37k9.tvc.ln@gargamel.hqd-internal> Message-ID: <3B671B63.23CC4490@raqia.com> Question - Does this affect the global lock at all? Is it some way to get around it? I wrote some simple threaded code awhile back that ran on a dual processor board. The global lock kept 2 threads from running in parallel on separate processors. david lees Gerhard H?ring wrote: > > On Tue, 31 Jul 2001 17:28:32 GMT, Courageous <jkraska1 at san.rr.com> wrote: > >>Didn't IBM just release a new (optional) threads package for Linux that > >>implements true lightweight threads? > > Yes. See http://oss.software.ibm.com/developerworks/opensource/pthreads/ > > >This would require a kernel-patch, yes? > > Yes. IBM's Next Generation Posix Threading is btw. based on GNU Pth (a > threading library that is non-preemptive and runs completely in userspace). > Python can be built against GNU Pth out of the box. > > Gerhard > -- > mail: gerhard <at> bigfoot <dot> 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, [chr(ord(x)^42) for x in list('zS^BED\nX_FOY\x0b')]) From db3l at fitlinxx.com Tue Jul 31 14:58:05 2001 From: db3l at fitlinxx.com (David Bolen) Date: 31 Jul 2001 14:58:05 -0400 Subject: Arg decoding with a template? References: <ljidmtouqj6som2t9ecagbkj95c53kjaeh@4ax.com> <4oA97.5883$9i1.519137@e420r-atl1.usenetserver.com> <duodmt0itqq9t1kq6bs5dhpnk9io64p2sj@4ax.com> Message-ID: <ulml5sz7m.fsf@ctwd0143.fitlinxx.com> Dale Strickland-Clark <dale at riverhall.NOSPAMco.uk> writes: > "Steve Holden" <sholden at holdenweb.com> wrote: > > OK, I've had a good look at this now. > > It's hideous! > > It's no wonder that people get fed up with computers if they get > given a user interface that expects pointless dashes all over the > place. > > You simply can't use this routine to code a nice arg string. I suppose that's a matter of taste. Certainly in the Unix domain, from whence this arose, where virtually everything was traditionally done via the command line, all command line utilities parse their command lines in exactly this way, it's extremely consistent and trying to do other manual approaches actually makes the non-conformant application stand out as such. In effect, such command line parsing is a standard interface, much as under Windows, there's standard UI elements in its GUI. It's also (unlike a GUI) designed as much for efficiency and flexibility as looks. You'll find that it's a flexible interface for something that has to deal with a textual command line. Try designing a CLI parser that has optional arguments, arguments with and without values even with multi-character options, spacing and order insensitive, and so on, and you'll find yourself replicating much of the getopt behavior. Personally, since DOS/Windows command line applications never really formed such consistency (IMO), and at least for me I find "-" less glaring on the command line than "/", I find the use of a getopt conformant command line to be nice as well as consistency cross-platform. I don't know what particular user interface you are looking to serve, so if you're comparing this to some GUI interface to obtain parameters, that's not apples to apples. But if you're working strictly with a command line, I wouldn't necessarily jettison getopt summarily. -- -- 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 peter at engcorp.com Sat Jul 14 00:52:20 2001 From: peter at engcorp.com (Peter Hansen) Date: Sat, 14 Jul 2001 00:52:20 -0400 Subject: How to use os.access()?? References: <3B4F82F8.D21C6EF3@uniserve.com> Message-ID: <3B4FD004.D0CCFBC2@engcorp.com> bvdpoel at uniserve.com wrote: > > I'm trying to use os.access() in my program. But, I'm stuck trying to > figure out the parms... obviously the first is the filename; but the 2nd > is supposed to be a constant (?) like F_OK. Unfortunately, it doesn't > appear that the F_OK, etc are defined anywhere. Either the docs are > wrong (no way!), or I'm missing a module file (likely), or I'm just > totally wrong about everything (quite likely!). You're right! (that you're totally wrong... ;-) >>> import os >>> dir(os) ['F_OK', 'O_APPEND', 'O_BINARY', 'O_CREAT', 'O_EXCL', 'O_RDONLY', 'O_RDWR', 'O_TEXT', 'O_TRUNC', 'O_WRONLY', 'P_DETACH', 'P_NOWAIT', 'P_NOWAITO', 'P_OVERLAY', 'P_WAIT', 'R_OK', 'TMP_MAX', 'UserDict', 'W_OK', 'X_OK', ... ] >>> os.access('c:/autoexec.bat', os.F_OK) 1 >>> F_OK Traceback (most recent call last): File "<stdin>", line 1, in ? NameError: name 'F_OK' is not defined >>> os.F_OK 0 >>> from os import * >>> F_OK 0 >>> You've probably forgotten to use os.F_OK and are using just F_OK. Unless you want to "from os import *", which is generally bad form, you need to prepend the name of the module in front of _everything_ you use from that module, whether function name or constant. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From sill at optonline.net Tue Jul 10 00:32:40 2001 From: sill at optonline.net (Rainy) Date: Tue, 10 Jul 2001 04:32:40 GMT Subject: curses woes Message-ID: <slrn9kl196.rts.sill@sill.silmarill.org> Hi, I ran into a problem with curses, here's what I'm doing: while 1: c = win.getch() if c == curses.KEY_BACKSPACE: do_something() The problem is that backspace key shows up as ^? and doesn't match the above test. I also tried doing c == 14 but also without luck. I'm using curses.wrapper() here. -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: http://silmarill.org/cymbaline From aahz at panix.com Mon Jul 2 20:45:57 2001 From: aahz at panix.com (Aahz Maruch) Date: 2 Jul 2001 17:45:57 -0700 Subject: Python for Commercial Games? References: <9haoiv$jnv$1@mtc1.mtcnet.net> <tjq5huamq17k11@news.supernews.com> <slrn9k21pe.aqd.kamikaze@kuoi.asui.uidaho.edu> Message-ID: <9hr4k5$peq$1@panix6.panix.com> In article <slrn9k21pe.aqd.kamikaze at kuoi.asui.uidaho.edu>, Mark 'Kamikaze' Hughes <kamikaze at kuoi.asui.uidaho.edu> wrote: > > I suspect that Infocom-style interactive fiction, with good production >values and nice packaging, could sell again just fine. You'd have to >sell it outside of most computer game shops, though, because the games >publishing and distribution networks just won't carry it, and the games >magazines won't review it (they're all run by and for hyperactive >adolescent males (of all ages))... ...and genders. ;-) -- --- 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'm not tense, i'm just terribly, terribly alert" --unknown From akuchlin at mems-exchange.org Fri Jul 20 09:38:54 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 20 Jul 2001 09:38:54 -0400 Subject: Python, C++, Java, Smalltalk, Eiffel,... References: <9is8rm$46d$1@panix3.panix.com> <slrn9l5ngp.87g.jajvirta@sirppi.helsinki.fi> <9iv7ae$gs0$1@nntp6.u.washington.edu> <9j63lk$ogp$1@newsfeed.th.ifl.net> <slrn9ldogs.488.philh@comuno.freeserve.co.uk> Message-ID: <3d4rs74t5d.fsf@ute.cnri.reston.va.us> philh at comuno.freeserve.co.uk (phil hunt) writes: > Supposedly, Microsoft's C# and CLR system will provide a fix for > this, by allowing the programmer to use any language that compiles > to CLR to call a routine in any other language that does. > > Does anyone have details on this? I'm a bit doubtful that the CLR will really be suited for languages other than C# or VB. Sure, with some hammering you can compile Python to CLR, just as you can compile it to Java bytecodes, but there seems to be a sizable performance hit, judging by a message from David Ascher archived at http://aspn.activestate.com/ASPN/Mail/Message/638072. I suspect .NET's multilanguage will turn out to be a feature used more as a selling point than in practical use. In much the same way, Internet Explorer is theoretically multiplatform, but I expect almost no one out there uses the Solaris and HP-UX IE ports. --amk From ajs at ix.netcom.com Tue Jul 31 06:55:23 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Tue, 31 Jul 2001 06:55:23 -0400 Subject: Changing the Division Operator -- PEP 238, rev 1.12 Message-ID: <001101c119af$67dd1d80$a9e1fea9@carol> Bill writes - >In this context, it comes from the CP4E motivation that people may be >called upon to script operations or interactions between their >`toys'... calling them "non-programmers" is shorter than saying, >`people who may need to program without knowing they are doing it' >(imo). But we are going around in circles - as I have been for some few years on the subject. I guess I had always hoped that CP4E was really going to focus on turning non-programmers into programmers. It made sense to me that it would, because it happens that IMO Python is a great tool for doing so. What tool `people who may need to program without knowing they are doing it' use is of very little interest - to me. Because now we have descended to the realm of semantic games. Are people who 'program without knowing they are doing it' in fact programming in any meaningful sense? Can than P in CP4E be used for those activities without with any real integrity. It happens that you have hit directly on my Big Beef. To me CP4E is, can and should be a true initiative, not a semantic game. But to the extent you have accurately described CP4E - well I feel foolish for having concerned myself with it. Got better stuff to do. ART From paulsid at home.com Sat Jul 21 21:06:24 2001 From: paulsid at home.com (Paul Sidorsky) Date: Sat, 21 Jul 2001 19:06:24 -0600 Subject: Here's a puzzle... References: <20010721195640.15632.00000532@ng-mh1.aol.com> Message-ID: <3B5A2710.B25B09E6@home.com> TheDustbustr wrote: > sender='Angel' > print data[len(sender)+2:string.find(data[len(sender)+2:],' ')] > And if you are up to it, feel free to help me splice (correct terminology, > parse?) for variables rcpt and message ;) By any chance are you coming from a C background? :-) That's a nasty one-liner, so I'm not even going to attempt to figure out how it works. Instead, here is a much nicer way to do this kind of thing: (This assumes the format is always the same, i.e. colons prefix each section and single spaces separate the first three variables.) def parsemsg(data): """Returns a tuple: (sender, command, rcpt, message)""" tmp = data.split(':') hdr = tmp[1].split(' ') return (hdr[0], hdr[1], hdr[2], tmp[2]) If you have this in a module called parsemsg you can use it like this: >>> teststring = ":Angel PRIVMSG Wiz :here is my message!" >>> import procmsg >>> sender, command, rcpt, message = parsemsg.parsemsg(teststring) >>> print sender Angel >>> print command PRIVMSG >>> print rcpt Wiz >>> print message here is my message! Hope that helps. -- ====================================================================== Paul Sidorsky Calgary, Canada paulsid at home.com http://members.home.net/paulsid/ From ejeandel at ens-lyon.fr Fri Jul 13 13:09:55 2001 From: ejeandel at ens-lyon.fr (Emmanuel Jeandel) Date: 13 Jul 2001 17:09:55 GMT Subject: Language Shootout References: <mailman.994910001.4712.python-list@python.org> <3b4eed03.298292@nntp.sprynet.com> Message-ID: <9ina13$jau$1@macareux.ens-lyon.fr> In article <3b4eed03.298292 at nntp.sprynet.com>, David C. Ullrich wrote: > On Wed, 11 Jul 2001 23:52:59 -0400, "Tim Peters" <tim.one at home.com> > wrote: > > [...] >> >>Here's another fun one: you can also write a long-int multiplication >>routine in Python that runs significantly faster than the builtin long *! >>Hint: recursion <wink>. > > I give up, howdaya do that? > > (When I read this I said aha, you're getting at something like > using > > [*] (a*2**k+b)*(c*2**k+d) = a*c*2**(2*k) + (a*d+b*c)*2**k + b*d. > Perhaps you mean : (a*2**k+b)*(c*2**k+d) = a*c*2**(2*k) + ((a+d)*(b+c) - a*c - b*d)*2**k + b*d. You only have to compute 3 multiplications a*c b*d (a+d)*(b+c) Then you can have an algorithm for multiplying a and b, if a and b are of the same size (len(a) = len(b)) of complexity len(a)**(1.6) significantly better than len(a)**2 (len(a)*len(b) is *not* linear, rather quadratic) Emmanuel From Tom_Good1 at excite.com Mon Jul 23 14:25:00 2001 From: Tom_Good1 at excite.com (Tom Good) Date: 23 Jul 2001 11:25:00 -0700 Subject: 2.2 features References: <gER67.534750$eK2.111982758@news4.rdc1.on.home.com> Message-ID: <ac677656.0107231024.3ab3e6f1@posting.google.com> "Nick Perkins" <nperkins7 at home.com> wrote in message news:<gER67.534750$eK2.111982758 at news4.rdc1.on.home.com>... > I can't believe the quantity of discussion (still) going on over the div > thing! > > And meanwhile, 2.2a1 is out, and there are far more interesting things > happening to our little language. > > Isn't there anything in 2.2 that deserves even a fraction of the discussion > going on about div? (which has been beaten to death 9 times) > > getset(), staticmethod(), classmethod(), etc... > > How about generators, who's tried them out? [snip] I like generators a lot. Here's a fun one: #------ begin code from __future__ import generators def fib(): "unbounded generator, creates Fibonacci sequence" x = 0 y = 1 while 1: x, y = y, x + y yield x if __name__ == "__main__": g = fib() for i in range(9): print g.next(), #------ end code c:\python22>python fib.py 1 1 2 3 5 8 13 21 34 Tom From emile at fenx.com Thu Jul 26 07:37:48 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 26 Jul 2001 04:37:48 -0700 Subject: Howto dynamically add object to the list References: <3B5FF76C.20B6AD98@sci.pam.szczecin.pl> Message-ID: <9jovlr$la72$1@ID-11957.news.dfncis.de> To create an instance of the class Patient, invoke the class with the constructor arguments, for example: pacjenci.append(Patient()) #note the extra ()'s HTH, -- Emile van Sebille emile at fenx.com --------- "Piotr Legiecki" <piotrlg at sci.pam.szczecin.pl> wrote in message news:3B5FF76C.20B6AD98 at sci.pam.szczecin.pl... > Hi > > I have such a class > > class Patient: > x=0 > ... > > And such a code to add objects of class Patient to a growing list: > > ... > while curPatient!=-1: > pacjenci.append(Patient) > curPatient=GetNextPatient(allPat, curPatient, pacjenci[i]) > ..... > > Well, it is wrong code (I add classes Patient ?! not objects of this > class). So how to add an object to the list in such a situation? > > something like: > .... > while curPatient!=-1: > obj=Patient > pacjenci.append(obj) > curPatient=GetNextPatient(allPat, curPatient, pacjenci[i]) > ..... > > Is it ok? > > -- > Regards > Piotr Legiecki From ajs at ix.netcom.com Sun Jul 22 07:14:57 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Sun, 22 Jul 2001 07:14:57 -0400 Subject: Future division patch available (PEP 238) Message-ID: <000f01c1129f$8afb2760$a9e1fea9@carol> >I'm cc'ing Bruce Sherwood and Davin Scherer, because they asked for >this and used a similar implementation in VPython. When this patch >(or something not entirely unlike it) is accepted into Python 2.2, >they will no longer have to maintain their own hacked Python. First let me say that VPython is something I use extensively in what I do in Python, and consider a real contribution to Python - particularly in a CP4E context. Thank you David and Bruce. However, I believe it is simply inaccurate to say they have felt it necessary to "maintain their own hacked Python". What they do is what I - as a novice - understood to do to avoid confusion over integer division issues when creating a facility to script coordinate geometry - cast coordinate arguments to a consistent numerical type, floats. They apparently do it in their C++ module. I am using Numeric, my coordinates are arrays, with a consistent typecode. No biggie. The VPython docs warn of the integer division issue, and the "fix" - appropriately, enough. >Floating Division >Python performs integer division with truncation, >so that 3/4 is 0, not 0.75. but before giving the "fix" >You can write 3./4., which is 0.75 by the rules >of "floating-point" division. the docs seem to go a bit out of their way to pick their nit: >This is inconvenient when doing scientific >computations, and can lead to hard-to-find >bugs in programs. In most contexts one concentrates on ones app, documents its API, not its nits with the language it has chosen to implement in. My feature requests for VPython are on visual-python-dev, not in the docs of my app that uses it. But then the docs are also very public about its nits with IDLE. As much as I appreciate VPython, never quite understood that. ART From ken_chiba at hotmail.com Sat Jul 14 19:40:24 2001 From: ken_chiba at hotmail.com (Ken) Date: Sat, 14 Jul 2001 23:40:24 GMT Subject: MySQLdb - possible without install? References: <3b4d0ea7.11581823@news1.on.sympatico.ca> <slrn9kqr2k.p1.gerhard.nospam@lilith.hqd-internal> <3b4d7a61.39160079@news1.on.sympatico.ca> <slrn9krt7k.nj.gerhard.nospam@lilith.hqd-internal> <3b4e2495.82731972@news1.on.sympatico.ca> <slrn9ksrdc.sa.gerhard.nospam@lilith.hqd-internal> Message-ID: <3b50d5dd.47261648@news1.on.sympatico.ca> Ok. Still no luck! In case I'm just missing something... here is a listing of various files/directories: My cgi-bin directory (all executable scripts must be in here to work): ftp> ls -l 227 Entering Passive Mode (x.x.x.x..x) 150 Opening ASCII mode data connection for file list drwxr-xr-x 4 a0005722 a0005722 512 Jul 12 17:24 . drwxr-xr-x 16 a0005722 a0005722 512 May 30 15:02 .. drwxr-xr-x 3 a0005722 a0005722 512 Jul 14 17:59 MySQLdb -rwxr-xr-x 1 a0005722 a0005722 264078 Jul 12 17:24 _mysql.so -rw-r--r-- 1 a0005722 a0005722 2288 Jul 12 17:24 _mysql_exceptions.py -rw-r--r-- 1 a0005722 a0005722 4156 Jul 12 17:24 _mysql_exceptions.pyc -rwxr-xr-x 1 a0005722 a0005722 24265 Mar 9 2000 formmail.cgi -rwxr-xr-x 1 a0005722 a0005722 149 Jul 12 16:54 test.cgi 226 Transfer complete. _mysql.so is set to read/execute for all, the other py[c] files are set to rw/r/r as they are in the site-packages directory locally. The contents of my test.cgi file are the same as before: #!/usr/contrib/bin/python import MySQLdb print "Content-Type: text/html\n\n" And the error message is the same as before (in the error_log logfile): Traceback (innermost last): File "test.cgi", line 4, in ? import MySQLdb File "MySQLdb/__init__.py", line 27, in ? import _mysql ImportError: File not found [Sat Jul 14 18:32:57 2001] [error] [client x.x.x.x] Premature end of script headers: /usr/home/v1/a0005722/html/cgi-bin/test.cgi Any more ideas? TIA! Ken On Fri, 13 Jul 2001 06:13:50 +0200, gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) wrote: >On Thu, 12 Jul 2001 22:34:46 GMT, Ken <ken_chiba at hotmail.com> wrote: >>Thanks for your continued help... I'm hitting a wall: I've compiled MySQLdb >>(on python 1.5.2) -- I believe that's what my ISP's using, and I have the >>files I (think I) need: >> >>_mysql.so >>_mysql_exceptions.py(c) >>MySQLdb >> - lots of files, and 'constants' within. >> >>I've copied these three files, plus the MySQLdb directory to the >>cgi-bin directory on the host. I placed a simple python script in the >>cgi-bin directory that just has: >> >>#!/usr/contrib/bin/python (the python path) >>import MySQLdb >>print "Content-Type: text/html\n\n" (so the browser doesn't choke). > >Should be ok so far. > >>I get a server 500 message, and checking the error_log file, I get: >> >>Traceback (innermost last): >> File "test.cgi", line 4, in ? >> import MySQLdb >> File "MySQLdb/__init__.py", line 27, in ? >> import _mysql >>ImportError: File not found >>[Thu Jul 12 17:25:48 2001] [error] [client 206.47.244.60] Premature >>end of script headers: /usr/home/v1/a0005722/html/cgi-bin/test.cgi > >It looks suspiciously like a problem with file permissions. You should check >that _mysql.so has read and execute permissions for "others". Taking away both >I could reproduce the above error message. > >In fact, any files in the cgi-bin directory need to be readable by others, >because the webserver usually does run under a different user and group id. > >>I've placed a copy of _mysql.so in both the root cgi-bin directory, >>and into the MySQLdb directory (since __init__.py is located there). >>But no luck! I looked for a _mysql file (without the .so), but could >>not find one. > >That's not the problem. The file is really called _mysql.so and only needs to >be in the cgi-bin directory. > >Gerhard >-- >mail: gerhard <at> bigfoot <dot> 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 matt at mondoinfo.com Tue Jul 3 15:20:54 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Tue, 03 Jul 2001 19:20:54 GMT Subject: using python to append a file References: <13e6b4a6.0107031113.441998c@posting.google.com> Message-ID: <slrn9k46om.rv.matt@happy-hour.mondoinfo.com> On 3 Jul 2001 12:13:41 -0700, Thanh Le <tle at firstlinux.net> wrote: >I am new to Python and was wondering if anyone could show me a way to >append a file (similar to the way Unix does by using >> ). I've tried >using open('file','r+') method and it overwrote whatever i had in that >file. I am sure there is a way to append a file, but havent had much >luck. Thanh, The mode you want is "a" (or "ab"). There's more detail in the description of the open() function at: http://www.python.org/doc/current/lib/built-in-funcs.html Regards, Matt From skip at pobox.com Wed Jul 25 10:49:28 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 25 Jul 2001 09:49:28 -0500 Subject: http In-Reply-To: <20010725053145.31033.qmail@mailFA9.rediffmail.com> References: <20010725053145.31033.qmail@mailFA9.rediffmail.com> Message-ID: <15198.56440.666530.340669@beluga.mojam.com> raghu> i do successfully get the home page of the server (yahoo) that i raghu> am sending my http 'GET' request but i get the following response raghu> We need to use "cookies" to identify u on our system..... raghu> how do i make modification in my program to ACCEPT COOKIES from a raghu> server and at which instance i shall do this either at the first raghu> 'GET' request when requesting for the home page of at the 'POST' raghu> request in my case urlopen or both the times Check out the Cookie module in the Python distribution: http://www.python.org/doc/current/lib/module-Cookie.html It includes a simple example of how to use cookies from Python. If you already have cookies in a file (from your interactive browser, perhaps), you can parse its contents and send the appropriate cookie info along with the original request. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From max at alcyone.com Fri Jul 27 11:36:57 2001 From: max at alcyone.com (Erik Max Francis) Date: Fri, 27 Jul 2001 08:36:57 -0700 Subject: PEP 238 (revised) References: <cp4rrz5onj.fsf@cj20424-a.reston1.va.home.com> <9jrscg$1uf$1@newsy.ifm.liu.se> Message-ID: <3B618A99.532D1801@alcyone.com> Paul Svensson wrote: > I liked the proposal to call '/' division, and '//' quotient; > ambiguities can be resolved by using 'classic division' or 'future > division'. I'm not sure what the attraction is. Division and quotient are synonymous. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ One cannot always be a hero, but one can always be a man. \__/ Goethe Alcyone Systems' CatCam / http://www.catcam.com/ What do your pets do all day while you're at work? Find out. From just at letterror.com Tue Jul 24 05:15:34 2001 From: just at letterror.com (Just van Rossum) Date: Tue, 24 Jul 2001 11:15:34 +0200 Subject: A use for integer quotients References: <mailman.995962124.21692.python-list@python.org> Message-ID: <3B5D3CB6.99C4D02C@letterror.com> Christian Tanzer wrote: > > Just van Rossum <just at letterror.com> wrote: > > > > As for the second line: do you really think > > > int(float(bytes)/float(k)+.5) is signigicantly better for rounding? > > > > 1) only one of the / operands need to be a float to force a float > > outcome, and 2) there is a round() builtin function. Now, if we > > initialize k to a float, we can write it like so: > > > > int(round(bytes/k)) > > My version of the Python Library Reference Manual (Release 2.1, 15 > April 2001) says: > > Conversion from floating point to (long or plain) integer may > round or truncate as in C; see functions floor() and ceil() in the > math module for well-defined conversions. > > That means that one should not use `int` to convert from float to > integer. No using `int (math.floor (a/b))` is quite a mouthful but > everybody caring about version compatibility will have to use such > abominations for a long time. (For instance, my main customer will > ship based products on 1.5.2 for several month to come, the shift to > 2.x *may* happen with the next major release which is planned for > the last quarter of the year). Erm, I did round(a/b), after which a conversion with int() is perfectly safe. But in general, it seems you're entirely correct. Just From jkraska1 at san.rr.com Thu Jul 26 22:05:06 2001 From: jkraska1 at san.rr.com (Courageous) Date: Fri, 27 Jul 2001 02:05:06 GMT Subject: Case insensitivity References: <mailman.995506711.21636.python-list@python.org> <cpvgkofyru.fsf@cj20424-a.reston1.va.home.com> <93d9a839.0107200315.4a0a8c28@posting.google.com> <4n4klt8ud0es25jep3u2v9pj02dctnte0u@4ax.com> <slrn9m0lp9.l0b.quinn@yak.ugcs.caltech.edu> Message-ID: <3ui1mt0e07vgp1b18306jd70pdufs91uva@4ax.com> >I don't understand this assertion, however. What keeps you from continuing to >use vim, ed, windows notepad, whatever, in this case? The language is exactly >the same. Because when identifier and someone else writes IdEnTIFIER, I want to kill them Actually, I'd like to kill them for changing the case at all. Lexigraphic similarity is an important visual cue for spotting things, IMO. C// From guido at python.org Tue Jul 24 17:25:34 2001 From: guido at python.org (Guido van Rossum) Date: Tue, 24 Jul 2001 21:25:34 GMT Subject: PEP0238 lament References: <mailman.995839419.19134.python-list@python.org> <cEN67.17775$EP6.4652917@news1.rdc2.pa.home.com> <cp3d7ngazy.fsf@cj20424-a.reston1.va.home.com> <dzZ67.20235$EP6.5031096@news1.rdc2.pa.home.com> Message-ID: <cpr8v6ow8o.fsf@cj20424-a.reston1.va.home.com> "Terry Reedy" <tjreedy at home.com> writes: > I just discovered how to access older versions of PEPs and checked > 1.3, which I at least partly read and you are right. My view and > memory of the PEP was distorted by anti-int-div float-div-religion > being pushed as fact by the PEP author and some other proponents, who > continue to this day. Yes, the arguments pro have been as heated as those against. :-) I know the PEP author personally, and I assure you he is not of ill will -- just susceptible to unbridled youthful enthusiasm once he's identified a good cause. :-) I will rectify the situation by taking co-authorship of the PEP, so he won't get the blame. > Some current examples nearly identical to several previous attempts: > > * "Many other languages do division correctly - Scheme, Perl and Tcl, > for instance." My claim: this is a religious statement. Obvious > implication of such statements: Python currently does division > wrongly. Subtler implication in at least some statements of this > sort: it is not intelligent to advocate that Python continue doing > division wrongly. Well, IMO, the current division semantics *are* wrong. They are very subtly wrong, just as C's int division semantics are subtly wrong (they give a less useful result for negative numbers). The wrongness doesn't come out immediately, and you can argue about it (so in a sense it is a religious point) but I am not a cultural relativist, and I find the proposed new semantics *better* than the old ones -- otherwise I would never have supported the PEP. I agree that pointing to other languages is unhelpful, unless we understand what the rationale for the decision in a given other language is. As I always say, votes don't count -- arguments do. I'll address the severe backwards compatibility issues in a separate post. > * "Integer division is a lousy tool in this particular example.." > [converting bytes to Kbytes]. Combined with the previous line, this > response denies the possibility of using (bytes + k/2)/k to round (or > that the original poster would have known how to do so) and claims > that int(float(bytes)/float(k)+.5) is factually better. I disagree. Yeah, but not worth arguing about. > * "Nobody said [int division] wasn't of any use, people just claim it > is *less* useful, and so should not be the most easily accessible." This is indeed a poor argument, and not supported by e.g. my survey of the Python standard library. > (from Moshe himself, last night). Since in any situation the most > useful form of division is the one that most easily gives the correct > answer, the premise is incorrect. So why do proponents even now keep > repeating an incorrect and unnecessary claim to justify the change? > Since the difference between '/' and '//' is too trivial to hardly > discuss, I tend to interprete the 'conclusion' to be an attempt, even > now, to justify something that really would be less accessible and > more obnoxious than '//', like div(i,j) or divmod(i,j)[0]. When > proponents of the change keep trying to justify making int div less > accessible, is it any wonder that people think that that is what they > really intend? Good point. > [snip] > > > Situation: Python '/' currently overloads and confounds two > > > arithmetic operations: whole-number result division and > > > fractional result division. This confuses some people. > > > Proposal: Make '/' consistently mean fractional division and > > > introduce a new operator '//' for truncated-result division. > > > Acknowledgement: This semantic replacement is a bit different > > > from most any previous change to Python. Extra care will be > > > needed to make the transition as smooth as possible. > > > This is exactly what the PEP said all the time. > > NO, NO, NO! Contrary to what I said above, it still does not. Moshe > writes, > "Rationale > The behavior of integer division is a major stumbling block ..." Sorry. I didn't realize that your point was that the motivation was wrong. I see this now, and I'll rectify it in the PEP. > This prejudiced view, which too many people have unnecessarily bundled > with the proposed change itself, is quite different from the > division-neutral rationale you quoted above, which locates the > 'problem' in the conflict *between* the two meanings. To repeat: > ''' > Situation: Python '/' currently overloads and confounds two arithmetic > operations: whole-number result division and fractional result > division. This confuses some people. > ''' > which I would today follow with: > ''' > Contention: Even though there will be many transition problems, it > will be in the long term interest of some current and many future > Python programmers to better separate the two meanings of 'division'. > ''' Indeed. I should add that I never meant that the problem was only important for novices or in an educational setting (I only meant this as an example of the kind of problems division crates). Some folks (like Arthur Siegel) have used a contrary novice's or educator's experience as a counter-argument to this. But they fall in the same trap as most of the other proponents of the status quo: because they don't use floats much, they don't care that floating point arithmetic is broken. > Proponents have pointed out that if someone writes a function like > def speed(distance, time): return distance/time > without checking inputs for conformance with preconditions and if > function users violate the preconditions (by feeding in two ints in > this case), the function will generally return a subtlely wrong > answer. Okay, but the same is just as true of > def minmaxpart(n,k): return (n+k-1)/k > The problem is the close overlap of the two meanings, not either in > itself. Hm, IMO the problem is different. Python's numerical model *almost* embeds the integers in the floats. (They should've been called reals, but that mistake is too insignificant to want to fix. :-) In *most* situations, where a float is expected, an int works just as well, and has the same effect as a float with the same mathematical value. Division is the exception and that's where the problem lies. But the converse is *not* true in today's Python: code expecting integers does *not* necessarily work when a float is passed, even if that float has an integral value. This is part of the fabric of Python's semantics. > I strongly recommend that the PEP Rationale (and Abstract) be > rewritten in a neutral manner starting with something like "The > conflict and confusion between the two closely related meanings of > number division is a stumbling block in the writing of correct Python > programs." In suggesting that a straightforward, if troublesome, > separation of meanings be divorced from attempts to assign blame to > one of the two meanings, I am attempting to help make the proposal > more palatable to those, like me, who do not and will not accept the > religious-philosophical views behind that assignment of blame. I think that's a good idea, and I'll try. > > > (Just noticed: http://python.sourceforge.net/peps/pep-0238.html > > > now proposes a *2 year* int/int warning period starting with > > > 2.3. It still needs a stipulation that someone write an intdiv > > > checker to help automate replacements.) > > > > Hm??? I don't see that on the URL you give. Maybe you live in an > > alternate universe where PEP 238 has a different contents than in > > mine? > > Your sarcasism is improving, but look again: > ''' > PEP: 238 > Title: Non-integer Division > Version: $Revision: 1.6 $ > ... > Changing the Semantics of the / Operator > ... > The warning will be off by default in the 2.2 release, and on by > default for in the next Python release, and will stay in effect > for 24 months. > ''' > Shall *I* rub it in? ;-) In *my* universe, 24 months is (24/12 =) 2 > years ;-) Touche. I couldn't find that passage in the PEP, and had even gone to the trouble of searching for "year"... :-( --Guido van Rossum (home page: http://www.python.org/~guido/) From barry at digicool.com Mon Jul 9 21:12:17 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Mon, 9 Jul 2001 21:12:17 -0400 Subject: Bug in rfc822 References: <slrn9khcjv.c7q.philh@comuno.freeserve.co.uk> <QFc27.8798$e5.1167735@newsb.telia.net> <2ih27.49242$he.3402812@e420r-atl1.usenetserver.com> <cp66d2i59b.fsf@cj20424-a.reston1.va.home.com> <slrn9kkcu1.gh1.philh@comuno.freeserve.co.uk> Message-ID: <15178.22129.161470.499112@anthem.wooz.org> >>>>> "ph" == phil hunt <philh at comuno.freeserve.co.uk> writes: ph> I am currently writing a program that reads emails, modifies ph> them in various ways (adding headers, encryption, etc) and ph> outputs the result. This actually sound like a good fit for mimelib, which is arguably misnamed (perhaps it should be called maillib?). ph> As part of this program, I'm writing a mail module that (when ph> finished) could be hacked into a replacement for rfc822. ph> rfc822's functionality is to read mail headers and allow ph> interrogation of their values easily. My module is ph> conceptually on a higher level; containing a MailHeader class ph> which can be used to write as well as read ascii ph> representations of email, and a Mail class that includes the ph> header and the body; again for composition as well as reading ph> emails. (for now, it uses rfc822 to parse incoming headsers). mimelib uses rfc822 for some functionality, but it has its own Parser and Generator class (to go from plaintext -> object tree -> plaintext). It uses rfc822 for some parts of the implementation, such as parsing addresses and realnames out of strings (so it's vulnerable to the RFC 2822 updates as well). ph> When it is written, perhaps it could be considered for ph> eventual inclusion in the standard library (I say eventually, ph> because IMO it'll take me a few attempts to get the API ph> exactly right) That's the hard part, all right! ph> My module doesn't know anything about Mime; which is good ph> because IMO there is room for a library that is higher-level ph> than rfc822 but lower levelb than knowing about Mime. ph> What is the process of getting a module in the standard ph> library? Post the code. :) I definitely want to look at what you've got, to see how well (or if) it fits with mimelib. IMO, if we're going aim at replacing rfc822.py and all the various and sundry MIME attempts, we ought to do it right, and simplify the choices end-users have to make in order to manipulate email messages. Let's collaborate! -Barry From bokr at accessone.com Mon Jul 9 16:35:42 2001 From: bokr at accessone.com (Bengt Richter) Date: Mon, 09 Jul 2001 13:35:42 -0700 Subject: Comment on PEP-0238 In-Reply-To: <20010709101650.B32419@xs4all.nl> References: <5.0.2.1.1.20010708185646.023c9640@mail.accessone.com> <cpsngaja4g.fsf@cj20424-a.reston1.va.home.com> <FFv17.1178$Y6.656565@news1.rdc2.pa.home.com> <cpelrskgrr.fsf@cj20424-a.reston1.va.home.com> <9i7a7k$h9ks6$1@ID-11957.news.dfncis.de> <cp4rsok3i7.fsf@cj20424-a.reston1.va.home.com> <mailman.994531918.7040.python-list@python.org> <9i8512$haelg$1@ID-11957.news.dfncis.de> <cpk81jip74.fsf@cj20424-a.reston1.va.home.com> <3b48de4e.1402626870@wa.news.verio.net> <5.0.2.1.1.20010708185646.023c9640@mail.accessone.com> Message-ID: <5.0.2.1.1.20010709093205.00a5f1e0@mail.accessone.com> At 10:16 2001-07-09 +0200, Thomas Wouters wrote: >On Sun, Jul 08, 2001 at 08:02:27PM -0700, Bengt Richter wrote: > > > >Doesn't fix the problems. What about this: > > > > > >semantics PRECISION, 0: > > > x = 2/7 > > > > > >semantics PRECISION, 100: > > > print x > > > I'm thinking that's trying to peek from one nested scope into another, > > and would be either illegal, trigger a special exception, or get you > > a NameError. I haven't thought this through, but that was > > part of the reason for a block rather than just setting global control > > parameters. I think only new bindings would be affected. Rebinding > > global names to stuff created within a semantic scope might have to carry > > environment along. I haven't thought that through either ;-) > >Note that currently, only functions and classes introduce a new scope, not >other blocks like if, for, try, etc. And this still is no solution: if you >can't carry values from your 'precision scopes' to upper scopes, they are Actually, my scopes were 'semantics' scopes. I just jumped on the precision thing as one possible use. I.e., 'semantics' being one keyword for similar patterns of use. >useless black bloxes that eat everything that goes in :) And an explicit >'return x' is not going to change anything about the problem. By that logic most programs are useless black bloxes ;-) (I.e., since they don't have an "upper scope" to carry values to). I realize about the blocks. I was thinking def/class/lambda/something. >And what about this, for that matter: > >def printme(x): > semantics PRECISION, 100: > print x It would seem to call for semantic coercion when using variables with different semantics. To carry the information about applicable semantics would be something like carrying bindings in a closure, I'm thinking. The latter is what I was getting at with "carrying environment" above. >semantics PRECISION, 0: > x = 2/7 > printme(x) Meaning 2/7 is evaluated with (PRECISION,0) rules, and the resulting value representation includes a reference to those rules (because the '/' operator is overridden within the scope to do that). The symbol x is bound to the value, and the value reference is passed to printme, which will have to deal with it according to its context. OTTOMH, perhaps the semantics keyword could cause the following block to be translated to an anonymous function (like lambda but full def capability) and then a reference to it would be passed to a standard method of the semantics-altering system object referred to in the semantics arg list, e.g., one bound to the symbol PRECISION in this case. If you call the tuple of semantics args t, and the lambda of the block f, then semantics processing might call t[0].__SEMANTICS__(f,t[1:]) by convention. Thus PRECISION.__SEMANTICS__(f,t[1:]) would see the lambda and be able to fiddle with its environment before it got executed. For PRECISION I assume that would involve overrides for some math operations. After the mods, which semantics knows nothing about, semantics would execute the lambda. If you had a semantics INTEGER_DIV: ... block, then INTEGER_DIV.__SEMANTICS__(f,()) would be called, perhaps overriding the '/' operator with divmod(x,y)[0] and % with divmod(x,y)[1] for the ensuing lambda execution. >(or even with printme defined as > >semantics PRECISION, 100: > def printme(x): > print x That would be ok for access within the scope, but it wouldn't be visible from the outside of the lambda. This could be an instance of PIHCAL (post in haste, cringe at leisure) but it's fun to toss around ;-) Regards, Bengt Richter From akuchlin at mems-exchange.org Thu Jul 5 12:19:42 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 05 Jul 2001 12:19:42 -0400 Subject: Most important text processing examples References: <mailman.994302849.7562.python-list@python.org> Message-ID: <3dr8vvqrfl.fsf@ute.cnri.reston.va.us> "Dr. David Mertz" <mertz at gnosis.cx> writes: > Always so impressed by the Python discussion group, I figure I will ask > its advice. I have recently contracted to write a book called _Text > Processing in Python_ for Sybex. The proposal and outline can be Excellent! "Text Processing in Python" has been floating on my TODO list for some time, but now I don't have to write it! There's nothing in my outline that's not in yours. Is chapter I, on interpreter basics, really necessary, though? Lots of people have written such introductory guides, and they all come out looking much the same anyway, so you could save some pages and writing time by not writing one more such introduction. "Mastering Regular Expressions" doesn't explain Perl's scalars; does "Data Munging" contain an introduction to the language? If not, then why should the Python book contain one? Oh, and if you haven't completed negotiating the contract yet, you might want to ensure that the rights revert to you if the book goes out of print. Then you could put the text up on a Web page if that happens. --amk From ralf.muschall at alphasat.de Tue Jul 31 01:51:11 2001 From: ralf.muschall at alphasat.de (Ralf Muschall) Date: 31 Jul 2001 07:51:11 +0200 Subject: Typing system vs. Java References: <mailman.996540777.8399.python-list@python.org> Message-ID: <u7puah1wa8.fsf@hpeesof.asc> <brueckd at tbye.com> writes: > I guess my thinking is something like this: _if_ the language forces the > programmer to be very involved with details like type information, then > some sort of strict, compile-time checking is a Good Thing. _If_, however, > the programmer doesn't have to deal with those issues (or at least not to > the same degree), then many of the related problems go away (or are > present to a much smaller degree), and therefore the ability to check for > those problems is much less beneficial. For example, Python handles most This is only valid for very simple type systems. In a really statically typed language, your example would go as follows (I don't speak curl, probably my stuff is no valid curl syntax): > let v = new # for now, leave it to the language what type v is > let s = "hi" # the language sees that the type of s must be String > {v.append s} # from this line the language sees that the type of v must have been # Array of String, since anything else would not fit. > let i:int = v[0] # ERROR: can't assign a String to an int True - if you want to protect yourself against mistakes, add explicit type information. This is one of the purposes it is intended for - the other one is to allow the compiler to decide all types at compile time, thus avoiding boxed data, checks etc. at runtime. Without the type info in the last line, the compiler would create an i of type int. Without giving any type hints, two things can happen in a statically typed language: (1) The compiler solves the constraints and finds all types, (2) it can't since there are more solutions and give an error message (or assumes a default). E.g. in hugs you get 2/3 -> 0.6666666667 (there are no typecasts at all, it interprets the "2" and "3" as Double at read time, since integers cannot be divided and the defaults tell it to assume Double rather than Rational). (2::Rational)/3 gives the fraction 2/3 (printed as "2 % 3"). Ralf From aleaxit at yahoo.com Fri Jul 13 07:35:57 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 13 Jul 2001 13:35:57 +0200 Subject: Maintaining the Python FAQ References: <mailman.994428256.27172.python-list@python.org> <cpvgl6jbyz.fsf@cj20424-a.reston1.va.home.com> <jpb-BA1E76.20231012072001@news-server.cfl.rr.com> <slrn9ksn6c.jl.grante@tuxtop.visi.com> Message-ID: <9immeu0129m@enews1.newsguy.com> "Grant Edwards" <grante at visi.com> wrote in message news:slrn9ksn6c.jl.grante at tuxtop.visi.com... ... > >To print it, so it can be read while I'm away from the net? > Away from the net? > Huh? Why would you ever be away from the net? ;) There isn't much net-connectivity on the buses I take to commute between work and home. So I make sure I have all the materials I may need, to make productive use of that couple of hours per day, in a local copy on my ultralight laptop. Until a couple of months ago, when I didn't have a laptop light and small enough to allow sensible use on a small seat in a crowded bus, I used to have to sacrifice dead trees to Athena, Goddess of Wisdom (aka "printing") for similar purposes. Alex From slinkp23 at yahoo.com Tue Jul 10 14:44:50 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Tue, 10 Jul 2001 18:44:50 GMT Subject: Python speed References: <roG27.666914$166.13798179@news1.rdc1.bc.home.com> Message-ID: <3B4B4BA9.DDB31826@yahoo.com> tyler spivey wrote: > > python is way slower than c. that's no big deal. but: > 1. is python slower than perl > 2. is python slower than ruby > 3. is python slower than lua (some kind of scripting language) > i want to know if python, or lua would be a good thing to design a mud in. probably not lua since i think it is dead. We've had some recent threads about this... You may want to see http://www.bagley.org/~doug/shootout/ but be sure to read the fine print to understand what the tests really do and don't tell you. For your application I doubt there will be any speed problem with python or any other comparable language. I noticed a MUD server in the Useless Python source code examples: http://home.jam.rr.com/mspiggie/ > why are they way more modules for ruby than python? Well, there's a lot of good stuff not included in the standard distribution, either because it's too large, or because it's not of sufficient general interest. Check out the Vaults of Parnassus: -- ................... paul winkler .................... custom calendars & printing: http://www.calendargalaxy.com A member of ARMS: http://www.reacharms.com home page: http://www.slinkp.com From jwbaxter at spamcop.com Mon Jul 9 21:56:25 2001 From: jwbaxter at spamcop.com (John W. Baxter) Date: Mon, 09 Jul 2001 18:56:25 -0700 Subject: Bug in rfc822 References: <slrn9khcjv.c7q.philh@comuno.freeserve.co.uk> <QFc27.8798$e5.1167735@newsb.telia.net> <2ih27.49242$he.3402812@e420r-atl1.usenetserver.com> <cp66d2i59b.fsf@cj20424-a.reston1.va.home.com> <15177.50705.483826.728871@beluga.mojam.com> <mailman.994696935.26488.python-list@python.org> Message-ID: <090720011856254589%jwbaxter@spamcop.com> In article <mailman.994696935.26488.python-list at python.org>, Frank "Fistolina" Lomax <lomax at pumpichank.com> wrote: > bass tech Sorry, but my not so nimble mind wondered why a technician is needed to deal with those passing fish on a musical tour. Probably a union thing. ;-) --John From root at rainerdeyke.com Tue Jul 24 11:24:37 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Tue, 24 Jul 2001 15:24:37 GMT Subject: Another Proposal re- Integer Division References: <mailman.995866298.23496.python-list@python.org> <eppstein-E19F08.00451323072001@news.service.uci.edu> <3B5BDCB4.A2010560@letterror.com> <GbW67.19921$EP6.4914854@news1.rdc2.pa.home.com> <3B5C3713.A5201C5A@letterror.com> <mailman.995966145.31953.python-list@python.org> <3gDsvgAkvUX7EwIv@jessikat.fsnet.co.uk> <3B5D6C54.ADE36880@letterror.com> <mailman.995980002.564.python-list@python.org> Message-ID: <Vqg77.3376$Xk6.761393@news2.rdc2.tx.home.com> "Chris Gonnerman" <chris.gonnerman at newcenturycomputers.net> wrote in message news:mailman.995980002.564.python-list at python.org... > Given: Portable integer division code between 2.2 and 2.4 > will be ugly, i.e.: > > floor(n/2) That would be incorrect. >>> a = 11111111111111111111111111111111111111111111111111111111111111111l >>> a / 2 5555555555555555555555555555555555555555555555555555555555555555L >>> floor(a / 2.0) 5.5555555555555555e+063 >>> long(floor(a / 2.0)) 5555555555555555511613257015757436156819784538568358631420461056L There is no excuse for using floating points, ever. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From eppstein at ics.uci.edu Sun Jul 15 22:28:17 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Sun, 15 Jul 2001 19:28:17 -0700 Subject: [Python-Dev] Re: PEP: Defining Unicode Literal Encodings (revision 1.1) References: <LNBBLJKPBEHFEDALKOLCGEHKKOAA.tim.one@home.com> <3B50C1FF.7E73739B@ActiveState.com> <200107150126.VAA23781@cj20424-a.reston1.va.home.com> <3B51CFB0.ACE9070D@ActiveState.com> <200107151729.NAA00455@cj20424-a.reston1.va.home.com> <mailman.995220627.11627.python-list@python.org> Message-ID: <eppstein-8E8777.19281715072001@news.service.uci.edu> In article <mailman.995220627.11627.python-list at python.org>, "M.-A. Lemburg" <mal at lemburg.com> wrote: > Even though putting the information into a comment would > indeed be easier to implement, I think that from a design point > of view, it is a hack and not a clean design. I tend to think putting anything at all in the text of the file is a hack and not a clean design -- this is meta-information rather than content, right? But maybe as long as you're going to do that you should go all the way and have some kind of "meta" directive that allows MIME directives beyond just charset=... -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From sholden at holdenweb.com Mon Jul 2 17:43:30 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 2 Jul 2001 17:43:30 -0400 Subject: amkCrypto/mxCrypto on Win32 with Visual C++ Message-ID: <HS507.15883$Lk6.1149673@e420r-atl2.usenetserver.com> I'm trying to get the amkCrypto (modified mxCrypto) package working under Win32, but Visual C++ is barfing about the declaration (and concurrent initialization) of public member variables. For example, mxCrypto.h includes the following declaration: class StreamCipher { protected: int mode; public: static int const blocksize = 1; static int const keysize = 0; StreamCipher(PyStringObject *v, int cipher_mode); ~StreamCipher(); PyObject *encrypt(PyStringObject *v); PyObject *decrypt(PyStringObject *v); int getmode(void) { return mode; }; }; The compiler says that the public member variables (blocksize and keysize) cannot be intialized in the header file. But clearly this code works under some compilers... Has anyone sucessfully installed this code on Windows? Nothing on Google to suggest previous problems. Thanks in advance Steve -- http://www.holdenweb.com/ From paul at boddie.net Thu Jul 19 04:41:36 2001 From: paul at boddie.net (Paul Boddie) Date: 19 Jul 2001 01:41:36 -0700 Subject: Which Python version to code for? References: <tlbbqas5b6hvff@corp.supernews.com> <9j50q4$a3f9@news1.gtech.com> Message-ID: <23891c90.0107190041.4b1f3c97@posting.google.com> "Peter Milliken" <peter.milliken at gtech.com> wrote in message news:<9j50q4$a3f9 at news1.gtech.com>... > > "Charles Crain" <chuxxx at swbell.net> wrote in message > news:tlbbqas5b6hvff at corp.supernews.com... > > > > It occurs to us that this is a general question facing anyone wishing to > > release a Python product. Do you code for the latest and greatest, or do > > you try to figure out what release is most "common" (in this case, still > > 1.5.2, since it ships with most major Linux distros) and code for that? > > In my opinion (for what it is worth :-)), 1.5.2 seemed to be a very popular > and stable release, so unless 2.X brought in some feature that you feel you > *really* can't do without, then 1.5.2 would be a pretty reasonable baseline > to use. This seems like sensible advice. Python 1.5.2 was very popular, stable and widely distributed, but if you must use a later release, I would think that Python 2.0(.1) is the one to support, given that some significant and useful features were introduced for that release: Unicode support being a notable example. Other things you might like in 2.x, but which involve syntactic incompatibilities with 1.5.2, include the augmented assignment constructs. Personally, I wouldn't recommend breaking compatibility with 1.5.2 through the use of such constructs unless they give you the means to achieve significant performance improvements which can't reasonably be achieved any other way. I think it's sensible to suggest that the simpler the module dependencies of your application, the less justifiable it is to insist on the latest and greatest Python release. If you only use standard modules which exist in acceptable forms for 1.5.2, potential users will be dissatisfied if you want them to upgrade to 2.1 (for example) purely because you've used some feature of that release more as a luxury than as a necessity. Paul From jwbaxter at spamcop.com Fri Jul 27 20:05:26 2001 From: jwbaxter at spamcop.com (John W. Baxter) Date: Fri, 27 Jul 2001 17:05:26 -0700 Subject: PEP 238 (revised) References: <mailman.996267654.842.python-list@python.org> Message-ID: <270720011705269800%jwbaxter@spamcop.com> In article <mailman.996267654.842.python-list at python.org>, Tim Peters <tim.one at home.com> wrote: > Here's one way to tell: > > >>> import math > >>> math.atan2(x, x) > -3.1415926535897931 > >>> math.atan2(0, 0) > 0.0 > >>> > > That is, I really did get minus 0 on Windows! BTW, that also hints at why > signed zeroes can be a life-saver when doing complex arithmetic. However, > whether atan2() handles signed zeroes correctly also varies across > platforms. OK, here is a PowerPC result which suggests--if I'm understanding you--that >>> -0.0 0.0 on PowerPC is a printing issue not a real +0.0 value issue: >>> math.atan2(-0.0, -0.0) -3.1415926535897931 >>> math.atan2(0.0, 0.0) 0.0 The Python is: Python 2.1 (#1, 04/22/01, 11:06:25) [GCC Apple DevKit-based CPP 6.0alpha] on darwin1 Type "copyright", "credits" or "license" for more information. The machine is Dual 533 Mac "G4" running Mac OS X 10.0.4. Just in case this all show up in published notes somewhere. --John From mal at lemburg.com Sat Jul 14 07:32:10 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Sat, 14 Jul 2001 13:32:10 +0200 Subject: PEP: Defining Unicode Literal Encodings (revision 1.1) References: <LNBBLJKPBEHFEDALKOLCAEEMKOAA.tim.one@home.com> <3B4F6E98.733B90DC@lemburg.com> <004c01c10be8$af2face0$4ffa42d5@hagrid> <3B4F746C.827BD177@lemburg.com> <15183.35133.264728.399408@beluga.mojam.com> Message-ID: <3B502DBA.761D4F69@lemburg.com> Skip Montanaro wrote: > > mal> Here's an updated version which clarifies some issues... > ... > mal> I propose to make the Unicode literal encodings (both standard > mal> and raw) a per-source file option which can be set using the > mal> "directive" statement proposed in PEP 244 in a slightly > mal> extended form (by adding the '=' between the directive name and > mal> it's value). > > I think you need to motivate the need for a different syntax than is defined > in PEP 244. I didn't see any obvious reason why the '=' is required. I'm not picky about the '='; if people don't want it, I'll happily drop it from the PEP. The only reason I think it may be worthwhile adding it is because it simply looks right: directive unicodeencoding = 'latin-1' rather than directive unicodeencoding 'latin-1' (Note that internally this will set a flag to a value, so the assigning character of '=' seems to fit in nicely.) > Also, how do you propose to address /F's objections, particularly that the > directive can't syntactically appear before the module's docstring (where it > makes sense that the module author would logically want to use a non-default > encoding)? Guido hinted to the problem of breaking code, Tim objected to requiring this. I don't see the need to use Unicode literals as module doc-strings, so I think the problem is not a real one (8-bit strings can be written using any encoding just like you can now). Still, if people would like to use Unicode literals for module doc-strings, then they should place the directive *before* the doc-string accepting that this could break some tools (the PEP currently does not restrict the placement of the directive). Alternatively, we could allow placing the directive into a comment, e.g. #!/usr/local/python #directive unicodeencoding = 'utf-8' u""" This is a Unicode doc-string """ About Fredrik's idea that the source code should only use one encoding: Well, that's possible with the proposed directive, since only Unicode literals carry data for Python is encoding-aware and all other parts are under the programmer's control, e.g. #!/usr/local/python """ Module Docs... """ directive unicodeencoding = 'latin-1' ... u = "H?ll? W?rld !" ... will give you pretty much what Fredrik asked for. Note that since Python does not assign encoding information to 8-bit strings, comments etc. the only parts in a Python program for which the programmer must explicitly tell Python which encoding to assume are the Unicode literals. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From max at alcyone.com Fri Jul 20 22:41:56 2001 From: max at alcyone.com (Erik Max Francis) Date: Fri, 20 Jul 2001 19:41:56 -0700 Subject: BURNING EARTHSHAKING Tuple Question References: <5e8bd451.0107191249.3c0d9f21@posting.google.com> Message-ID: <3B58EBF4.F24E5129@alcyone.com> kevin parks wrote: > By the way is tuple pronounced tOOple (god i hope it is), or is it > pronounced > like the word "couple". Tuple like "couple" would be too high brow. I've always heard it pronounced to rhyme with _couple_, but a mathematician friend of mine insisted that it was pronounced the other way. When I checked a dictionary it said both were legal. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ But we go on pretending / Stories like ours / Have happy endings \__/ The Russian and Florence, _Chess_ Esperanto reference / http://mirror/alcyone/max/lang/esperanto/ An Esperanto reference for English speakers. From tim.one at home.com Mon Jul 23 22:00:38 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 23 Jul 2001 22:00:38 -0400 Subject: PEP0238 lament In-Reply-To: <gmhplt4kitb3514p6kkdfg1kgl1eqr1fqg@4ax.com> Message-ID: <LNBBLJKPBEHFEDALKOLCAEIGLAAA.tim.one@home.com> [Tim] > try-giving-it-a-rest-for-12-hours?-ly y'rs - tim [Stephen Horne] > Sorry - insomnia brought on by anxiety due to the anticipation of > severe damage to my professional reputation and a lot of unnecessary > work. OK, then give it a rest for a whole week. You may be close to setting a record for sheer repetition, and I can assure you Guido doesn't have the time to read 50 copies of the same basic rant -- in reality, you're doing the best job you possibly could of encouraging him to tune out (he won't, but I'd be surprised if he didn't skip your posts by now). > If you had as many cases of "?"+str(Amount/100)+"."+str(amount%100) > and similar in your code as I do - most of which I don't even know who > has it or who might have tweaked versions (and I know as an absolute > fact those warnings will either not be seen at all or will be ignored) > you'd be just as pissed of as I am. Pissed off at what? Nothing has changed. It's possible nothing will. It's certain nothing will for half a year at earliest. It's being discussed -- or at least *was*, for a little while. > I trusted Python and I put myself out on a limb advocating it - and > now that limb is being deliberately broken - and I don't accept that > the change is such an undeniably great idea in the long term, let > alone in the here and now. In my position, how would *you* feel. I'm not prone to getting emotionally involved in tech debates; it's happened, of course, but it's never been fruitful when it has, and posting when pissed is right out. > I just happened to start keeping track of the newsgroup in the last > couple of days - just in time to see the oncoming disaster, People have been predicting Python Disaster for a decade. Is *anything* new on Usenet <0.7 wink>? > but apparently too late to do the slightest thing about it. If you believed that, would you be c.l.py's most-frequent poster over the last several days? > How many people like me aren't going to find out until *after* > everything goes tits up? Most of them would find out late; whether it would be a disaster depends on the details that a *few* people have been trying to talk about. From bill-bell at bill-bell.hamilton.on.ca Sun Jul 1 09:47:40 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Sun, 1 Jul 2001 09:47:40 -0400 Subject: commenting code well In-Reply-To: <993979929.553.457.l6@yahoogroups.com> Message-ID: <3B3EF1BC.30875.2C92629@localhost> On Sat, 30 Jun 2001, Rob Andrews wrote: >My code comments are often weak, if existent. What is good practice >for commenting code? I wonder if Rob Andrews is still reading this thread and, if he is, whether he has found Steve McConnell's treatment of comments in "Code Complete" useful? From steve at lurking.demon.co.uk Mon Jul 23 16:47:45 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Mon, 23 Jul 2001 21:47:45 +0100 Subject: PEP0238 lament References: <3B5B37B9.4D7A80CD@Lugoj.Com> <LNBBLJKPBEHFEDALKOLCMECPLAAA.tim.one@home.com> <mailman.995900686.5170.python-list@python.org> <9jhmoc$9nm$1@panix6.panix.com> Message-ID: <lnvoltg0h2gqmcfbsks7ppbt1cmh4pav4p@4ax.com> On 23 Jul 2001 13:26:36 -0400, roy at panix.com (Roy Smith) wrote: >> Tim> Why is that? It's because unlike any other builtin arithmetic >> Tim> operation, "/" today can cause *catastrophic* loss of information >> Tim> silently, and in ordinary cases. > >Surely assignment causes catastrophic loss of information, no? If I >say "x = 4", havn't I lost the old value of x? Depends if another identifier references the same object - to reopen another can of worms ;-) From paulp at ActiveState.com Sun Jul 8 17:34:19 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sun, 08 Jul 2001 14:34:19 -0700 Subject: Unicode -> String problem References: <20010708204337.MJGP11827.femail4.rdc1.on.home.com@jparlar> Message-ID: <3B48D1DB.C3F726C9@ActiveState.com> Jay Parlar wrote: > >... Is there a simple way to convert the unicode text to > StringType, removing the resulting unicode strings for unrepresentable > characters? >>> import codecs >>> codecs.ascii_encode(u"foo\u3333bar", "ignore") ('foobar', 7) -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From claird at starbase.neosoft.com Wed Jul 25 15:13:20 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 25 Jul 2001 14:13:20 -0500 Subject: How to telnet to other unix machines and grep log files etc? References: <fa7108b0.0107250742.7b38c678@posting.google.com> <slrn9lu024.vpg.quinn@regurgitate.ugcs.caltech.edu> <slrn9lu0fg.vpg.quinn@regurgitate.ugcs.caltech.edu> Message-ID: <3E9DA22F3FF99072.0E52F24E38E09F05.89F1DF1C896E89C5@lp.airnews.net> In article <slrn9lu0fg.vpg.quinn at regurgitate.ugcs.caltech.edu>, Quinn Dunkan <quinn at regurgitate.ugcs.caltech.edu> wrote: >On 25 Jul 2001 17:22:12 GMT, Quinn Dunkan <quinn at regurgitate.ugcs.caltech.edu> >wrote: >>On 25 Jul 2001 08:42:44 -0700, Chris <bit_bucket5 at hotmail.com> wrote: >>>Relative unix newbie. Would like to write a python script to do what >>>I do manually--telnet to two different unix machines from a third unix >>>machine. Grep through some log files, gather the grep results from >>>the different machines and spit them out. I think I need to do >>>something with popen, or popen2, or ??? I don't know where to start. >>>Any pointers much appreciated. >> >>This is a shell task: >> >>(ssh machine1 'grep foo /sys/log/bar'; >> ssh machine2 'grep baz /sys/log/faz') >results >> >>Create an RSA key with no passphrase if you don't want to have to type >>passwords all the time. > >BTW, if you *really* wanted to use python for it, you couldn't use popen >(stdio wins again!). You'd need to use ptys to trick telnet that it's being >run by a terminal. That means either figuring out how unix ptys work and >using pty.py, or installing expect and ExpectPy. Both are more work than >installing openssh (and once you do that you can toss telnet anyway). > >Unless, of course, machine{1,2} don't have ssh and you have no control over >them. There are any number of ugly hacks you could do at that point, and >expect is one of them. > >or-publish-the-logs-on-the-web-and-use-wget-ly y'rs Exactly. That is, ssh is a fine way to solve these problems--unless you don't have control over the re- mote end. Long term, ExpectPy might be in better shape than you realize. There are glimmers of hope that Expect might be rewritten in a way that eases maintenance of ExpectPy (and maybe brings Win* within range, too). In the meantime, you might consider using stock Expect. You might be able to get your job done with just a few lines. If you need more, there are plenty of ways to tie together Tcl and Python codings. -- Cameron Laird <claird at NeoSoft.com> Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From bill-bell at bill-bell.hamilton.on.ca Thu Jul 19 13:04:28 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Thu, 19 Jul 2001 13:04:28 -0400 Subject: Examples of using XML and Python? In-Reply-To: <995561518.767.71055.l9@yahoogroups.com> Message-ID: <3B56DADC.23924.3AF08E9@localhost> "Mark Ainsworth" <marka at sundance.com> wrote, in part: > Has anyone got any simple examples of using Python and XML? The plan > is to use XML as the data format for information files. These need to > be able to be read, for data extraction, and also written too for > modification. "XMLtreeview" under "Cool Contribs" in the demo that is included with wxPython shows how to ~read~ an XML doc into a tree control. I can't evaluate this in comparison with what Cameron Laird has already posted in response to your query; however, XMLtreeview is a particularly easy-to-read example. From m.mariani at imola.nettuno.it Tue Jul 24 10:13:40 2001 From: m.mariani at imola.nettuno.it (Marco Mariani) Date: Tue, 24 Jul 2001 16:13:40 +0200 Subject: re bad leadership In-Reply-To: <00af01c11440$87a53c20$0101010a@local> Message-ID: <20010724161340.A19700@zoidberg> On Tue, Jul 24, 2001 at 07:59:45AM -0500, Chris Gonnerman wrote: > Malevolent Dictator For Life > > While I'm not happy with Guido over this change (because it makes cross- > version code very ugly, and introduces errors in meaning that may be hard > to detect) I would not call him such a rude name. Of course not. Guido is not bad at all, he's just chaotic good :-) From zdweeb at yahoo.com Thu Jul 19 21:48:26 2001 From: zdweeb at yahoo.com (z) Date: Fri, 20 Jul 2001 01:48:26 GMT Subject: Distributing a Python app References: <mailman.995588673.14353.python-list@python.org> Message-ID: <K5M57.80950$EF2.11337237@typhoon.nyroc.rr.com> I have had excellent success with the Py2Exe http://starship.python.net/crew/theller/py2exe/ and the Inno http://www.jrsoftware.org/isinfo.htm combo. My apps are wxPython and python, no problems. I am able to run them on Win2K and Win NT sp5. I have on my todo list a python script to automate the building of the Inno config script. -- --zDweeB .:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._. ASCII art?? I thought it was a regular expression! "Tim Peters" <tim.one at home.com> wrote in message news:mailman.995588673.14353.python-list at python.org... > [Gordon McMillan] > > ... > > As far as a free Windows installer (for py2exe or [Gordon's] Installer), > > Inno gets good reviews. I don't know anyone who can stand InstallShield. > > Wise is the commercial one most people use. > > FYI, I'm seriously looking at switching the PythonLabs Windows installer > over to Inno. It's simple (as such things go) and easy to use (as such > things go). We've been happy with the Wise installer Mark Hammond talked > them into letting us use in '94 or '95, but it's showing its age and I'm > apparently not nearly as persuasive as Mark (they don't even acknowledge > receiving my emails -- but then I wouldn't either <wink>). > > ms-should-bundle-python-as-a-public-service-ly y'rs - tim > > From root at [127.0.0.1] Sat Jul 7 11:02:25 2001 From: root at [127.0.0.1] (nobody) Date: Sat, 07 Jul 2001 15:02:25 GMT Subject: problem with popen on Win32 Message-ID: <5wF17.2821$V5.4774@news1.rivrw1.nsw.optushome.com.au> I'm using ActivePython 2.0/2.1 on W2K.. foo.py: import os child = os.popen("cmd /c bar.bat") for line in child.readlines(): pass child.close() bar.bat: start calc foo.py is supposed to start bar.bat, wait for it to finish, and then continue. However, bar.bat finishes but foo.py won't continue until calc is closed. Is it possible to get popen to wait only for the program specified to complete, not all of the grandchildren? From hinsen at cnrs-orleans.fr Wed Jul 11 05:59:02 2001 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 11 Jul 2001 11:59:02 +0200 Subject: European Python Meeting report References: <mailman.994840578.17876.python-list@python.org> Message-ID: <m3n16bbxcp.fsf@chinon.cnrs-orleans.fr> Marc Poinot <Marc.Poinot at onera.fr> writes: > - We were not a lot of Python users (about 20), and it looks like we have > a lot of work to make it an European event. But the Python users there > though it was worth trying again. Definitely. > We also had the first European Python Meeting supper in Bordeaux > downtown (with foie gras and wine), nine of us where there. No fried python, of course. We are not cannibals. Finally, let's not forget to thank Marc for organizing all this! We need more idealists of his kind ;-) 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 noselasd at frisurf.no Fri Jul 13 06:30:55 2001 From: noselasd at frisurf.no (Nils O. Selåsdal) Date: Fri, 13 Jul 2001 12:30:55 +0200 Subject: Comparison of different types does not throw exception References: <mailman.994953783.6278.python-list@python.org> Message-ID: <O4A37.23$Fv3.59@news1.oke.nextra.no> "Gordon Williams" <g_will at cyberus.ca> wrote in message news:mailman.994953783.6278.python-list at python.org... > I would like to know why python does not produce an exception when a > comparison of objects of different types is made. For example: > > >>> 1 < "aaa" > 1 > > I cant see why anyone would like to have comparisons of different types as > it has no meaning. It is a programming error and an exception should be > produced. > > This one tripped me up in an assert statement for a couple of hours. The > assert statement was returning true when it should have been false to give > me a warning that there was a problem. It was something like: > > lengthA= 3 > lengthB= "2" > > assert lengthA <= lengthB > > and was returning true In any OO language its desired to take advantage og polymorphisme, and let comparison between diffrent objects be allowed.The programmer is responsible, for providing comparison functions. I wanna know if my User also equals my SecureUser.... From tjreedy at home.com Sun Jul 29 21:21:35 2001 From: tjreedy at home.com (Terry Reedy) Date: Mon, 30 Jul 2001 01:21:35 GMT Subject: FEEDBACK WANTED: Type/class unification References: <cp66cd12yp.fsf@cj20424-a.reston1.va.home.com> <mailman.996351001.12473.python-list@python.org> <cpwv4syrzd.fsf@cj20424-a.reston1.va.home.com> <3B643C58.1C6C94F9@ActiveState.com> <200107291708.NAA07525@cj20424-a.reston1.va.home.com> <3B6465E0.368A104@ActiveState.com> <mailman.996447295.25645.python-list@python.org> Message-ID: <zE297.50718$EP6.11188601@news1.rdc2.pa.home.com> I find it interesting that the hackish hook you first added so one person could write C extension classes should be a doorway to unification. Did you have this in mind when you wrote it? --- Re the 17 line paragraph condenses as "(Confusion alert: ... To add to the confusion, ...slot!)" I would remove the outer () and add label 'Explanation:'. I would also remove the two confusion alerts -- since your explanation is pretty straightforward, given the knowledge assumed and the previous reminder that 'type' is it own type, I find them more distracting than helpful. --- "(The names aren't quite symmetric; tp_free() corresponds to tp_alloc(), which is fine, but tp_dealloc() corresponds to tp_new(). Maybe the tp_dealloc slot should be renamed?)" I first guessed that dealloc corresponded to alloc. Since it is most like __del__, how about delete? --- Terry J. Reedy From peter at engcorp.com Wed Jul 11 18:02:58 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 11 Jul 2001 18:02:58 -0400 Subject: Is Python Dead? Long Live Python! References: <MNS%6.355$Xs4.225014@news.pacbell.net> <mailman.994599260.9137.python-list@python.org> <5174eed0.0107091109.d3a53f6@posting.google.com> <mailman.994711525.24100.python-list@python.org> <9ifgpe$1b5$1@verence.demon.co.uk> Message-ID: <3B4CCD12.A4992E65@engcorp.com> Paul Wright wrote: > > In article <mailman.994711525.24100.python-list at python.org>, > Paul Prescod <paulp at ActiveState.com> wrote: > >> > From what I can tell, PHP and Ruby > >> > are flying past Python in acceptance rates. The difference that I see > >> > in these groups, is a sensitivity to industry, rather than an > >> > adoration for pure acedemic elegance. > > > >I think even the Ruby people would be surprised to hear about Edward's > >statistics about it flying past Python! > > Shurely he means that the derivative of the number of users wrt time is > greater for Ruby than for Python, which may be true because Python has a > far larger user base and so is nearer "saturation". Wouldn't this only hold true if Ruby's _potential_ user base were sufficiently large compared to Python's potential user base? I believe that many more people will eventually use Python than will use Ruby (language war thread!). That might mean Python's rate of increase in user base per unit time is still larger than Ruby's. (And this certainly fits with my own observations over the last year.) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From new_name at mit.edu Mon Jul 2 23:09:07 2001 From: new_name at mit.edu (Alex) Date: 02 Jul 2001 23:09:07 -0400 Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> <bebbba07.0107021206.70a22aa8@posting.google.com> <mailman.994111084.403.python-list@python.org> <etdofr32d4f.fsf@lola-granola.mit.edu> <mailman.994126144.24483.python-list@python.org> Message-ID: <etdsngeg14c.fsf@w20-575-3.mit.edu> > What I meant is that for each airplane, he needs to calculate the > distance to every other airplanes; that's O(N^2). ;-) And what I meant was that he doesn't. *shrug* > Ultimately, though, it depends on how the data (from the radar) are > given to Python script, and this wasn't clear in the original post. How does the general collision-detection algorithm depend on the format of the data received from the radar? > Judging by his thin skin, I don't think it was a serious post. I think that both his original post and his response were pretty reasonable, actually. Alex. From sh at ttsoftware.co.uk Mon Jul 23 06:05:26 2001 From: sh at ttsoftware.co.uk (Steve Horne) Date: Mon, 23 Jul 2001 11:05:26 +0100 Subject: PEP0238 lament References: <3B5B3676.40F39389@alcyone.com> <eppstein-03540D.13070222072001@news.service.uci.edu> <mailman.995836120.7223.python-list@python.org> <vyIKbWAP62W7EwC+@jessikat.fsnet.co.uk> <9jg6ei$ges7$1@sky.inp.nsk.su> <23891c90.0107230118.752e3f00@posting.google.com> Message-ID: <u3tnlt0480u7o655p988bsr9p3vc1g14ee@4ax.com> On 23 Jul 2001 02:18:29 -0700, paul at boddie.net (Paul Boddie) wrote: >I can see people seriously suggesting a "pythonfork" project if the >debate gets any more intense. :-O I've had idle thoughts for some time about a language that would allow you to define - within the language itself - the syntax and semantics for sublanguages. Only the lexical rules would be fixed, though there would need to be several built-in sublanguages - grammar and translation definition, simple compile-time imperative and simple run-time imperative being the obvious ones. The thought was originally provoked by wanting to support many different paradigms efficiently and concisely in the same language - if anyone comes up with a new paradigm, they just create a library that defines a suitable grammar and translation and, hey presto, anyone can use it without changing languages, and without discarding code written for other paradigms. It suddenly seems so much more like a practical idea. >> Guys, if you really need something returning floats for division, make it >> new operator, I guess everyone could be made happy with 1/2 == 0 and 1//2 == >> 0.5. > >The most sensible suggestion yet! I was reading the previous messages >in this thread waiting for someone to suggest this, and it's about >time someone did! There's a lot of weight behind adding a new >operator, yet most people seem to advocate adding the // operator and >then *changing* the / operator... which is madness! Agreed - I already made the same suggestion in the 'Future division patch available (PEP 238) thread. >If beginners want an operator which behaves as they expect, they >certainly aren't going to have any preconceptions about what it's >going to look like - they are beginners, after all. Therefore, why >even bother suggesting changing the / operator? Just introduce // and >be done with it! Nothing gets broken, the beginners get their new >operator, and those wanting the C++ comment syntax in Python will just >have to be disappointed. ;-) I'll live ;-) -- Steve Horne Home : steve at lurking.demon.co.uk Work : sh at ttsoftware.co.uk From db3l at fitlinxx.com Mon Jul 30 20:52:45 2001 From: db3l at fitlinxx.com (David Bolen) Date: 30 Jul 2001 20:52:45 -0400 Subject: win32api exception names? References: <9k4r84$n85$1@uranium.btinternet.com> Message-ID: <uhevt6hsy.fsf@ctwd0143.fitlinxx.com> "G. Willoughby" <thecalm at NOSPAM.btinternet.com> writes: > I'm using this function to open a file listed in a Tkinter Listbox widget, > but i've run into some problems. First when i double click on .htm files > listed they work perfectly, opening in Explorer, But when i double click on > .txt files i get this error: > > Exception in Tkinter callback > Traceback (most recent call last): > File "c:\program files\python\lib\lib-tk\Tkinter.py", line 1285, in > __call__ > return apply(self.func, args) > File "D:\Backup\Python Programs\PyFind\PyFind.py", line 61, in executeFile > win32api.ShellExecute(0, "open" , str(resultPane.get(ACTIVE)),"","",1) > api_error: (31, 'ShellExecute', 'A device attached to the system is not > functioning.') > > i'm trying to handle this exception, but being new to them i dunno what > exception is being raised, the 'except EnvironmentError:' line really isn't > getting it. any ideas? I can't necessarily address why your code is returning that specific exception (perhaps a bad path?), but each of the PythonWin modules all raise an api_error exception for any general Win32 errors. The first element in the instance data tuple will be the underlying Win32 error code (31 in this case is ERROR_GEN_FAILURE), then the failing function call, and finally a textual description. So if you want to catch these in your exception handler, you can use: except win32api.api_error, info and then if necessary, inspect the actual Win32 API error code (in info[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 aleaxit at yahoo.com Sat Jul 14 17:41:07 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 14 Jul 2001 23:41:07 +0200 Subject: not safe at all References: <mm8tkt4te3qnbpv3nh5nhsi591o1osln73@4ax.com> <slrn9ku3c3.mrk.9nick9m@localhost.localdomain> <u26ukt4vot7b1qu02hkp8l1pnmdi0sfp3l@4ax.com> <3B4F743C.66778F9F@tundraware.com> <9ip1qa012en@enews4.newsguy.com> <3B509C1F.B2E7ABD6@tundraware.com> Message-ID: <9iqea10f19@enews1.newsguy.com> "Tim Daneliuk" <tundra at tundraware.com> wrote in message news:3B509C1F.B2E7ABD6 at tundraware.com... ... > Sure, there are places where portability is important. And portability > is not a "Yes" or "No" things - there are degrees. But the most > important thing that needs to be portable are *the skills of the > people* so that they can be used in many different roles. As in, taking a world-renowned specialist in surface-modeling, and ensuring he wast^H^H^H^H spends enough time to be able to program a GUI, or knows enough SQL to write some queries, or...? Thanks, but NO, THANKS. One advantage for a software development firm to grow to middling-size (to be offset against several minuses) is being able to AFFORD a few all-out specialists in those areas that are key competitive differentiators for the firm's products. For us, that means specialists in such things as 3-D kernels, surfacing, surface/solid integration, and PDM needs of middle-sized mechanical engineering firms. It's *NOT* a problem if the PDM specialist doesn't know what's a NURBS, and the surfacing specialist doesn't know what's a BOM -- it DOES matter that the firm as a whole has, say, a dozen such key people in the right areas out of a couple hundred developers -- people able and eager to concentrate on very specific, narrow, focused domains, with the total unremitting concentration and enthusiasm that such specialists tend to bring to their work. Their skills need not be "portable" to other areas or roles -- they need to be allowed to concentrate on what they're exceptionally good at, in order to develop the innovations that spearhead new products and versions. (If and when such guys *WANT* to branch out in other fields, it's of course clever to support their explorations -- that may well be a spring of innovations too, among other issues -- but it's exceedingly rare that a specialist WANTS to leave his or her specific field, where he or she always seems able to find new fascinating challenges and new worlds to conquer). > DEC once estimated that there was something like an 8 or 10 to 1 > ratio of the cost of owning code vs. the initial cost to produce May make sense, depending on the code's longevity (related to the speed of advances in the specific field). > the code. The ongoing reliability and maintenance of software and > systems tends to be way more important than portability of the code > itself because that is a relatively lower cost to produce the code > than to maintain it. But porting, when it's needed, is part of the "cost of owning", not of the "cost of producing". Raising the producing-cost a little bit, by caring about portability right from the start, may significantly lower the owning-cost, depending on porting-needs -- which, again, will in part correlate to longevity. Code that you'll pension off in 6 months may easily never need to be ported -- code you'll carry around for 10 years is VERY unlikely to not need porting, in a platform market subject to reasonably fast innovation. So, the dominance of ongoing costs vs initial ones doesn't indicate a LOW importance for portability -- indeed, the very contrary! > Anyway, our code, *by intent* was *not* portable. It couldn't > be portable in any practical sense because the underlying > infrastructure paradigms are really different between, say TPF, Underlying infrastructure paradigms do tend to differ deeply when portability is a problem (otherwise, portability is basically free and it would be very silly to ignore it:-). But it's a serious error to claim that a program cannot be portable if the underlying infrastructure paradigms differ widely! Such underlying differences just raise (a bit) the COST of portability, because you have to write most of your code to a higher-level abstraction and also implement that abstraction on different underlying platforms. But the costs only grow by _a bit_, because good software IS 'layered' anyway -- levels of different abstraction built on top of each other. You just have to ensure your lowest levels are designed in a way that is decently decoupled from specific bits of infrastructure -- often not MUCH harder than coupling them heavily and strongly, and often worthwhile anyway (if the lower-level quirks aren't ALLOWED to percolate upwards and pollute the higher-level architecture, that may often be all to the good of the higher-level cleanness and resulting productivity in development and maintenance). A long time ago, in a galaxy far, far away, we had different GUI's running on top of WIDELY different infrastructure paradigms -- the bare paint-pixels-yourself approach of a now-obsolete HP proprietary minicomputer, Apollo's Domain, Dec VMS (I forget how their GUI subsystem was called), an early release of Windows, some X or other (I think it already was X11, but I'm not sure)... and we had not taken the trouble to design a _portable_ GUI architecture. Fortunately, at one point, we did, even though it did mean more than refactoring -- it was a big-bang junk-and-rewrite of a lot of stuff, given how badly we had allowed non-portability to 'percolate upwards' -- the cost of porting and maintaining on (at that time) half a dozen platforms was killing us (we were much smaller then, so the cost was a really large portion of our total investments). The resulting portable architecture, highlighting *decoupling* between portable parts (the higher-levels, amounting to a VAST majority of the applications) and non-portable ones (the lower-levels, handled by *specialists* of both the platforms AND the subject-area -- this early specialization freed most developers from having to know or care how you paint a pixel or respond to a button clic on any given platform, gave us higher-quality GUI's AND better application-logic, and paved the way for our growth) served us well for years. When, much later, we jumped on the Win95 bandwagon (having sniffed out that this cranky unreliable OS bid fair to conquer engineers' desktops, whether we liked it or not), we gained "native Win32 look and feel" faster and more smoothly than our competitors, and with the involvement of less than 10% of our developers -- all the others could still (lucky them) develop on Unix, respecting our in-house portability rules, and "it all just worked". GUI's are one example, but I have others, from the same bunch of real-life experiences, in such things as RDBMS's and network protocols. Attention to portability, mostly by designing intermediate layers and letting most everybody program to those layers while a few specialists slave away at implementing the layers on top of various platform-quirks, has always stood us in VERY good stead... > more interested in creating competitive and distinctive market > advantage than serving the abstract idea of portability. What gave you the idea that anybody around here is interested in "serving abstract ideas"? I'm interested in serving *our customers*, all 10,000+ of them at last count -- ensuring the applications they buy from us (or actually, these days, _rent_ -- we've successfully transitioned to a subscription business model) have very good architecture (including the careful layer separation that also ensures portability) is a means to that end (which in turn is a means to the end of making a whole lot of money of course:-). > I think code portability really only becomes an issue if it > is a first-order component of the economics of a company. For example, > if you sell compilers, portability is probably pretty important. > OTOH, if you write drives, it is not much of an issue. And if you write mechanical CAD and PDM in the current market, it may not SEEM much of an issue -- if you're too young to remember all your former-competitors killed by having put all their eggs into one non-portable basket, to exploit some nifty-looking doodad in a platform that then became defunct too fast. Fortunately, enough of our guys used to be the best developers from just such quondam competitors, so I don't think they're likely to forget:-). > > -- they claim speed-ups > > of about 60% overall, more solidity, etc, as a consequence. If that > > Speed-up, I believe. But "more solidity" by switching C++, I doubt. > That probably has more to do with 2nd generation software being > better than the 1st. Or else the claim is unwarranted -- who knows, but it wouldn't be the first time that marketing overclaims something:-). Alex From thecalm at NOSPAM.btinternet.com Thu Jul 26 15:23:08 2001 From: thecalm at NOSPAM.btinternet.com (G. Willoughby) Date: Thu, 26 Jul 2001 20:23:08 +0100 Subject: how on earth do i get a drive list? Message-ID: <9jpqlh$phf$1@uranium.btinternet.com> how on earth do i get a drive list? i've been searching for a command to display a tuple or list containing all available drives, but i can't find it! is it just me or are the standard python docs quite confusing. oh well any ideas out there? G. Willoughby From ajm at enteract.com Tue Jul 24 15:46:11 2001 From: ajm at enteract.com (Alan Miller) Date: Tue, 24 Jul 2001 15:46:11 -0400 Subject: Future division patch available (PEP 238) References: <mailman.995776716.24336.python-list@python.org> Message-ID: <MPG.15c7942e7652fd7b989800@news-enteract> Guido van Rossum (guido at digicool.com) wrote: >- after "from __future__ import division", / is changed to return a > float result from int or long operands (and so is /=). So who's going to write slashnanny.py that will go through old code and warn about existing operations that will be broken by the change? ajm From tim at vegeta.ath.cx Mon Jul 16 16:03:33 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Mon, 16 Jul 2001 20:03:33 GMT Subject: re Challenge: More Compact? References: <mailman.995247446.16415.python-list@python.org> <slrn9l4llv.p58.tim@vegeta.ath.cx> <mailman.995271867.5441.python-list@python.org> Message-ID: <slrn9l6iqr.qqs.tim@vegeta.ath.cx> [ please don't reply and post ] Me parece que Thomas Wouters <thomas at xs4all.net> dijo: > On Mon, Jul 16, 2001 at 02:39:50AM +0000, Tim Hammerquist wrote: > > > I'm in the habit (in Python as well) of return undef on > > false because in some methods, 0 is ambiguous. So, in cases where 0 is > > not ambiguous, 0 is idiomatically preferred to None? > > You wouldn't call those functions in a boolean context, now would you ? I > prefer to return -1 if 0 is a valid return value, or just raise an exception > if -1 is valid as well. We're talking an entirely different function though, > one where an 'error return' really is exceptional. A valid point. =) > > Ok, so here's my version (I hate wasted line space and unnecessary temp > > vars): > > Just wait until you revisit this code in 6 months ;) Actually, never had a problem understanding my own code. The only problem I've had understanding other people's code is when their indentation is deplorable (which obviously doesn't apply to Python). <wink> -- Sometimes we can choose the path we follow. Sometimes our choices are made for us. And sometimes we have no choice at all. -- Morpheus, The Sandman From tim.one at home.com Fri Jul 13 21:56:12 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 13 Jul 2001 21:56:12 -0400 Subject: Light Speed Socket Connections In-Reply-To: <EbJ37.5150$z21.530071@newsc.telia.net> Message-ID: <LNBBLJKPBEHFEDALKOLCKEFHKOAA.tim.one@home.com> [/F] > from the Python library reference: > > clock() > > Return the current CPU time as a floating point > number expressed in seconds. The precision, and > in fact the very definition of the meaning of ''CPU > time'' , depends on that of the C function of the > same name > > ANSI C leaves the "era" and resolution open, and Microsoft > has defined it as: > > The clock function's era begins (with a value of 0) > when the C program starts to execute. It returns > times measured in 1/CLOCKS_PER_SEC (which > equals 1/1000 for Microsoft C). Python doesn't use the MS clock() for time.clock() on Windows; it uses the MS QueryPerformanceCounter API instead. MS clock() is approximately useless for anything (yes, it has millisecond resolution, but is updated less than 20 times per second; while even on Win95, QueryPerformanceCounter typically has better then microsecond resolution and updating). From arisen at start.no Mon Jul 9 06:43:10 2001 From: arisen at start.no (=?ISO-8859-1?Q?Andr=E9?=) Date: 9 Jul 2001 03:43:10 -0700 Subject: Cool use for a generator? Message-ID: <fed2e489.0107090243.32027672@posting.google.com> Assuming i got the generator concept correctly from PEP 255, this little (untested) snippet shows how to process asynchronous events in an "iterative fashion". Assuming also that ping is an interface to the libping library (which would be nice to have anyway. See e.g. http://www.joedog.org/libping/docs/man/pinghost3.html) import ping, time def now(): return time.time() * 1000 # We want milliseconds def pinggen(host): while 1: then = now() if ping.pinghost(host) == 1: yield now() - then else: return if __name__ == "__main__": hostname = "localhost" for pingtime in pinggen(hostname): print "Reply from %s: time=%.1f" % (hostname, pingtime) -- Regards Andr? Risnes From bsass at freenet.edmonton.ab.ca Wed Jul 18 18:18:13 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Wed, 18 Jul 2001 16:18:13 -0600 (MDT) Subject: Language change and code breaks In-Reply-To: <cpvgkq1f2b.fsf@cj20424-a.reston1.va.home.com> Message-ID: <Pine.LNX.4.33.0107181336320.15405-100000@bms> On Wed, 18 Jul 2001, Guido van Rossum wrote: > Roman Suzi <rnd at onego.ru> writes: > > > Windows is case-insensitive and thus "easy to use" only before one needs > > to put web-pages on the real (UNIX) web-server. Then they understand all > > the troubles with mised case, national-charset filenames, abbr~ted > > filenames, local file references "C:\Mydocs\lalala", bmp-images etc. > > But it's still open for debate whether the problem here is Windows or > Unix! All programming languages and file systems used to be > case-insensitive, until the designers of Unix and C decided that it > was too much work to write and use a case-insensitive comparison > routine. It wasn't necessarily intended to be better, just easier to > implement. But times have changed, and that's a lousy excuse. [Ok, I'll bite] I don't see either Windows or Unix as the problem, they are just different. Problems only arise when you try to move between the two possible worlds without a mapping function. Mapping from Windows to Unix is trivial because case-insensitivity is a subset of case-sensitivity; mapping from Unix to Windows with the same 1:1 rule is impossible for the same reason... so you need a more complicated mapping function, and will end up with a longer string of characters in the Windows world than in the Unix world. In the very least, case-sensitive Unix can convey information more succinctly than case-insensitive Windows, and I would go so far to say that Unix is more expressive than Windows in this aspect. I don't think the question is "whether the problem here is Windows or Unix!", but rather... Would a less expressive programming environment be better for programs or programmers? or if you prefer... Would restricting program text to a subset of the available symbols be better for programs or programmers? The way I see it, going case-insensitive would be like ripping the "shift" key out of the keyboard... such a move would not even be considered in the real world; since programming is an effort to simulate what goes on in the real world, and it seems to have been found to take more than 36 symbols and some punctuation to express real world ideas, it seems counter-productive to artificially restrict the expressiveness of programmers. Someone who has trouble figuring out case-sensitivity is going to have a hard time with programming <period>. If such a person is looking at programming it will be within a restricted domain, so there should be a language tailored to that audience and that domain. Languages intended for wider domains should be as expressive as the natural language used to describe them. There is nothing stopping a small domain language from being a subset of that used in a larger domain, but the requirements of the subset should not limit the expressiveness of the whole language. Exposing Python to a non-programmer, so the non-programmer can (say) program their cell phone, does not require any aspect of Python be designed to make things easy for the non-programmer... all that is required is that a subset of Python can be made to appear to be non-programmer friendly. Maybe PyChecker should grow an option to check for mixed case labels in programs, or perhaps rexec should be able to force case-insensitivity. - Bruce From rnd at onego.ru Sat Jul 14 02:26:50 2001 From: rnd at onego.ru (Roman Suzi) Date: Sat, 14 Jul 2001 10:26:50 +0400 (MSD) Subject: converting from perl: variable sized unpack In-Reply-To: <3B4FD35A.26B4568E@Lugoj.Com> Message-ID: <Pine.LNX.4.30.0107141014240.3574-100000@rnd.onego.ru> On Fri, 13 Jul 2001, James Logajan wrote: >Roy Smith wrote: >> >> What's the best way to translate this perl snippet into python: >> >> ($f1, $f2, $f3, $f4, $f5, $f6) = split ('\s+', $line); >> >> The obvious translation would be: >> >> [f1, f2, f3, f4, f5, f6] = string.split (line) >> >> but the problem is that line may have fewer than 6 fields on it. Perl >> handles this smoothly by leaving the "extra" variables undefined, whereas >> python raises a ValueError exception. What I'd like to do is have the >> extra field variables left as null strings. > >This may not be the most elegant or efficient, but how about this: > >[f1, f2, f3, f4, f5, f6] = (string.split (line) + 6*[None])[:6] My variant is: f1, f2, f3, f4, f5, f6 = map(lambda x, y: x, string.split(line), 6*[None]) (maybe 6*[None] could be written as xrange(6), but I am not sure if xrange will allow it after stripping down) - this is VERY common problem when analysing logs. I will be grateful if somebody could point me to how to give names to log fields in efficient manner (logs are long, you know!). Probably, this is better done in C. Maybe, some kind of support from string module or Python itself could be had, for example: f1, f2, f3, f4, f5, f6 = pad(string.split(line), 6, None) (where None could be omitted to be default value) There could also be rpad to pad from right. * re module could also be used, with named groups which name fields. But I wonder how efficient it is to use re where split is enough... Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Saturday, July 14, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "A mainframe: The biggest PC peripheral available." _/ From aleaxit at yahoo.com Sat Jul 14 10:30:39 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 14 Jul 2001 16:30:39 +0200 Subject: More on "with" statement References: <3b4f3602$0$15367@wodc7nh6.news.uu.net> <poP37.19002$Kf3.249024@www.newsranger.com> <9ioru01pc9@enews4.newsguy.com> <%qV37.19159$Kf3.249506@www.newsranger.com> Message-ID: <9ipl2901n36@enews4.newsguy.com> "Levente Sandor" <nospam at newsranger.com> wrote in message news:%qV37.19159$Kf3.249506 at www.newsranger.com... ... > >def with(obj, statements, globs=None): > > if globs is None: globs=globals() > > exec statements in vars(obj), globs > > Sorry but I can't see how it simulates the 'with' statement in Pascal or VB. That's probably because I had switched the two dictionaries in the exec statement -- here's a corrected, simpler version: >>> def with(obj,stmt): ... exec stmt in globals(), vars(obj) ... >>> with(x, "pak=23; pok=24") >>> x.pak 23 >>> x.pok 24 >>> In lieu of globals() one surely wants to default to the *caller*'s globals, sys._getframe(1).f_globals, of course. Alex From tim.one at home.com Sun Jul 22 13:40:51 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 22 Jul 2001 13:40:51 -0400 Subject: can't find fpectl In-Reply-To: <6rC67.32302$Ek3.11785061@news1.rdc1.md.home.com> Message-ID: <LNBBLJKPBEHFEDALKOLCKECBLAAA.tim.one@home.com> [Eric Hagemann] > Running through the 2.1 library reference and found info on the > 'fpectl' -- floating point exception control module. > > When I tried to run the examples and import the module I get an > Import error -- does this module exist ? Which platform? For example, it's not available on Windows. From nospam at newsranger.com Mon Jul 30 21:23:38 2001 From: nospam at newsranger.com (Levente Sandor) Date: Tue, 31 Jul 2001 01:23:38 GMT Subject: PythonPath for ASP References: <996471911.551564@emperor.labs.agilent.com> Message-ID: <uMn97.12165$ar1.37961@www.newsranger.com> In article <996471911.551564 at emperor.labs.agilent.com>, Brian Zhou says... >Is there a place I can set that makes C:\Python21\PIL in PythonPath? Create a file with the extension ".pth" in your Python installation directory, then add the line PIL to it. You can add more (both relative and absolute) paths to the Python path in this way, each one in a new line. (You must restart the Python interpreter after doing this.) Or: you can do it (temporarily) anywhere in your script: .. import sys sys.path.append("c:\\python21\\pil") import Image .. Another way goes trough the Windows Registry but I never tried that. Levi From nospam at eurologic.com Wed Jul 25 12:10:41 2001 From: nospam at eurologic.com (Pat Knight) Date: 25 Jul 2001 17:10:41 +0100 Subject: Deposing Dictators References: <9jmjne$q54$1@wisteria.csv.warwick.ac.uk> Message-ID: <sxvgkh56ri.fsf@eurologic.com> <margg at ux-ma160-18.csv.warwick.ac.uk> writes: > Many political historians claim that, in short to medium term timescales, > the best form of governance is the benevolent dictatorship -- where the > leader cares about his people, and has the ability and intelligence > to act quickly on their behalf. However, it is unstable in the long term: > either the dictator, or the next in line, stops caring about the > populace, and becomes capricious and vain. > > I have been pondering recently whether we are seeing this process in > action with Python. Guido van Rossum has been an extremely strong and > benevolent dictator, and Python itself is a much better language, and > has a bigger mindshare, than it would under many other leadership > systems. However, we may be getting to the stage now where the task of > guiding Python should be taken out of his hands. > As recently as yesterday it appeared Guido wasn't listening. Having seen his posts today on the subject of both integer division and case-sensitivity, I now think he was listening and *thinking*. In other words, waiting until he'd considered what the rioting masses were asking for before responding. I'm much happier now with his current positions on both these issues, and feel that they show he has listened. I'd also like to complement Guido on having the grace and courage to do what he feels right and best for the language, in the face of some uncalled for ad-hominem remarks. I'm particularly impressed that he's able to modify his position publicly in circumstances where another might have stuck to their guns to "save face." Well done, Guido. -- Cheers, Pat Tel: 0117 930 9621 (Intl: +44-117-930-9621). From peter at engcorp.com Sat Jul 14 00:34:30 2001 From: peter at engcorp.com (Peter Hansen) Date: Sat, 14 Jul 2001 00:34:30 -0400 Subject: python reviewers References: <mailman.995046026.1258.python-list@python.org> Message-ID: <3B4FCBD6.B49F5DA1@engcorp.com> Kristen_Blanco at prenhall.com wrote: > > I am writing from Prentice Hall publishing and > I am seeking reviewers for an upcoming publication. ... > We are presently seeking qualified technical reviewers to > verify that the Deitels' coverage of Python in their forthcoming book is > accurate. In return, we are offering a token honorarium. >From http://www.dictionary.com/cgi-bin/dict.pl?term=token to?ken (tkn) n. 1. Something serving as an indication, proof, or expression of something else ... 5. A keepsake or souvenir. 6. A piece of stamped metal used as a substitute for currency: subway tokens. I wonder which of the above they mean and, if the first, what is the "something else" which this honorarium is an indication of? That they didn't even offer to put your name in the credits? Presumably _that_ would be more interesting to many people here than some amount of money that has to be described as "token". I wonder how thick the book is... ( http://philip.greenspun.com/wtr/dead-trees/story.html ) From new_name at mit.edu Mon Jul 9 11:50:57 2001 From: new_name at mit.edu (Alex) Date: 09 Jul 2001 11:50:57 -0400 Subject: Sample code for using readline References: <3B49CD3C.F157E2F@yahoo.com> Message-ID: <etdhewm14pq.fsf@pickled-herring.mit.edu> Poke around the neighbourhood of these url's a bit: http://python.org/doc/lib/readline-example.html http://python.org/doc/lib/module-rlcompleter.html Alex. From thomas at gatsoft.no Thu Jul 26 08:26:12 2001 From: thomas at gatsoft.no (Thomas Weholt) Date: Thu, 26 Jul 2001 12:26:12 GMT Subject: SlightlyOffTopic: syntax-highlighting in XEmacs running on Windows Message-ID: <E%T77.147$bXi.169905152@news.telia.no> Hi, I want to use X/Emacs to write Python-code on Windows too, but I have a small problem with the python-mode.el. Where do I put the stuff that should have gone into .emacs? Cannot create such a file on win32 filesystem. Why aren't my code colorized in XEmacs 21.x using the python-mode like Emacs under Linux, using the exact same python-mode.el-file? Any ideas? Thomas From kens at sightreader.com Tue Jul 3 19:07:31 2001 From: kens at sightreader.com (Ken Seehof) Date: Tue, 3 Jul 2001 16:07:31 -0700 Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> <bebbba07.0107021206.70a22aa8@posting.google.com> <20010702175245.A4092@node0.opengeometry.ca> Message-ID: <07c001c10414$f4af22e0$a325fea9@his> For liability reasons, I can't give you advice on whether or not to use python for an air traffic control application :-) However, if I were (hypothetically, of course) to give you advice, it would be the following, of which your reading constitutes an agreement that I am not responsible for injury, deaths, and property damage resulting from that which would be my advice, were it not, if fact, hypothetical, which it is. Seems to me that python would be a good choice. You can write bugs in any language, including python. However, python bugs tend to be less subtle and easier to detect and fix than C/C++ bugs. The lack of type checking and function prototyping is not nearly as big of a problem (if it's a problem at all) as C++ programmers tend to fear. This fear is due to the fact that in some statically typed languages such as C++, an undetected type mismatch is likely to cause rather horrible bugs which are often intermittent and often corrupt unrelated data. These kinds of type mismatch bugs that C++ programmers are terrified of (memory overwrites, etc.) simply do not exist in python at all. Python doesn't ever need to infer the addresses of bytes of data from dubious type information at runtime (as C++ does). Type information is always stored within the objects themselves. In python, data of the wrong type is not really any worse than data of the wrong value, so these kinds of bugs tend to only have local effects which are easily caught when tested. Not surprisingly, I have found that I usually get fewer type related bugs in Python than in C++. Saying that python is unreliable because it lacks type checking is like saying fish cause pollution because they lack bicycles. - Ken -- Disclaimer: The hypothetical opinions expressed above do not necessarily represent my own opinions. ----- Original Message ----- From: "William Park" <opengeometry at yahoo.ca> To: "Russ" <18k11tm001 at sneakemail.com> Cc: <python-list at python.org> Sent: Monday, July 02, 2001 2:52 PM Subject: Re: Python for air traffic control? > > From: Russ (18k11tm001 at sneakemail.com) > > Subject: Python for air traffic control? > > Date: 2001-06-29 17:42:45 PST > > > > 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. > > Of course, you idiot... It depends how well you did in high school > math. If there are N airplanes whose positions are given by > (x,y,z)_i, i=1,2,...N > then you have to calculate distance from an airplane at to every other > airplanes. > > You would be maintaining NxN table to see > - if any position is outside the assigned trajectory, or > - distance (between any two position) is too close > > Am I missing something? > > -- > William Park, Open Geometry Consulting, <opengeometry at yahoo.ca> > 8 CPUs cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc. > > -- > http://mail.python.org/mailman/listinfo/python-list From lomax at pumpichank.com Wed Jul 25 10:55:57 2001 From: lomax at pumpichank.com (Frank "Cookie Jar" Lomax) Date: Wed, 25 Jul 2001 10:55:57 -0400 Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <eppstein-03540D.13070222072001@news.service.uci.edu> <LNBBLJKPBEHFEDALKOLCOECNLAAA.tim.one@home.com> <mailman.995899647.346.python-list@python.org> <tclolt053o18f8q0ntb7n4aggitdkmeg4h@4ax.com> <Io_67.23543$B7.3779351@ruti.visi.com> <slrn9lp2m5.vp.Gareth.McCaughan@g.local> <p56plt8q4rs3bgcqbepk61q2r3g0tr2vhe@4ax.com> <slrn9ls3ae.2fm.Gareth.McCaughan@g.local> <cpitghbq05.fsf@cj20424-a.reston1.va.home.com> <9jlo4v$rhbl$1@sky.inp.nsk.su> Message-ID: <15198.56829.103987.322803@anthem.wooz.org> > To many of us, programmers, 1/2 is 0 with 1 as a reminder:) > We are like children, and any child will say _for sure_ that 1 > cookie for two children means one cookie for 1 child and 0 > cookies for another:) No, 1 cookie for 2 children always means no cookies for either child, lots of crumbs for the dog to lick up, and years of therapy for the entire family. proof-that-integer-division-causes-thousands-of-disfunctional-families- per-year-and-must-be-abolished-ly y'rs, - frank From thomas.heller at ion-tof.com Thu Jul 19 15:14:46 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Thu, 19 Jul 2001 21:14:46 +0200 Subject: Make an *.EXE Using Python. References: <oAI17.647550$166.13393459@news1.rdc1.bc.home.com> <7b515e0f.0107081724.56b2a434@posting.google.com> <9j7ao4$ir$1@neptunium.btinternet.com> Message-ID: <9j7bj7$mrt5r$1@ID-59885.news.dfncis.de> "G. Willoughby" <thecalm at NOSPAM.btinternet.com> wrote in message news:9j7ao4$ir$1 at neptunium.btinternet.com... > thanks that works great! but one more question... i have compiled my script > to an .exe BUT is there a way of getting rid of the console window. i tried: > > pythonw setup.py py2exe > > instead of > > python setup.py py2exe > > but this only copied the 'tcl' dir to the 'dist' dir! any ideas??? > RTFM? These are the command line flags: --console or -c build a console application, similar to running the script with python.exe. The default is to create a console application if the script has the extension .py, a console-less GUI application if the script has the extension .pyw --windows or -w build a windows application, similar to running the script with pythonw.exe Thomas From tim.one at home.com Sun Jul 22 20:27:16 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 22 Jul 2001 20:27:16 -0400 Subject: PEP0238 lament In-Reply-To: <eppstein-0DEDA4.16273222072001@news.service.uci.edu> Message-ID: <LNBBLJKPBEHFEDALKOLCOEDGLAAA.tim.one@home.com> [David Eppstein] > My intuition is that the users who will be surprised that 1/2 = 0 are > the same ones who would be bitten by roundoff-error bugs if 1/2 = 0.5. Anyone using floats will get bitten eventually; ditto anyone using rationals, for that matter. This is a "lesser of evils" thing more than a "good vs evil" thing. > Result: buggier code since the errors are less obvious. Perhaps; I don't know of evidence one way or the other, and don't put much stock in "head arguments" predicting programmer behavior. I've never heard that, e.g., Pascal programs were especially prone to numerical bugs (a language in with 1/2 does return 0.5; and I did work on a vector Pascal compiler for Cray Research, so it's not that I've heard nothing at all about Pascal in numeric contexts). I haven't heard knocks against Algol 60 on this count either, which for several years was the de facto standard for publishing numeric algorithms (and in which int/int also returned a real; it had a different operator for int division). > If you have a routine "velocity" in which it doesn't make sense to do > integer truncation, and it doesn't coerce its args to float by > adding 0.0, that's also a bug. According to who? Routines are often *used* in ways authors didn't anticipate, and a dynamic language (like Python) encourages that. The current rules for "/" work against it. From aleaxit at yahoo.com Fri Jul 6 13:47:01 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 6 Jul 2001 19:47:01 +0200 Subject: [TO]What's the big deal with EJB? [Re: PEP scepticism] References: <mailman.993747643.21070.python-list@python.org> <9hfqb5$dsllb$3@ID-89274.news.dfncis.de> <3dhex01n1m.fsf@ute.cnri.reston.va.us> <etdk81vduw0.fsf_-_@lola-granola.mit.edu> <3d8zib16g7.fsf@ute.cnri.reston.va.us> <Xns90D3694AD53FBbeablebeable@30.146.28.98> <yoxd77fh4pr.fsf@karhu.tp.spt.fi> <9i201402voe@enews1.newsguy.com> <mailman.994350172.18735.python-list@python.org> <9i2jva23cm@enews2.newsguy.com> <3B45C48D.413A5E@divalsim.it> Message-ID: <9i56ph0eke@enews4.newsguy.com> "Nicola Musatti" <objectway at divalsim.it> wrote in message news:3B45C48D.413A5E at divalsim.it... > Ciao, Alex. > > Alex Martelli wrote: > [...] > > Haven't done *identical* projects in C++ and Python yet, except > > for Python extensions prototyped in Python then coded with Boost > > Python, and for those (small extensions) it seems I'm about 4 > > times more productive in Python than in C++. I have no personal > > experience doing the same task in Python and Java, yet. > > How do you measure your productivity? For a given task (sometimes estimated, in turn, in function points, but that's irrelevant here, since we're not comparing different tasks!), productivity = K / (number of hours I spend on the task), for some constant K. The number-of-hours part is easy for tasks I perform for work since I'm supposed to report on that, therefore I measure it (as Senior SW Consultant I'm a "shared resource" for the firm, so my time is debited to whatever projects have used it; there's no formal concept of "billable hours" but it comes close). As I reported on other threads, I've done identical tasks in C++ and Java, and other identicals tasks in Python, C++, and C, so I do have a reasonable measurement of what happens to my own productivity dependin on language. Of course, the _second_ time I program the same things I may well be more productive because of learning effects, and I have not controlled for that -- the 15/20% advantage for Java over C++ may partly be due to learning, and the 4-to-1 advantage for Python over C++ may be actually higher since in that case I did the Python first. (And it's in one specific field -- extending Python; in another, writing simple COM servers, Python and C++/ATL took me the same time when I tried [but the servers had SIMPLE logic indeed in that case]). Alex From gerhard.nospam at bigfoot.de Mon Jul 9 19:49:39 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Tue, 10 Jul 2001 01:49:39 +0200 Subject: Error Building PyPgSQL References: <L6i27.261092$Z2.3119989@nnrp1.uunet.ca> <slrn9kjihk.pj.gerhard.nospam@lilith.hqd-internal> <o9o27.261200$Z2.3123178@nnrp1.uunet.ca> Message-ID: <slrn9kkepv.5ie.gerhard.nospam@lilith.hqd-internal> >"Gerhard H?ring": >> On Mon, 9 Jul 2001 09:13:36 -0400, Rod MacNeil wrote: >> >Hello, >> > >> >I'm trying to build PyPgSQL on a RH7 box with Python 1.5 and postgres 7.0 >> >and gcc-2.96-54. I left the Setup.in file as it shipped because it looked >> >correct to me. I get the following when I run make. >> > >> >gcc -fPIC -I/usr/local/pgsql/include -g -02 - >> >I/usr/include/python1.5 -I/usr/include/python1.5 - >> >DHAVE_CONFIG_H -c ./libpqmodule.c >> >./libpqmodule.c: In function `PgConnection_New': >> >./libpqmodule.c:196: parse error before `PgConnection' >> > >> >[other compiler errors] > > >> >This looks like a compiler error to me but I'm not a C programmer. The >> >four lines of code appear to be using the same syntax, is this a syntax >> >error or possibly a compiler version issue? >> > >> >Has anyone else had this problem or know of a solution? >> >> The latest release uses distutils and it works fine. I think you should use >> this one (edit paths in setup.py, then "python setup.py build" then >> "python setup.py install"). On Mon, 9 Jul 2001 16:06:00 -0400, Rod MacNeil wrote: >I have version 1.2 from sourceforge, it doesn't mention using distutils or >have a setup.py script. Have I got the latest? I'm new to distutils, am I >missing something basic? Sorry for spreading misinformation. I was using the CVS version. 1.2 didn't use distutils, yet. I was testing the 1.2 version and it works fine with on my machine. I think the problem is that this module isn't designed to work with Python 1.5.2 anymore. The first offending line contains a call to PyObject_New. And the changelog says the author has recently changed all instances of PyObject_NEW to PyObject_New. I didn't find the _New in the Python 1.5.2 headers. You might try to undo this change. Or install Python 2.1 and build with that. Strange that Redhat *still* ships 1.5.2. Gerhard -- mail: gerhard <at> bigfoot <dot> 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 dirck at pacbell.net Sat Jul 14 02:11:59 2001 From: dirck at pacbell.net (Dirck Blaskey) Date: Fri, 13 Jul 2001 23:11:59 -0700 Subject: not safe at all References: <mm8tkt4te3qnbpv3nh5nhsi591o1osln73@4ax.com> <slrn9ku3c3.mrk.9nick9m@localhost.localdomain> <u26ukt4vot7b1qu02hkp8l1pnmdi0sfp3l@4ax.com> Message-ID: <PoR37.146$iJ3.195862@news.pacbell.net> "Dennis Roark" <denro at earthlink.net> wrote in message news:u26ukt4vot7b1qu02hkp8l1pnmdi0sfp3l at 4ax.com... > Python is an attractive language. But for a large program I > would still rather be forced to declare the name of a > variable (and its type) rather than risk misspelling or > misuse 500 lines later in the program. My original note was > not intended to be an indictment of Python, but only to > bring up some reasons that for me make more strongly typed > languages like C++ or Object Pascal better at coding very > large projects. And now that you're completely overwhelmed by the response, here's yet-another-something-to-consider: Static/strong typing and type safety are of great use - to a *compiler*. C/C++/Pascal, etc. could not do what they do, or do it as well, without knowing this information. They create a functioning program out of raw hardware: memory & cpu, and they have to keep track of every bit, or the program won't run. A smart compiler can optimize your code as well, but only because it knows what's what. The Python compiler doesn't have this restriction, because Python runs on a virtual machine made out of much smarter components. The components 'know' what they are, the compiler doesn't have to. There is a school of thought that strong typing is extremely important for program 'correctness'. What everybody here is saying, basically, is that there are a lot more important considerations when it comes to making a program correct, and they all have enough real experience in this area for you to take their argument seriously. A non-trivial program cannot ever be 'proven' correct anyway; Computers are inherently chaotic systems, and the 'state space' of a complex running system is practically infinite. Make sure all the pieces are as good as you can make them, (or perhaps just as good they need to be,) and use that as your base of confidence that the program will work as well as necessary. There are very few problem domains where perfection is a requirement, notably anything involving potential loss of human life. These domains require unusual and exceptional techniques to ensure high quality. As an experienced programmer, I know I would never want to work on anything where a coding mistake could kill someone. It does happen. Just to belabor the point a bit more. d From alankarmisra at hotmail.com Sun Jul 29 14:52:23 2001 From: alankarmisra at hotmail.com (gods1child) Date: 29 Jul 2001 11:52:23 -0700 Subject: 100,000 messages celebration? Message-ID: <25b2e0d9.0107291052.7780d1f8@posting.google.com> All this heated discussion over floats has led me to wonder if we need to lighten up a little bit and celebrate the fact that were close to 100,000 (94,100 as of this moment) messages on this news-group which IMHO is some sort of a mile-stone for this neat little group. Suggestions for celebrations? From max at alcyone.com Sun Jul 22 21:00:45 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 22 Jul 2001 18:00:45 -0700 Subject: PEP0238 lament References: <3B5B3676.40F39389@alcyone.com> <eppstein-03540D.13070222072001@news.service.uci.edu> <mailman.995836120.7223.python-list@python.org> <vyIKbWAP62W7EwC+@jessikat.fsnet.co.uk> Message-ID: <3B5B773D.791E90D@alcyone.com> Robin Becker wrote: > The leadership seems to want to python become more available to a > lower > grade of student than first year undergraduates. > > I think that is wrong, but I use python in a professional capacity. I > think languages succeed or fail because they work for programmers. > Division in computers is always discrete (unless we ever manage to get > quantum things working). I couldn't agree more. Certainly there's no reason for a language to be deliberately opaque, but the goal of the language (except a language primarily intended for education) should be for programmers to get their job done. A good beginning programming language is one that has a simple syntax and straightforward rules to follow. Python already qualifies in that capacity very well; I don't see any reasons to "dumb down" Python any further in order to try to make Python easier for "non-programmers" (non-programmers won't be programming anyway! :-) to use in areas where the benefit to non-programmers will be questionable in the first place. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ When the solution is simple, God is answering. \__/ Albert Einstein REALpolitik / http://www.realpolitik.com/ Get your own customized newsfeed online in realtime ... for free! From robin at jessikat.fsnet.co.uk Sun Jul 1 12:25:34 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sun, 1 Jul 2001 17:25:34 +0100 Subject: Pmw subclassing problem Message-ID: <pgtrPLA+70P7EwKo@jessikat.fsnet.co.uk> I'm sure the cause of this must be obvious, I want to specialise a scrolled text. The existing one shows all the right behaviours, but when I recode to use the trivial subclass class RL_ScrolledText(Pmw.ScrolledText): def __init__(self,*args,**kw): apply(Pmw.ScrolledText.__init__,(self,)+args,kw) and change the client code to match ie change Pmw. to RL_ self.log = RL_ScrolledText(mainlog.pane('log'), labelpos = 'n', label_text = 'Log') I seem to lose the automatic scroll bars etc, what am I doing wrong? Am I missing some class bindins somewhere? -- Robin Becker From sholden at holdenweb.com Tue Jul 17 20:32:44 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 17 Jul 2001 20:32:44 -0400 Subject: Python 2 times slower than Perl References: <8f41cfd.0107171238.6ff33b9b@posting.google.com> <170720011359545210%mday@apple.com> <87n163mfdc.fsf@elbereth.ccraig.org> <mailman.995408249.15783.python-list@python.org> Message-ID: <hL457.16323$PF1.759797@e420r-atl2.usenetserver.com> "Skip Montanaro" <skip at pobox.com> wrote in message news:mailman.995408249.15783.python-list at python.org... > > Christopher> I can't speak for Perl, but Python definately does not > Christopher> evaluate the expression at compile time. This is a problem > Christopher> I've had with Python. I wish that when given the -O option > Christopher> the compiler would do constant subexpression elimination. > > It's rare in normal Python code to actually see a constant expression > computed inside a loop. Fortunately, it would appear most folks aren't that > dumb, so while you can take steps to eliminate them, there aren't generally > going to be very many to eliminate. > [ ... ] Skip, this talk of eliminating dumb people who code inefficient loops identifies you all too clearly as a hit man for the PS From carlf at panix.com Sun Jul 1 19:08:54 2001 From: carlf at panix.com (Carl Fink) Date: 1 Jul 2001 23:08:54 GMT Subject: GUI Builder for Python ? References: <aknrjt8j3cm3qcnpu6qsgvu313rlmi8emg@4ax.com> <3B3DE732.660AF0E1@earthlink.net> <3l1vjtg9cu1jcr78hdgnchmp8bt53cuhbi@4ax.com> Message-ID: <slrn9jvbc6.pdh.carlf@panix2.panix.com> In article <3l1vjtg9cu1jcr78hdgnchmp8bt53cuhbi at 4ax.com>, Lothar Scholz wrote: > > Perhaps you have missed that i was asking for an verion > alpha. > I think Pythoncard will not be useable for some years. The current _Linux Journal_ has an article on Glade as a Python GUI builder. It surely looks impressive to me, but I haven't tried it. You'd end up with a GTK program (no native Windows/Mac look and feel) if that matters to you. (I suppose you could use a GTK widget set that looks like WinX or Mac?) -- Carl Fink carlf at dm.net From aahz at panix.com Fri Jul 20 19:36:41 2001 From: aahz at panix.com (Aahz Maruch) Date: 20 Jul 2001 16:36:41 -0700 Subject: One Worry for 2.2 References: <ENi57.22469$M9.7022637@typhoon.we.rr.com> <3B55CFFD.C805B34A@bioreason.com> Message-ID: <9jafa9$flt$1@panix2.panix.com> In article <3B55CFFD.C805B34A at bioreason.com>, Mitch Chapman <chapman at bioreason.com> wrote: > >-- >Mitch >Who is sometimes able to pass himself off as a programmer, >even though he isn't descended from one. I am. Descended from one, that is. Actually, to be even more precise, it's multiple inheritance (both of my parents were programming before I was born). I doubt there are many people older than me who can claim that. -- --- 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 Fortune cookie: Watch your relations with other people carefully, be reserved. From stevewilliams at wwc.com Thu Jul 5 13:56:25 2001 From: stevewilliams at wwc.com (Steve Williams) Date: Thu, 05 Jul 2001 17:56:25 GMT Subject: Is Python Dead? References: <MNS%6.355$Xs4.225014@news.pacbell.net> <458b194a.0107050711.72007607@posting.google.com> <3B448C81.4DAC7DD@wwc.com> <D2017.3540$i8.346893@e420r-atl3.usenetserver.com> Message-ID: <3B44AAF2.2F5BB811@wwc.com> Steve Holden wrote: > [snip] > Does anyone actually USE DB/2 with Python? > Yes. From nperkins7 at home.com Sun Jul 8 22:24:38 2001 From: nperkins7 at home.com (Nick Perkins) Date: Mon, 09 Jul 2001 02:24:38 GMT Subject: Confusion about dictionaries - keys use value or identity? References: <mailman.994626615.9894.python-list@python.org> <roy-2F9DAF.19464308072001@news1.panix.com> Message-ID: <GB827.441629$eK2.89791917@news4.rdc1.on.home.com> "Roy Smith" <roy at panix.com> wrote in message news:roy-2F9DAF.19464308072001 at news1.panix.com... > So, here's my plan. I was thinking that I might write a thin wrapper > around the re class which kept a cache of regexes it had compiled. > myRe.match would take the passed-in regex, look it up in the cache, and if > it found it, just use the cached compiled version. I figure it would be > very close to the speed of storing the pre-compiled versions in the > mainline code, as shown above, but still have the convenience and > comprehensibility of keeping the regex string at the place where it's used. sounds like a plan, something like this: class matcher: def __init__(self): self.compiled = {} def match(self,pattern,data): if compiled.has_key(pattern): comp = self.compiled[pattern] else: comp = re.compile(pattern) self.compiled[pattern] = comp return comp.match(data) ..it reminds me of a general purpose function i use: def memoize(fn): results={} def mem(*args): if results.has_key(args): return results[args] else: result = fn(*args) results[args]=result return result return mem This needs nested scopes. It will wrap any function that takes hashable arguments. It is good for functions that do a lot of work, and are frequently called with the same args. ( I suppose it won't work with kwd args.. ) From paulsid at home.com Tue Jul 24 17:24:47 2001 From: paulsid at home.com (Paul Sidorsky) Date: Tue, 24 Jul 2001 15:24:47 -0600 Subject: Importing from Another Path References: <mailman.995997582.18776.python-list@python.org> <3B5DE390.2F35B36A@accessforall.nl> Message-ID: <3B5DE79F.3E5D50C7@home.com> Ype Kingma wrote: > > sys.path.append("..\\common") > That is almost as portable as it gets: when also you take > the common directory from the command line sys.argv, eg: > > sys.path.append(sys.argv[1]) > > I wouldn't know of a more portable way. > The non portable part is then moved into the script(s) that > start(s) the client and the server. Actually I just meant that it wasn't portable between Windows and Linux because I'm using backslashes in the path. It looks like I'll have to just clean it up to use os.path.join() to take care of that and live with it the way I've got it. This is not the answer I was hoping to hear, but at least it's an answer. Thanks! > Also you should be aware that the sys module (any imported module > in fact) is unique in the process that runs the python interpreter, > so you should not add the common directory when it is already there: > > if sys.argv[1] not in sys.path: sys.path.append(sys.argv[1]) Ah, good point. -- ====================================================================== Paul Sidorsky Calgary, Canada paulsid at home.com http://members.home.net/paulsid/ From bill-bell at bill-bell.hamilton.on.ca Tue Jul 10 08:21:12 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Tue, 10 Jul 2001 08:21:12 -0400 Subject: PythonCOM and Office. Arrgh! In-Reply-To: <994739270.397.63036.l8@yahoogroups.com> Message-ID: <3B4ABAF8.26026.2302C75@localhost> Matthew <matthewm at ihug.co.nz> wrote, in part: > No matter what I try, I CAN NEVER get named keyword arguments to do > anything via PythonCOM Excel automation. > > xlapp.Workbooks.Open("D:\\Fred.xls", Password='fred') > profers no error. The xcel window opens with Password Dialog opem. > Type in 'fred' and s/s loads up. Named arg passed in call apparently > ignored. > > xlapp.Workbooks.Open("D:\\Fred.xls", password='fred') > generates error - Open got unexpected keyword argument 'password', so > it seems to me that somethings going on with passed named args Unfortunately, about all I can say at this point (gotta go to a meeting) is that there is something I don't understand. I've tried to use late binding, as outlined in the Hammond-Robinson book, hoping that the case of the named password would disappear as a problem. No such luck. xlapp = win32com.client.dynamic.Dispatch('Excel.Application') >>> xlapp.Workbooks.Open(r'C:\0 Query responses\Book1.xls', password=r'seamus') Traceback (most recent call last): File "<interactive input>", line 1, in ? TypeError: Open() got an unexpected keyword argument 'password' Tried running makepy, again on the advice of the book, hoping that this would enable pycom to handle the argument successfully. No go. That book does suggest getting one's hands dirty with lower-level calls. Haven't time to try any of that. Would be interested in knowing what you find out. Good luck. Bill From kirschh at lionbioscience.com Tue Jul 10 03:30:38 2001 From: kirschh at lionbioscience.com (Harald Kirsch) Date: 10 Jul 2001 09:30:38 +0200 Subject: File processing References: <9id5p9$8r62@interserv.etn.com> Message-ID: <yv2pub9gs0x.fsf@lionsp093.lion-ag.de> "Chris McMillan" <christopherjmcmillan at eaton.com> writes: > Hello all! > > I'm trying to write a script that will open a file, delete the first line, > and then save the file with the same name. Can someone please point me in > the right direction? Thanks! Umpf. I really like python, but sometimes other solutions are less cumbersome. With bash it's a one-liner like: for x in *; do y=`basename $x`.new; tail +1 $x >$y; mv $y $x; done Sorry, couldn't read from your message if you are on Microsoft where a bash script usually does not help a lot. Harald Kirsch -- ----------------+------------------------------------------------------ Harald Kirsch | kirschh at lionbioscience.com | "How old is the epsilon?" LION bioscience | +49 6221 4038 172 | -- Paul Erd?s *** Please do not send me copies of your posts. *** From qztgee at finaledgedev.com Fri Jul 6 08:13:06 2001 From: qztgee at finaledgedev.com (qztgee at finaledgedev.com) Date: Fri, 06 Jul 2001 12:13:06 GMT Subject: More Than New 3766 Message-ID: <mXh17.145488$WB1.25887566@typhoon.tampabay.rr.com> How would you like your own provider law firm standing ready to assist you and your entire family with: Contracts - Investments and Finance - Marriage - Divorce - Adoption - Child Custody and Support - Credit - Your Home all for the cost of an average cup of coffee per day ! http://bushhousechat.com/prepaylegal.htm ofhfghoveinbiqjlurbbdlbpbzfrsuuhsldvtmxdixjotifbnwfjswrsuojtpvtfrqistl From duncan at NOSPAMrcp.co.uk Thu Jul 26 05:22:21 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Thu, 26 Jul 2001 09:22:21 +0000 (UTC) Subject: Static method and class method comments References: <9jn382$lqf$1@license1.unx.sas.com> <mailman.996103958.4468.python-list@python.org> Message-ID: <Xns90EA6710921D8duncanrcpcouk@127.0.0.1> Paul Prescod <paulp at ActiveState.com> wrote in news:mailman.996103958.4468.python-list at python.org: > Agree strongly. This will also be a problem for documentation generation > tools, type extraction tools and class browsers. I believe it would be > easy to add a contextual keyword > >> class C: >> def static foo(x, y): print "classmethod", x, y > > Not a keyword. You could just make it an optional identifier. If you change the existing grammar: funcdef: "def" funcname "(" [parameter_list] ")" ":" suite to: funcdef: "def" [funcmodifier] funcname "(" [parameter_list] ")" ":" suite funcmodifier: identifier And make it that if a funcmodifier is present, then funcname is set to the result of calling funcmodifier on the function. then you get: def classmethod foo(x, y): print "classmethod", x, y but you also get the flexibility to write your own modifiers: def protected(fn): return protectionwrapper(fn) def protected foo(x, y): pass -- 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 researchstudy2001 at yahoo.com Mon Jul 16 17:01:13 2001 From: researchstudy2001 at yahoo.com (researchstudy2001 at yahoo.com) Date: Mon, 16 Jul 2001 17:01:13 -0400 Subject: Please answer a research survey on personal use of the Internet at work Message-ID: <098b01c10e3a$727d7080$9a748e88@sis.pitt.edu> http://ebiz.sis.pitt.edu/survey Dear newsgroup user: We apologize for our cross-posting, but we needed representative coverage of a relatively small subset of current newsgroups. We have embarked on a study to learn more about personal use of the Internet while at work. We think you will find this an unusually interesting questionnaire to complete. Please click here: http://ebiz.sis.pitt.edu/survey If you are currently employed or have held a job providing some access to the Internet, please consider completing this short questionnaire, whether or not you used the Internet for personal goals while on the job. Please answer honestly, and be assured that your identity is completely unknown. We have not set and do not read any "cookies," we do not run any covert code, we do not "pop up" a stream of browser windows, and we do not trick your system into revealing your identity. You are welcome to examine the source code for this page to verify that. If you would like to express any comments about our study or request a copy of our results, we would be happy to read and respond. It might take a few days for our responses, so please be patient. To enter your comments, please click the "comment" button near the bottom of the form. A new window will pop up with a separate form for this purpose. We hope you find this study interesting. Sincerely, Dennis F. Galletta Associate Professor of Business Administration Peter Polak Doctoral Candidate http://ebiz.sis.pitt.edu/survey From python_binto at yahoo.com Thu Jul 12 02:23:22 2001 From: python_binto at yahoo.com (binto bient) Date: Wed, 11 Jul 2001 23:23:22 -0700 (PDT) Subject: about extension module In-Reply-To: <9ijee5+6ea8@eGroups.com> Message-ID: <20010712062322.70198.qmail@web14810.mail.yahoo.com> hi, is there somebody know the procedure to make... extension module, because i confuse when i follow Python/C API Reference Manual, by Guido van Rossum what do i need to make extension module.. __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/ From cookedm+news at physics.mcmaster.ca Tue Jul 10 14:15:30 2001 From: cookedm+news at physics.mcmaster.ca (David M. Cooke) Date: 10 Jul 2001 14:15:30 -0400 Subject: File processing References: <9id5p9$8r62@interserv.etn.com> <mailman.994736537.19096.python-list@python.org> <994742167.67214@yabetcha.drizzle.com> Message-ID: <qnklmlw3b25.fsf@arbutus.physics.mcmaster.ca> At some point, Donn Cave <donn at drizzle.com> wrote: > That's cool, but you might be interested to see if tail on > your platform supports a positive index (bet it does): > > for f in `whole buncha files` > do > if tail +1 $f > $f.tmp > then mv $f.tmp $f > else rm $f.tmp > fi > done > > In the unlikely event it doesn't, sed '1d' is a safe bet. You want tail +2 -- that starts output on the second line. tail +1 starts on the first line (the beginning of the file). -- |>|\/|< /--------------------------------------------------------------------------\ |David M. Cooke |cookedm(at)physics(dot)mcmaster(dot)ca From ramzi.abunofal at novasemi.com Thu Jul 5 19:14:36 2001 From: ramzi.abunofal at novasemi.com (Ramzi Abu Nofal) Date: 05 Jul 2001 23:14:36 GMT Subject: History command Message-ID: <3B44F444.CE6FBCB0@novasemi.com> Hi all , I am trying to find history command ( like history in Unix,or doskey in dos/win) to list all the command that have been executed . I can do it using the readline module, but I need to save the result of the commnad too. Any idea . Thanks. -Ramzi -- Ramzi Abu Nofal Ramzi.Abunofal at novasemi.com NOVA Semiconductors Inc. Tel: (408)-918-7912 1403 Parkmoor Ave. Fax: (408)-298-0144 San Jose, CA 95126 From peter.milliken at gtech.com Wed Jul 18 17:58:13 2001 From: peter.milliken at gtech.com (Peter Milliken) Date: Thu, 19 Jul 2001 07:58:13 +1000 Subject: Which Python version to code for? References: <tlbbqas5b6hvff@corp.supernews.com> Message-ID: <9j50q4$a3f9@news1.gtech.com> Well, you also have to consider the case of different platform ports not necessarily being the "lastest" version of Python i.e. I am writing something in 1.5.2 on a VMS box. I believe that a port of 2.X is in the works somewhere but at the moment I am stuck with 1.5.2. In my opinion (for what it is worth :-)), 1.5.2 seemed to be a very popular and stable release, so unless 2.X brought in some feature that you feel you *really* can't do without, then 1.5.2 would be a pretty reasonable baseline to use. Peter "Charles Crain" <chuxxx at swbell.net> wrote in message news:tlbbqas5b6hvff at corp.supernews.com... > I am part of the team working on SCons, the build tool for the Software > Carpentry project. We have an interesting quandry before us: what is the > earliest version of Python we should support? On the one hand, we would > like to use the latest and greatest and be able to take advantage of the > several powerful features added in recent Python releases. On the other > hand, we would like to avoid putting any barriers to adoption of our product > that might arise from requiring users (particularly those in large > organizations with high-intertia IT departments) to upgrade Python versions > in order to use it. > > It occurs to us that this is a general question facing anyone wishing to > release a Python product. Do you code for the latest and greatest, or do > you try to figure out what release is most "common" (in this case, still > 1.5.2, since it ships with most major Linux distros) and code for that? Is > there any consensus as to what to do here? > > In particular, does anyone have a feeling for how pmuch of a pain people > consider upgrading Python versions so that they may run a particular piece > of software? In my experience, upgrading Python versions, and even running > concurrent versions, is pretty easy. > > Thanks for anyone that can help out. > > -Charles Crain > > > From paulp at ActiveState.com Sun Jul 1 01:39:51 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sat, 30 Jun 2001 22:39:51 -0700 Subject: The standard library References: <LNBBLJKPBEHFEDALKOLCEEKPKLAA.tim.one@home.com> Message-ID: <3B3EB7A7.533B8389@ActiveState.com> Tim Peters wrote: > >... > > 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. Personally, I don't really see any problems with the scope of the standard library. As things evolve (e.g. Unicode, XML, IPv6, HTTP), people have emerged to extend it. There are things I would like in the library that aren't there but getting them from a third party is usually good enough. My concern with the standard library is that it seems very disorganized compared to the language itself. Some of these may be idiosyncratic complaints but the overall point is that we don't discuss this stuff to the same degree that we do the language, so I don't know how others feel. * Some modules are very low-level and others very high-level. * Some use callbacks where another would use inheritance. * The naming conventions are not consistent. * The case conventions are not consistent. * The influence of C still pervades even as the set of programmers coming from raw C declines. * Things are not package-ized. * IMO, platform specific stuff should be moved into platform-specific modules and out of "os" and "time" etc. * cStringIO versus StringIO. Why do I need both? * sometimes "flags" are passed as strings and sometimes as |'d integers. * why do we need a "stat" module for interpreting stat() results. Why aren't stat's results self-describing? (i.e. an object) * there's some little-used stuff in there that could probably be moved into a third-party extension * do we really need four variants of popen and seven of exec (none of them having any relationship to Python's exec keyword)? I do feel that this is a problem that only PythonLabs could really address because a library overhaul would be large, pervasive, controversial and would require Guido's approval at every step. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From paul at andreassen.com.au Sun Jul 15 00:00:31 2001 From: paul at andreassen.com.au (Paul Andreassen) Date: Sun, 15 Jul 2001 14:00:31 +1000 Subject: do .. while loops ? Message-ID: <FFEOLIJPEIIGEJDICKALGEJKCAAA.paul@andreassen.com.au> Could someone please tell me why "do .. while" loops are not part of the python language? I realise they are rarely used but the implementation should be easy. Thanks for any reply, except abuse. Paul Paul Andreassen consultant for Pinnacle Plus BN6542554 (prop Jabibny Pty Ltd ACN010139429) ABN15787426700 Address: P.O. Box 47 Finch Hatton 4756 Australia Web: http://home.austarnet.com.au/paul1/ Phone: +61 7 49583196 Email: paul at andreassen.com.au From aahz at panix.com Mon Jul 9 09:24:02 2001 From: aahz at panix.com (Aahz Maruch) Date: 9 Jul 2001 06:24:02 -0700 Subject: I'm Sure There's A Better Way References: <3B465858.CB7F38E8@tundraware.com> <3b4676ad$0$324$8eec23a@newsreader.tycho.net> Message-ID: <9icb9i$o68$1@panix6.panix.com> In article <3b4676ad$0$324$8eec23a at newsreader.tycho.net>, Neil Macneale <mac4-devnull at theory.org> wrote: > >Note: this sollution requires 2 characters after the decimal point.... > >def isDollarAmount(s): > try: > if s.count == 1 and s[-3] == '.': > dol, cen = s.split('.') > int(dol) > int(cen) > return 1 > int(s) > return 1 > except: > return None I would change "int(dol)" to "long(dol)". -- --- 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 "How come we choose from just two people for President but more than 50 for Miss America?" --AEN From tbryan at python.net Tue Jul 24 22:04:39 2001 From: tbryan at python.net (Tom Bryan) Date: Wed, 25 Jul 2001 07:04:39 +0500 Subject: Sorting Lists References: <lSh77.64029$2V.13507417@news3.rdc1.on.home.com> <0bj77.544176$eK2.114166570@news4.rdc1.on.home.com> Message-ID: <9jm8re$a1c$1@slb1.atl.mindspring.net> Nick Perkins wrote: > You don't have to use a custom compare sort. > You can get what you want by creating a temp list, consisting of > 'decorated' values, and sorting that list. [...snip...] > Here's an example of sorting records by a given field: > > def sort_by_field(seq,index): > tmp = [ (item[index],item) for item in seq ] > tmp.sort() > return [ item for (_,item) in tmp ] > > > data = [["Mickey","Mouse","50"], > ["Stan","Mantz","3"], > ["Junior","Wilst","40"], > ["Kim","Bean","15"]] > > data_by_lastname = sort_by_field(data,1) While it's probably much harder to read, one could avoid copying the list twice and maintain the semantics of sorting in place by doing something like the following... def sort_by_field( index ): def cmpfunc( x, y, i=index ): return cmp( x[i], y[i] ) return cmpfunc data.sort( sort_by_field( 2 ) ) ---Tom From edcjones at erols.com Fri Jul 6 13:11:15 2001 From: edcjones at erols.com (Edward C. Jones) Date: Fri, 06 Jul 2001 13:11:15 -0400 Subject: Comment on PEP-0238 References: <mailman.994427714.26169.python-list@python.org> <cpsngaja4g.fsf@cj20424-a.reston1.va.home.com> Message-ID: <3B45F133.7050206@erols.com> Guido van Rossum wrote: > 1. First we introduce a new function div() and a future statement that > makes integer division return a float result for a specific module. I suggest including a program that will read Python code and tell the user where all the "/" divisions are in the code. Thanks for the wonderful language, Ed Jones From paulp at ActiveState.com Mon Jul 2 13:54:25 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Mon, 02 Jul 2001 10:54:25 -0700 Subject: Augmented Assignement (was: Re: PEP scepticism) References: <mailman.993952381.32699.python-list@python.org> <zbN%6.415855$oc7.58414702@news2.rdc2.tx.home.com> <q0avjto87p59hn7gv28r5cf1c84j2fb8c7@4ax.com> <naO%6.416271$oc7.58537852@news2.rdc2.tx.home.com> <vm40kt8knq3pplpv1rarjubl73vnl12ure@4ax.com> <20010702145211.M8098@xs4all.nl> <mailman.994083124.18397.python-list@python.org> <uN107.141431$L4.17198481@news1.rdc1.az.home.com> Message-ID: <3B40B551.5A554148@ActiveState.com> Tim Hochberg wrote: > > ... > > Someone made a decision at some point that the builtin mutable types should > mutated by augmented assigment. If the newbies were sacrificed on somebody's > alter, it was not NumPy's. I've come to the same conclusion myself. I don't know what the rationale is for this "mutable types behave one way" and "immutable types behave another" philosophy. "Advanced" types could have "smart" behaviour and simple types could have x=x+y behaviour. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From zessin at decus.de Thu Jul 19 01:29:01 2001 From: zessin at decus.de (zessin at decus.de) Date: Thu, 19 Jul 2001 07:29:01 +0200 Subject: Which Python version to code for? Message-ID: <009FF3AC.F21C86F2.3@decus.de> Peter Milliken wrote: > Well, you also have to consider the case of different platform ports not > necessarily being the "lastest" version of Python i.e. I am writing > something in 1.5.2 on a VMS box. I believe that a port of 2.X is in the > works somewhere but at the moment I am stuck with 1.5.2. Correct. I am working on 2.1.1 - stay tuned. -- Uwe Zessin From loewis at informatik.hu-berlin.de Tue Jul 31 07:55:00 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 31 Jul 2001 13:55:00 +0200 Subject: Unicode File References: <3B66179D.1D55B27C@yahoo.com> Message-ID: <j4u1ztb9ez.fsf@artagnan.informatik.hu-berlin.de> Tksee Lhsoh <tksee at yahoo.com> writes: > For example, > s=open("unicode_filename").read(); > seems to return oridinary string, not unicode. > > What should I do ? I recommend to use codecs.open. You'll need to specify the encoding, e.g. s = codecs.open("unicode_filename",encoding="ucs-2").read() Regards, Martin From philh at comuno.freeserve.co.uk Thu Jul 5 19:21:07 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Fri, 6 Jul 2001 00:21:07 +0100 Subject: Is Python Dead? References: <MNS%6.355$Xs4.225014@news.pacbell.net> <458b194a.0107050711.72007607@posting.google.com> Message-ID: <slrn9k9tj3.129.philh@comuno.freeserve.co.uk> On 5 Jul 2001 08:11:48 -0700, Resty Cena <rcena at epcor.ca> wrote: >"Edward B. Wilson II" <ed at ewilson.com> wrote in message news:<MNS%6.355$Xs4.225014 at news.pacbell.net>... >> I have been following Python for five years now, and I am still just as >> frustrated with it as I was in 1996. >> >> Python still doesn't have good database support, > >I, too, have been following Python since 1996, waiting all the while >to make it easy for me to do database programming. What I'd call good >database support is where I download a file or set of files into a >directory under my Python directory, perhaps run an install program, >then start Python, import a package, issue a command to connect to >Oracle, and start playing around with the scott/tiger database. I >don't want, nor do I have the time, to compile anything, nor muck >around with the Windows registry, nor manually set paths -- I just >want to try the product, not install it for production use. Ideally, >I'd like the IDE to do this for me. Then why don't you write one, instead of just complaining that the tools available don't work quite how you like? -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From grante at visi.com Fri Jul 13 10:04:12 2001 From: grante at visi.com (Grant Edwards) Date: Fri, 13 Jul 2001 14:04:12 GMT Subject: not safe at all References: <mm8tkt4te3qnbpv3nh5nhsi591o1osln73@4ax.com> Message-ID: <wdD37.14722$B7.2684737@ruti.visi.com> In article <mm8tkt4te3qnbpv3nh5nhsi591o1osln73 at 4ax.com>, Dennis Roark wrote: >For amusement, run this little script which demonstrates a >near ultimate in the lack of type safety in the language. >(Perhaps there is a bit of type safety in that you can't do >this: 4 + "one") But look at what you can do in the >following script: > >x = 3 >x = x + 2 >print "x =", x >x = "now I'm a string" >print x >x = [ 5, x ] >print "and now a list:", x > >If you don't believe it, run it. Should any language allow >x to be such a chameleon, to where it can even be a >different type on two sides of an assignment? You're laboring under a very fundamental misapprehension: x doesn't have a type. x is a name. It is bound to an object. That object has a type. You can bind the name x to any type of object you wish. If you want x to be bound to an integer, bind it to an integer. If you don't want x to be a list, don't bind it to a list. Did you realize that FORTRAN allows you to assign the _wrong_ value to a variable? x = 1.234 WRONG! x is supposed to be 0.49487! No language can prevent you from writing programs that yeild incorrect results. -- Grant Edwards grante Yow! I think my career at is ruined! visi.com From speedy911 at mindspring.com Wed Jul 11 15:45:20 2001 From: speedy911 at mindspring.com (Charles Harrison) Date: 11 Jul 2001 12:45:20 -0700 Subject: yapsnmp Message-ID: <6f78b8b.0107111145.5decb8be@posting.google.com> I am very interested in implementing this module in some of my programs that use snmp commands, but I cant get it to install and dont really know enough C to pull apart the place in net-snmp where the installer is failing. I was wondering if anyone else has had trouble with the installation of this module or has any other insight as to how I might be able to get this module to run on my system. I think it should work; I have the latest version of net-snmp. Heres the transcript from my install attempt: [root at icispare1 yapsnmp-0.7]# ./configure creating cache ./config.cache checking for a BSD compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking whether make sets ${MAKE}... yes checking for working aclocal... found checking for working autoconf... found checking for working automake... found checking for working autoheader... found checking for working makeinfo... found checking host system type... i686-pc-linux-gnu checking build system type... i686-pc-linux-gnu checking for ranlib... ranlib checking for gcc... gcc checking whether the C compiler (gcc ) works... yes checking whether the C compiler (gcc ) is a cross-compiler... no checking whether we are using GNU C... yes checking whether gcc accepts -g... yes checking for ld used by GCC... /usr/bin/ld checking if the linker (/usr/bin/ld) is GNU ld... yes checking for BSD-compatible nm... /usr/bin/nm -B checking whether ln -s works... yes updating cache ./config.cache checking for object suffix... o checking for executable suffix... no checking for gcc option to produce PIC... -fPIC checking if gcc PIC flag -fPIC works... yes checking if gcc supports -c -o file.o... yes checking if gcc supports -c -o file.lo... yes checking if gcc supports -fno-rtti -fno-exceptions ... yes checking if gcc static flag -static works... -static checking if the linker (/usr/bin/ld) is GNU ld... yes checking whether the linker (/usr/bin/ld) supports shared libraries... yes checking command to parse /usr/bin/nm -B output... ok checking how to hardcode library paths into programs... immediate checking for /usr/bin/ld option to reload object files... -r checking dynamic linker characteristics... Linux ld.so checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... no checking for objdir... .libs creating libtool loading cache ./config.cache checking for gcc... (cached) gcc checking whether the C compiler (gcc -g -O2 ) works... yes checking whether the C compiler (gcc -g -O2 ) is a cross-compiler... no checking whether we are using GNU C... (cached) yes checking whether gcc accepts -g... (cached) yes checking for swig... swig checking for patch... patch checking for kstat_open in -lkstat... no checking for init_snmp in -lsnmp... yes checking how to run the C preprocessor... gcc -E checking for ANSI C header files... yes checking for ucd-snmp/ucd-snmp-config.h... yes checking for ucd-snmp/ucd-snmp-includes.h... yes checking for ucd-snmp/transform_oids.h... yes checking for ucd-snmp/asn1.h... yes checking for ucd-snmp/snmp_api.h... yes checking for ucd-snmp/snmp.h... yes checking for ucd-snmp/snmp_client.h... yes checking for ucd-snmp/mib.h... yes checking for ucd-snmp/default_store.h... yes checking for /usr/include/ucd-snmp... yes checking for python1.5/Python.h... yes checking for /usr/lib/python1.5/site-packages... yes checking for working const... yes checking for size_t... yes checking whether time.h and sys/time.h may both be included... yes updating cache ./config.cache creating ./config.status creating Makefile creating src/Makefile creating doc/Makefile creating config/Makefile creating config.h [root at icispare1 yapsnmp-0.7]# make make all-recursive make[1]: Entering directory `/home/charrison/yapsnmp-0.7' Making all in src make[2]: Entering directory `/home/charrison/yapsnmp-0.7/src' cp /usr/include/ucd-snmp/snmp_api.h . patch < snmp_api.h-patch patching file snmp_api.h cp /usr/include/ucd-snmp/snmp_client.h . patch < snmp_client.h-patch patching file snmp_client.h cp /usr/include/ucd-snmp/mib.h . patch < mib.h-patch patching file mib.h swig -python -shadow -I/usr/include/ucd-snmp net-snmp.i Generating wrappers for Python snmp_api.h : Line 95. Warning. Array member will be read-only. snmp_api.h : Line 97. Warning. Array member will be read-only. snmp_api.h : Line 186. Function pointers not currently supported (ignored). snmp_api.h : Line 216. Warning. Array member will be read-only. snmp_api.h : Line 220. Warning. Array member will be read-only. snmp_api.h : Line 276. Constant SNMP_MAX_SEC_NAME_SIZE multiply defined. (2nd definition ignored) snmp_api.h : Line 396. Warning. Array member will be read-only. snmp_api.h : Line 397. Warning. Array member will be read-only. net-snmp.i : Line 56. Warning. Array member will be read-only. /bin/sh ../libtool --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/include/python1.5 -I/usr/local/include/python1.5 -g -O2 -c net-snmp_wrap.c gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/include/python1.5 -I/usr/local/include/python1.5 -g -O2 -c net-snmp_wrap.c -fPIC -DPIC -o net-snmp_wrap.lo net-snmp_wrap.c: In function `_wrap_snmpv3_parse': net-snmp_wrap.c:1967: too few arguments to function `snmpv3_parse' net-snmp_wrap.c: In function `_wrap_print_description': net-snmp_wrap.c:3637: too few arguments to function `print_description' net-snmp_wrap.c: In function `_wrap_fprint_description': net-snmp_wrap.c:3666: too few arguments to function `fprint_description' make[2]: *** [net-snmp_wrap.lo] Error 1 make[2]: Leaving directory `/home/charrison/yapsnmp-0.7/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/charrison/yapsnmp-0.7' make: *** [all-recursive-am] Error 2 If you've gotten this far thank you so much in advance for all of your time. -Charles From christopherjmcmillan at eaton.com Wed Jul 11 09:09:52 2001 From: christopherjmcmillan at eaton.com (Chris McMillan) Date: Wed, 11 Jul 2001 09:09:52 -0400 Subject: Newbie problem with user input Message-ID: <9ihit4$8r611@interserv.etn.com> Hello all! The partial code below prompts a user to enter a path. I then want it to find (and later do something with) all the files in that directory matching the specified string. The problem is that when I run the script, and enter, for example D:\test it does not find any of the files. I believe it is because the glob command is searching for ''D:\\test'\\*.dat' With the extra single quotes. How can I get it to search for 'D:\\test\\*.dat' ? Thanks! Chris print 'Enter the path:' # prompt user for directory path path = raw_input() for fname in glob.glob('path\\*.dat'): # finds files matching string From sholden at holdenweb.com Tue Jul 3 15:01:55 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 3 Jul 2001 15:01:55 -0400 Subject: accessing class data members References: <3B420804.9882D166@bioeng.ucsd.edu> Message-ID: <KCo07.36014$zT1.1970850@e420r-atl3.usenetserver.com> "Curtis Jensen" <cjensen at bioeng.ucsd.edu> wrote in message news:3B420804.9882D166 at bioeng.ucsd.edu... > In many OO languages, and theory, it is often the case that when you > want to know the value of some data member, that a function is written > to return that value. However, in Python it seems that people just > access the data member directly. > > for example: > if there were a class that represented a physical object. In the class > there were data members that held the objects temperature and location. > If I wanted to know the temperature of an object, I could just use > obj.temperature. Though in other languages, the convention seems to > call a function that returns the value, like: obj.get_temperature. > > Which is better? I would say oranges are definitely better than apples :-) In Python you can write accessor methods if you want, but (I believe) most Python programmers are pragmatic enough to say that this is unnecessary overhead for simpler, well-understood programs. Unlike other languages, you can do it either way: an object has effectively no way of hiding attributes from access by other objects, and so the Python programmer relies on discipline to ensure everything works. Java and C++, for example, allow attributes (members) to be private in various ways. regards Steve -- http://www.holdenweb.com/ From bokr at accessone.com Sun Jul 29 03:33:23 2001 From: bokr at accessone.com (Bengt Richter) Date: Sun, 29 Jul 2001 07:33:23 GMT Subject: int vs float divide: abbreviating numbers w/SI units References: <eppstein-D36BE1.12293028072001@news.service.uci.edu> Message-ID: <3b63a8ec.700705120@wa.news.verio.net> On Sat, 28 Jul 2001 12:29:30 -0700, David Eppstein <eppstein at ics.uci.edu> wrote: >Some time buried in the recent division flamewar I posted a message listing >the uses I'd recently made of integer division, one of which was some short >code for abbreviating numbers like 1008926 to e.g. 988k for more readable >text output of file sizes in a web photo gallery generator. > >Anyway, I decided it would be a good idea to make it more general and >robust, and discovered somewhat to my surprise that float division seems to >be a better fit for the task. The new code is below if anyone wants to >critique or use it. > [...] I was going to make a one-liner, but it would be really ugly and repeat stuff ;-) But there might be something in this you can use?: import math def abbrn(n,k=1000): if n==0: return '0' nk, rk = divmod(math.log(abs(n)), math.log(k)) nkr = max(-9, min(int(nk), 9)) suffix= 'kyzafpnum kMGTPEZYk'[nkr+9] + (abs(nkr)==9)*("^%d" % (nk,) ) sr = ("%1.1f" % (math.exp(rk),)) adjlen = len(sr) - 2*(sr[-1]=='0' or len(sr)>3) return '-'*(n<0) + sr[0:adjlen] + suffix I think it does what yours does, except I rely on %1.1f to round and just chuck the '.0' or .x if there's more than 3 chars, which makes some differences, e.g., for the args 2.0*10.**-30 1000 yours => 2.0k^-10 mine => 2k^-10 whereas for the args 2.0*10.**30 1000 yours => 2k^10 mine => 2k^10 JFTHOI-ly ;-) From rjh at 3-cities.com Sat Jul 7 13:05:44 2001 From: rjh at 3-cities.com (Robert J. Harrison) Date: 7 Jul 2001 10:05:44 -0700 Subject: Comment on PEP-0238 References: <mailman.994427714.26169.python-list@python.org> <cpsngaja4g.fsf@cj20424-a.reston1.va.home.com> Message-ID: <7ef50c46.0107070905.4f9fa92@posting.google.com> Guido van Rossum <guido at python.org> wrote in message news:<cpsngaja4g.fsf at cj20424-a.reston1.va.home.com>... > The warning framework and the future statement are there to make the > transition easier. Here's my plan, "new division in four phases": > > 1. First we introduce a new function div() and a future statement that > makes integer division return a float result for a specific module. > > 2. In a following revision, we add a warning when / is used on two int > or long arguments, recommending to use div() instead. (It is > important not to start warning in phase 1, so folks have time to > switch to div() voluntarily first; maybe phase 1 could have a > command line option to warn about integer division.) > > 3. A revision later, we change all plain integer divisions to be an > error, *forcing* folks to use div() or use the future statement to > specify floating point division. > > 4. Finally we can implement the "future" behavior by default. > > I haven't picked dates yet; if folks agree, I would like to add div() > and a future statement to 2.2 and space the other steps a single > revision apart, so phase 4 would be at Python 2.5 (April 2003, if we > keep the current release schedule up). Is that too aggressive? > > I currently favor div(x, y) over x//y and x div y. Maybe also add > mod(x, y) for symmetry (that would also explain divmod() as a > messenger from the future :-). > > I'm not sure how to spell the future statement. Here are some > choices: > > from __future__ import float_division > from __future__ import real_division > from __future__ import new_division > from __future__ import division > > --Guido van Rossum (home page: http://www.python.org/~guido/) Sounds good to me. If it must happen, then the sooner the better. However, I think that some details of the numerics also need to be clarified before you boldly go. Specifically, - What about long division? A float cannot capture all results. Should it raise a Value/Range error? Should the programmer be forced to use divmod? Should it return a rational? I don't really like the last two choices and the first two choices obviate much of the usefulness of longs. Perhaps Paul Dubois's kinds mechanism comes to the rescue? He does have a trial implementation in numeric (though I am not in favor of seeing much of the current numeric integrated into the core) Robert rjh at 3-cities.com From graham at coms.com Fri Jul 6 06:09:27 2001 From: graham at coms.com (Graham Ashton) Date: Fri, 06 Jul 2001 11:09:27 +0100 Subject: import syntax References: <E15IBZ2-0003ru-00@mail.python.org> <mailman.994351509.21525.python-list@python.org> Message-ID: <r7g17.1683$h45.11340@news.uk.colt.net> In article <mailman.994351509.21525.python-list at python.org>, "Andrew Todd" <aetodd at wm.edu> wrote: > This isn't terribly important, but wouldn't it be nice if you could do > the following... > > from module import a and b > > instead of having to write... > > from module import a > from module import b A bit like this then: ratchet% python Python 2.1 (#7, Jun 24 2001, 18:32:35) [GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2 Type "copyright", "credits" or "license" for more information. >>> from syslog import openlog, closelog >>> From hughett at mercur.uphs.upenn.edu Sat Jul 28 13:00:32 2001 From: hughett at mercur.uphs.upenn.edu (Paul Hughett) Date: 28 Jul 2001 17:00:32 GMT Subject: IPC10 Call For Tutorials References: <3B5D9A09.A49F7C7B@sage.att.com> <mmh77.25356$EP6.5928862@news1.rdc2.pa.home.com> <20010727.182145.933110197.16613@hp.com> Message-ID: <9jur3g$6eh$1@netnews.upenn.edu> Bill Anderson <anderson at hp.com> wrote: : In article <mmh77.25356$EP6.5928862 at news1.rdc2.pa.home.com>, "Terry Reedy" : <tjreedy at home.com> wrote: :> "Garry Hodgson" <garry at sage.att.com> wrote in message :> news:3B5D9A09.A49F7C7B at sage.att.com... :>> :>> We're now accepting proposals for tutorials for IPC10, the annual :>> Python conference. We had a good batch last year, and are hoping to :>> have some equally good ones this year. :> :> How about someone doing "Surving Language Change"? (Only half jesting.) :> :> : Is that mean to be Serving or Surviving. ;^) We can have a debate between those who want more language change and those who want less. (With a sidebar discussion for those who want more change HERE but less change THERE!) Paul Hughett From piet at cs.uu.nl Fri Jul 6 09:47:57 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 06 Jul 2001 15:47:57 +0200 Subject: deleting directories w/ subfolders References: <9i37ta$p61$1@bob.news.rcn.net> Message-ID: <ud77ei2ya.fsf@cs.uu.nl> >>>>> "Chris Duncan" <chrisd at rocketnetwork.com> (CD) writes: CD> Anyone know a way to delete a parent directory containing files & CD> subfolders? rmtree in the shutil module. -- Piet van Oostrum <piet at cs.uu.nl> URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From JamesL at Lugoj.Com Mon Jul 23 23:24:47 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Mon, 23 Jul 2001 20:24:47 -0700 Subject: thread module References: <20010723210218.11240.00000881@ng-fv1.aol.com> Message-ID: <3B5CEA7F.497E5DA3@Lugoj.Com> TheDustbustr wrote: > > What args are encessary when you call thread.start_new_thread()? The module > index says: > > "start_new_thread (function, args[, kwargs]) > Start a new thread. The thread executes the function function with the argument > list args (which must be a tuple). The optional kwargs argument specifies a > dictionary of keyword arguments." > > How do I create a simple thread like so: > def hi(): > print "Hi!" > thread.start_new_thread(hi(),args) > > What are the args? Since the function hi() takes no arguments, the "args" argument should be an empty tuple, which is represented by an open and close parenthesis. Also, the "function" argument should be just the function name WITHOUT the parenthesis. You used "hi()" when you should have simply used "hi". So to start the thread, you would do: thread.start_new_thread(hi, ()) Here is, hopefully, a more revealing example: Suppose you want two threads running, one of which prints multiples of 2 every 5 seconds and another that prints multiple of 3 every 10 seconds. So first define a function that takes an identifier, the time to wait, and the amount by which to increment, and then use it to launch two threads: import thread import time def Func(id, numSecs, incBy): val = 0 while 1: print id, val val = val + incBy time.sleep(numSecs) thread.start_new_thread(Func, ("First thread", 5.0, 2)) thread.start_new_thread(Func, ("Second thread", 10.0, 3)) Hope this helps! From m.faassen at vet.uu.nl Mon Jul 2 12:24:13 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 2 Jul 2001 16:24:13 GMT Subject: Is Python Dead? References: <MNS%6.355$Xs4.225014@news.pacbell.net> <mailman.994049882.30354.python-list@python.org> <9hp1f002dp6@enews4.newsguy.com> Message-ID: <9hq77d$i0g$2@newshost.accu.uu.nl> Alex Martelli <aleaxit at yahoo.com> wrote: [snip] >> The only other time is when I must work with dBase tables... but I would >> hardly typify that as not being "good database support". > http://www.stud.ifi.uio.no/~larsga/download/python/ > or mxODBC + the dBase/clipper/foxpro ODBC drivers, or...? You can use the ODBC that comes with PythonWin to access dBase tables, in fact. I've done so in the past. Windows comes with dBase drivers for ODBC by default. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From martin at strakt.com Mon Jul 30 02:50:59 2001 From: martin at strakt.com (Martin Sjögren) Date: Mon, 30 Jul 2001 08:50:59 +0200 Subject: [OT] Number theory [Was: A use for integer quotients] In-Reply-To: <slrn.pl.9m9tnf.gim.qrczak@qrnik.zagroda> References: <IjA77.97824$Rr4.589251@ozemail.com.au> <3b602afa.930850@nntp.sprynet.com> <slrn9m121m.e6f.Gareth.McCaughan@g.local> <3b617133.1013412@nntp.sprynet.com> <slrn9m3ssq.1c5.Gareth.McCaughan@g.local> <3b62c8c4.2448381@nntp.sprynet.com> <slrn9m61e6.1jof.Gareth.McCaughan@g.local> <3b6409e0.2079581@nntp.sprynet.com> <3b645f76.747435355@wa.news.verio.net> <slrn.pl.9m9tnf.gim.qrczak@qrnik.zagroda> Message-ID: <20010730085059.A1005@strakt.com> On Mon, Jul 30, 2001 at 05:55:59AM +0000, Marcin 'Qrczak' Kowalczyk wrote: > Sun, 29 Jul 2001 22:20:09 GMT, Bengt Richter <bokr at accessone.com> pisze: > > > BTW, note the usefulness of boolean-as-integer returned from > > comparison operators, if you want to be picky about plurals: > > > > print "There %s %d error%s." % ( ['were','was'][n==1], n, 's'*(n!=1) ) > > I would write it > print "There %s %d error%s." % (if n==1 then ('was', n, '') > else ('were', n, 's')) > if I could. I would write it if n == 1: print "There was one error." else: print "There were %d errors." % n If you've ever tried to translate programs to other languages, using gettext for example, you quickly realize that all other constructs are abominations and impossible to translate to other languages. Okay, that was off topic :) Martin -- Martin Sj?gren martin at strakt.com ICQ : 41245059 Phone: +46 (0)31 405242 Cell: +46 (0)739 169191 GPG key: http://www.strakt.com/~martin/gpg.html From grante at visi.com Thu Jul 26 16:02:11 2001 From: grante at visi.com (Grant Edwards) Date: Thu, 26 Jul 2001 20:02:11 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <eppstein-03540D.13070222072001@news.service.uci.edu> <LNBBLJKPBEHFEDALKOLCOECNLAAA.tim.one@home.com> <mailman.995899647.346.python-list@python.org> <tclolt053o18f8q0ntb7n4aggitdkmeg4h@4ax.com> <Io_67.23543$B7.3779351@ruti.visi.com> <slrn9lp2m5.vp.Gareth.McCaughan@g.local> <p56plt8q4rs3bgcqbepk61q2r3g0tr2vhe@4ax.com> <slrn9ls3ae.2fm.Gareth.McCaughan@g.local> <cpitghbq05.fsf@cj20424-a.reston1.va.home.com> <MWD77.27751$EP6.6983549@news1.rdc2.pa.home.com> <9jnt9p$qhe$1@newsy.ifm.liu.se> <SYV77.27286$B7.4239335@ruti.visi.com> <cpitgf7itx.fsf@cj20424-a.reston1.va.home.com> <WIY77.27607$B7.4257794@ruti.visi.com> <xi_77.30701$EP6.7899249@news1.rdc2.pa.home.com> Message-ID: <7H_77.27771$B7.4269021@ruti.visi.com> In article <xi_77.30701$EP6.7899249 at news1.rdc2.pa.home.com>, Terry Reedy wrote: >I believe that 5.0//2.0 will be 2.0, not 2 Ah, but 2.0 and 2 are the same value.... -- Grant Edwards grante Yow! Of course, you at UNDERSTAND about the PLAIDS visi.com in the SPIN CYCLE -- From pkalliok at cc.helsinki.fi Tue Jul 10 18:01:10 2001 From: pkalliok at cc.helsinki.fi (Panu A Kalliokoski) Date: 10 Jul 2001 22:01:10 GMT Subject: Adding a package to the standard distribution References: <9iad21$btd$1@oravannahka.helsinki.fi> <mailman.994687591.32116.python-list@python.org> Message-ID: <9iftv6$lq1$1@oravannahka.helsinki.fi> Skip Montanaro <skip at pobox.com> wrote: > Panu> asynchat. However, I don't know what mailing list / person I > Panu> should write to to get the package included in the standard > Panu> distribution. > For starters, I'd suggest you make it available via HTTP or FTP and post an > announcement to the Python announcements list/group. Also, submit it to the I suppose this is comp.lang.python.announce? I'll post there. FYI, the code is avail. at http://sange.fi/~atehwa-u/selecting/ > Vaults of Parnassus. As for persuading the powers-that-be, you can send a > note to python-dev at python.org. I tried to find information about appropriate lists on www.python.org, but found none. Maybe python-dev just slipped my eye. What are Vaults of Parnassus? Some kind of open repository for Python code? Anyway, thank you for the advice. Panu Kalliokoski From cliechti at mails.ch Fri Jul 27 19:55:20 2001 From: cliechti at mails.ch (chris liechti) Date: 28 Jul 2001 01:55:20 +0200 Subject: Changing the Division Operator -- PEP 238, rev 1.12 References: <mailman.996263475.24304.python-list@python.org> Message-ID: <Xns90EC142294EAAcliechtimailsch@62.2.32.50> there is just one unpleasan't thing left over: in the transition phase its __div__, __truediv__, __floordiv__ and their respective 'i' version for arg assignment. this solution allows the object to "see" what the caller wants for a division type. ok, but.. classes would need a change when upgrading from 2.x to 3.x ( __truediv__ will become the same as __div__ in 3.x but its not with "from __future_ import division" in 2.x)? what would 3.x do? search for __truediv__ and then for __div__? that would give wrong results with old modules that only have a __div__ (emulating the missbehaviour) and no __truediv__. (ok i don't realy belive in classes emulating some missbehaviour, see next paragraph) wouldn't it be better when only __div__ and __floordiv__ were needed? classes could not provide the two diffrent meanings of '/' but how many classes do realy need this? when somebody is implementing his own number object he will anyway provide a true division, wouldn't he? this would also *not* introduce a new name that's later unused/merged with __div__. (remember: one obvious way to do it) and now for the positive things... I can agree with the motivation section. Now that the big picture mostly clear - i like it. (Can't wait for a unified numeric model, it sounds good ;-) chris the following two reasons have changed my mind from "oh no! - code breaks" to "yes! let's do it": Guido van Rossum <guido at zope.com> wrote in news:mailman.996263475.24304.python-list at python.org: > PEP: 238 ... > It is the opinion of the authors that this is a real design bug in > Python, and that it should be fixed sooner rather than later. > Assuming Python usage will continue to grow, the cost of leaving > this bug in the language will eventually outweigh the cost of > fixing old code -- there is an upper bound to the amount of code > to be fixed, but the amount of code that might be affected by the > bug in the future is unbounded. > > Another reason for this change is the desire to ultimately unify > Python's numeric model. This is the subject of PEP 228[0] (which > is currently incomplete). A unified numeric model removes most of > the user's need to be aware of different numerical types. This is > good for beginners, but also takes away concerns about different > numeric behavior for advanced programmers. (Of course, it won't > remove concerns about numerical stability and accuracy.) ... -- chris <cliechti at mails.ch> From guido at python.org Wed Jul 25 00:54:45 2001 From: guido at python.org (Guido van Rossum) Date: Wed, 25 Jul 2001 04:54:45 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <LNBBLJKPBEHFEDALKOLCEEIJLAAA.tim.one@home.com> <mailman.995949762.26287.python-list@python.org> Message-ID: <cp66chbobw.fsf@cj20424-a.reston1.va.home.com> "Chris Gonnerman" <chris.gonnerman at newcenturycomputers.net> writes: > Some of us have tried. Besides my alternative, I have seen two > others which allow case-by-case preservation of the old semantics > where they may have been intended. > > I have seen very few comments on them though (except from Stephen Horne). It's not easy to find the light among the heat. > ASSERTIONS: > 1. Best-effort handling of division is desirable. > 2. An explicit operator for truncating division is desirable > (as in, explicit is better than implicit). > 3. Code breakage is bad, and difficult-to-detect code breakage > is worse. > 4. Difficulty in writing backwards-compatible code is bad > (thus, code to implement partitioning of a dataset would > naturally use the // operator in 2.2+ but would not be able > to in pre-2.2, so the div() function would have to be > religiously used, hurting readability). > > Assertion 1 and 2 conflict with 3 and 4; #4 in particular bothers > me. Hm, #4 is relatively new in this discussion (for me, anyway). I will have to adapt to this new requirement, which I find reasonable (although I wish it didn't exist -- but I understand the motivation). > Many have said that #3 is irrelevant as we have from 2.2 to 2.4 to > fix it, but I have upgraded several systems directly from 1.5.2 to > 2.1 without substantial problems; going direct to 2.4 from 2.1 would > not be so painless. You will have at least from 2.2 to 2.6 though (at least two years), and in reality more because I propose to add a command line option to revert to old division semantics for several releases after 2.6. > SOME way is needed to specify, in module scope, which set of > mathematics rules should be enforced. Whatever method is used > should (IMHO) be uniform from 2.2 to 2.4; my method, as given, is > the only one where the code reads the same from 2.2 on: > > from __numerics__ import original # or standard, etc... Not bad. But I am still uncomfortable with making the old semantics a *permanent* wart of the language. I'd much rather deal with a future statement for 5 years than with a __past__ statement forever. An alternative that would not need this would be to require from __future__ import division in order to use the new semantics, and use the proposed command line option (say, "python -D old") to default to the old behavior as long as you have to support unconverted code. > Just thinking about the implementation gives me headaches, but Guido > and Co. have readily implemented fancy things like the > software-time-machine > > from __future__ import phasers, warp_drive # or whatever > > and so my proposal (or a mutation thereof) should be no biggie. Indeed, this wouldn't be hard -- although maybe a friendlier syntax, like "directive blah, blah, blah" might make sense *if* we decide to do this. (Which I still don't think is the best solution, but I do see your point.) > As I said, you can't honestly say we ALL haven't been trying. It's > not that I object directly to the change, it's the overall > plan/effect/semantics etc. that I don't like. Would it be more palatable to you if the new semantics didn't become the default (or the law) until Python 3.0 was introduced? That's how Perl dealt with a much larger incompatible language change: Perl4 was left alone (I believe there are still plenty installations that require it) and Perl5 was the future. --Guido van Rossum (home page: http://www.python.org/~guido/) From gmcm at hypernet.com Tue Jul 31 14:04:17 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 31 Jul 2001 18:04:17 GMT Subject: Best practices with import? References: <9jvnoe$om2$1@slb5.atl.mindspring.net> <3B6369D4.671C1870@alcyone.com> <Xns90ED38309C442cliechtimailsch@62.2.32.50> <3B63973B.490D4B08@engcorp.com> <Xns90ED5DA29D6E3gmcmhypernetcom@199.171.54.154> <3B66AE57.79A2C217@cybermesa.com> Message-ID: <Xns90EF8F3563021gmcmhypernetcom@199.171.54.155> Jay O'Connor wrote: [using import inside functions, classes...] > class MyEngine: > def __init__ (self): > import engine_support > > def doSomething (self): > #is engine_support is scope? > engine_support.do_something() [snip] > hmmmm...I just tested it, both references to engine_support outside of > __init__ fail with a NameError. *THAT* would be something useful to > have...a class level import; import the module in __init__, it's in > scope for the whole class > > The best workaround for now I could think of is either to assign an > instance variable to the module [snip] > or to assign it to a global in the module so that once it's imported, > it's available to the whole module. > > I can see the use for being able to import a module into a function, but > having it in visible outside of that function (especially in classes) Assigning to an instance variable is a perfectly sane way to do that. Note that in def f1(): import x def f2() import x f1() f2() all the heavy lifting is done when f1 executes. When f2 executes, import finds x already in sys.modules, so the second import is very cheap (but not free). I would suggest staying away from trying to make a delayed import visible globally, it's just too fragile. - Gordon From gregj at pdxperts.com Fri Jul 20 04:11:06 2001 From: gregj at pdxperts.com (Greg Jorgensen) Date: Fri, 20 Jul 2001 08:11:06 GMT Subject: Python 2 times slower than Perl References: <8f41cfd.0107171238.6ff33b9b@posting.google.com> <9j3rvk$26bt$1@norfair.nerim.net> <3B559B30.61A90EA@jam.rr.com> <9j4af20d2o@enews4.newsguy.com> <ZOw57.375583$p33.7544629@news1.sttls1.wa.home.com> <87elrdtgps.fsf@ivory.localhost> <X%M57.379696$p33.7613309@news1.sttls1.wa.home.com> <87ofqgdtxr.fsf@ivory.localhost> Message-ID: <uIR57.381357$p33.7644280@news1.sttls1.wa.home.com> "Patrick W." <anapraxis at yahoo.com.au> wrote [long, interesting reply omitted] Patrick, I appreciate your thoughtful reply. I think we agree on the big picture. Personally I would be happy programming in C, Scheme, and Python as you suggest, but the real world is a lot messier. There's lots of legacy code written in COBOL, Fortran, PL/I, what have you. And there's lots of code that is written in languages that seem less than ideal choices to us Python-enlightened: Visual Basic, C++, and Java (give it ten years). I'd add SQL (or something like it) to your list. Not for writing entire programs, of course, but when dealing with relational sets you want a language designed for that. That's not to say that relational databases are the only way to organize data, but they are an efficient way to organize some kinds of data, and more important lots of valuable data is already stored in relational databases. When junior programmers ask me what language they should learn to maintain their marketability, I always recommend SQL. Benchmarks are good for measuring and improving the implementation of a language, but they really don't say much about the language itself, or how it compares to other languages. A language can't really be said to be slower than another language; benchmarks only test implementations. Some languages are by design difficult or impossible to implement as efficiently as, say, C, but comparing those languages to C is comparing apples to oranges, like comparing a Toyota Camry to a semi truck. Python's clear syntax, rich built-in data types, and excellent standard library appealed to me right off when I read Guido's tutorial. A few hours of experimenting proved to me that I could easily write useful Python programs, and that those programs excecuted acceptably fast enough for most of my purposes (and I'm one of those C programmers who thinks in C). Python was already mature when I discovered it. After ten years of work by some clearly very talented people I'd be very surprised if huge performance problems were lurking undiscovered in the code. I don't need benchmarks to tell me that: the size and sophistication of the Python community, and my own experience with the language, are enough. When newbies post their "benchmarks" in comp.lang.python I cringe because they are blind to the most important things about Python. Ironically, my regular job has me writing a large web-based application entirely in PL/SQL, Oracle's "procedural extensions" to SQL. PL/SQL was chosen through a wrong-headed but typical corporate decision-making process. The code I am writing is already legacy code, and it isn't even fully-deployed yet. I've been able to use Python to help me preprocess mixed HTML + PL/SQL code, but Python is not on the list of approved "production languages," nor is it likely to be, because it doesn't add to anyone's job security or political power. Fortunately I'm a contractor so the project will someday be a memory and resume-enhancer for me, and a maintenance headache for someone else. This is, in my experience, a fairly typical situation in the "real world" my fellow programmers frequently refer to. Regards, Greg Jorgensen PDXperts LLC Portland, Oregon, USA From peter at engcorp.com Tue Jul 24 23:58:40 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 24 Jul 2001 23:58:40 -0400 Subject: Pinecones multiply like rabbits around here... References: <mailman.995975742.21691.python-list@python.org> Message-ID: <3B5E43F0.E8654A32@engcorp.com> Skip Montanaro wrote: > > I was on a walk with my wife and dog yesterday. Out of the blue I asked her > "what's the result of five divided by two?" After a little back-and-forth > where she tried to figure out how I was trying to trick her and make her > look foolish she answered, "two-and-a-half". I then posed, "Suppose you > have five pinecones and you want to clump them into groups of two. What > would you do?". Her answer was, "Put two in the first group, two in the > second group, and break the last pinecone in two so the third group would > have two as well." I think you might have phrased the second question closer to "Suppose you have five pinecones and you want to create groups containing two whole pinecones. What would you do?". Would that likely have elicited a different response? One with, perhaps, a remainder pinecone? (Being overly serious, yes, but I did chuckle at the story. :) From mcherm at destiny.com Thu Jul 12 11:01:09 2001 From: mcherm at destiny.com (mcherm at destiny.com) Date: Thu, 12 Jul 2001 10:01:09 -0500 Subject: Version incomptabilities, code changes, __future__, etc Message-ID: <a9b1cafe.cafea9b1@destiny.com> simonb at webone.com.au wrote: > i don't want to see any more versions of python. > ITS FINISHED > AND I LOVE IT RIGHT NOW > if you want more then make a new language. Regretably, Simon, you are out of luck. In order to convince Microsoft to support Python natively in their .NET initiative, Guido was forced to make several major concessions. One of those was to recind the "Open Source" liscense, which allowed anyone to freely use Python -- using any version they wanted for (pretty much) any purpose. Unfortunately, Python is now released on a more restrictive liscense, which, in a future version, will require all Python programs to contact a Microsoft Certification server and present a Passport certification before executing. In order to ensure that everyone migrates to the new version of the software (to be released as soon as Microsoft finishes building the infrastructure), the migration will be mandatory. This is too bad, because up until this change, it would have been allowed -- actually, ENCOURAGED -- for you to keep a copy of Python 2.1 around and continue using it. It would EVEN have been permissible for you to keep the SOURCE CODE so you could make your own updates as technology and standards march forward! (Although most of the code is a badly-commented mess written in an obscure and difficult language called "C", so you might find this difficult.) This would have allowed you to keep this "FINISHED" product around for as long as you want. I'm sorry you got caught up in this... but this kind of comercialization is unavoidable in today's world. The change has not been made public yet, but you should expect an announcement any day now. -- Michael Chermside PS: I wouldn't know myself, but some say that the PSU was actually behind the change. Some sort of plan to subvert .NET and engineer a massive takeover of From sh at ttsoftware.co.uk Mon Jul 23 07:21:59 2001 From: sh at ttsoftware.co.uk (Steve Horne) Date: Mon, 23 Jul 2001 12:21:59 +0100 Subject: PEP0238 lament References: <220720012039325082%jwbaxter@spamcop.com> <mailman.995861918.11181.python-list@python.org> Message-ID: <ni1olt8lmseiqracnh1j1oe5coegc11ulo@4ax.com> On Mon, 23 Jul 2001 00:16:19 -0400, "Tim Peters" <tim.one at home.com> wrote: >case which I intended. If this happens, the transitional release should >also produce runtime warnings pinpointing lines where "/" is applied to >integer arguments, so if you've got good unit tests nothing will be missed. Assuming that people realise they need to retest all those scripts they've be using trouble-free for years. I think you underestimate the number of people who will some day figure that 1.5.2 is a bit old, install the latest version, and have hell break lose over night when half their scripts stop working. >Don't forget that this has been debated repeatedly over the course of >several years. Most people drop out of these things after the fifth time ><0.5 wink>. There's no point arguing these things if you don't believe anyone would ever really do it. Now it looks like, after spending some time advocating Python and talking people into letting me use it, suddenly I'm going to look a right arse. I'll either have to warn everyone not to upgrade because "the new version has serious compatability issues with a basic arithmetic issue - nothing you wouldn't expect from *any* language honestly - please stop laughing at me", or just hope like hell that the problems aren't serious enough to get me the sack. I couldn't find every copy of my scripts that's in use if I wanted to - and besides, how am I going to justify having to suddenly take time out to "fix the serious compatability issues with a basic arithmetic operator in that language I kept insisting was so great". Python advocates are going to end up looking pathetic. How long do you think they'll carry on advocating Python? -- Steve Horne Home : steve at lurking.demon.co.uk Work : sh at ttsoftware.co.uk From quinn at yak.ugcs.caltech.edu Thu Jul 26 13:59:15 2001 From: quinn at yak.ugcs.caltech.edu (Quinn Dunkan) Date: 26 Jul 2001 17:59:15 GMT Subject: Exceptions' Behaviour References: <mailman.995459309.19355.python-list@python.org> <ac677656.0107181058.71f62494@posting.google.com> <mailman.995526636.21726.python-list@python.org> <ac677656.0107191006.28da887e@posting.google.com> Message-ID: <slrn9m0mjj.l0b.quinn@yak.ugcs.caltech.edu> On 19 Jul 2001 11:06:02 -0700, Tom Good <Tom_Good1 at excite.com> wrote: >Martin Sj?ren <martin at strakt.com> wrote in message news:<mailman.995526636.21726.python-list at python.org>... >> Yes I know that, but that's not what I'm asking. What I'm asking is why i >> n >> >> >>> raise ("a","b") >> >> the "b" disappears? IMO that's a pretty weird behaviour. Yes anybody usin >> g >> non-class exceptions derived from Exception in a real-world program are >> insane, but this is a puristic thing of mine. :-) >> >> Martin > >I agree, it is kind of weird, and I don't know why it works that way. >I would probably expect trying to raise a tuple to generate an error. I expect it's backwards compatibility. Many moons ago there were no user-defined classes, and hence no instance exceptions. Ever notice the __getitem__ trickiness IOError does so it can be unpacked like like a 2-tuple? I have a feeling that once upon a time it was. Try starting python with -x and notice that the 'b' no longer disappears. Instance exceptions are probably an example of a past major change which could have broken a lot of code. It seems to have been handled quite well, which is good, because there is code using -x and string exceptions to this day. It has left a couple little warts behind, but you can't please everyone. The trick is balancing compatibility against acquiring warts. From guido at python.org Tue Jul 31 13:36:02 2001 From: guido at python.org (Guido van Rossum) Date: Tue, 31 Jul 2001 17:36:02 GMT Subject: from __future__ import generators not working in IDLE References: <xUy87.107718$ph7.20561327@news.hananet.net> Message-ID: <cp4rrtypb2.fsf@cj20424-a.reston1.va.home.com> "Grace" <nospam at nospam.com> writes: > "from __future__ import generators" does not work in IDLE which is included > in Python 2.2a1. > > See the copy&pasted text from the real IDLE running: > > >>> from __future__ import generators > >>> > >>> <string>:2: Warning: 'yield' will become a reserved keyword in the > future > <string>:2: Warning: 'yield' will become a reserved keyword in the future > <string>:2: Warning: 'yield' will become a reserved keyword in the future > def f(): > yield 1 > > SyntaxError: invalid syntax > >>> > > Is there any workarounds? Not yet (apart from adding "from __future__ import generators" to the top of codeop.py). But in python-dev Michael Hudson is working on a fix to codeop that will let us select compilation flags. --Guido van Rossum (home page: http://www.python.org/~guido/) From cb921 at voice.co.za Tue Jul 31 08:33:23 2001 From: cb921 at voice.co.za (Campbell) Date: Tue, 31 Jul 2001 14:33:23 +0200 Subject: Control of flow Message-ID: <Pine.LNX.4.31.0107311355450.2321-100000@cb921.local> Hi, I use python to write telephony apps, and I find that a 'goto' is often a nice tool (stop going 'aargh', its properly "useful" sometimes =). Here is a little snippet that gets a month/day from a caller. If the day entered is not in the range of days valid for the month entered, we repeat from the top. Does anyone have a few minutes to waste helping me?? How better can I code things that look like this: >>> snip <<< while 1: cont = 1 ## ugh! month = getdtmf("enter2digs.vox", 2) if month < 1 or month > 12: play("invalidmonth.vox") continue while 1: day = getdtmf("enterday", 2) if day < 1 or day > Month[month]: play("invalidday.vox") cont = 1 cont = 0 if cont == 1: continue break >>> snip <<< It gets worse quite easily. And because there's a person on the other end of the phone hearing the files and entering keypad digits, I must dumb down the program to their level, sometimes ending up with a huge string of while 1:'s and half-job loop control variables like cont. Thank you, Thank you, Campbell. The world is our spoon tick, tock. From eppstein at ics.uci.edu Fri Jul 27 11:57:22 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Fri, 27 Jul 2001 08:57:22 -0700 Subject: Toppling the numeric tower References: <DLW77.49367$Cy.6275542@news1.rdc1.az.home.com> <eppstein-749F84.08434526072001@news.service.uci.edu> <3b6174fa.1981112@nntp.sprynet.com> Message-ID: <eppstein-073A07.08572227072001@news.service.uci.edu> In article <3b6174fa.1981112 at nntp.sprynet.com>, ullrich at math.okstate.edu (David C. Ullrich) wrote: > About whether isintegral should imply isexact: I dunno much > algebra. For the flavors of "algebraic integer" that seem dimly > familiar it seems like one could give an exact representation. > Is this true? Yes, but we've seen convincing arguments earlier in this thread that isintegral() should be true only for members of Z, not for algebraic integers. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From mal at lemburg.com Sat Jul 14 12:23:44 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Sat, 14 Jul 2001 18:23:44 +0200 Subject: DB-API 1.0 vs. 2.0 References: <AjW37.9662$e5.1281275@newsb.telia.net> Message-ID: <3B507210.AF4C1D1C@lemburg.com> Fredrik Lundh wrote: > > DB-API 1.0 (dated April 9, 1996) specifies that a connection object > should provide "all Cursor Object attributes and methods". > > this requirement seems to have been dropped in the (undated) > DB-API 2.0 specification -- but this fairly major change isn't listed > under "Major Changes from Version 1.0 to Version 2.0"... > > what's the deal here? should a 2.0 implementation provide an > implicit cursor, or not? It can, but is not required to. The deal is: explicit is better than implict :-) > (btw, maybe the people involved could add a release date to the > 2.0 specification?) Done. (See CVS) -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From phlip_cpp at my-deja.com Wed Jul 18 07:00:49 2001 From: phlip_cpp at my-deja.com (Phlip) Date: Wed, 18 Jul 2001 11:00:49 +0000 Subject: alpha blend in tkinter Canvas Message-ID: <Y3k57.10$_c5.51814@news.pacbell.net> Hypo Nt: If I have a tkinter Canvas, how do I paint in an object that "blends" with the color under it, instead of just jamming its own color in? -- Phlip phlip_cpp at my-deja.com ============ http://c2.com/cgi/wiki?PhlIp ============ -- All sensors report Patti having a very good time -- From ymor at checkpoint.com Sun Jul 29 18:50:37 2001 From: ymor at checkpoint.com (Yossi Mor) Date: Mon, 30 Jul 2001 00:50:37 +0200 Subject: Need help in creating a simple package in python Message-ID: <9k20ih$jq3$1@news.netvision.net.il> Hi Can you help me ? I am new with Python and I would like to ask several questions: 1. For creating a package I have to create a *.py script that will group selected modules and contain the following script __init__.py. -> Can you elaborate on this script definition (give an example how the script should be written ). 2. I have tried to create a package that contains 2 modules and succeeded in importing the package itself but not a module inside the package for example 'import pkg.fib1' - what was wrong ? Thanks Yossi From drobinow at yahoo.com Thu Jul 5 16:56:10 2001 From: drobinow at yahoo.com (David Robinow) Date: 5 Jul 2001 13:56:10 -0700 Subject: Comment on PEP-0238 References: <3B3BE855.A6223E70@3-cities.com> <cp7kxvlake.fsf@cj20424-a.reston1.va.home.com> <Y4J%6.4084$Z6.2010194@news1.rdc2.pa.home.com> <mailman.994016102.30019.python-list@python.org> <7ef50c46.0107020554.31cc948b@posting.google.com> <mailman.994084684.19932.python-list@python.org> <7ef50c46.0107030657.2e0fc92b@posting.google.com> <mailman.994177387.31239.python-list@python.org> <3B42B152.5EC4F056@3-cities.com> <mailman.994276569.27572.python-list@python.org> Message-ID: <59a4b541.0107051256.78336636@posting.google.com> Paul Prescod <paulp at ActiveState.com> wrote in message news:<mailman.994276569.27572.python-list at python.org>... > > Arithmetic expressions that > > involve only integers currently always result in an integer. > > >>> import math > >>> math.cos(5) > 0.28366218546322625 Surely you are not claiming that " math.cos(5) " is an arithmetic expression involving only integers? ... > > >... > > Who expects? You are already seeing in this discussion that many > > people think that the current behaviour is not only what they expect > > but is actually very justifiable. > > Sure, people with a bunch of programming language experience. > > http://www.python.org/doc/essays/cp4e.html I read this. There's a pointer to Prof. Pausch's page that is purported to prove the difficulty of closed integer division. There is absolutely no such reference. In fact, the evidence suggests that newbies picked up Python quickly. > > >... From sh at ttsoftware.co.uk Tue Jul 24 08:35:13 2001 From: sh at ttsoftware.co.uk (Steve Horne) Date: Tue, 24 Jul 2001 13:35:13 +0100 Subject: PEP0238 lament References: <9s4pltg7l5r04652q60oqgfu792ha0f1b2@4ax.com> <mailman.995927281.7201.python-list@python.org> <gmhplt4kitb3514p6kkdfg1kgl1eqr1fqg@4ax.com> <Xns90E862BBEA7B5duncanrcpcouk@127.0.0.1> Message-ID: <vqiqltsf8tl5kuklp653tki84rkc9lggfe@4ax.com> On Tue, 24 Jul 2001 08:56:53 +0000 (UTC), Duncan Booth <duncan at NOSPAMrcp.co.uk> wrote: >Stephen Horne <steve at lurking.demon.co.uk> wrote in >news:gmhplt4kitb3514p6kkdfg1kgl1eqr1fqg at 4ax.com: > >> If you had as many cases of "?"+str(Amount/100)+"."+str(amount%100) >> and similar in your code as I do > >This is an example where even today you might be better off writing >"?%d.%02d" % divmod(Amount, 100) >especially if you ever have single digit pennies. The code examples were simplified to get to the point, but this is true - barring a few points... 1. A lot of people these scripts are passed on to are non-programmers who, nonetheless, need to do some fiddling to keep things up to date. Separate / and % with formatting done longhand (and with the number of digits required specified, of course) tend to cause less confusion. 2. I just plain habitually use / and % anyway, having a C and C++ background and having never (previously) had a reason to change. 3. I dislike % substitution because I dislike sprintf formatting, and besides - I tend to think it should specify the subscript for the data to substitute in the string - not just rely on the list/tuple order. Not a particularly *good* reason in point 3, but theres a little bit of irrationality in most people. -- Steve Horne Home : steve at lurking.demon.co.uk Work : sh at ttsoftware.co.uk From rdbruno at btinternet.com Wed Jul 4 07:24:50 2001 From: rdbruno at btinternet.com (Ralph Bruno) Date: 4 Jul 2001 04:24:50 -0700 Subject: Windows2000 console control Message-ID: <6698e4b2.0107040324.1e4b14e6@posting.google.com> My application calls an a java app (FOP, which converts xml into pdf) , that consequently opens a console to display it's progress. I want to hide the console, but also capture the output for parsing. However, I also need to know when the Java app has finished so that I can then open or print the resulting acrobat. And finally, this all has to work as a gui app. I first tried win32process.CreateProcess, which according to the docs has a 'CREATE_NO_WINDOW' setting to hide the console, but this gave me an 'Attribute Error' whenever I ran it. It did give me a handle to the process, but it didn't allow me any way of at getting at the console output. Putting a pipe command in the actual Java command line was also unsuccessful as the Java command treated it as another argument and failed to execute. I've tried win32pipe, but this doesn't seem to allow me to get the process handle, although I can get at the console output. Is there a neat way of combining the two, or is a completely different approach needed? Thanks in advance From gerhard.nospam at bigfoot.de Wed Jul 4 08:17:58 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Wed, 4 Jul 2001 14:17:58 +0200 Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <87lmm5dqjq.fsf@litterbox.meowing.net> Message-ID: <slrn9k5vo5.nv.gerhard.nospam@lilith.hqd-internal> On 04 Jul 2001 04:54:21 -0400, Methodical Meowbot wrote: >18k11tm001 at sneakemail.com (Russ) wrote: > >> I am thinking about using Python for a unique safety-critical >> application in air traffic control. > >Software like that would seem to be begging for a language with some >formal validation behind it, like Ada. The "validation" behind Ada is sometimes misunderstood. A "validated compiler" is simply one that passes a certain test suite checking ANSI/ISO standard compliance, which is IMO a very good thing. I think that Ada 95 is the best language to use for safety critical systems such as air traffic control. That's precisely the field Ada was designed for: large, safety-critical realtime software. For those interested in proofing software correctness, there is an Ada subset called SPARK which makes this feasible (with the help of "annotations" that capture the code designers intention, and additional verification tools). I found quite interesting what I've read about it on http://www.sparkada.com/ Gerhard -- mail: gerhard <at> bigfoot <dot> 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 Fri Jul 27 15:36:10 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 27 Jul 2001 15:36:10 -0400 Subject: Eliminating upgrade risk In-Reply-To: <3B61A275.82581457@Lugoj.Com> Message-ID: <LNBBLJKPBEHFEDALKOLCMEMELBAA.tim.one@home.com> [James C. Ahlstrom] > The problem is that the new Python features, as wonderful as they are, > are chosen for Computer Science Purity, not day-to-working-day > importance to someone actually trying to write a widely used bullet > proof program. [Tim Peters] > As my physicists friend like to say, "that's not even wrong". > Write a PEP. [James Logajan] > Are you seriously suggesting he write a PEP to inhibit the other PEPs? > Or are you demanding something else? Such point as there was was two-fold: 1. The idea that Python features are chosen for "Computer Science Purity" is so far off base it's "not even wrong". 2. The PEP process is the place to flesh out future language directions, and is open to everyone. If someone (named James or not) wants a change of any kind, they should write a PEP; venting on c.l.py may or may not feel good, but probably isn't going to accomplish anything. So "write a PEP" was advice, not a demand. I didn't have in mind a PEP opposing other PEPs, but a PEP fleshing out something specific that would be of "day-to-working-day importance to someone actually trying to write a widely used bullet proof program." Robin Becker suggested that the ability to split lists fell in that category <wink>, but I'm sure I have scant idea what it means to JimA. >> while-compsci-purists-denounce-python-for-its-pragmatism-ly y'rs - tim > I've checked the Google archives, and I've come to the conclusion that > you are of the position that anyone who doesn't constantly upgrade > should not be supported, in the sense that if they report bugs, write > books about Python, or ask for porting assistance, their questions will > all be answered with "Upgrade first, then we'll talk". Is that basically > correct? In *most* cases advice to upgrade is met with "Thanks! That solved the problem.". So of course that's always my first suggestion, for cases that upgrades can solve. The idea that I'd say "upgrade first" to someone writing a book doesn't make sense, so I'll skip that one. If a user with a bug or a porting problem can't upgrade, it depends on the specifics. There was never a bugfix release for 1.5.2, so there *usually* isn't much else to be said to people who had deep problems with 1.5.2. I'm very happy the community (in the persons of Moshe Zadka and Thomas Wouters -- and special thanks to Aahz for championing the PEP that made it possible!) volunteered to produce bugfix releases for 2.0 and 2.1. When closing a bug via "fixed in 2.0" on SourceForge, or reporting on c.l.py that a bug has been so closed, the correct way to read that isn't "upgrade or die", it's "so it will show up in the appropriate follow-on bugfix release -- provided volunteers step up to produce one". For people who can't deal with that either, what would you like me to do? I'm paid to work on "the next" release, including but pretty much limited to repairing bugs discovered in prior releases, and for my own (unpaid) Python work don't even keep old versions of Python sitting around. That doesn't mean I never volunteer "spare time" to help people who have problems with old versions, but most days, yes, I'd rather go see a movie. although-i-haven't-had-time-for-that-in-about-3-months-ly y'rs - tim From sholden at holdenweb.com Mon Jul 9 09:17:11 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 9 Jul 2001 09:17:11 -0400 Subject: Credit card processing on the web Message-ID: <Z6i27.49545$he.3417932@e420r-atl1.usenetserver.com> I've been doing some work on credit card transaction verification, and as a result of certain experiences with a third party vendor, my client has requested that I look for another verification company. Has anyone actually used Python to verify credit card data? If so, with which company or companies? If you have time to post about your experiences I would be grateful. In fact, we don't even *have* to use Python, although the work I have done so far did, socket-based with mx/amkCrypto to implement the Blowfish encryption. I'd prefer to use Python, though. Just because I can. Thanks in advance Steve -- http://www.holdenweb.com/ From aleaxit at yahoo.com Mon Jul 16 16:55:12 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 16 Jul 2001 22:55:12 +0200 Subject: Most efficient solution? References: <20010716202955.LXMI20827.femail3.rdc1.on.home.com@jparlar> Message-ID: <0a9f01c10e39$a5a0fb40$0300a8c0@arthur> "Jay Parlar" <jparlar at home.com> writes: ... > > > for eachItem in A: > > > if eachItem in B: > > > A.remove(eachItem) > > > > > > Now, this will work fine, > > > > Are you sure about that? Normally, modifying the list > > you're iterating on does NOT work fine. Have you tested ... > Hmm... That's very interesting. Well, I guess you learn something new every day ;-) I suppose the simple solution (to my > original code) is to place all non-offending items in a new list, ie. > > >>> for eachItem in a: > ... if each not in b: > ... final.append(eachItem) > ... Or, more simply, loop on a _copy_ of the list you need to alter: for eachItem in a[:]: if eachItem not in b: a.remove(eachItem) > I've never noticed the list behaviour before that you pointed out, what causes that, if you don't mind my asking? Officially, the point is that altering the list you're iterating on causes unspecified behavior -- whatever happens to happen, happens:-). In practice, the loop on the list has more or less these semantics: i = 0 while 1: try: item = a[i] except IndexError: break else: i += 1 whatever(item) being equivalent to: for item in a: whatever(item) If you alter a, the index i used internally still goes up by one each time through the loop, until it hits an IndexError (which tells the interpreter that the for-loop is finished). So, say the loop's body is just a.remove(item). Now: for item in a: a.remove(item) we can see as equivalent (in the current implementation) to: i = 0 while i<len(a): a[i:i+1] = [] i = i+1 which deletes *alternate* items of list a... ...but you shouldn't rely on this to do "clever" things -- tomorrow, the for loop implementation might be optimized and do OTHER strange things when the body alters the list it's looping on!-) Akex _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com From guido at python.org Tue Jul 24 15:44:58 2001 From: guido at python.org (Guido van Rossum) Date: Tue, 24 Jul 2001 19:44:58 GMT Subject: Future division patch available (PEP 238) References: <GNZwEiAJepW7Ew0F@jessikat.fsnet.co.uk> <mailman.995776716.24336.python-list@python.org> <mailman.995825018.9832.python-list@python.org> <9jfjd6$ad4$2@newshost.accu.uu.nl> <7u6nltoqdnqjjdiquu6ngtaruflhvbvdl5@4ax.com> <mailman.995886519.23021.python-list@python.org> <fauolt41gp2mjlsqiuc9rnl84dtinsle9j@4ax.com> Message-ID: <cpae1uqfgs.fsf@cj20424-a.reston1.va.home.com> Stephen Horne <steve at lurking.demon.co.uk> writes: > If I take serious damage to my professional reputation because of this > change and my vocal Python advocacy, I'll more than likely be starting > up my own competing scripting language. I won't expect success, but it > will be interesting and I will expect that others will have the same > thought, so once the breakaway projects start coalescing there might > well be a *better* alternative in the end. Maybe a bit melodramatic, > but it's not like it's hard to find a scripting language market these > days. More power to you. Since your new language won't be restricted by backwards compatibility, you'll find that the better choice for int/int is to return a float, or perhaps a rational, rather than following C (whose insistence on closing integers under division, as that of so many other languages, is inspired by the price of floating point hardware twenty years ago). --Guido van Rossum (home page: http://www.python.org/~guido/) From robin at illusionsexeculink.com Mon Jul 2 16:25:20 2001 From: robin at illusionsexeculink.com (robin at illusionsexeculink.com) Date: Mon, 02 Jul 2001 16:25:20 -0400 Subject: Postgres support Message-ID: <gul1kts5l6aolk55o7vguk97uorjd08j9f@4ax.com> I have been quite happy working with Python, and have become quite evangelical in my support for this language and its excellent user community. One area in which I believe Python to be very lacking is database support. Languages like Perl and even PHP come with compete support for all the popular databases. With Python I'm left scrambling around trying out different half-done modules. This is a significant barrier to Python adoption. Until Python ships with modules for each major database it will not be a mature tool for many users. As an example, I would like to find a cross-platform (Linux, Windows, etc.) Postgres interface that works with Python 2 or greater and Postgres 7 or greater, conforming to the dbAPI. Not too much to ask, one might think. I've found these four candidates, but judging by their sometimes sparse web sites, none fit the bill. But I could be wrong. PyGreSQL -- http://www.druid.net/pygresql/ psycopg -- http://initd.org/Software/psycopg PoPy -- http://popy.sourceforge.net/ PyPgSQL -- http://www.sf.net/projects/pypgsql Can anyone suggest a solution? ----- robin robin at illusionsexeculink.com media artist / remove illusions to reply information architect www.execulink.com/~robin/ Isolation tank paves way to execute an attack. From sholden at holdenweb.com Thu Jul 12 13:38:12 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 12 Jul 2001 13:38:12 -0400 Subject: Long Live Python! References: <mailman.994874959.29064.python-list@python.org> <slrn9kpe08.496.sill@sill.silmarill.org> <slrn9kpkco.32b.quinn@yak.ugcs.caltech.edu> <9ijpfk02a67@enews4.newsguy.com> <3b4dd783$0$2149@wodc7nh6.news.uu.net> Message-ID: <kel37.3407$u76.70914@e420r-atl3.usenetserver.com> "Rufus V. Smith" <nospam at nospam> wrote in message news:3b4dd783$0$2149 at wodc7nh6.news.uu.net... > > "Alex Martelli" <aleaxit at yahoo.com> wrote in message > news:9ijpfk02a67 at enews4.newsguy.com... > > My proposed solution relied on the fileinput module's "in-place" > > behavior (WITH a backup, but that's optional I guess:-). That > > module nicely wraps whatever concerns may need to be wrapped, AND > > works on as many files as you desire. > > > > def allbutfirst(files): > > for line in fileinput.input(files,inplace=1,backup='.bak'): > > if fileinput.filelineno()>1: print line, > > > > I'm a definite Newbie, but to me this looks like it outputs the result > to stdout, rather than creating a new file with the first line removed, > which is what I thought the goal was. The manual says: """Optional in-place filtering: if the keyword argument inplace=1 is passed to input() or to the FileInput constructor, the file is moved to a backup file and standard output is directed to the input file. This makes it possible to write a filter that rewrites its input file in place. If the keyword argument backup='.<some extension>' is also given, it specifies the extension for the backup file, and the backup file remains around; by default, the extension is '.bak' and it is deleted when the output file is closed. In-place filtering is disabled when standard input is read.""" So I guess the martellibot is correct again, which I know will stagger few regular readers :^) . don't-argue-with-a-bot-ly y'rs - steve -- http://www.holdenweb.com/ From ejones17 at austin.rr.com Fri Jul 6 00:43:51 2001 From: ejones17 at austin.rr.com (ERIC JONES) Date: Fri, 06 Jul 2001 04:43:51 GMT Subject: GUI for Fortran under Linux References: <9hvtk6$sst$1@watserv3.uwaterloo.ca> <zHQ07.42503$TW.212386@tor-nn1.netcom.ca> <3B440D12.FD036CA1@wldelft.nl> <3B44A1FC.70F13315@bioeng.ucsd.edu> Message-ID: <bmb17.143805$lq1.35223239@typhoon.austin.rr.com> Fortran: f2py works pretty well at wrapping most f77 and f90 codes. PyFort is also a good candidate, although I have no experience with it. Both of these help you clean up the interface to functions reducing the number required arguments considerably. Once you've wrapped your functions using f2py, they are usable from any Python script. I would recommend using f77 as much as possible to keep code portable to different machines (g77 is everywhere) and also to ease integration with Python (f90 pointers don't have an easy translation to C code). Also, use Python for your memory allocation when ever possible. Visualization: VTK (www.kitware.com) works well for visualizing scientific data and has reasonable Python wrappers. It has a steep learning curve, but also a wealth of capabilities (many many helpful algorithms) beyond OpenGL. GUI Toolkit: VTK is supported by both TkInter and wxPython so you can use either. We use wxPython on both Linux and Windows and am happy with the choice. regards, eric From skip at pobox.com Fri Jul 20 21:38:44 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 20 Jul 2001 20:38:44 -0500 Subject: Help with PDF In-Reply-To: <000801c11181$3145dcc0$2cde3dd8@glindshome> References: <000801c11181$3145dcc0$2cde3dd8@glindshome> Message-ID: <15192.56612.938501.851439@beluga.mojam.com> Greg> What is available in Python to produce Portable Document Format Greg> (PDF) files? Check ReportLab: http://www.reportlab.com/ -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From dgoodger at bigfoot.com Wed Jul 25 21:29:28 2001 From: dgoodger at bigfoot.com (David Goodger) Date: Wed, 25 Jul 2001 21:29:28 -0400 Subject: Deposing Dictators In-Reply-To: <9jmjne$q54$1@wisteria.csv.warwick.ac.uk> References: <9jmjne$q54$1@wisteria.csv.warwick.ac.uk> Message-ID: <B784EAB7.14F50%dgoodger@bigfoot.com> on 2001-07-25 10:05 AM, margg at ux-ma160-18.csv.warwick.ac.uk wrote: > 1) New versions of 'Python' are not 'Python', and should be indicated > as such -- perhaps by calling it 'Python++' :) True, Python 2.2 is not Python 2.1. Also, 2.1 != 2.0, 2.0 != 1.6, 1.6 != 1.5.2, etc., back to 1990. So what? > If Guido does change Python in the way it currently appears it will, > and if so many people disagree with the way it is developing, then > why not stand up and call for people to ignore the dictator, and > keep Python the way it should be? Go ahead, keep Python the way you like it. Nobody's forcing you to upgrade. The source code is completely open. > This new version of Python will not be one that I will be happy to use. So don't use it? > If there are enough people who feel as I do, then perhaps we will be > able to depose the dictatorship, and create a stable and sensible > system for developing Python (not Python++). If you want stability, stick with Python version X.Y. If you want new capabilities without new core language features, and backport the standard libraries you want to use. Create an open source project for them; I'm sure there'd be a market. But then, your X.Y won't match everybody else's X.Y. -- David Goodger dgoodger at bigfoot.com Open-source projects: - Python Docstring Processing System: http://docstring.sourceforge.net - reStructuredText: http://structuredtext.sourceforge.net - The Go Tools Project: http://gotools.sourceforge.net From mwh at python.net Sun Jul 1 18:00:04 2001 From: mwh at python.net (Michael Hudson) Date: 01 Jul 2001 23:00:04 +0100 Subject: Why Not Translate Perl to C References: <mailman.993922352.32302.python-list@python.org> Message-ID: <m3y9q8z4wr.fsf@atrus.jesus.cam.ac.uk> Oleg Broytmann <phd at phd.fep.ru> writes: > 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. I think the "obvious" approach to making Python go faster is some kind of dynamic recompilation, so that if a function gets called fifteen thousand times with integer arguments you can compile up a specialised version. Going further you could even implement schemes where functions are inlined (or methods cached or whatever) and if the name of the inlined function is rebound you run all over the heap smashing the code that has this function inlined in, and so on. This would obviously be quite slow - but you don't rebind function names very often, certainly much much less often than you call them (in general). I believe Self uses a boatload of tricks of this form, but that's about as much as I know about Self. Also, hard work. Who's going to pay for it? It's not the sort of thing that's going to happen in one's spare time. Armin Rigo has been having some fun in this area - read this post for more info: http://mail.python.org/pipermail/python-dev/2001-June/015566.html It's all still some way from being useful, sadly. Cheers, M. Getting truly off into the far blue yonder: It also seems to me that dynamic recompilation is the way forward for getting good performance out of modern chips where branch misprediction has such a high cost - surely the best way to find out which way a branch is likely to go is to check. Ars Technica has a fascinating article on HP's Dynamo which explores things in this direction: http://arstechnica.com/reviews/1q00/dynamo/dynamo-1.html (If you haven't read this article , read it now) Has anyone had the opportunity to run Python under Dynamo? That would be interesting, to say the least. -- . <- the point your article -> . |------------------------- a long way ------------------------| -- Cristophe Rhodes, ucam.chat From sholden at holdenweb.com Mon Jul 9 08:12:23 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 9 Jul 2001 08:12:23 -0400 Subject: Q: Duplicating Objects ... HOW ??? References: <9ia0ru$80k$1@sun.rhrk.uni-kl.de> <etd7kxjcp8x.fsf@pickled-herring.mit.edu> <Uh327.14798$i8.1312190@e420r-atl3.usenetserver.com> <Nl327.20471$F%5.1437375@e420r-atl2.usenetserver.com> <slrn9khoer.cpe.philh@comuno.freeserve.co.uk> Message-ID: <f9h27.23482$F%5.1661317@e420r-atl2.usenetserver.com> "phil hunt" <philh at comuno.freeserve.co.uk> wrote in message news:slrn9khoer.cpe.philh at comuno.freeserve.co.uk... > On Sun, 8 Jul 2001 16:29:59 -0400, Steve Holden <sholden at holdenweb.com> wrote: > >"Steve Holden" <sholden at holdenweb.com> wrote in message > >news:Uh327.14798$i8.1312190 at e420r-atl3.usenetserver.com... > >> "Alex" <new_name at mit.edu> wrote in message > >> news:etd7kxjcp8x.fsf at pickled-herring.mit.edu... > >> > > >> > You may be happier in the long run keeping the sequence of test objects > >> > in a sequence, like a list. You could do something like this: > >> > > >> > import copy > >> > test_list = [copy.copy(obj) for obj in 20*[test]] > >> > > >> Or, possibly, in a dictionary: > >> > >> dict = {} > >> for i in range(1,21): > >> dict[test+str(i)] = copy.copy(obj) > >> > >Sorry, read that last as > > > > dict["test"+str(i)] = copy.copy.(obj) > > You're not haviong much luck with the typos, are you? > Typos, thinkos, I get htem all. Talk about "let yuor fngiers do the wlaking"... regards Steve -- http://www.holdenweb.com/ From dgrisby at uk.research.att.com Tue Jul 24 09:27:47 2001 From: dgrisby at uk.research.att.com (Duncan Grisby) Date: 24 Jul 2001 13:27:47 GMT Subject: PEP0238 lament References: <mailman.995814276.15005.python-list@python.org> <mailman.995930743.17137.python-list@python.org> <9jjfts$9k2$1@pea.uk.research.att.com> <mailman.995977483.25907.python-list@python.org> Message-ID: <9jjt4j$od0$1@pea.uk.research.att.com> In article <mailman.995977483.25907.python-list at python.org>, Paul Prescod <paulp at ActiveState.com> wrote: [...] >> I return to my question. Suppose Python 2.2 is released with this >> __future__ division. Now suppose I must maintain some code which can >> run on Python 2.0, 2.1 and 2.2, which needs integer division. What am >> I to do? > >I think divmod()[0]. (or maybe I've missed something there) As long as the definition of divmod() is updated to do that. It currently says divmod(a, b) Take two numbers as arguments and return a pair of numbers consisting of their quotient and remainder when using long division. With mixed operand types, the rules for binary arithmetic operators apply. For plain and long integers, the result is the same as (a / b, a % b). ... Assuming divmod() continues to returns integers with integer arguments, divmod()[0] can be used, but it isn't exactly concise or easy to follow. Cheers, Duncan. -- -- Duncan Grisby \ Research Engineer -- -- AT&T Laboratories Cambridge -- -- http://www.uk.research.att.com/~dpg1 -- From m.faassen at vet.uu.nl Mon Jul 23 15:25:08 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 23 Jul 2001 19:25:08 GMT Subject: Language change and code breaks References: <mailman.995479471.31821.python-list@python.org> Message-ID: <9jhtmk$ap4$1@newshost.accu.uu.nl> Michael Chermside <mcherm at destiny.com> wrote: [snip] > Don't encourage sloppy habits: require case sensitivity. Right, the case-(in)sensitivity issues are very similar to the indentation issues. Python enforces the way code looks by making indentation required (and the only thing); we get consistently indented code that way. I believe that is good. Python currently also enforces consistently case-spelled code. I believe that this is good as well. People sometimes counter this by using the 'bondage and discipline' argument, but I believe some consistency actually doesn't hurt on this level; it's not a major hoop through jump through. Bondage and discipline can hurt on the (surface) semantic level, where it makes it much easier to code oneself into a corner. So, I believe we should encourage "there should be one obvious way to do it" on the syntactic level here. Frequently having more than one way to do it on the semantic level is however a good thing if that means increased flexibility. 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 Sun Jul 1 10:40:34 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Sun, 01 Jul 2001 14:40:34 GMT Subject: GUI Builder for Python ? References: <aknrjt8j3cm3qcnpu6qsgvu313rlmi8emg@4ax.com> Message-ID: <3B3DE732.660AF0E1@earthlink.net> A major new project is underway, called Pythoncard, see http://groups.yahoo.com/group/pythoncard . Maybe you can contribute ;-)))) Lothar Scholz wrote: > Is there something other then "Black Adder" which is behind an alpha > version ? From hirner at yahoo.com Tue Jul 10 19:20:53 2001 From: hirner at yahoo.com (ThaFacka) Date: Wed, 11 Jul 2001 01:20:53 +0200 Subject: compiling c app in MSVC Message-ID: <3b4b8bc7$0$26110$6e365a64@newsreader02.highway.telekom.at> MSVC5 complains when compiling a program with <python.h>, that the lib file python20.lib is either invalid or my disk is corrupted (cant set file pointer to 0xblabla). and no my disk is not corrupted. anybody compiled succesfully with MSVC5? thx From guido at python.org Wed Jul 25 15:48:37 2001 From: guido at python.org (Guido van Rossum) Date: Wed, 25 Jul 2001 19:48:37 GMT Subject: Numeric methods again References: <9jmelr$m2g$1@tyfon.itea.ntnu.no> Message-ID: <cplmlc94dr.fsf@cj20424-a.reston1.va.home.com> "Magnus Lie Hetland" <mlh at idi.ntnu.no> writes: > Now that Python seems to be getting numerig methods > (like "5 .__add__" etc.) I'm pretty happy about that. > But I find it odd that there has to be whitespace > in front of the reference dot... For a simple parser > it might be difficult to know whether 5. was a float > or the beginning of a reference, but with a bit of > lookahead that can't be too hard? Is there any way > that 5._ is not the beginning of a reference to a > numeric method? Can a number ever be directly followed > by an identifier? Is the parser to weak to parse this > stuff? Am I just being dense? > > This definitely looks like a (little) wart to me... > > (I'm sure I should RTFM here - but I've looked through > the PEPs and haven't found this in there...) This is the kind of wartlet that's hard to fix right (there could be an arbitrary about of comments between the "5." and the "__add__") and not a problem in practice. You won't be writing "5 .__add__" in practice -- you'll be writing "x.__add__", where x happens to contain an integer. --Guido van Rossum (home page: http://www.python.org/~guido/) From sholden at holdenweb.com Sun Jul 29 21:06:35 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sun, 29 Jul 2001 21:06:35 -0400 Subject: Eliminating upgrade risk References: <tlu596rosgngd9@news.supernews.com> <mailman.996105586.6334.python-list@python.org> <biDHvIAmJ2X7Ewtm@jessikat.fsnet.co.uk> <3B601811.4B68578B@interet.com> Message-ID: <Zm297.540$WD1.103799@e420r-atl2.usenetserver.com> "James C. Ahlstrom" <jim at interet.com> wrote in message news:3B601811.4B68578B at interet.com... > > Robin Becker wrote: > [ ... ] > The problem is that the new Python features, as wonderful as they are, > are chosen for Computer Science Purity, not day-to-working-day > importance to someone actually trying to write a widely used bullet > proof program. The current rate of language change is fine for a > student or casual programmer I'm sure, but I don't have that luxury. > I prefer to think that the problem here is that the new Python features that would break existing code are to fix a wart that has been in the language for a long time. Originally my own approach was "so live with the wart", but I really don't anticipate the division change giving me many problems in my own (admittedly limited) installed base. The rate of language change has little to do with it, and the main question is "does code from the last version run on the new version?" How many cases (besides the division proposal, for which the timeframe is two years, or indefinitely if you use the command-line option) can you quote where that question would be answered in the negative? new-features-don't-stop-old-features-working-(mostly)-ly y'rs - steve -- http://www.holdenweb.com/ From rcena at epcor.ca Thu Jul 5 11:11:48 2001 From: rcena at epcor.ca (Resty Cena) Date: 5 Jul 2001 08:11:48 -0700 Subject: Is Python Dead? References: <MNS%6.355$Xs4.225014@news.pacbell.net> Message-ID: <458b194a.0107050711.72007607@posting.google.com> "Edward B. Wilson II" <ed at ewilson.com> wrote in message news:<MNS%6.355$Xs4.225014 at news.pacbell.net>... > I have been following Python for five years now, and I am still just as > frustrated with it as I was in 1996. > > Python still doesn't have good database support, I, too, have been following Python since 1996, waiting all the while to make it easy for me to do database programming. What I'd call good database support is where I download a file or set of files into a directory under my Python directory, perhaps run an install program, then start Python, import a package, issue a command to connect to Oracle, and start playing around with the scott/tiger database. I don't want, nor do I have the time, to compile anything, nor muck around with the Windows registry, nor manually set paths -- I just want to try the product, not install it for production use. Ideally, I'd like the IDE to do this for me. I'm a database programmer, and I want to write applications right away. I'm also lazy and I expect much from my tools. From kens at sightreader.com Fri Jul 27 00:38:58 2001 From: kens at sightreader.com (Ken Seehof) Date: Thu, 26 Jul 2001 21:38:58 -0700 Subject: [OT] Number theory [Was: A use for integer quotients] References: <yCK67.17615$EP6.4467503@news1.rdc2.pa.home.com> <mailman.995860718.9550.python-list@python.org> <mailman.995862939.15013.python-list@python.org> <mailman.995883879.12071.python-list@python.org> <3B5C5665.8D41D1F1@tundraware.com> <slrn.pl.9los0f.jh4.qrczak@qrnik.zagroda> <3B5C749A.59F97320@tundraware.com> <JDa77.97061$Rr4.549007@ozemail.com.au> <Xns90E97C9849AD5robindotgarneratinam@172.18.25.3> <IjA77.97824$Rr4.589251@ozemail.com.au> <3b602afa.930850@nntp.sprynet.com> <Xns90EB76175FA2Brobindotgarneratinam@172.18.25.3> Message-ID: <029801c11656$0db44100$6501a8c0@pacbell.net> Robin wrote: > ullrich at math.okstate.edu (David C. Ullrich) wrote in > news:3b602afa.930850 at nntp.sprynet.com: > > > On Thu, 26 Jul 2001 00:01:15 +1000, "michael" <serrano at ozemail.com.au> > > wrote: > > > >>> But strictly > >>> speaking the Integer 2 and the Real Number 2 are different entities. > >> > >>So strictly speaking, Z (the set of integers) is not a subset of R (the > >>set of reals)? > > > > Strictly speaking yes, but nobody _ever_ speaks this strictly > > (except in contexts like the present). > > > > What I was getting at was that the integer 2 (as an element of the ring of > integers) is different to the real number 2 (as an element of a field). As > a real number, 2 has a multiplicative inverse, whereas as an integer it > does not. (and as an element of Z_5 it does etc etc) > > As sets (and from the p.o.v. of analysis), Z is a subset of R, but as > algebraic entities there is a distinction. > > Robin Yay! Somebody talking sense! There are good theoretical arguments to thinking of Z as a subset of R as well as Z being a different kind of animal from R. In software, when doing anything with the concepts of modulus and quotient, one is almost always exclusively in the world of integers, where words like "floor" make no sense. Usually we are talking about pixels or positions in a grid, or relative position in a repeating sequence, or some other discrete phenomenum. In these cases Z doesn't really -seem- like a subset of R. Okay, if you say 5.0 // 2.0 == 2.0, it makes some kind of sense to call that "floor division", but I don't think // will be used with floats very often (just nice to support floats for polymorphic consistency). But // is really there because of integers. "//" = "quotient" - Ken From michael at stroeder.com Tue Jul 10 11:12:13 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Tue, 10 Jul 2001 17:12:13 +0200 Subject: SMTP server class ?? References: <d0alktgu1k5qvlt2bqdmb8l0k1rlmqm6ie@4ax.com> <mailman.994773686.29026.python-list@python.org> Message-ID: <3B4B1B4D.671EA09C@stroeder.com> "Barry A. Warsaw" wrote: > > >>>>> "SK" == Sheila King <sheila at spamcop.net> writes: > > SK> Actually, I found what Barry Warsaw calls his "experimental" > SK> smtp server (RFC821 compliant) at the Vaults at > SK> Parnassus. I've downloaded it. > > It's actually now in the standard library as smtpd.py. It's > asyncore/asynchat based, and it's not perfect, but at least one other > person than me has found it useful <wink>. To give some feedback: It will probably be useful for me too during the next months. From a rather short look it seems to me that it has a easily understandable API. I'm looking at mimelib too... Ciao, Michael. From tim at digicool.com Mon Jul 23 13:06:43 2001 From: tim at digicool.com (Tim Peters) Date: Mon, 23 Jul 2001 13:06:43 -0400 Subject: PEP0238 lament In-Reply-To: <3B5C4BB5.932C041D@alcyone.com> Message-ID: <BIEJKCLHCIOIHAGOKOLHKEFBCDAA.tim@digicool.com> [Erik Max Francis] > I wouldn't think how JavaScript does things would be a valid defense in > any case. Neither would I, but in the context snipped away I was replying to someone who seemed to think that it was, but misunderstood what JS actually does. Even bad arguments should be accurate <wink>. or-ignored-ly y'rs - tim From aleaxit at yahoo.com Mon Jul 2 16:25:33 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 2 Jul 2001 22:25:33 +0200 Subject: Augmented Assignement (was: Re: PEP scepticism) References: <mailman.993952381.32699.python-list@python.org> <zbN%6.415855$oc7.58414702@news2.rdc2.tx.home.com> <q0avjto87p59hn7gv28r5cf1c84j2fb8c7@4ax.com> <naO%6.416271$oc7.58537852@news2.rdc2.tx.home.com> <vm40kt8knq3pplpv1rarjubl73vnl12ure@4ax.com> <20010702145211.M8098@xs4all.nl> <mailman.994083124.18397.python-list@python.org> <9hq57a0jnd@enews4.newsguy.com> <mailman.994095972.11214.python-list@python.org> Message-ID: <9hqlel016bl@enews4.newsguy.com> "Paul Prescod" <paulp at ActiveState.com> wrote in message news:mailman.994095972.11214.python-list at python.org... ... > > Depending on how you define "real world", I have some use of that > > with my still-unreleased "in-house" (literally:-) "gmpy 1.0", where I > > have mutable numbers. > > That's pretty weird but I have no objection to consenting adults doing > weird things. I would suggest you consider lightweight proxies instead > of mutable numbers so that you get optimization for x = x + y "for > free". Care to expand on this...? Say that x is (a lightweight proxy holding) a Python long of a few hundred digits which is counting the number of occurrences of some event-classification in a space of events that is pretty huge because of combinatorial-explosion. y is another count I have to add to x, typically a few hundred thousands or a few millions at most. How would x and y being lightweight proxies save me any computational effort? Won't Python still have to allocate another chunk of a few hundred digits to store the new value of x, since the old one is immutable? With GMP (exposing its innards as mutable numbers) I save the allocation (except when x becomes "longer", which happens rarely enough that I don't worry about it) by doing in-place addition (GMP exposes functions with 3 arguments, one destination and two sources, and allows the destination to have the same identity as either source OR to be another new mpz-object). Are you suggesting I should implement '+' lazily (by chunking or whatever)? I fail to see what it would buy me -- that 'x' is going to be incremented many times. I am quite a fan of lightweight proxies but here I can't see any speed benefit they could bring me. So what am I missing...? > But let me try another tact: what if we just changed the behavior of > lists. Rather than saying "mutable objects do this, immutable objects do > that", I would like to say "built-in, ordinary, typical objects do this, > rare, advanced, specialized objects do that." > > "This" is the simplest interpretation x +=y is equivalent to x = x + y. > > "That" is the more sophisticated polymorphic interpretation where the > type chooses its own behaviour. > > Would this be an acceptable compromise? Everyone wins. I don't understand whether you're arguing in the abstract, or concretely proposing to break any Python program, written in the last year or so, which decided to code "mylist += somemore" as opposed to coding "mylist.extend(somemore)" while some other reference to mylist may be outstanding. If the latter, I don't see how such code breakage may be "a compromise". In the abstract, if you were designing a new language from scratch and wanted to have both mutable and immutable datatypes in it, I guess you could draw the line for a switchover in +='s behavior at different thresholds; mutable vs immutable is very easy to draw, 'ordinary' vs 'advanced' may not be, but maybe in such a hypothetical language you might have other ways to easily flag ordinary vs advanced data types so people cannot get confused. It need not be Python, but it might be an interesting thought-experiment, I guess. Alex From benc1 at today.com.au Sun Jul 29 01:58:40 2001 From: benc1 at today.com.au (Ben C) Date: 28 Jul 2001 22:58:40 -0700 Subject: The Evolution Of Python References: <8beb91f5.0107280407.5a30341d@posting.google.com> <3B62FAFF.BB987077@Lugoj.Com> <mailman.996347633.4448.python-list@python.org> Message-ID: <8beb91f5.0107282158.4785ae5e@posting.google.com> IMHO the reason why C has survived as a language and not become an endangered species like Rexx, pascal et al is because it has it's own 'niche' ... initially evolving alongside of the unix environment it has become the most suited language (currently) for systems programming ... this has been both its strength and its weakness ... to add more functionality it has had to fragment itself into other competing 'species' and hence we now have C++ (and all its sub species) ... C is analogous to the carnivore of the programming languages ... yes fast and efficient ... but is also in a lot of respects quite crude ... I don't think Python has it's own true 'niche' ... it competes well with many other languages ... hence it has to either keep evolving into a 'better' competing language or find a niche or other languages will inevitably supplant it ... what will happen to all your Python code then? Will you invest the time learning and re-writing it to the newer language? ... Paul Prescod <paulp at ActiveState.com> wrote in message news:<mailman.996347633.4448.python-list at python.org>... > James Logajan wrote: > > > > ... > > > > b.1\ Or K&R C (in which Python was written for a long time to maximize > > portability) or ANSI C (which tried to maintain compatibility with K&R). A > > case where stagnation helped lead to success. > > I believe that the stagnation followed success. The same may happen to > Python. If it is ever the "default programming language" then it will > become essentially impossible to change in any reasonable time frame. > Guido is trying to make the changes now because they won't be possible > then. From gmcm at hypernet.com Sat Jul 14 10:17:13 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 14 Jul 2001 14:17:13 GMT Subject: Importing XML modules in py2exe or Installer? References: <Xns90DE9C2957BDgustaflalgonetse@194.213.69.152> Message-ID: <Xns90DE68B66343Agmcmhypernetcom@199.171.54.154> [posted and mailed] Gustaf Liljegren wrote: > Have completed a fairly large project where I, among other modules, use > the Python XML package from the XML SIG. Now I want to make a DOS > binary to distribute it as a standalone application for Windows users. > > Neither py2exe nor Installer is able to find the XML modules by > themselves, and I haven't been able to figure out how to include them. [snip] > > The XML modules reside at e:\python\_xmlplus in this computer. I have > tried the respective include options, but don't know if I do it right: > > python e:\pyinst\builder.py myscript.cfg --includes e:\python\_xmlplus Doesn't help to use py2exe args with Installer! Edit myscript.cfg and put packages=_xmlplus in the PYZ section. I don't know if that's enough - I've never worked with the XML package. - Gordon From root at rainerdeyke.com Mon Jul 9 12:03:17 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Mon, 09 Jul 2001 16:03:17 GMT Subject: license suggestions? References: <mailman.994639514.14007.python-list@python.org> <Fij27.24993$F%5.1707320@e420r-atl2.usenetserver.com> Message-ID: <9Bk27.469493$oc7.75721180@news2.rdc2.tx.home.com> "Steve Holden" <sholden at holdenweb.com> wrote in message news:Fij27.24993$F%5.1707320 at e420r-atl2.usenetserver.com... > And some of us wonder what it is about the GPL that stops your previous, > liberally-licensed, version from existing? Given: software A is released under the BSDL. Somebody creates an improved version of it (software B) and releases it under the GPL. A still exists. But B is better than A, so people will be more likely to use B than A. A still exists, but A is competing with a better version of itself. New programmers will be more likely to improve B than A, because they don't want to duplicate effort. The original author is unable to incorporate the improvements to A in future software C unless C is released under the GPL. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From steve at lurking.demon.co.uk Mon Jul 23 16:47:42 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Mon, 23 Jul 2001 21:47:42 +0100 Subject: BURNING EARTHSHAKING Tuple Question References: <5e8bd451.0107191249.3c0d9f21@posting.google.com> <3B58EBF4.F24E5129@alcyone.com> <pmglltoiomis08cg8s18ogql1psmb4knkj@4ax.com> <3B5B15FE.A6B51D9F@alcyone.com> <9jfe8v$gu4$1@slb6.atl.mindspring.net> <slrn.pl.9lokkh.h62.qrczak@qrnik.zagroda> Message-ID: <rptoltoirtn1s3i1ro9um091gu9r0cu7sl@4ax.com> On 23 Jul 2001 16:36:33 GMT, Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl> wrote: >Sun, 22 Jul 2001 16:54:08 +0500, Tom Bryan <tbryan at python.net> pisze: > >> In both my undergraduate and graduate studies in mathematics in the U.S., >> I only remember hearing tuple pronounced so that it rhymes with goop. If >> anyone pronounced it to rhyme with couple, it was rare enough that I don't >> remember it. But we also said "pie" for pi and "fee" for phi. > >Because you have ambiguous orthography :-) > >At least in Polish tupla is unambiguously pronounced tooplah >(or translated to krotka), and we say pee and fee. And pit-on. So instead of two slightly different pronunciations, you have two completely different words ;-) From tjreedy at home.com Thu Jul 26 00:17:46 2001 From: tjreedy at home.com (Terry Reedy) Date: Thu, 26 Jul 2001 04:17:46 GMT Subject: [OT] Number theory [Was: A use for integer quotients] References: <yCK67.17615$EP6.4467503@news1.rdc2.pa.home.com> <mailman.995860718.9550.python-list@python.org> <mailman.995862939.15013.python-list@python.org> <mailman.995883879.12071.python-list@python.org> <3B5C5665.8D41D1F1@tundraware.com> <slrn.pl.9los0f.jh4.qrczak@qrnik.zagroda> <3B5C749A.59F97320@tundraware.com> <JDa77.97061$Rr4.549007@ozemail.com.au> <Xns90E97C9849AD5robindotgarneratinam@172.18.25.3> <IjA77.97824$Rr4.589251@ozemail.com.au> Message-ID: <KRM77.30105$EP6.7511661@news1.rdc2.pa.home.com> "michael" <serrano at ozemail.com.au> wrote in message news:IjA77.97824$Rr4.589251 at ozemail.com.au... > > But strictly > > speaking the Integer 2 and the Real Number 2 are different entities. > > So strictly speaking, Z (the set of integers) is not a subset of R (the set > of reals)? This is a very subtle question, which I believe underlies much of the recent heat on this newsgroup. I was taught (by an algebraist) that Z is isomorthic to a subset of R but is not the same as that subset (having existed prior to R). On the other hand, at least some set theorists regard isomorphic sets as the same set (which is why there is only 1 empty set!), which would make the two one and the same. So it depends on the meaning of 'set'. Terry J. Reedy From dgallion1 at yahoo.com Sun Jul 22 11:20:50 2001 From: dgallion1 at yahoo.com (Darrell) Date: 22 Jul 2001 08:20:50 -0700 Subject: Any Suggestions for an Editor with MS-Windows ? References: <92757716C8BFF476.D432477A795DB759.E2FB05E062137965@lp.airnews.net> Message-ID: <b0c5da3a.0107220720.4d3eaf2c@posting.google.com> http://www.scintilla.org/ zeke <Zeke at xyz.net> wrote in message > Am almost half way through the manual and getting ready for the easy > job of bringing over some basic files (yea, right). Currently using > Ultra Edit but having doubts about it. > zeke From Randy.L.Kemp at motorola.com Tue Jul 3 13:09:58 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Tue, 3 Jul 2001 12:09:58 -0500 Subject: Calculus Message-ID: <E566B020833BD311B6610008C791A39705CA51F0@il93exm04.css.mot.com> But Pythagoras and other Greeks played with mathematics. Perhaps that's why the Simpson's rule has 'Homer'. -----Original Message----- From: Alex Martelli [mailto:aleaxit at yahoo.com] Sent: Tuesday, July 03, 2001 10:33 AM To: python-list at python.org Subject: Re: Calculus "Andrew Todd" <aetodd at wm.edu> wrote in message news:mailman.994164981.2922.python-list at python.org... ... > that has functions commonly used in Calculus. For example, > the Simpsons Rule, and the formula that allows you to find I agree the Simpsons rule (my personal favourite is Lisa), but I didn't think they were now used in Calculus, too... Alex From mal at lemburg.com Thu Jul 26 04:32:28 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Thu, 26 Jul 2001 10:32:28 +0200 Subject: [Python-Dev] Re: Static method and class method comments References: <9jn382$lqf$1@license1.unx.sas.com> <3B5F565C.5F452AC5@ActiveState.com> <15199.23581.653505.336350@beluga.mojam.com> Message-ID: <3B5FD59C.5FA52611@lemburg.com> Skip Montanaro wrote: > > Paul> Agree strongly. This will also be a problem for documentation > Paul> generation tools, type extraction tools and class browsers. I > Paul> believe it would be easy to add a contextual keyword > > >> class C: > >> def static foo(x, y): > >> print "classmethod", x, y > > Even better yet, why not simply reuse the class keyword in this context: > > class C: > def class foo(x, y): > print "classmethod", x, y AFAIK, the only way to add classmethods to a class is by doing so after creation of the class object. In that sense you don't have a problem with parsing doc-extraction tools at all: they don't have a chance of finding the class methods anyway ;-) Importing doc-extraction tools won't have a problem with these though and neither will human doc-extraction tools, since these will note that the class methods are special :-) -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From tim.one at home.com Sat Jul 14 19:56:01 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 14 Jul 2001 19:56:01 -0400 Subject: python and applications In-Reply-To: <9iqf6r0g0r@enews1.newsguy.com> Message-ID: <LNBBLJKPBEHFEDALKOLCGEIGKOAA.tim.one@home.com> [Alex Martelli] > I have modest visual impairment (slowly worsening with age) and I > agree. But when and if it gets to blindness, I don't know if Python's > reliance on whitespace/indentation will be a problem -- normal screen > readers won't help much, I guess it would require a special one that > understands the significance of indent and dedent. Perhaps not too > big a project, but I'm not aware of any such special readers, which > would seem to indicate a dearth of blind (as opposed to visually > impaired) Python programmers -- even pretty serious visual problems > still leave one able to see the block structure/indentation quite well > (perhaps with some magnification of course, but less than would be > needed for, say, braces!) -- but total blindness is another issue. Three years ago to the day, a blind Python user described an Emacs python-mode extension he wrote to deal with this issue: http://groups.yahoo.com/group/python-list/message/40107 The primary trick appeared to be the code already in pymode that uses the status line to indicate which block is being closed by a dedent: Thus, as I close each block, I hear the block that I am closing with utterances of the form "closes block while: i<n" "closes block def foo: " etc. I don't know how that could help when just *reading* code, although pymode has lots of Python-savvy navigation commands ("go to nearest-enclosing def", etc) that could be hooked to a speech driver. From Randy.L.Kemp at motorola.com Wed Jul 18 13:52:08 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Wed, 18 Jul 2001 12:52:08 -0500 Subject: What is happening with this program Message-ID: <E566B020833BD311B6610008C791A39705CA5264@il93exm04.css.mot.com> Can someone tell me what is happening here? Is it saying my original directory is not present? If not, can anyone tell me how to fix this program? The program ran fine in windows, and I am enclosing: 1. Results of executing program on Solaris. 2. File on server where program is being executed 3. Program with IP and sign on information changed. ------------------------> Results of executing program <--------------------------------------------------------------------------- ----- pdsweb:/usr2/websoftware/pythonprograms> ./ftpclient.py tablespace.list,redologs.list,logfile.list,controlfile.list,dumpdest.list,us r2_pdswebdbfiles_oradata_pdsweb_drsys01.dbf.Z,usr2_pdswebdbfiles_oradata_pds web_indx01.dbf.Z,usr2_pdswebdbfiles_oradata_pdsweb_MECLABTS.dbf.Z,usr2_pdswe bdbfiles_oradata_pdsweb_PCBTRACK.dbf.Z,usr2_pdswebdbfiles_oradata_pdsweb_rbs 01.dbf.Z,usr2_pdswebdbfiles_oradata_pdsweb_system01.dbf.Z,usr2_pdswebdbfiles _oradata_pdsweb_temp01.dbf.Z,usr2_pdswebdbfiles_oradata_pdsweb_tools01.dbf.Z ,usr2_pdswebdbfiles_oradata_pdsweb_users01.dbf.Z,usr2_pdswebdbfiles_oradata_ pdsweb_VINNIE.dbf.Z,usr2_pdswebdbfiles_oradata_pdsweb_redo03.log.Z,usr2_pdsw ebdbfiles_oradata_pdsweb_redo02.log.Z,usr2_pdswebdbfiles_oradata_pdsweb_redo 01.log.Z,usr2_pdswebdbfiles_oradata_pdsweb_control01.ctl.Z,usr2_pdswebdbfile s_oradata_pdsweb_control02.ctl.Z,usr2_pdswebdbfiles_oradata_pdsweb_control03 .ctl.Z,backup.controlfile,initpdsweb.ora,tnsnames.ora,listener.ora filename = filename name = name Traceback (most recent call last): File "./ftpclient.py", line 16, in ? ftp.storbinary("STOR " + name, open(filename, 'rb')) File "/usr2/ActivePython-2.1/lib/python2.1/ftplib.py", line 371, in storbinary conn = self.transfercmd(cmd) File "/usr2/ActivePython-2.1/lib/python2.1/ftplib.py", line 296, in transfercmd return self.ntransfercmd(cmd, rest)[0] File "/usr2/ActivePython-2.1/lib/python2.1/ftplib.py", line 278, in ntransfercmd resp = self.sendcmd(cmd) File "/usr2/ActivePython-2.1/lib/python2.1/ftplib.py", line 229, in sendcmd return self.getresp() File "/usr2/ActivePython-2.1/lib/python2.1/ftplib.py", line 202, in getresp raise error_perm, resp ftplib.error_perm: 553 /usr2/websoftware/oraclebackupfiles/pdsweb/tablespace.list: No such file or directory. pdsweb:/usr2/websoftware/pythonprograms> -----------------> File on sending server <-------------------------------------------------------------------- pdsweb:/usr2/websoftware/oraclebackupfiles/pdsweb> ls backup.controlfile controlfile.list dumpdest.list initpdsweb.ora listener.ora logfile.list redologs.list tablespace.list tnsnames.ora usr2_pdswebdbfiles_oradata_pdsweb_MECLABTS.dbf.Z usr2_pdswebdbfiles_oradata_pdsweb_PCBTRACK.dbf.Z usr2_pdswebdbfiles_oradata_pdsweb_VINNIE.dbf.Z usr2_pdswebdbfiles_oradata_pdsweb_control01.ctl.Z usr2_pdswebdbfiles_oradata_pdsweb_control02.ctl.Z usr2_pdswebdbfiles_oradata_pdsweb_control03.ctl.Z usr2_pdswebdbfiles_oradata_pdsweb_drsys01.dbf.Z usr2_pdswebdbfiles_oradata_pdsweb_indx01.dbf.Z usr2_pdswebdbfiles_oradata_pdsweb_rbs01.dbf.Z usr2_pdswebdbfiles_oradata_pdsweb_redo01.log.Z usr2_pdswebdbfiles_oradata_pdsweb_redo02.log.Z usr2_pdswebdbfiles_oradata_pdsweb_redo03.log.Z usr2_pdswebdbfiles_oradata_pdsweb_system01.dbf.Z usr2_pdswebdbfiles_oradata_pdsweb_temp01.dbf.Z usr2_pdswebdbfiles_oradata_pdsweb_tools01.dbf.Z usr2_pdswebdbfiles_oradata_pdsweb_users01.dbf.Z pdsweb:/usr2/websoftware/oraclebackupfiles/pdsweb> -------------------> Python program (with sensitive data changed to protect the innocent) <--------------------------------------------- #!/usr2/ActivePython-2.1/bin/python import string, os import ftplib import glob filename = os.path.join("usr2", "websoftware", "oraclebackupfiles", "pdsweb") listname = string.join(os.listdir('/usr2/websoftware/oraclebackupfiles/pdsweb'),',') print listname ftp = ftplib.FTP('999.999.999.999') #specify host ftp.connect() # defaults to port 21, check docs for further options ftp.login(user='fudd',passwd='elmer',acct='looney') # user info ftp.cwd('/usr2/pdsweb/oraclebackupfiles2/pdsweb/') for filename in glob.glob('/usr2/websoftware/oraclebackupfiles/pdsweb/*'): name = string.split(filename, '\\')[-1] print "filename = " + 'filename' + "\n" print "name = " + 'name' + "\n" ftp.storbinary("STOR " + name, open(filename, 'rb')) ftp.retrlines('LIST') # list directory contents ftp.quit() From aleaxit at yahoo.com Tue Jul 31 09:20:30 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 31 Jul 2001 15:20:30 +0200 Subject: how to know the end of a file(use readline) References: <mailman.996580197.11033.python-list@python.org> Message-ID: <9k6bb1027th@enews4.newsguy.com> "sdf" <wqh-2 at 263.net> wrote in message news:mailman.996580197.11033.python-list at python.org... > I use readline to process the whole ,but > I do not know how to control it,when it > is the end of the file f.readline() returns an empty string, '', when f is at end of line, and in no other case (when reading an empty line, it returns '\n': just a special useful case of the fact that readline does NOT remove the trailing '\n' from the line it reads). Alex From emmanuel.astier at winwise.fr Wed Jul 4 14:01:07 2001 From: emmanuel.astier at winwise.fr (Emmanuel Astier) Date: Wed, 04 Jul 2001 18:01:07 GMT Subject: Performance in embeded / extended python References: <3b431024.15341289@news.iway.fr> <vle6kt8736tsqu498op6srgshmat6ouabf@4ax.com> Message-ID: <3b4358e0.33960742@news.iway.fr> On Wed, 04 Jul 2001 15:42:08 GMT, Courageous <jkraska1 at san.rr.com> wrote: > >>Have someone a clue of something I could have done wrong ? > >If you have a C program which embeds Python, you're going to have >to profile your C program using whatever profiling tools are available >under your development platform. > >>Can't extended python be faster ? > >You have verified yet that it's not your C code. > >You may be able to profile your Python code, however. Look into the >"profile" module. > >C// > I sure profile my C program, but the frame rate is enougth to tell when there is a problem. I must confess a part of the problem was in my C code. The python can handle the 200 iterations, but 800 is too much... As the manipulations I make on my objects are here really simple, 800 is not that hight. It means I can't handle more than 100 object with real manipulations... I was hoping some more... Emmanuel From aleaxit at yahoo.com Tue Jul 31 15:24:06 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 31 Jul 2001 21:24:06 +0200 Subject: Typing system vs. Java (fwd) References: <mailman.996258291.15055.python-list@python.org> <psog0besc97.fsf@jekyll.curl.com> <3b65a820_7@Usenet.com> <9k4l5c$o985@news1.gtech.com> <200107311422.KAA28982@panix2.panix.com> Message-ID: <9k75se01n2l@enews3.newsguy.com> Hi Aahz, <aahz at panix.com> wrote in message news:200107311422.KAA28982 at panix2.panix.com... > Mind if I repost this to another newsgroup? (alt.polyamory if you're > curious.) Not at all, though I'll admit to curiosity about the relevance to alt.polyamory (I did use to be a regular there, but that was a LONG time ago -- and anyway, now that Elf posts to comp.lang.python, there are surely more prominent ex-a.p'ers than me on c.l.p...?-). Alex From mal at lemburg.com Wed Jul 18 09:34:51 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Wed, 18 Jul 2001 15:34:51 +0200 Subject: PEP: Defining Python Source Code Encodings References: <Pine.LNX.4.21.BCL.0107171620190.704-100000@suzi.com.onego.ru> Message-ID: <3B55907B.206DE96D@lemburg.com> Roman Suzi wrote: > > On Tue, 17 Jul 2001, M.-A. Lemburg wrote: > > > > I think, that if encoding is not given, it must sillently assume "UNKNOWN" > > > encoding and do nothing, that is be 8-bit clean (as it is now). > > > > To be 8-bit clean it will have to use Latin-1 as fallback encoding > > since this encoding assures the roundtrip safety (decode to Unicode, > > then reencode). > > Nope. There must be no encode-decode back. Or it will slow down > starting Python _scripts_ unnecessary. > > That is why I suggested "unknown" encoding - a safe default > for those who do not want any back-and-force recodings. If you want to avoid having to decode and the reencode data in ther parser, we would have to live with two sets of parsers in Python -- one for Unicode and one for 8-bit data. I don't think that anyone would like to maintain those two sets, so it's basically either go all the way or not move at all. > > > Otherwise, it will slow down parser considerably. > > > > Yes, that could be an issue (I don't think it matters much though, > > since parsing usually only done during byte-code compilation and > > the results are buffered in .pyc files). > > No! Scripts are compiled each time they run. > If this will be implemented, developers will need to do the trick > of making each script a module and so on. This is not good idea. > > There clearly must be the way to prevent encode-decode. And it would be > better if only EXPLICITLY given encoding will trigger encode-decode > mechanism. That's not true: Python caches byte-code compiled versions of scripts in .pyc|o files. So the performance problem is really not all that important. > > > I also think that if encoding is choosen, there is no need to reencode it > > > back to literal strings: let them be in Unicode. > > > > That would be nice, but is not feasable at the moment (just try > > to run Python with -U option and see what happens...). > > Then indeed --encoding= is needed with -U ;-) No, a lot of voluntary work is needed to make the Python standard lib Unicode compatible ! > > > Or am I missing something? > > > > It won't switch any time soon... there's still too much work > > ahead and I'm also pretty sure that the 8-bit string type won't > > go away for backward compatibility reasons. > > ...and efficiency reasons too. re was slowed down significantly by adding > Unicode support. I seriously doubt that. Fredrik (who wrote the sre engine) is an optimization genius and in some cases even made the sre engine faster than the string module implementations of e.g. find(). > > > > To make this backwards compatible, the implementation would have to > > > > assume Latin-1 as the original file encoding if not given (otherwise, > > > > binary data currently stored in 8-bit strings wouldn't make the > > > > roundtrip). > > > > > > ...as I said, there must be no assumed charset. Things must > > > be left as is now when no explicit encoding given. > > > > This is what the Latin-1 encoding assures. > > I still think something like "raw" is needed... Latin-1 gives you this "raw" feature. > > > > 4. The encoding used in a Python source file should be easily > > > > parseable for en editor; a magic comment at the top of the > > > > file seems to be what people want to see, so I'll drop the > > > > directive (PEP 244) requirement in the PEP. > > > > > > > > Issues that still need to be resolved: > > > > > > > > - how to enable embedding of differently encoded data in Python > > > > source code (e.g. UTF-8 encoded XML data in a Latin-1 > > > > source file) > > > > > > Probably, adding explicit conversions. > > > > Yes, but there are cases where the source file having the embedded > > data will not decode into Unicode (I got the example backwards: > > think of a UTF-8 encoded source file with a Latin-1 string literal). > > utf-7 bit for embedded things ;-) > > > Perhaps we should simply rule out this case and have the > > programmer stick to the source file encoding + some escaping > > or a run-time recoding of the literal data into the preferred > > encoding. > > This is probably wise. Python program need not be a > while Zoo of encodings... I'll put this into the PEP update. > > > No variant is ideal. The 2nd is worse/best than all > > > (it depends on how to look at it!) > > > > > > Python has no macro directives. In this situation > > > they could help greatly! > > > > We've been discussing these on python-dev, but Guido is not > > too keen on having them. > > And this is right. I even think encoding information could be EXTERNAL. No -- how are editors supposed to know about these external files ? > For example, directory will need to have "__encodings__.py" file where > encodings are listed. > > Then, Python if started with some key could check for such file and > compile modules accordingly. > > If there is not __encodings__.py, then Python proceed as it does now, > WITHOUT any conversions to and from. > > This will make script-writer happy (no conversion overhead) and those who > want to write encoding-enabled programs (they could specify > __encodings__.py) > > I think, this solves most problems. > > > > That "#!encoding" is special case of macro directive. > > > > > > May be just put something like ''# <!DOCTYPE HTML PUBLIC'' > > > at the beginning... > > > > > > Or, even greater idea occured to me: allow some XML > > > with meta-information (not only encoding) somehow escaped. > > > > > > I think, GvR could come with some advice here... > > > > > > > Comments are welcome ! > > > > Thanks for your comments, > > I just hope the realisation of your PEP will not make Python scripts > running slower ;-) while allowing truly useful i18n functionality. By the time the PEP will be implemented, CPUs will run at least 50% faster than they do now -- this should answer your question ;-) -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From donovan at sherbet.co.uk Wed Jul 18 08:22:00 2001 From: donovan at sherbet.co.uk (Donovan Hide) Date: Wed, 18 Jul 2001 13:22:00 +0100 Subject: Partition Problem References: <tku1tt92ac2g8e@corp.supernews.co.uk> <3B4FBEA0.D5A6DC8A@engcorp.com> <9ioru22pc9@enews4.newsguy.com> <3B5042C2.F821D916@engcorp.com> <9itb14$2oi$1@newsg1.svr.pol.co.uk> <Xns90E0B338278B2arneleitheno@148.122.208.74> <9iv5e9$bru$1@newsg1.svr.pol.co.uk> <fSI47.12086$p7.3693169@news1.rdc2.pa.home.com> <Xns90E1337E8B341arneleitheno@148.122.208.74> <0oR47.12485$p7.4220508@news1.rdc2.pa.home.com> <Xns90E1CD0C46990arneleitheno@148.122.208.67> <Usa57.127$EP6.29198@news1.rdc2.pa.home.com> Message-ID: <tlavt7jeqqt7b3@corp.supernews.co.uk> Wow, fascinating! The minds of two 'algorthmistas' battling the pros and cons of there code and techniques. I can't tell you how interesting this is. I really get the feeling that Python needs a good combinatorics module. CombPy, maybe? If not that, then an extension to NumbPy. Anyway, until the next issue of DDJ reaches my newsagent, thanks for the help. Donovan Hide. From rhaper at houston.rr.com Sat Jul 21 15:05:26 2001 From: rhaper at houston.rr.com (Rod Haper) Date: Sat, 21 Jul 2001 19:05:26 GMT Subject: Language change and code breaks References: <mailman.995378792.16515.python-list@python.org> <cpvgkq1f2b.fsf@cj20424-a.reston1.va.home.com> <9j9i19$p96$1@panix2.panix.com> <3B596D95.C87DFFCD@mac.com> Message-ID: <3B59D276.EAC2B8B9@houston.rr.com> jorjun wrote: > > Aahz Maruch wrote: > > i'M aFraId i doN't UnDerStaNd wHy YoU THinK caSE-InsENsitIvitY miGhT bE > > A gOoD idEA. > > -- > Currently if I import a module and the identifiers lOoK_lIkE_ThIs > then I have to precisely follow the ugly conventions in my own code. You're not really "stuck" with the imported names. You could use "from <> import <> as <>" or just assign your own names to the imported references. It's extra effort but if it really bugs you enough, you can assign and use names that you prefer. -- "Okay, okay! So it works in practice. But will it work in theory?" From grante at visi.com Mon Jul 23 10:45:08 2001 From: grante at visi.com (Grant Edwards) Date: Mon, 23 Jul 2001 14:45:08 GMT Subject: PEP0238 lament References: <mailman.995839419.19134.python-list@python.org> <cEN67.17775$EP6.4652917@news1.rdc2.pa.home.com> Message-ID: <ULW67.22965$B7.3754505@ruti.visi.com> In article <cEN67.17775$EP6.4652917 at news1.rdc2.pa.home.com>, Terry Reedy wrote: >Situation: Python '/' currently overloads and confounds two arithmetic >operations: whole-number result division and fractional result >division. This confuses some people. That's life. The foo[] overloads different operations also: indexing into a sequence, looking up an element in a dictionary. What about the other overloaded math operators like "+", "-", "*"? Should "/" behave differently from the others? Personally, I don't think so. -- Grant Edwards grante Yow! I know things about at TROY DONAHUE that can't visi.com even be PRINTED!! From guido at python.org Tue Jul 31 02:39:21 2001 From: guido at python.org (Guido van Rossum) Date: Tue, 31 Jul 2001 06:39:21 GMT Subject: PEP 238 (revised) References: <cp4rrz5onj.fsf@cj20424-a.reston1.va.home.com> <3B61C0B0.30477AFB@home.net> <3b62459e.609746999@wa.news.verio.net> <3B659D16.5E52DE63@home.net> Message-ID: <cpitg9zjph.fsf@cj20424-a.reston1.va.home.com> Chris Barker <chrishbarker at home.net> writes: > [...] The problem, for me, is that > 1.0 can't be used as a sequence index. While it may not be know whether > x//y is an exact value, it IS know that it is an integer value, and > should therefor be usable as an index. This brings up the usefulness of > the concept of the inexact integer. Totally useless IMO -- and wrong. If it's inexact, that means it could really be any number inside some interval around the represented value, and thus by definition you can't tell whether it is an Integer at all. > I'm also not so sure about your above rational: While I do understand > that the result of x//y may not be an exact number, given that x and/or > y may not be exact, the question is: does that matter? Acn anyone think > of a case where they would use // (or floor, or ceil, or round) when it > would hurt for the final result to be considered exact? When the width of the inexactness interval is larger than 1, there's more than one Integer that's the possible result, so we don't know the result exactly. --Guido van Rossum (home page: http://www.python.org/~guido/) From guido at python.org Tue Jul 24 15:47:35 2001 From: guido at python.org (Guido van Rossum) Date: Tue, 24 Jul 2001 19:47:35 GMT Subject: Language change and code breaks References: <Pine.LNX.4.33.0107191316390.24983-100000@bms> <mailman.995571273.18192.python-list@python.org> <9j7gv8$9mg@dispatch.concentric.net> <cppuawfqbm.fsf@cj20424-a.reston1.va.home.com> <Pine.LNX.4.33.0107231434170.15565-100000@oliphant.ee.byu.edu> Message-ID: <cp7kwyqfce.fsf@cj20424-a.reston1.va.home.com> Travis Oliphant <oliphant at ee.byu.edu> writes: > I'll just chime in to say that as one who uses Python for > science/engineering, I would be very unhappy not to be able to define the > variables h and H to mean two different things. Engineers often uses > case to distinguish between the function and it's Fourier transform for > example. How did engineers cope with Fortran? Fortran has long been the preferred language for engineers, after C.S. folks moved on to C and C++... --Guido van Rossum (home page: http://www.python.org/~guido/) From tim at digicool.com Mon Jul 23 15:41:18 2001 From: tim at digicool.com (Tim Peters) Date: Mon, 23 Jul 2001 15:41:18 -0400 Subject: PEP0238 lament In-Reply-To: <916olt0p3kciv0evmotdg6jev9bl29l57i@4ax.com> Message-ID: <BIEJKCLHCIOIHAGOKOLHIEFNCDAA.tim@digicool.com> [Steve Horne] ... > I think you'll find it's the picking of languages where 1/2 = 0.5 that > has to be done carefully - I can think of Pacal, Modula 2, LISP and - > taking into account your correction - Perl and JavaScript. LISP doesn't belong in that list, but members of the Algol family do. > The last to are enough to prove that your *opinion* is valid, Which opinion is that? I haven't said I'm in favor of PEP 238, and indeed I haven't made up my mind. I do believe I understand why Guido thinks it's important, though, and burned some time trying to flesh it out. > those are not in use to anywhere near the same extent as languages > like , C++, Java and BASIC. Already said I don't care what other languages do here, and, yes, of course that's my opinion -- like yours is yours. From thomas.heller at ion-tof.com Tue Jul 31 07:06:23 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Tue, 31 Jul 2001 13:06:23 +0200 Subject: Python 2.1 distutils swig_cpp and binary installation target dir question References: <3b647cb1_7@news.newsgroups.com> Message-ID: <9k63fg$2nfq2$1@ID-59885.news.dfncis.de> [posted and mailed] "Brad Clements" <bkc at Murkworks.com> wrote in message news:3b647cb1_7 at news.newsgroups.com... > Question 1. Is there any way to specify swig_cpp in the setup.py file? I > couldn't figure it out No. You should specify it in the setup.cfg file, which allows to specify default command line arguments: ----- [build_ext] swig-cpp=1 ----- > > Question 2. I created a binary self-extracting windows package.. It installs > to <pythonDir>, where I expect it to install to > <pythonDir/Lib/site-packages> or <pythonDir/Lib> > > Is this the correct behavoir, or did I do something wrong? This is correcr behaviour, although it is likely to change - See PEP250. If you are running 'python setup.py install' you can override it with command line options, but not in a self-extrating window package (I assume you're speaking of bdist_wininst here). Thomas Heller From grante at visi.com Tue Jul 3 11:16:45 2001 From: grante at visi.com (Grant Edwards) Date: Tue, 03 Jul 2001 15:16:45 GMT Subject: Python for air traffic control? References: <134704696.994123281122.JavaMail.root@boots> <mailman.994128604.28588.python-list@python.org> <bebbba07.0107022044.106d9da8@posting.google.com> Message-ID: <xll07.7615$B7.1404761@ruti.visi.com> In article <bebbba07.0107022044.106d9da8 at posting.google.com>, Russ wrote: >Just for the record, Mr. Park is publicly posting my private >replies to him. I guess I should have expected something like >that from him. Ignore him. >I'm sure you all understand that I don't like being called an >"idiot" for asking a general question about the suitability of >Python for a certain type of application. I thought it was a valid and very interesting question. >You must also understand, of course, that the safety-critical >application I am referring will not actually be deployed in a >critical mode for several years at least, during which time it >will be thoroughly and completely tested. Believe me, I'm >talking about more testing than you think. It will first be >used for years as a non-critical back-up for (human) >controllers before it is ever used as a primary means of >assuring separation. My gut feeling is that if the system is done in C or C++ (for example) it is going to have to use dynamic memory allocation. Once you've taken that step, I don't think that Python is inherently more likely to have memory problems, and I think that Python is inherently _less_ likely to have many other types of bugs. If this were a simple, hard-realtime system with response time requirements in the milliseconds, I'd stay away from Python, away from C++, and away from dynamic memory allocation. However, with response time requirements in the hundreds of milliseconds and a problem domain that probably requires dynamic memory allocation I think Python would be suitable. The introspection features could be very useful for automated testing, as could some simple instrumentation of the memory management functions. >> > Which "city am I working at"? Boy, you really ARE stupid, >> > aren't you? The GRE score is fact. >> >> It would be helpful to me to know which airport you intend to >> write this Python code for. Apparently Mr. Park thinks that ATC is a function of local airports and they each build their own systems. -- Grant Edwards grante Yow! My polyvinyl cowboy at wallet was made in Hong visi.com Kong by Montgomery Clift! From Tom_Good1 at excite.com Mon Jul 30 12:20:37 2001 From: Tom_Good1 at excite.com (Tom Good) Date: 30 Jul 2001 09:20:37 -0700 Subject: Suggestion for impriving list comprehensions References: <mailman.996205196.16876.python-list@python.org> <ac677656.0107271023.a5d1328@posting.google.com> <mailman.996282541.32450.python-list@python.org> Message-ID: <ac677656.0107300820.58f71c93@posting.google.com> Neil Schemenauer <nas at python.ca> wrote in message news:<mailman.996282541.32450.python-list at python.org>... > Tom Good wrote: > > Consider the following: > > > > >>> from __future__ import generators > > >>> def g(): > > ... yield 1 > > ... yield 2 > > ... > > >>> i = iter(g) > > Traceback (most recent call last): > > File "<stdin>", line 1, in ? > > TypeError: iter() of non-sequence > > >>> > > > > iter(g) doesn't work, but it somehow feels as if it should. > > What could iter(g) possibly mean? This seems to be some very weird > confusion about a function object and the object a function returns. > Are you surprised when: > > def one(): > return 1 > > print one + 2 > > does not print 3? > > Neil No, I'm not surprised by the result in your example. And when I stop and think about it, of course iter(g) doesn't work. *At a glance* though, "iter(g)" (where g is a generator) and "iter(i)" (where i is another iterator) look very similar, but the latter works and the former is an error. Tom From paul at svensson.org Fri Jul 27 10:04:00 2001 From: paul at svensson.org (Paul Svensson) Date: 27 Jul 2001 14:04:00 GMT Subject: PEP 238 (revised) References: <cp4rrz5onj.fsf@cj20424-a.reston1.va.home.com> Message-ID: <9jrscg$1uf$1@newsy.ifm.liu.se> Guido van Rossum <guido at python.org> writes: > The names associated with these variations are: > > - Overloaded operator methods: > > __div__(), __floordiv__(), __truediv__(); > > __idiv__(), __ifloordiv__(), __itruediv__(). Do we really neead to add __truediv__ and __itruediv__ ? As far as I can see, the only reason for these would be to let someone writing their own numeric class explicitly differentiate between classic division and future division. Are there really such classes out there that need to be catered to ? If not, I'd suggest letting __div__ and __idiv__ handle both. Other than that, I really don't like the term 'true division', I'm not sure exactly why, but it just doesn't ring... I liked the proposal to call '/' division, and '//' quotient; ambiguities can be resolved by using 'classic division' or 'future division'. /Paul From max at alcyone.com Mon Jul 23 02:42:03 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 22 Jul 2001 23:42:03 -0700 Subject: A use for integer quotients References: <3B5BA29B.E08FEEE9@alcyone.com>, <yCK67.17615$EP6.4467503@news1.rdc2.pa.home.com> <mailman.995860718.9550.python-list@python.org> <mailman.995862939.15013.python-list@python.org> Message-ID: <3B5BC73B.2D52E5E2@alcyone.com> Moshe Zadka wrote: > Quietly? Note that in the 2.2 release, there will be *no* change > except > that you *can* use //, and the only change is if you > "from __future__ import division". > In 2.3, as I understand it, you'll be able to get warnings out when > you > are doing something whose semantics will change. ... > Or just running tests with all warnings except this one turned off, > and going through the pinpointed lines. Or you could not change it in the first place, eliminate the transition period requirement, keep Python's integer division operator consistent with other languages like it already was, not have to worry about the PR hit it is going to necessarily take ("In Python the meaning of the builtin operators change every third release! What a crock"), and prevent experienced Python programmers from shaking their heads in confusion and wonder. I simply cannot believe that the benefit that will be gained will be worth the price in inconvenience. -- 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 stronger in the world than gentleness. \__/ Han Suyin Erik Max Francis' bookmarks / http://www.alcyone.com/max/links/ A highly categorized list of Web links. From tjreedy at home.com Tue Jul 24 12:01:36 2001 From: tjreedy at home.com (Terry Reedy) Date: Tue, 24 Jul 2001 16:01:36 GMT Subject: PEP0238 lament References: <mailman.995814276.15005.python-list@python.org> <cp66clexxt.fsf@cj20424-a.reston1.va.home.com> <9jhbfj$79s$1@pea.uk.research.att.com> <mailman.995930743.17137.python-list@python.org> <9jjfts$9k2$1@pea.uk.research.att.com> Message-ID: <AZg77.25346$EP6.5915842@news1.rdc2.pa.home.com> "Duncan Grisby" <dgrisby at uk.research.att.com> wrote in message news:9jjfts$9k2$1 at pea.uk.research.att.com... > The thing about this change is that it is different from other changes > there have been (that I'm aware of), in that it changes a fundamental > part of the language semantics. Switching from the current / behaviour > to the new proposal is not the same as _removing_ a feature -- it is > _changing_ a feature. That is far more insidious. This is an excellent summary of the essay I wrote two weeks ago entitled Language Change and Code Breaks, which I have appended below for those who missed it. (I know, should start a web page for such things.) I am disappointed that the floatist proponents of the division change have before and since spent more time throwing quasi-religion dogmatisms at us than dealing with the nitty-gritty issues raised therein. [From yesterday: Guido von Rossum: " Reiterating why the current definition of '/' is evil: int and float together aren't really two distinct types:" Paul Foley "Integer division" isn't division" [restated 4 different ways] ... Computer-language-related retardation is the problem. ] =========================================================== LANGUAGE CHANGE AND CODE BREAKS --with particular reference to Python and recent discussions in comp.lang.python Terry J. Reedy, tjreedy at udel.edu July 10, 2001 Summary: After discussing two generals issues (type and audience), I particularly look at the effect on new programmers and the effect of replacement changes. Types of Change: As in other realms, such as text editing, we can categorize programming language changes as addition, deletion, and replacement. While replacement can be modeled by or reduced to deletion and addition (see Keywords below), replacement in the specific sense of changing the meaning of a construct legal both before and after is qualitatively different in its effect on programmers and code. It should therefore be kept as a separate category. Audience: Each type of change will have different effects on old and new code (defined as that written for the the old and new versions of the language) when run on the 'wrong' version on the language interpreter. Programmers will also see the change differently depending on whether they learn the language before or after the change . Existing users who pay attention to the change will have to upgrade their knowledge and maybe their code. New users who initially learn only the new version of the language and then read old code or run code on old interpreters without backdating their knowledge may be surprised. Deletions: If a feature is directly deleted, it presumably is rare used and not too useful. When present in code run on a new system, there should be a syntax error and the programmer will have to remove it and maybe do something else. New users reading old code will seldom see deleted features. (I have never, for instance, seen an access statement.) If and when they do, they may ignore it, guess its meaning, or find its meaning in old documentation. Additions: Old code runs fine in new interpreters. New users will never see the new feature they learned in old code. If they try to use it with an old interpreter, they will get an error message and either work around its absence or stick with new interpreters. Keywords: Addition of a word as a keyword implicitly deletes its previous usage as a name. As long as the legal usages before and after are disjoint, any wrong usages will be flagged as errors. This combination of deletion and addition is different from replacement in the narrow sense I use here. Example: The statement 'yield <expression>' is disjoint from any current legal use of 'yield' as, for instance, a name for bond yield. Replacements: These are the most troublesome changes since they amount to a silent code break. There will be no error message (at least not at the point of misinterpretation) when code is run under the wrong interpreter. Similarly, there is no reason for a flag to raised in the mind of a new user who only knows the new meaning of the construct. A further complication is that incompatibility is bidirectional. Old code that does not use a deleted feature and new code that does not use an added feature can run on both old and new interpreters. After a replacement, code must avoid the changed-meaning syntax entirely, in both old and new meanings, to achieve the same flexibility. For various reasons, transitions may take several years before everyone upgrades their interpreters to any particular release level. Last I knew, for instance, some Linux distributions still install Python 1.5.2. Code-breaking replacements probably inhibit ungrades more that non-code-breaking additions Example 1 - nested scooping: As I understand it, the value assigned to y in x = 1 def f(): x = 'one' def g(): y = x is changing from 1 to 'one'. This transition is eased by the fact that duplicate intermediate names are currently unnecessary (just change the spelling) and rare. As a transition measure, the compiler can detect this usage and emit a warning, strongly suggestion a name change before the scope-hiding meaning is deleted by being replaced. As for newcomers, those few who really delve into into the advanced topic of nested functions and name scoping can also read an included warning about the older two-level rule. Example 2 - integer (int+long) division: This transition is more involved and will be harder even with extra planning. a. While it is fairly easy to write the future meaning of int/int in the current language, using '.0' and float() as people do now, the currently possible rewrite of the current meaning so it will remain valid -- divmod(e1,e2)[0]) -- is more complex and slower to run. Therefore, a simultaneous (or preceeding) addition of something like infix 'div' is desirable (and already planned). b. Nested scoping applies to all nested functions; its uses are detectable at compile time, which makes warnings about deprecated usages easy. The change in meaning of e1 / e2 is partial in that it only affects integer-integer division. While the case of two literal constants could be detected at compile time, detection generally awaits the run-time dispatching in the function that implements '/'. A warning mechanism will have to include run-time warnings. A mechanism to turn warnings on and off on a per-statement basis would be helpful. c. Nested scoping was intended to be an addition until someone noticed the existence of a foolish-but-legal conflict. The change in meaning of integer / integer is a true bidirectional replacement that will invalidate actual and not just theoretically possible code. To make code cross-compitible, one will generally (without specific program analysis) have to avoid all occurrence of integer-integer division in any form, with either / or div or with constants or variables. d. If the change in meaning brought about by a replacement is large, one may hope that the uncaught error introduced by a legal but incorrect cross-usage will bring about an exception sometime later in the computation. However, the division change may only change the type of the result, which may well change but not crash further computation. And, of course, the value error, if not zero, may be small and similarly hard to detect. e. Almost everyone who does much of any programming will use division sometime, so everyone should be taught how to program it. So this change affect beginners and not just advanced programmers. For years after the change, anyone who might use an older system that they do not control, such as at a school campus or workplace, should also be taught that 'integer / integer' used to mean 'interger div integer', and that subtle and hard-to-detect errors can arise from erroneous cross-usage. From com-nospam at ccraig.org Thu Jul 5 18:47:40 2001 From: com-nospam at ccraig.org (Christopher A. Craig) Date: 05 Jul 2001 18:47:40 -0400 Subject: Question about scope References: <3B44D696.61A8B915@tundraware.com> Message-ID: <87hewrkn77.fsf@elbereth.ccraig.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Tim Daneliuk <tundra at tundraware.com> writes: > I thought that python checked local scope for a variable first and if > it did not find it, it appealed to the local namespace. What am I missing > here - it's probably at the end of my nose, but I cannot seem to make sense > of it... I presume you meant "appealed to the global namespace". This makes you half right. When _referencing_ a variable Python (sans nested-scopes) first checks the local scope and then, if it can't find it, the global. When _assigning_ a variable however Python always uses the local scope (I'm not sure what happens with variables declared as global, but I suspect they live across namespaces), even if a global variable exists. For a good example try this code >>> baz = 5 >>> def foo(): bar = baz baz = 4 >>> foo(): Traceback (most recent call last): File "<stdin>", line 1, in ? File "<stdin>", line 2, in foo UnboundLocalError: local variable 'baz' referenced before assignment Because Python compiled the function foo() before executing it, and because 'baz' is assigned in foo(), 'baz' is a local variable. And one which has not been assigned yet when it is first used, thus the error. - -- Christopher A. Craig <com-nospam at ccraig.org> "Going to school make a person educated, any more than going to a garage makes a person a car" Slashdot -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: Processed by Mailcrypt iEYEARECAAYFAjtE7owACgkQjVztv3T8pzvc9ACdFBsfvMyYhWyuknfq7MehjA2f kpcAn1nGDYygBjKiIqfjv1lwCkbevu+V =AHP4 -----END PGP SIGNATURE----- From slinkp23 at yahoo.com Thu Jul 26 19:18:00 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Thu, 26 Jul 2001 23:18:00 GMT Subject: Tests for calendar module Message-ID: <3B60A388.C6E11F75@yahoo.com> I've written a first draft of a test for the calendar module, using doctest according to the suggestions in Lib/test/README from CVS. I'd like to submit these tests for the python distribution, but I have a couple of questions: 1) Who maintains calendar.py? Lots of contributors listed in the cvs logs. 2) I found a couple of possible bugs in calendar.py. Who should I provide details and patches to? -- ................... paul winkler .................... custom calendars & printing: http://www.calendargalaxy.com A member of ARMS: http://www.reacharms.com home page: http://www.slinkp.com From mertz at gnosis.cx Thu Jul 5 14:55:40 2001 From: mertz at gnosis.cx (Lulu of the Lotus-Eaters) Date: Thu, 05 Jul 2001 14:55:40 -0400 Subject: There's got to be an easy way to do this (fwd) Message-ID: <sgLR7kKkXIkY092yn@bellatlantic.net> "Emile van Sebille" <emile at fenx.com> wrote |I'm not sure how you mean slower, but I tested just now to see, and this is |the fastest of the four. |- 500- std_re cpl_re str_join flt_lmbda | 50 : 3.74 3.60 0.70 0.75 FWIW, the version I presented was not my first thought. I first wrote: def flt_lmbda2(iters): for i in iters: filter(lambda c:c in '0123456789', '(123)/456-7890') But before I pressed the "send" button, the variant: def flt_lmbda(iters): for i in iters: filter(lambda c:c.isdigit(), '(123)/456-7890') Seemed a bit more clear, and a few characters shorter. However, applying timings with the first thought included gives: - 500- std_re cpl_re str_join flt_lmbda flt_lmbda2 5 : 0.77 0.74 0.10 0.14 0.10 10 : 1.54 1.50 0.21 0.29 0.19 50 : 7.71 7.44 1.04 1.44 1.00 Which puts me back with a tiny speed advantage over all comers :-). (But apparently with slower CPU than Emile... time to start saving). Yours, Lulu... From m.1.robinson at herts.ac.uk Fri Jul 27 04:35:55 2001 From: m.1.robinson at herts.ac.uk (Mark Robinson) Date: Fri, 27 Jul 2001 09:35:55 +0100 Subject: byte compiled files References: <3B602FA0.6030809@herts.ac.uk> Message-ID: <3B6127EB.2080002@herts.ac.uk> Thanks for the help guys, sorry I didn't include the code (what can I say, duh). Anyway I did manage to fix the problem but I am still kinda interested as to why I was getting that previous behaviour. I am running python 2.1 under red hat 7, and python 2.1.1 under windows NT and had the same problem under both. Here is the code: def checkValidData(bsite): repeats = ['AAAA', 'CCCC', 'GGGG', 'TTTT'] for x in bsite: #check new bsite contains valid charactors if(x is not 'A' and x is not 'G' and x is not 'C' and x is not 'T' ): return 0 for x in repeats: if (string.find(bsite, x) != -1): return 0 return 1 Changing where I test if x is A, C, G or T by using the != test rather than 'is not' solved the problem, and I guess I may have been using it inappropriately, but I still don't see why it would have working correctly first run and then incorrectly when working from the .pyc file. Blobby Mark Robinson wrote: > can anyone shed some light on the mysterious behaviour of my byte > compiled files. I am currently working on a python script which analyses > patterns in a DNA sequence. I have a function which checks a pattern (a > substring of approx 6 chars) to ensure only valid charactors are > present. When I first run this program it runs fine, but if I > immediately rerun the program (i.e using the pre-byte compiled file) it > finds all patterns non-valid. If I delete the .pyc file between runs > this problem does not occur. Can anyone explain what is happening here > to me and how to prevent it? > > blobby From bill-bell at bill-bell.hamilton.on.ca Sat Jul 7 13:54:49 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Sat, 7 Jul 2001 13:54:49 -0400 Subject: Marking a Python COM server safe for Internet Explorer In-Reply-To: <994489633.560.16933.l7@yahoogroups.com> Message-ID: <3B4714A9.7778.1925A5@localhost> "Steve Holden" <sholden at holdenweb.com> wrote, in part: > Because [MS is] the largest software company in the world, by the > nature of things they come in for a bashing now and then. I hand out > my share, mostly in fun, but sometimes with a real point. > > In this case, as you and another poster have pointed out, it was my > misunderstanding. Well, yes and no, eh. I'm grateful to "Neil Hodgson" <nhodgson at bigpond.net.au> for telling me about the following page. http://support.microsoft.com/support/kb/articles/Q161/8/73.ASP It's title is "HOWTO: Mark MFC Controls Safe for Scripting/Initialization" and it contains the following advisory, "Please keep in mind that a control should only be marked as safe if it is, in fact, safe." I could hardly believe my eyes when first I read that. Duh, sound advice from the world's biggest. From hfoffani at yahoo.com Tue Jul 31 14:24:43 2001 From: hfoffani at yahoo.com (Hernan M. Foffani) Date: 31 Jul 2001 18:24:43 GMT Subject: sleep command/function & searching the python docs References: <9k6ilm$2sed8$1@ID-91520.news.dfncis.de> <m3bsm1hyje.fsf@kepler.ibp.de> <9k6mev$2vg4b$1@ID-91520.news.dfncis.de> <mailman.996601079.13064.python-list@python.org> Message-ID: <20010731142443.815$L2@newsreader.com> skip at pobox.com (Skip Montanaro) wrote: > >>> ... is there any way to search the Python docs for a specific > >>> function/module etc? Or is there any resource on the web that > >>> provides a searchable interface? > > Rajarshi> Another post in this thread mentioned http://web.pydoc.org > - Rajarshi> looks pretty useful > > On Alta Vista (and probably a > number of other search engines as well) you can search for something like > > options url:www.python.org/doc/current/lib Or, if you've got a Windows workstation you can download the docs in Microsoft HTML Help format. http://www.orgmf.com.ar/condor/pytstuff.html And there is a bigger package with some more interesting stuff. Regards, -Hernan -- -------------------- http://NewsReader.Com/ -------------------- Usenet Newsgroup Service From bsass at freenet.edmonton.ab.ca Thu Jul 19 02:55:31 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Thu, 19 Jul 2001 00:55:31 -0600 (MDT) Subject: python newbie question In-Reply-To: <9j5u0m+jpri@eGroups.com> Message-ID: <Pine.LNX.4.33.0107190052440.15405-100000@bms> On Thu, 19 Jul 2001 donmalla at yahoo.co.in wrote: > Hi All, > I am a newbie to python. I am following the "Diving into Python > tutorial". > However I am having a problem with the for loop > Here is the problem: > > >>> vec = [2,4,6] > >>> [3*x for x in vec] > SyntaxError: invalid syntax <...> > Please help me. I am using Python 1.5 on Windows 2000. You need Python 2.0 or newer to use [list comprehensions]. -Bruce From kragen at dnaco.net Sun Jul 1 07:17:31 2001 From: kragen at dnaco.net (Kragen Sitaker) Date: Sun, 01 Jul 2001 11:17:31 GMT Subject: Is this a true statement: Part II References: <9hiifr$sjs$1@taliesin.netcom.net.uk> <mailman.993843346.4433.python-list@python.org> Message-ID: <fFD%6.19908$zT1.1099537@e420r-atl3.usenetserver.com> In article <mailman.993843346.4433.python-list at python.org>, Paul Prescod <paulp at ActiveState.com> wrote: >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. Well, they're equivalent in the theoretical sense that what you can express in one, you can express in another. But there are some major practical differences: * some languages are much easier to express some computations in; Python is much easier than C++ or C to express almost any computation in. This is a topic one could write about for pages upon pages, but the difference is a matter of small factors: typically 5 to 20. * different languages have different implementations; the same computation running on different implementations (of the same language or of different languages) can use vastly different quantities of memory and CPU time. Factors of 20 to 100 in CPU time usage are commonplace; factors of 100,000 in CPU time usage are not unheard of. Likewise, factors of 10 in memory usage are commonplace, and factors of 100 in memory usage are not unheard of. In particular, Python programs tend to be between 10 and 1000 times as slow as equivalent programs written in C, use between 1 and 20 times as much RAM as the C version, take about 1/10 the programming time as the C version, and contain about 1/10 the bugs of the C version does. Given these tradeoffs, people tend to implement simpler programs in C than in Python when faced with the same problem, which often results in solving the problem less efficiently. >But the input and output parts depend on the environment that the >program is runing in. Yes. >You could write an operating system that could only be directly >programmed in Python. I'm not sure how. Nobody has yet come up with an operating system that could only be directly programmed in C, or Lisp, or Algol, or Java, despite implementing operating systems in all four. I think some of the Burroughs machines required special god privileges to run the assembler, but there was still an assembler. -- <kragen at pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/> Perilous to all of us are the devices of an art deeper than we possess ourselves. -- Gandalf the White [J.R.R. Tolkien, "The Two Towers", Bk 3, Ch. XI] From tim.one at home.com Sun Jul 1 02:18:51 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 1 Jul 2001 02:18:51 -0400 Subject: The standard library In-Reply-To: <3B3EB7A7.533B8389@ActiveState.com> Message-ID: <LNBBLJKPBEHFEDALKOLCEELDKLAA.tim.one@home.com> [Paul Prescod, with many good gripes about the libraries] > ... > I do feel that this is a problem that only PythonLabs could really > address because a library overhaul would be large, pervasive, > controversial and would require Guido's approval at every step. Guido knows this, if for no other reason than that Eric Raymond keeps reminding him of it. PEP 2 is supposed is the first step on this path. although-it's-a-long-path-and-tiny-steps-so-far-ly y'rs - tim From peter at engcorp.com Mon Jul 9 21:44:32 2001 From: peter at engcorp.com (Peter Hansen) Date: Mon, 09 Jul 2001 21:44:32 -0400 Subject: PEP scepticism References: <mailman.994528591.28994.python-list@python.org> <cpy9q0iobo.fsf@cj20424-a.reston1.va.home.com> <9icbft$okp$1@panix6.panix.com> <L3DTqUAyejS7Ew2k@jessikat.fsnet.co.uk> Message-ID: <3B4A5E00.BDB4245A@engcorp.com> Robin Becker wrote: > > In article <9icbft$okp$1 at panix6.panix.com>, Aahz Maruch <aahz at panix.com> > writes > >"Who killed Cock Robin? > >I, said the sparrow > >With my bow and my arrow > >I killed Cock Robin." > here in London the sparrow population (still officially a pest) has > crashed by 95%, probably the PSU having killed all the Norwegian Blues > is overloading sparrows with portable nuclear devices. I feel sure you meant to say "swallow". The airspeed of a laden swallow is greater than that of a laden sparrow. (I think... -- Waa!) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From aleaxit at yahoo.com Fri Jul 13 07:25:38 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 13 Jul 2001 13:25:38 +0200 Subject: MySQLdb - possible without install? References: <3b4d0ea7.11581823@news1.on.sympatico.ca> <slrn9kqr2k.p1.gerhard.nospam@lilith.hqd-internal> <3b4d7a61.39160079@news1.on.sympatico.ca> <slrn9krt7k.nj.gerhard.nospam@lilith.hqd-internal> <3b4e2495.82731972@news1.on.sympatico.ca> <slrn9ksrdc.sa.gerhard.nospam@lilith.hqd-internal> Message-ID: <9imlrj011du@enews1.newsguy.com> "Gerhard H?ring" <gerhard.nospam at bigfoot.de> wrote in message news:slrn9ksrdc.sa.gerhard.nospam at lilith.hqd-internal... ... > >#!/usr/contrib/bin/python (the python path) > >import MySQLdb > >print "Content-Type: text/html\n\n" (so the browser doesn't choke). > > Should be ok so far. Except there's a newline too many, because you have two explicitly specified and an extra one is implicitly added by the print statement. This can't be the cause of your problem here (I think), I'm just pointing it out in case it DOES turn out to be a problem for someone. Alex From peter.milliken at gtech.com Mon Jul 30 17:54:21 2001 From: peter.milliken at gtech.com (Peter Milliken) Date: Tue, 31 Jul 2001 07:54:21 +1000 Subject: Typing system vs. Java References: <mailman.996258291.15055.python-list@python.org> <psog0besc97.fsf@jekyll.curl.com> <3b65a820_7@Usenet.com> Message-ID: <9k4l5c$o985@news1.gtech.com> Sorry Tom, Just can't let the statement "The ideal language would support both strong and weak typing." go by :-). As soon as you allow "both" (and damned if I know how you would do that! :-)), then your typical C/C++ programmer (unfair there, I should say "programmer") will choose the loose typing everytime, because he "knows" what he means, even if the compiler can't work it out, doesn't he? :-) So all the benefits that you just acknowledged for strong typing are lost :-). I have used a very strongly typed language (Ada), I haven't tried Haskall or Ocaml as one repondent mentioned, but I claim that with Ada, 95-98% of "normal" bugs are out of my programs once I get the compiler to produce executable code. The only bugs that are left are the purely logic bugs. Once you have used a truly strongly typed language, then you would never consider doing a large job (multiple programmers) in anything else. I love and use Python, but anything more than a one man job would see me turfing it for a better suited language. Sometimes I think that even the idea of using Python may be a mistake because the number of hours I have spent chasing down code bugs in my Python programs that would have been caught by a decent typed language compiler are too numerous to count :-). Peter "Tom" <tom-list at home.com> wrote in message news:3b65a820_7 at Usenet.com... > > "Christopher Barber" <cbarber at curl.com> wrote in message > news:psog0besc97.fsf at jekyll.curl.com... > > <brueckd at tbye.com> writes: > > > > > In most jobs I've used C/C++ or Java and for me the stronger the typing > > > rules the more problems (and in turn bugs) it caused. > > > > I am really surprised to hear this. My experience has been the opposite. > > I agree with you. Strong typing can be very useful. Its better to have the > compiler catch an error than to catch it during unit testing. > > The ideal language would support both strong and weak typing. > > Tom. > > > > For example, if I need to store a list of points and color > > > values I can't just make an array of (x,y,color) tuples. I need to > > > create a class to hold them and then create instances and store them in > > > an array or Vector. > > > > You seem to be complaining about the lack of tuples, not static > type-checking > > per-se. > > > > > Strong typing seems to prevent a very small class of errors at great > > > expense, and none of the errors it prevents should escape good testing > > > (which you should have anyway). > > > > I am all for unit testing, but I know from experience that it is > *extremely* > > difficult to comprehensively test a code unit, and virtually impossible if > you > > do not have a good code coverage tool. If the compiler can catch a type > error > > for me at compile-time, that is at least one less unit test I have to > write. > > > > I agree that static type declarations add complexity to a language, but > there > > is a significant body of developers that really appreciate what they can > do > > for you. It would really be nice if Python could add some sort of > optional > > type declarations. It should be technically feasible. > > > > - Christopher > > > > Posted Via Usenet.com Premium Usenet Newsgroup Services > ---------------------------------------------------------- > ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY ** > ---------------------------------------------------------- > http://www.usenet.com From revyakag at umdnj.edu Wed Jul 4 19:22:15 2001 From: revyakag at umdnj.edu (Andrey Revyakin) Date: Wed, 04 Jul 2001 19:22:15 -0400 Subject: More Message-ID: <3B43A527.ED7FCBF@umdnj.edu> Actually it does look like there's something bad about the way the machine is configured. Even if I simply make a test like this: import cgi cgi.test() ...and try to send data to this test.cgi file by POST, it generates the same type of error. If I send data by GET or don't send anything it does not generate it. But I still don't know what needs to be done on th server to fix this. File "/usr/local/lib/python2.0/cgi.py", line 838, in test form = FieldStorage() # Replace with other classes to test those File "/usr/local/lib/python2.0/cgi.py", line 502, in __init__ self.read_urlencoded() File "/usr/local/lib/python2.0/cgi.py", line 574, in read_urlencoded qs = self.fp.read(self.length) IOError: [Errno 9] Bad file descriptor Andrey. From erno-news at erno.iki.fi Tue Jul 3 21:19:44 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 04 Jul 2001 04:19:44 +0300 Subject: AttributeError: 'getopt' module has no attribute 'GetoptError' References: <Xns90D3ECC92390Dgustaflalgonetse@194.213.69.152> Message-ID: <ku7kxp32z3.fsf@lasipalatsi.fi> In article <Xns90D3ECC92390Dgustaflalgonetse at 194.213.69.152>, gustafl at algonet.se (Gustaf Liljegren) writes: | I use Python 2.1 on Win98. Try to use the getopt module, but get | the error in the subject line. What's wrong? your test program isn't called "getopt.py" by any chance? -- erno From djc at object-craft.com.au Sun Jul 22 00:18:09 2001 From: djc at object-craft.com.au (Dave Cole) Date: 22 Jul 2001 14:18:09 +1000 Subject: Sybase module 0.28 (Brown Paper Bag) released References: <m3pubqd3i7.fsf@vole.object-craft.com.au> Message-ID: <m3bsmd1try.fsf@vole.object-craft.com.au> >>>>> "Dave" == Dave Cole <djc at object-craft.com.au> writes: Dave> What is it: The Sybase module provides a Python interface to the Dave> Sybase relational database system. The Sybase package supports Dave> almost all of the Python Database API, version 2.0 with Dave> extensions. Huh!?! I didn't post that (I posted the original a long time ago - but this isn't it). Looking at the path, who are onlynews.com? Path: vic.nntp.telstra.net!intgwlon.nntp.telstra.net!newsfeeds.ihug.co.nz!news.xtra.co.nz!nntp-relay.ihug.net!ihug.co.nz!news-out.nibble.net!hub1.nntpserver.com!cyclone-sjo1.usenetserver.com!news-out-sjo.usenetserver.com!newsin.onlynews.com!newsout.onlynews.com!news1.onlynews.com.POSTED!not-for-mail - Dave -- http://www.object-craft.com.au From qrczak at knm.org.pl Mon Jul 23 11:56:30 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 23 Jul 2001 15:56:30 GMT Subject: PEP0238 lament References: <mailman.995814276.15005.python-list@python.org> <3B5BC1C3.41330762@cosc.canterbury.ac.nz> <jt4oltg3ekdlig096677p295f7mnbumteu@4ax.com> Message-ID: <slrn.pl.9loi9e.2il.qrczak@qrnik.zagroda> Mon, 23 Jul 2001 13:50:51 +0100, Steve Horne <sh at ttsoftware.co.uk> pisze: > It's not a different operation on the same data. It's the same > operation on a different datatype. No, it's different operation on the same data, as long as we agree that "same data" means "Python's '==' holds". 3.0 == 3 2.0 == 2 3.0/2.0 != 3/2 > You might as well claim floating point addition is different from > integer addition - that also requires a different algorithm and gives > a different result. They give the same result, except a very small rounding error sometimes, and except where the integer addition doesn't give any result because it overflows. If x and y are integers, then float(x+y) == float(x)+float(y), with disclaimers above. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From trhoffend at mediaone.net Thu Jul 19 09:54:37 2001 From: trhoffend at mediaone.net (Thomas Hoffend) Date: Thu, 19 Jul 2001 13:54:37 GMT Subject: How to change Tkinter Label widget text without global variable in a class? References: <ZtB57.5672$X6.251588@typhoon.mn.mediaone.net> Message-ID: <xEB57.5707$X6.251718@typhoon.mn.mediaone.net> Never mind, I figured it out as soon as I graduated to list boxes. Silly me, here is the new code snippet: .... # Put some text under the button to show the path self.PathStr = fullpath self.label1 = Label(frame, text=self.PathStr) self.label1.pack() # The class will store the full path: PathStr = fullpath # Here is a function to go up one directory - eventually (right now it just manipulates the path name): def go_up_one(self): print "Going Up!" self.PathStr = (os.path.dirname(self.PathStr)) print self.PathStr self.label1['text']=self.PathStr ... "Thomas Hoffend" <trhoffend at mediaone.net> wrote in message news:ZtB57.5672$X6.251588 at typhoon.mn.mediaone.net... > > I am new to Python and working on learning Tkinter. > > I ordered some of the books recommended on the Python web site, and also > have been going > through the online tutorial on Tkinter and reading old newgroup articles. > There is one point which > I found that sort of bugs me, and that is I can't figure out how to change a > Label widget text > without using some sort of global variable. It seems that declaring a > global variable inside a class > is not the best thing to do, especially if there is the possibility that you > will create multiple instances of > the class (unless maybe I don't understand the scope of the global > variable - is it > global just inside the class?). So is there some way to change the label > text without a global > variable? For example: > > # > # Script to pop up the current directory name in a window and go up one > directory; > # I hope to turn this into a directory selector. > # > > from Tkinter import * > import os > import os.path > > path = os.path.abspath('.') > fullpath = os.path.normpath(path) > > class mywidget: > # > def __init__(self, master): > > frame = Frame(master) > frame.pack() > > # Make a button to go up one directory (well, at least manipulate a > string with the path name for now): > self.upbutton = Button(frame, text="Up", command=self.go_up_one) > self.upbutton.pack(side=TOP) > > # Put some text under the button to show the path: > global vCurrentPath > vCurrentPath = StringVar() > label1 = Label(frame, textvariable=vCurrentPath) > label1.pack() > vCurrentPath.set(self.PathStr) > > # The class will store the full path: > PathStr = fullpath > > # Here is a function to go up one directory - eventually (right now it > just manipulates the path name): > def go_up_one(self): > print "Going Up!" > self.PathStr = (os.path.dirname(self.PathStr)) > print self.PathStr > vCurrentPath.set(self.PathStr) > > root = Tk() > app = mywidget(root) > root.mainloop() > > From robin at jessikat.fsnet.co.uk Fri Jul 27 04:03:15 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 27 Jul 2001 09:03:15 +0100 Subject: Deposing Dictators References: <9jmjne$q54$1@wisteria.csv.warwick.ac.uk> <3b602daf.1623450@nntp.sprynet.com> <UuxEMIARGKY7Ew1w@jessikat.fsnet.co.uk> <3B60AEAD.CB287C47@engcorp.com> Message-ID: <UW1ECVADBSY7EwWj@jessikat.fsnet.co.uk> In article <3B60AEAD.CB287C47 at engcorp.com>, Peter Hansen <peter at engcorp.com> writes ..... >The difference in readability (and thus ease of maintenance and >ease of developing robust code) is sufficiently large to outweigh >any performance differences. > >Obviously, the question of whether Python wins or loses, against >Perl or any other language, is largely a matter of opinion. >As long as the performance is not an order of magnitude slower >for my kind of application, I have zero reason to look enviously >at Perl users... > I don't disagree on readability, but given that the scripties can do perl already and the result is often faster python won't get a look in at the sort of mundane tasks in web serving/shell scripting etc. -- Robin Becker From db3l at fitlinxx.com Thu Jul 12 19:25:13 2001 From: db3l at fitlinxx.com (David Bolen) Date: 12 Jul 2001 19:25:13 -0400 Subject: File processing References: <9id5p9$8r62@interserv.etn.com> <9if3fv$8r65@interserv.etn.com> <wkzoaaf53m.fsf@mail.connact.com> Message-ID: <uitgxybl2.fsf@ctwd0143.fitlinxx.com> phawkins at connact.com writes: > >>>>> "CM" == Chris McMillan <christopherjmcmillan at eaton.com> writes: > > CM> Thank you everyone for your imput!! On a side note: I would have loved to > CM> use bash, sed, etc, but unfortunately I'm forced to use a Windows NT > CM> machine. I just thought this might be an excellent python exercise since > CM> I'm in the process of learning it. > > So get cygwin -- http://sources.redhat.com/cygwin/ Seconded, thirded, ad infinitum ... I had to switch to an NT environment (totally Unix before that) when coming to my current job and I don't know where I'd be without Cygwin. -- -- 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 db3l at fitlinxx.com Fri Jul 27 17:50:15 2001 From: db3l at fitlinxx.com (David Bolen) Date: 27 Jul 2001 17:50:15 -0400 Subject: defining classes within loops? References: <roy-10E6A4.08233827072001@news1.panix.com> Message-ID: <un15qm488.fsf@ctwd0143.fitlinxx.com> Roy Smith <roy at panix.com> writes: > The documentation for the "continue" statement says: > > > continue may only occur syntactically nested in a for or while loop, > > but not nested in a function or class definition > > Just out of curiosity, how many people have ever written a function or > class definition nested inside a loop? Seems like sort of a strange thing > to do, although I suppose it might be useful in some situations. I personally haven't, but the function definition method would certainly fit in with some of the threads about using a named function close to invocation instead of lambda. -- -- 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 gmcm at hypernet.com Sun Jul 29 09:11:57 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 29 Jul 2001 13:11:57 GMT Subject: Best practices with import? References: <9jvnoe$om2$1@slb5.atl.mindspring.net> <3B6369D4.671C1870@alcyone.com> <Xns90ED38309C442cliechtimailsch@62.2.32.50> <3B63973B.490D4B08@engcorp.com> Message-ID: <Xns90ED5DA29D6E3gmcmhypernetcom@199.171.54.154> Peter Hansen wrote: [snip] > There is at least one situation where import in a function is very > useful, and that is to delay execution of the import. If the first > module is imported by another, and all of its import statements are > at the top, each import executes at that time, slowing down loading > of the first module. If one of the imported modules is needed only > in one of the functions, which may or may not be called, putting > the import statement in the function will postpone (perhaps avoid) > the import and improve responsiveness. It's also very useful in some circular import situations. Circular imports are fine where both modules use the "import <module>" form of import. They fail when the 2nd module wants to grab a name out of the first ("from module import name") and the import is at the top level. That's because names in the 1st are not yet available, (the first module is busy importing the 2nd). As above, this is a sensible solution only if the use of the imported module is confined to the one function. - Gordon From phd at phd.fep.ru Sat Jul 7 03:48:17 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Sat, 7 Jul 2001 11:48:17 +0400 (MSD) Subject: SRE vs PRE: speed In-Reply-To: <E1q17.8496$e5.1109140@newsb.telia.net> Message-ID: <Pine.LNX.4.33.0107071144520.731-100000@phd.fep.ru> Hello. Thank you for response. On Fri, 6 Jul 2001, Fredrik Lundh wrote: > Oleg Broytmann wrote: > > My company doen't want to switch from python 1.5.2 to 2.0+ - our CTO is > > very disappointed with SRE speed. SRE is 3-4 times lsower. > > > Any plans to make it faster? > > sure. Nice! > but the priority this far has been "match" and "search", not > "sub". change your benchmark to use "search" or "findall", > and you'll find that SRE is 5-10 times faster than PRE. Ok, we'll see. > and you can easily make your code faster without having > to wait for an upgrade: just use the string.replace function > instead. it's about 15 times faster than PRE on this one... > (25 times faster if you use unicode strings ;-) It is not that easy. We really use re in our programs, and what is more, we use other libraries that use re heavily (mxDateTime, for example). Our programs are much slower with Python 2.0 comparing to 1.5.2, and profiling revealed it is due to re. 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 Fri Jul 20 14:29:38 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 20 Jul 2001 14:29:38 -0400 Subject: Python 2.2 alpha - generators test In-Reply-To: <m62gltsov3nn6jiuhgk03u1ul0831gv60k@4ax.com> Message-ID: <LNBBLJKPBEHFEDALKOLCGEMMKPAA.tim.one@home.com> [Steve Horne] > I've been playing with the Python 2.2 alpha, found it to be pretty > reliable so far, and I've fallen in love with the iterators and > generators. However, I did find what I think is a problem in the > test_generators.py (sorry if the filenames slightly wrong) file. By definition, if test_generators.py passes, there are no problems <wink>. > I was looking at the 2**i * 3**j * 5**k problem, and decided to try my > own approach. I reached a point where I needed essentially a > duplicate-removing priority queue (if such a thing exists) but I > couldn't be bothered revising my heap theory so temporarily I decided > to just merge the new items into a simple ordered list. > > I remembered a generator called merge or xmerge or something, and > decided to borrow that to get the initial version running quickly. > > Trouble is, it didn't work at all. > > Looking back at the merge function, I realised that when either one of > the input generators is exhausted the generator terminates immediately > - it does not pass on the remaining items from the other generator. In > fact, if one of the input generators ends immediately (empty list), no > items will be output at all irrespective of the number of items the > other generator could generate. > > I'm not sure of the implications in the algorithm it was used in > (which I didn't fully understand), but it is certainly incorrect for > merging two ordered sequences - which is what it appeared to be - and > is certainly what caused my problems. > > Is this a real bug, or just a case of me jumping to daft conclusions > about what the generator was meant to do? The merge in test_generators was specifically written for the test case at hand. It assumes both input streams are: (a) unbounded; and, (b) non-decreasing. When programming with infinite streams (the appropriate way to view this part of the test), #a is an utterly conventional assumption. Indeed, one of the joys of working with unbounded streams is that you don't have to clutter up your logic with termination tests. You *do* have to worry about whether stream algorithms can always make progress, and #b isn't actually strong enough on its own to guarantee that. But it's a test case, not a stream tutorial <wink>. From nospam at mega-nerd.net Tue Jul 17 07:25:09 2001 From: nospam at mega-nerd.net (Erik de Castro Lopo) Date: Tue, 17 Jul 2001 11:25:09 GMT Subject: Bug in Python DNS module References: <3B535691.96BDB5E3@mega-nerd.net> <3B53751F.4CA0DC4@stroeder.com> Message-ID: <3B54208B.77B5163E@mega-nerd.net> Michael Str?der wrote: > > Erik de Castro Lopo wrote: > > > > A couple of days ago I asked for and received a link to a Python DNS > > module. I have since found a bug in the ParseResolvConf() functions. > > [..] > > I'm not sure who to send it to so I'm posting it here. > > Erik, thanks for submitting this fix. > > I've included it into my version of the DNS module. I'd be interested in seeing what you have. > I wrote Anthony > Baxter who maintained the version I grabbed and modified but no > response so far what to do with the module. If nothing happens > during the next two or three weeks I will probably upload it to a > SourceForge project. That would be a good idea. > If anybody knows something about the license let me know. Would be nice to know wouldn't it. I'm in Australia so I might try and track the author down. Erik -- ----------------------------------------------------------------- Erik de Castro Lopo nospam at mega-nerd.com (Yes its valid) ----------------------------------------------------------------- "The earth is degenerating these days. Bribery and corruption abound. Children no longer mind parents ...and it is evident that the end of the world is approaching fast." -- Assyrian Tablet Engraved in 2800 B.C. From guido at python.org Fri Jul 27 22:52:26 2001 From: guido at python.org (Guido van Rossum) Date: Sat, 28 Jul 2001 02:52:26 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <eppstein-03540D.13070222072001@news.service.uci.edu> <LNBBLJKPBEHFEDALKOLCOECNLAAA.tim.one@home.com> <mailman.995899647.346.python-list@python.org> <tclolt053o18f8q0ntb7n4aggitdkmeg4h@4ax.com> <Io_67.23543$B7.3779351@ruti.visi.com> <slrn9lp2m5.vp.Gareth.McCaughan@g.local> <p56plt8q4rs3bgcqbepk61q2r3g0tr2vhe@4ax.com> <slrn9ls3ae.2fm.Gareth.McCaughan@g.local> <cpitghbq05.fsf@cj20424-a.reston1.va.home.com> <MWD77.27751$EP6.6983549@news1.rdc2.pa.home.com> <9jnt9p$qhe$1@newsy.ifm.liu.se> <SYV77.27286$B7.4239335@ruti.visi.com> <cpitgf7itx.fsf@cj20424-a.reston1.va.home.com> <WIY77.27607$B7.4257794@ruti.visi.com> <cp3d7j75jv.fsf@cj20424-a.reston1.va.home.com> <mailman.996192239.4930.python-list@python.org> <U_387.50579$Cy.6523947@news1.rdc1.az.home.com> <eppstein-4B8DDD.19163726072001@news.service.uci.edu> <cp1yn25wee.fsf@cj20424-a.reston1.va.home.com> <ygey9p9yf4x.fsf@asfast.com> Message-ID: <cp8zh922at.fsf@cj20424-a.reston1.va.home.com> Lloyd Zusman <ljz at asfast.com> writes: > Lately I've been consulting on Wall Street, and it turns out that in > the computations done in that universe, there is a great need for > non-float decimal types, such as your example about 0.98 being used as > a price. > > Accountants and their kin want ledgers, positions, etc. to balance to > the penny (or centavo, or whatever is the smallest fractional currency > in a given country). This can only be accomplished using decimal > arithmetic ... like Bignums with implied decimal places. I think there are two variations here. You can use binary BinNums with an implied decimal point, e.g. the tuple <314, 2> might represent 3.14 and <4, 0> might represent 4. Or you can actually use decimal or packed decimal as the storage format. The latter is probably a bit slower than binary and slightly less storage-efficient, but has a huge advantage for I/O conversion (no need to divide to print the number). If you don't do a lot of computation but you do a lot of I/O that can be a huge advantage. If all you need is to make sure your pennies add up, binary is fine. If your app is I/O intensive, decimal may be better. --Guido van Rossum (home page: http://www.python.org/~guido/) From sdm7g at Virginia.EDU Thu Jul 26 09:59:47 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Thu, 26 Jul 2001 09:59:47 -0400 (EDT) Subject: Submodules in dynamic modules? In-Reply-To: <20010726084732.A28949@strakt.com> Message-ID: <Pine.NXT.4.21.0107260951540.376-100000@localhost> On Thu, 26 Jul 2001, Martin Sjgren wrote: > Is there a standardized way to use submodules in a dynamic module written > in C? I have a module (foo) that should have a few submodules in it, foo > by itself won't contain much at all, but it's nice to group things up in > submodules, so I could do > > from foo import bar > > or > > from foo import bar, baz > > The way I'm doing it right now is that I've more or less copied the source > code from Py_InitModule4() to set things up, and then insert the module > object into the dictionary. I don't know if there's a standard way and I don't know if it's better, but what I have done is to define the macro: #define ADD_MODULE(x) if (-1 == \ PyModule_AddObject( m, (x), PyImport_ImportModule((x)))) return NULL And in Carbonmodule.c (for MacOSX) where I have a whole bunch of these submodules, I have: m = Py_InitModule("Carbon",CarbonMethods ); (void) initWin(); ADD_MODULE("Win"); (void) initMenu(); ADD_MODULE("Menu"); (void) initEvt(); ADD_MODULE("Evt"); (void) initDlg(); ADD_MODULE("Dlg"); ... This was done because there were problems getting the mac toolbox modules to link as separate shared libs on OSX because of cross linkages between the modules. It was done this way so that, not only would "from Carbon import Evt" work, but so that all of the sub-modules would go into sys.modules, and after an initial "import Carbon", other imports like "import Evt" unqualified by the Carbon module would also work, so all previous Mac "classic" toolbox modules would still work as long as an "import Carbon" was done sometime before -- possibly in site.py. -- Steve Majewski From sdm7g at Virginia.EDU Fri Jul 27 02:36:48 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Fri, 27 Jul 2001 02:36:48 -0400 (EDT) Subject: Suggestion for impriving list comprehensions In-Reply-To: <9jqi0m$5oe$1@newsy.ifm.liu.se> Message-ID: <Pine.NXT.4.21.0107270233100.319-100000@localhost> On 27 Jul 2001, Paul Svensson wrote: > > No need to cover cases that are clearer expressed > without involving a list comprehensions at all. > > fib()[:N], I would assume works. > Nope! Generators don't implement __getitem__ or any of the other sequece methods ( __len__, ... ) . You could, however, define a generator class that implements __getitem__, et.al. as well as next. -- Steve Majewski From sill at optonline.net Fri Jul 27 14:19:22 2001 From: sill at optonline.net (Andrei Kulakov) Date: Fri, 27 Jul 2001 18:19:22 GMT Subject: PEP 238 (revised) References: <cp4rrz5onj.fsf@cj20424-a.reston1.va.home.com> Message-ID: <slrn9m3bt8.114.sill@sill.silmarill.org> On Thu, 26 Jul 2001 22:09:06 GMT, Guido van Rossum <guido at python.org> wrote: > > The correct work-around is subtle: casting an argument to float() > is wrong if it could be a complex number; adding 0.0 to an > argument doesn't preserve the sign of the argument if it was minus > zero. When is 0 different from -0? -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: http://silmarill.org/cymbaline From tdickenson at devmail.geminidataloggers.co.uk Thu Jul 26 03:59:03 2001 From: tdickenson at devmail.geminidataloggers.co.uk (Toby Dickenson) Date: Thu, 26 Jul 2001 08:59:03 +0100 Subject: Version numbers in traceback References: <5nitltsbrurir59906mbdtectsoah2ppcc@4ax.com> <j4vgkhgkqr.fsf@informatik.hu-berlin.de> Message-ID: <objvltk6lv8vmsuk2e7lurv7u4qolt5f1f@4ax.com> Martin von Loewis <loewis at informatik.hu-berlin.de> wrote: >Dale Strickland-Clark <dale at riverhall.NOSPAMco.uk> writes: > >> Is there a standard way for a module to register its version number so that it is reported by >> traceback or other debugging tools. >> >> I thought something nice and simple like >> >> _Module_Version_ = '10.5C' >> >> would be nice. > >The standard constant for a module version is __version__. However, >there is no way to integrate it into a traceback. Instead, debugging >tools would need to find out the module of each function in the >traceback themselves (which sometimes cannot be done), and then access >the __version__ if desired. I don't think that the traceback module >should fetch __version__, though. Zope already does something similar; if a function has a local variable __traceback_info__ then this is included as an extra line in the traceback. I find this *very* handy. Toby Dickenson tdickenson at geminidataloggers.com From ajd111 at york.ac.uk Tue Jul 24 12:41:11 2001 From: ajd111 at york.ac.uk (Anthony J Doggett UG) Date: 24 Jul 2001 17:41:11 +0100 Subject: 2.0b2: SystemError: frexp() result out of range Message-ID: <vktpuaqnuu0.fsf@pc153s.cs.york.ac.uk> Please, if I were to ask nicely for our local installation of python to be upgraded, would the bug shown below to go away? What's the best way to get around it? (Alas, binary mode is a must.) Thanks, Anthony. > python Python 2.0b2 (#1, Oct 9 2000, 18:12:36) [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2 Type "copyright", "credits" or "license" for more information. >>> import cPickle >>> f = open('delme', 'w') >>> cPickle.dump(float('inf'), f, 1) Traceback (most recent call last): File "<stdin>", line 1, in ? SystemError: frexp() result out of range -- Anthony Doggett *** Do you want quality or choice? *** From esr at thyrsus.com Thu Jul 12 20:04:23 2001 From: esr at thyrsus.com (Eric S. Raymond) Date: Thu, 12 Jul 2001 20:04:23 -0400 Subject: [Python-Dev] [development doc updates] In-Reply-To: <20010712235043.5A42D2892B@cj42289-a.reston1.va.home.com>; from fdrake@acm.org on Thu, Jul 12, 2001 at 07:50:43PM -0400 References: <20010712235043.5A42D2892B@cj42289-a.reston1.va.home.com> Message-ID: <20010712200423.A13553@thyrsus.com> Fred L. Drake <fdrake at acm.org>: > The development version of the documentation has been updated: > > http://python.sourceforge.net/devel-docs/ > > Lots of small updates. > > Added Eric Raymond's documentation for the XML-RPM module added to > the standard library. Calling the effbot! Calling the effbot! Fredrik, please proofread my stuff and fill in any important bits you think are missing. -- <a href="http://www.tuxedo.org/~esr/">Eric S. Raymond</a> "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -- Benjamin Franklin, Historical Review of Pennsylvania, 1759. From SBrunning at trisystems.co.uk Tue Jul 31 05:05:53 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Tue, 31 Jul 2001 10:05:53 +0100 Subject: Compiling Message-ID: <31575A892FF6D1118F5800600846864D78BF3A@intrepid> > From: Soup-a-Stu [SMTP:stupot999 at hotmail.com] > I am very new to Python and i need a bit of help with compiling my stuff. > i'm using windows ME, and the latest version of Python. Python can't be compiled as such, but I have found that py2exe (here <http://starship.python.net/crew/theller/py2exe/>) gives the result that most people want when they *say* that they want a compiler. In conjunction with Inno setup (here <http://www.jrsoftware.org/isinfo.htm>), you can go from a Python script to a Windows setup program. Is this what you need? 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 piet at cs.uu.nl Mon Jul 23 09:41:07 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 23 Jul 2001 15:41:07 +0200 Subject: Language change and code breaks References: <mailman.995378792.16515.python-list@python.org> <cpvgkq1f2b.fsf@cj20424-a.reston1.va.home.com> Message-ID: <ud76rn4p8.fsf@cs.uu.nl> >>>>> Guido van Rossum <guido at python.org> (GvR) writes: GvR> But it's still open for debate whether the problem here is Windows or GvR> Unix! All programming languages and file systems used to be GvR> case-insensitive, until the designers of Unix and C decided that it GvR> was too much work to write and use a case-insensitive comparison GvR> routine. This is not true. Algol 60 was case-insensitive from the beginning. By design, as Algol 60 was designed the way it is in spite of the difficulties it would give its implementors. -- Piet van Oostrum <piet at cs.uu.nl> URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From guido at python.org Sun Jul 8 08:27:11 2001 From: guido at python.org (Guido van Rossum) Date: Sun, 08 Jul 2001 12:27:11 GMT Subject: Comment on PEP-0238 References: <mailman.994427714.26169.python-list@python.org> <cpsngaja4g.fsf@cj20424-a.reston1.va.home.com> <FFv17.1178$Y6.656565@news1.rdc2.pa.home.com> <cpelrskgrr.fsf@cj20424-a.reston1.va.home.com> <9i7a7k$h9ks6$1@ID-11957.news.dfncis.de> <cp4rsok3i7.fsf@cj20424-a.reston1.va.home.com> <mailman.994531918.7040.python-list@python.org> <9i8512$haelg$1@ID-11957.news.dfncis.de> Message-ID: <cpk81jip74.fsf@cj20424-a.reston1.va.home.com> "Emile van Sebille" <emile at fenx.com> writes: > # default setting > precision 0 # everything behaves as it does now > print 2 / 7 # -> 0, ie to precision 0 decimal places > print 2/7.0 # -> 0.285714285714 > > precision 1 # all calculations yield 1 decimal point precision interim > results > print 2 / 7 # -> 0.2, ie to precision 1 decimal places > > precision 2 > print 2 / 7 # -> 0.28, ie to precision 2 decimal places > > precision 3 > print 2 / 7 # -> 0.285, ie to precision 3 decimal places > > This seems to me to break no existing code other than where precision is > currently used as a label, and allows us to teach others, when they get > stung by unexpected results, that they need to set precision appropriately. > Once explained, integer division would not be a surprise to newbies, nor > would the precision of floating point be lost to those who understand and > benefit from its use. And those of us that just want to write business > accounting applications will be able to set precision 2 at the top of each > module and be done with it. Your examples don't show what should happen in this example: precision 0 x = 2/7 precision 4 print x In other words, is the precision a property of the printing or a property of the value stored? There are lots of other ways to get this effect for printing ("%.4f"%x comes to mind); if you intended the effect to apply to computation results, there are questions about the scope of the calculation. If I write precision 3 x = f() # some function that uses int division should every calculation in f() be affected by the precision statement? Etc., etc. This is exactly why I was asking you to write a PEP. I don't mean that you have to write an implementation. (Despite the seeming requirement in PEP 2, that's not a requirement before a PEP is accepted for review -- that's only required before a standard PEP is finally approved for inclusion in the language. There are plenty of PEPs without a shred of implementation.) --Guido van Rossum (home page: http://www.python.org/~guido/) From paulp at ActiveState.com Tue Jul 31 09:36:36 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Tue, 31 Jul 2001 06:36:36 -0700 Subject: Tangent on wireless hysteria (was: Language Niches (long)) References: <8beb91f5.0107280407.5a30341d@posting.google.com> <mailman.996429234.13926.python-list@python.org> <BEDD41E8FBB8D77F.D3FD7D805E4BEA41.1A906D050F601417@lp.airnews.net> <3B65FD2B.39BA0A95@engcorp.com> <CE671DDD22B40C3E.25CDBEE912BDD9F9.C0CD28D28A68C3E3@lp.airnews.net> Message-ID: <3B66B464.B60B8C2C@ActiveState.com> Cameron Laird wrote: > >... > I confess I posted a bit disingenuously here. > My scant contact with WAP has given me no > reason to doubt that it's diving rapidly to > extinction, as Andrew Odlyzko describes in > <URL: http://www.firstmonday.dk/issues/issue6_2/odlyzko/ >. > Thanks to a correspondent for offering me this > URL. Note that PLENTY of other apparently- > knowledgeable people (Clay Shirky, for > example), reinforce this judgment. Anyway, > my real intent was to expose as delicately > as possible my surprise that Paul would use > WAP in his illustrations of language growth. I was trying to make the point (admittedly obliquely) that any random-seeming technology could be the next killer platform. Maybe even a resuscitated from the dead WAP! Who would have thought that Unix could come back from the brink of death to compete toe to toe with Microsoft's next millenium OS. Remember the Byte cover? If it was obvious what the next big platform was we'd just port Python, buy stock in Zope.com, ride the wave and retire to Tahiti. But more likely it will be something that we initially think is kind of weird that some weird-thinking hacker invents a new programming language for. Seriously, I don't expect a comeback from WAP but I really don't know the name of the real wireless platform of the future. Symbian? Windows WE? -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From rnd at onego.ru Sun Jul 8 15:41:24 2001 From: rnd at onego.ru (Roman Suzi) Date: Sun, 8 Jul 2001 23:41:24 +0400 (MSD) Subject: [OT] Eternal programming In-Reply-To: <ge7hktsqvsqu8n87shns7os99co09nmgk2@4ax.com> Message-ID: <Pine.LNX.4.30.0107082340320.22080-100000@rnd.onego.ru> On Sun, 8 Jul 2001, Ben Wolfson wrote: >Pah! Unlambda >(http://www.eleves.ens.fr:8080/home/madore/programs/unlambda/) is the only >option for *true* simplicity and ease of use! brrr... especially the later! Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Sunday, July 08, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "The days of the digital watch are numbered" _/ From gtcopeland at earthlink.net Fri Jul 13 08:41:09 2001 From: gtcopeland at earthlink.net (Greg Copeland) Date: 13 Jul 2001 07:41:09 -0500 Subject: Encryption and python? References: <m27kxdy543.fsf@mouse.copelandconsulting.net> <3B4EB456.5A315CF9@stroeder.com> Message-ID: <m2vgkxvw62.fsf@mouse.copelandconsulting.net> Michael Str?der <michael at stroeder.com> writes: > Greg Copeland wrote: > > > > I've been browsing around for a while now trying to come up with > > "the" python encryption library that I can make use of. > > This is a very general question. What are you looking for? > - Low-level algorithms (hashes and encryption) > - Crypto Protocols (e.g SSL or S/MIME) > - Key stores > ... > > There's also a mailing list (currently very low volume): > http://listserv.surfnet.nl/archives/python-crypto.html > > Ciao, Michael. Fair enough. I'm looking for low-level algorithms for public key exchange, some encryption, digital signatures and hashes. Greg From philh at comuno.freeserve.co.uk Tue Jul 24 21:43:57 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Wed, 25 Jul 2001 02:43:57 +0100 Subject: PEP0238 lament References: <5sdnlt072hm6hp17nluu6f0fqq4bvr6mj8@4ax.com> <mailman.995873261.11975.python-list@python.org> <916olt0p3kciv0evmotdg6jev9bl29l57i@4ax.com> <Xns90E77C7A1776Cjimpublishingresourc@207.126.101.100> <3B5C52EA.9430255E@alcyone.com> <cpofqaova7.fsf@cj20424-a.reston1.va.home.com> Message-ID: <slrn9ls92t.eia.philh@comuno.freeserve.co.uk> On Tue, 24 Jul 2001 21:46:15 GMT, Guido van Rossum <guido at python.org> wrote: > >(2) A command line option to change division semantics. I propose > -Dnew to make the new division semantics the default, -Dold to > make the old semantics the default. -Dold will be the default > until the wait period is over, then -Dnew will become the > default. The -D option is retired when nobody needs -Dold any > more. Modules that contain a future statement always use the new > default; there's no way to force the old default on a *per-module* > basis (since that would be a language feature that could never be > removed). How about having two executables, 'oldpython' and 'newpython' which correspond to -Dold and -Dnew. Furthermore, since 'oldpython' is the same as the existing 'python', let's rename it 'python'. We also might be dealing with a mixture of new and old code, so lets furthermore have a rule that modules ending in .py are by default compiled with 'python' and modules ending in .ny are compiled with 'newpython'; in both cases they compile to the same .pyc format. In this way, newpython can cope with any change to the nature of the language, however outlandish (like including $ before variable names :-)) without breaking a single line of existing code. And people can gently "dip their toe into the water" of the new features, without having to immediately go all the way. -- #===== Philip Hunt == philh at comuno.freeserve.co.uk ======# Herbivore: effort-free public key email encryption. See: <http://www.vision25.demon.co.uk/oss/herbivore/intro.html> *** herbrip software now released *** From peter at engcorp.com Wed Jul 11 09:19:48 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 11 Jul 2001 09:19:48 -0400 Subject: Newbie asks(2): How to do this line of C in Py? References: <tkmfvla7npuqfd@news.supernews.com> <uzoaci9zw.fsf@ctwd0143.fitlinxx.com> <7s9oktcv5vll2hberldlt51mcdg5qnitke@4ax.com> Message-ID: <3B4C5274.2220577C@engcorp.com> Joe Potter wrote: > > On 10 Jul 2001 20:29:23 -0400, David Bolen <db3l at fitlinxx.com> wrote: > > >"Steve S.L. Wong" <sailwong at alumni.cuhk.edu.hk> writes: > > > >> if sscanf(command,"%c%d",&c,&d) != 2 { > >> } > > > >You seem to be posting a lot of one line translation requests - are > >you trying to get a program translated to Python one line at a time? > > > >If so, perhaps you could just post the whole thing and we'd have a > >shot at it in one pass and save some electrons :-) > > I have followed these questions with great interest. I hope he keeps asking for a > while --- and folks here keep answering. > > As a newbie to Python, I find that the one liners in c are easy to follow and the > translation into Python show me where I am missing Python techniques. > > My purpose in writing this is simply to say you are not just helping Mr. Wong when > you respond. Good point, Joe. My slightly boorish response failed to consider that fact. On the other hand, posting obscure one-liners from C is not necessarily the best way to learn much, if anything about Python. Context is always useful, and the response might be different if more of the original C code were made available. I think this is similar to an attempt to translate from one spoken language into another, one word at a time, which looks like it works for a while but doesn't withstand serious scrutiny. (As it stands, Steve kindly wrote to me off-line and mentioned he was attempting to port GnuGo from C to Python as a learning exercise. If we want "context" we can always go look at the source ourselves. :-) Joe (and other self-professed newbies), why don't you find some other interesting one-liners (or two, or three-liners) and post them here? Maybe the code base for GnuGo is not one of the best sources of example code for conversion to Python... Based on a sample size of three, it consists of 33% strtok() calls and 67% sscanf() calls, making it one of the all-time poorest C programs! ;-) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From heikowu at ceosg.de Sun Jul 1 05:45:18 2001 From: heikowu at ceosg.de (Heiko Wundram) Date: Sun, 1 Jul 2001 11:45:18 +0200 Subject: zope en cmf References: <9hhfdh$5odi$1@reader02.wxs.nl> <9hi2t7$58a$06$1@news.t-online.com> <m2r8w27nic.fsf@mycroft.actrix.gen.nz> Message-ID: <9hmrbf$36l$07$1@news.t-online.com> Paul Foley wrote on 30 Jun 2001 13:41:15 +1200: > You'd be surprised...I think just about everyone here reads Dutch :-) Huh? How come?! ;) Oh, you mean the reference to Guido... Yep... :) OK. ;) See ya! Heiko W. From vvainio at karhu.tp.spt.fi Wed Jul 18 09:40:05 2001 From: vvainio at karhu.tp.spt.fi (Ville Vainio) Date: 18 Jul 2001 16:40:05 +0300 Subject: Stop a duty in a Tkinter program References: <3B558E86.1E7441C4@ccsr.cam.ac.uk> Message-ID: <yoxzoa2mk3u.fsf@karhu.tp.spt.fi> XiaoQin Xia <XQ.Xia at ccsr.cam.ac.uk> writes: > I am programming with Tkinter. After the user click "Go" button or menu, > my program will carry out some operation which won't stop until the end > time (which is set by user) reach. In order to let user interupt the > operation, a "Stop" button is present. But during the period of the > operation, my program is not able to respond to any click at all, it > seems dead before the operation finished. How can I terminate the > operation without exit the program? Any help is welcome. Well, since you accept *any* help, I must say, not knowing that much about Tkinter, that you have to start the operation in it's own thread so that Tkinter message loop may proceed and the button becomes clickable. Make clicking "stop" just kill the thread or signal it in a more polite fashion (flag). -- 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 rumjuggler at cryptarchy.org Mon Jul 16 01:37:31 2001 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Mon, 16 Jul 2001 05:37:31 GMT Subject: re Challenge: More Compact? References: <slrn9l4fob.p58.tim@vegeta.ath.cx>, <3B51E6B1.47E25214@tundraware.com> <92ae279c.0107151429.398e6e9e@posting.google.com> <mailman.995256714.17440.python-list@python.org> Message-ID: <o9v4lt08hdjjjrehfg732u9kd9gjsargb4@4ax.com> On Mon, 16 Jul 2001 07:06:01 +0300, Moshe Zadka <moshez at zadka.site.co.il> wrote: >: import re >: valid_ip_re = re.compile(r'^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$') >: def valid_ip(ip): >: match = valid_ip_re.match(ip) >: if not match: >: return >: return ![x if int(x)>255 for x in match.groups()] > >And now it's even correct! s/!/not/ and it is, anyway. -- Barnabas T. Rumjuggler No man can run so fast that he can escape his own past's projectile vomit. From macias at bp.com.pl Tue Jul 3 08:03:45 2001 From: macias at bp.com.pl (Maciej Pilichowski) Date: Tue, 03 Jul 2001 12:03:45 GMT Subject: Augmented Assignment (was: Re: PEP scepticism) -- what variable names are you using? Message-ID: <3b41b15a.22907188@news.tpi.pl> Hello there, As far as I can see everybody uses examples likes this: x += 2 Max. was 2 chars name long. Gosh, in my programs I use as long name as it is possible and as short as it is still understandable. So if it is 11 p.m. I would love to see possibility of writing BiezaceWolneSrodkiKlienta += LimitKredytu instead of BiezaceWolneSrodkiKlienta = BiezaceWolneSrodkiKlienta+LimitKredytu /sorry for non-english names/. It is much clearer. Less to typing, less thinking "is that the same variable?". For me -- I see only advantages of such operator. One rule more to learn? Well, the idea is simple -- "adding in place" /for example above/ -- that defines very well all cases /I think/. And if you don't want to learn? Well -- don't. I vote for go :-) have a nice day bye -- Maciej "MACiAS" Pilichowski http://www.torun.pdi.net/~macias/ z a k u p i e : pisma Komputer: 3/86,4/87 From brakedon at hotmail.com Sun Jul 8 21:52:21 2001 From: brakedon at hotmail.com (eric_brake) Date: 8 Jul 2001 18:52:21 -0700 Subject: calling a variable from a separate function Message-ID: <7b515e0f.0107081752.5dc1680d@posting.google.com> Let's say def function1: self.variable1 = 22 def function2: print variable1 Would function2 look like "print function1.variable1" or some other way? By the way I already know that the "function1.variable1" format doesn't work. thanks for any help. From volucris at hotmail.com Wed Jul 25 01:43:49 2001 From: volucris at hotmail.com (Volucris) Date: Wed, 25 Jul 2001 00:43:49 -0500 Subject: Python for Palm OS References: <20010725.4442652@mis.configured.host> Message-ID: <3b5e5bf4$0$317$6e49188b@news.goldengate.net> Go to www.python.org It's called Pippy. -- Volucris (a) hotmail.com "Eu n?o falo uma ?nica palavra do portugu?s." "Robert Roberts" <kj7ny at email.com> wrote in message news:20010725.4442652 at mis.configured.host... I have heard several times that there is a version of Python for the palm os. Have palm version 3.5. Can anyone direct to the proper download? Thanks in advance. From tjreedy at home.com Thu Jul 5 14:58:53 2001 From: tjreedy at home.com (Terry Reedy) Date: Thu, 05 Jul 2001 18:58:53 GMT Subject: There's got to be an easy way to do this References: <ABEE81BE08ADD311B6A1009027DE908D0BD87D90@conmsx03.conway.acxiom.com> <mailman.994351690.22119.python-list@python.org> <9i27i8$gd9bq$1@ID-11957.news.dfncis.de> <3B44B031.819C93E@stroeder.com> <9i2c77$gmc74$1@ID-11957.news.dfncis.de> Message-ID: <NN217.3762$e7.829230@news1.rdc2.pa.home.com> "Emile van Sebille" <emile at fenx.com> wrote in message news:9i2c77$gmc74$1 at ID-11957.news.dfncis.de... > I'm not sure how you mean slower, but I tested just now to see, and this is > the fastest of the four. > def str_join(iters): > for i in iters: > "".join([x for x in '(123)/456-7890' if x in '0123456789']) This could use either conditional '0' <= x <= '9' with 2 compares instead of average 5.5 or x.isdigit() from below. > > def flt_lmbda(iters): > for i in iters: > filter(lambda c:c.isdigit(), '(123)/456-7890') would two compares be faster than one func call? TJ Reedy From kp87 at lycos.com Thu Jul 19 22:09:23 2001 From: kp87 at lycos.com (kevin parks) Date: 19 Jul 2001 19:09:23 -0700 Subject: Bunch lists into sublists via alternation References: <5e8bd451.0107190415.7cc17f93@posting.google.com> <ac677656.0107191257.4c787a89@posting.google.com> Message-ID: <5e8bd451.0107191809.304e143d@posting.google.com> Thanks for taking the time to reply. So the first way is the i was trying to go, but the second that is the list comprehension approach, i guess? I'll study these. Very helpful indeed. Many thanks. cheers, -kevin From gerson.kurz at t-online.de Fri Jul 13 09:03:48 2001 From: gerson.kurz at t-online.de (Gerson Kurz) Date: Fri, 13 Jul 2001 13:03:48 GMT Subject: Developing Visual Studio add-ins in Python? References: <tH637.142074$R7.25090399@typhoon.kc.rr.com> Message-ID: <3b4eee8b.543625@news.t-online.de> On Thu, 12 Jul 2001 01:03:21 GMT, "Russ Shotts" <rashotts at mn.rr.com> wrote: >Has anyone used Python to create a Visual Studio add-in? I need to perform >some fairly complex processing, and their VBScript macros just cannot handle >the task. I have started writing an add-in. Its a bit tricky to add to Pythoncom, because a) there is no typelib (at least no typelib I know of), even though the stuff is IDispatch-derived. b) Objects are not created; instead the DLL gets passed a pointer to the main IApplication object. I'm doing this: a DevStudio Extension DLL that at the same time exposes a Python Extension (so it can be import-ed) that returns the DevStudio object via callback. I hope to have a working draft ready by next week. From mal at lemburg.com Fri Jul 13 11:04:26 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 13 Jul 2001 17:04:26 +0200 Subject: Encryption and python? References: <m27kxdy543.fsf@mouse.copelandconsulting.net> <3B4EB456.5A315CF9@stroeder.com> <m2vgkxvw62.fsf@mouse.copelandconsulting.net> Message-ID: <3B4F0DFA.6098003D@lemburg.com> Greg Copeland wrote: > > Michael Str?der <michael at stroeder.com> writes: > > > Greg Copeland wrote: > > > > > > I've been browsing around for a while now trying to come up with > > > "the" python encryption library that I can make use of. > > > > This is a very general question. What are you looking for? > > - Low-level algorithms (hashes and encryption) > > - Crypto Protocols (e.g SSL or S/MIME) > > - Key stores > > ... > > > > There's also a mailing list (currently very low volume): > > http://listserv.surfnet.nl/archives/python-crypto.html > > > > Ciao, Michael. > > Fair enough. I'm looking for low-level algorithms for public > key exchange, some encryption, digital signatures and hashes. Then you should have a look at amkCrypto (www.amk.ca)... -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From gmcm at hypernet.com Wed Jul 18 09:01:02 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 18 Jul 2001 13:01:02 GMT Subject: Importing XML modules in py2exe or Installer? References: <Xns90DE9C2957BDgustaflalgonetse@194.213.69.152> <9iq4oc$kme5j$1@ID-59885.news.dfncis.de> <Xns90DF21CFC7984gustaflalgonetse@194.213.69.152> Message-ID: <Xns90E25BD095F65gmcmhypernetcom@199.171.54.154> [posted and mailed] Gustaf Liljegren wrote: [snip] > E:\jane>jane > Traceback (most recent call last): > File "<string>", line 54, in ? > File "friend.pyc", line 22, in __init__ > File "friend.pyc", line 49, in getName > LookupError: unknown encoding This will probably clear up if you force the "encodings" package into the build. - Gordon From chrishbarker at home.net Fri Jul 6 20:10:46 2001 From: chrishbarker at home.net (Chris Barker) Date: Fri, 06 Jul 2001 17:10:46 -0700 Subject: Time for a Python distribution? take two. References: <6957F6A694B49A4096F7CFD0D900042F27D4F5@admin56.narex.com> <mailman.994459751.9032.python-list@python.org> Message-ID: <3B465386.4AF72A30@home.net> Paul Prescod wrote: > Actually, the better command is "search". Yup, that's what I was looking for, and I figured it would be there, I just had to download and instal it first, before I could find out what was there, that's all I was saying. > Yes, Chris is right that we could advertise and document better. And I'm sure you will > And I don't think anyone at ActiveState minds if Chris sets up a > distribution. ActiveState can't do everything and doesn't want to. Frankly, I'd be just has happy if you folks made my ideas obsolete, but until then, I think I'll get started on 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 rnd at onego.ru Fri Jul 6 03:12:03 2001 From: rnd at onego.ru (Roman Suzi) Date: Fri, 6 Jul 2001 11:12:03 +0400 (MSD) Subject: string methods to string module? Re: There's got to be an easy way to do this In-Reply-To: <slrn9kalkm.a6q.scarblac@pino.selwerd.nl> Message-ID: <Pine.LNX.4.30.0107061110100.30238-100000@rnd.onego.ru> On 6 Jul 2001, Remco Gerlich wrote: ># The same with filter, too bad we need a lambda >stripped_phone = filter(lambda c: c.isdigit(), phone_number) Maybe, we need string.isdigit and all other string methods to be available in string? Does it sound like small feature request? Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Friday, July 06, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ ""Stupid" is a boundless concept." _/ From akuchlin at mems-exchange.org Fri Jul 6 14:18:37 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 06 Jul 2001 14:18:37 -0400 Subject: Comment on PEP-0238 References: <mailman.994427714.26169.python-list@python.org> <cpsngaja4g.fsf@cj20424-a.reston1.va.home.com> Message-ID: <3dd77drkea.fsf@ute.cnri.reston.va.us> Guido van Rossum <guido at python.org> writes: > 3. A revision later, we change all plain integer divisions to be an > error, *forcing* folks to use div() or use the future statement to > specify floating point division. Step 3 strikes me as a bit odd; does that mean documentation for that release will have to say "applying the / operator to integers is an error, full stop"? And then in the next release the docs will again have to be changed to say that integer division now works? IMHO step 3 should be dropped; one release with a warning every time integer division is attempted should be sufficient. > from __future__ import float_division > from __future__ import real_division > from __future__ import new_division > from __future__ import division 'float_division'. There's no type corresponding to "real", nor is that terminology used anywhere in the docs; 'new_division' and 'division' strike me as unclear. I still like 'x div 3' better than div() or //, but can live with div(). > Unfortunately, the number of potential Python programmers who will be > frustrated by the current integer division is much larger than the > number of established Python programmers. I'm still unconvinced about that, though. Like the occasional claims that there would be many more Python users if more conventional block delimiters are used, this strikes me as proof by assertion. --amk From tim at zope.com Sun Jul 29 18:55:19 2001 From: tim at zope.com (Tim Peters) Date: Sun, 29 Jul 2001 18:55:19 -0400 Subject: Python Windows installer: good news! Message-ID: <LNBBLJKPBEHFEDALKOLCMECILCAA.tim@zope.com> Wise Solutions generously offered PythonLabs use of their InstallerMaster 8.1 system. Every PythonLabs Windows installer produced to date used Wise 5.0a, and while that's done a great job for us over the years, some of you have noticed <wink> that it was starting to show its age. I've completed upgrading our Windows installation procedures to InstallerMaster 8.1, and we'll release the next alpha of Windows Python 2.2 using it. Even if you have no interest in *testing* 2.2a2 at that time, if you're running on a Windows system please download the installer (when it's released) just to be sure it works for you! As always, we have direct access to only a few Windows boxes, so we rely on cheerful volunteerd to uncover surprises. Some things to note: + The installer it produces is a 32-bit program, so this should be the end of "failure in 16-bit subsystem" deaths some people see on Win2K (at least 4 reports of that, and no real handle on why). + The uninstaller has a new "repair" option. The install.log saves away file fingerprints at installation time, and so long as you still have the original installer .exe, the repair option can detect installed files that changed since installation, and (optionally) restore them from the original .exe. + Aborting an installation in midstream no longer (necessarily) leaves a bunch of crap sitting around. Instead you get a new dialog box offering to roll back the changes made so far. This even works if you hit the "Cancel" button on the final "installation finished" screen. + A Backup directory is created under the root of the Python installation, where the installer stores files it changes or replaces. We don't do much of that, but it *does* allow the uninstaller to restore Start Menu entries too -- nice for alpha and beta testers (before, whatever pre-existing Start Menu entries they had were simply wiped out by an uninstall). + Since IDLE is an essential part of the Windows Experience for most PythonLabs users, I folded the old Tcl/Tk component into the main Python interpreter component -- one less checkbox to worry about. Also removed the time-wasting "Welcome!" dialog, and made a few cosmetic improvements. Other than those, the look and feel are much the same, it just runs better! It's slick -- I think you'll like it. and-if-you-don't-write-a-pep<wink>-ly y'rs - tim From nospam at nospam.de Thu Jul 12 13:53:44 2001 From: nospam at nospam.de (Uwe Hoffmann) Date: Thu, 12 Jul 2001 19:53:44 +0200 Subject: Coexistence of SOAP-server and MS-IIS References: <3b4dd214.587664066@news.mch.sni.de> Message-ID: <3B4DE428.CA376A57@nospam.de> Nikolai Kirsebom wrote: > > I have a web-server running IIS and would like to make a small > testapplication using the SOAP protocol. Is it possible to have both > IIS running and a SOAP-server running on the same machine, or will > they 'fight' for the same resources (communication). > > Nikolai Should be no problem if they are using different ports (e.g. 80 and 8080) From loewis at informatik.hu-berlin.de Sat Jul 28 03:54:14 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 28 Jul 2001 09:54:14 +0200 Subject: Unusual minidom behaviour: Part Deux References: <vKJ77.12050$Up.355596@sea-read.news.verio.net> Message-ID: <j466cdv68p.fsf@informatik.hu-berlin.de> "Victor Bazarov" <vAbazarov at dAnai.com> writes: > So, I dug deeper and found out that two threads were apparently > struggling to get xml.sax.__init__ module to execute a very > suspect __import__("xml.sax.expatreader"). How exactly did you find out about that? If one of the threads would raise an exception that is not caught, would you see the traceback or would it get eaten silently by the calling Java application? Regards, Martin From robin at jessikat.fsnet.co.uk Tue Jul 31 07:17:38 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Tue, 31 Jul 2001 12:17:38 +0100 Subject: Language Niches (long) References: <8beb91f5.0107280407.5a30341d@posting.google.com> <UK2E1VAMB+Y7EwX$@jessikat.fsnet.co.uk> <mailman.996429234.13926.python-list@python.org> <Ej5QPKA1WHZ7EwvP@jessikat.fsnet.co.uk> <175D9DAD48302704.2A098F904A50FA12.D77210EAD1B10B5B@lp.airnews.net> <4s1vMVAEtYZ7Ew4w@jessikat.demon.co.uk> <m3n15lijp1.fsf@kepler.ibp.de> <mailman.996571138.27540.python-list@python.org> Message-ID: <K9QzYUBSPpZ7Ewu9@jessikat.demon.co.uk> I think Fame's licensing might be even more expensive http://www.fame.com -- Robin Becker From steve at lurking.demon.co.uk Wed Jul 25 03:27:03 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Wed, 25 Jul 2001 08:27:03 +0100 Subject: Steve Summary of views on the Is-It-Actually-Better? (was re: a use for...) References: <3B5BC73B.2D52E5E2@alcyone.com> <3B5BA29B.E08FEEE9@alcyone.com> <yCK67.17615$EP6.4467503@news1.rdc2.pa.home.com> <mailman.995860718.9550.python-list@python.org> <mailman.995862939.15013.python-list@python.org> <mailman.995883879.12071.python-list@python.org> <apaolto6pr6cevpk0lgudiapnbrttaj8u9@4ax.com> <m2wv4yhm6v.fsf@mycroft.actrix.gen.nz> <m28rltg94shda00u63lt3tdj3dhvu731sr@4ax.com> Message-ID: <13ssltss2rd0d4up7c52laghh7rvgfbcrm@4ax.com> Updating to address another issue - I figure it's better to maintain it here in one complete lump than keep splatting bits all over the newsgroup. The focus is the long-term pros/cons of the new semantics, but the relative here-and-now cost compared with alternative changes is mentioned in several places. Please ignore the I'm-right-you're-wrong-and-what-your-doing-is-stupid wording - it was deliberately aimed at some similar cases from the pro-pep side (which are not as representative as my anger led me to percieve) but I haven't got time to fix it ATM. Changes marked with - (deletion), + (insertion) and # (other change). This updates are... a. Point 10 - to address Paul Prescods claim that integer division and float division are fundamentally different because of the existence of the remainder in integer arithmetic. b. Removing a couple of particularly bad bits of sarcasm and general nastiness. I believe PEP0238 is wrong in principle because... 1. The fact that mathematicians have had many views on integers and division, and the one that is in most non-specialist mindsets doesn't meet the pragmatic requirements for several fields of mathematics, is understood. That doesn't make the other definitions from less demanding, more down-to-earth fields invalid. 2. It particularly does not invalidate the practical view which most people can easily understand, which is taught to everyone at a very early age and which also happens to work extremely well for typical programming tasks (not just specialist applications). Doesn't the pro-pep views insistence on the most pragmatic possible definition of discrete integer division seem more than a little inconsistent with their sloppy attitude to the much more fundamental difference between discrete and continuous mathematics? Just because it isn't the unnecessarily pragmatic (for normal programming tasks) field of mathematics that a few people subscribe to, it doesn't make it wrong. It is simply from a less specialised, more basic and more generally useful field that doesn't address the specialist problems of the minority over the general day-to-day practicality of the majority. 3. Practically all programs use discrete integer quantities - indices, subscripts, counters, sizes and more - whereas numerics is a particular specialist field. Making life more awkward for the majority just to suit a few specialist fields is not rational. It's the specialists dealing with specialist fields who should have to deal with awkward special case syntax and semantics - not the everyday user. 4. Discrete measures and continuous measures are not the same thing and should not be arbitrarily confused. Discrete integer division makes perfect sense despite the fact that specialist fields have outlawed it for specialist reasons relating to specialist problems. This is much more fundamental than just switching between different representations of continuous measures. The pro-pep groups arbitrarily application of continuous measure division principles with a discrete integer type is wrong in mathematics, and it is wrong in engineering, and it is wrong in programming. My use of more practical day-to-day discrete principles for discrete integer arithmetic than would be appropriate in field theory - or even 16-year-old pure mathematics, I fully agree - is not the same thing at all. 5. Having established that division on the discrete integer type should work in the only practical way that makes sense while not erroneously confusing the properties of discrete and continuous measures, it makes sense for it to apply a simple everyday convension for rounding direction - wordy and pragmatic systems should be saved for the specialist fields where they are necessary. 6. No-one has yet explained why bugs with misusing discrete integer types in continuous contexts cannot be detected and handled by simple validation. # The need for validation of externally sourced inputs is a # fundamental principle which should not be discarded just because # it is inconvenient. If the validation requirements are too fiddly to be practical, then that is a valid reason to consider adding new validation syntax and semantics which could even have wider applications. It is not a valid reason to break the widespread uses of discrete integer division in existing code, nor to make the distinction between discrete and continuous measures even harder to maintain than it already is. #7. People who are really dealing with numerics should be used to # dealing with subtle and insidious float approximations problems. # They should already be able to spot and handle the big errors # caused by confusing discrete integers and floats. 8. If you are worried about the learning curve of newbies and students, then you should be worried about making the learning curve faster and easier - not disguising or hiding it, and not creating a comfort zone where you encourage bad habits while pretending there is no principle that needs to be learned. 9. If you are dealing with 3D graphics, then you are either getting a library or hardware interface to do the rendering for you and MOST (but not all) of what you handle will be continuous measures represented by floats (which obviously should not be confused with discrete integers), or else you will be doing the rendering yourself and you will need to handle a lot of discrete integer mathematics AND continuous floating point mathematics. Pixels are a discrete integer measure and they are handled using algorithms that require discrete integers to behave as discrete integers. Discrete and continuous principles should not be arbitrarily confused, however. 10. Discrete integer division is not fundamentally different to - continuous float or rational division. There is no need for a different notation for division, as mathematitians noticed long ago. The fact that mathematicians have additional notations for floor and ceiling which they use when necessary in specialist fields is irrelevant - we have the capability if we need it but most of the time using a simple convention is more practical. + Float division is a clear extension of integer division. The fact + that it extends far enough into less-significant-digit territory + that remainder is rarely of interest is besides the point. + + However, it could be argued that supporting the remainder for + floats MIGHT be useful for specific applications to determine the + error in specific calculations. I could even imagine it being used + in numerics to help track the scale of errors in different + evaluation methods which would, for exact evaluation, give the + same result but with floats do not. + + There would also need to be some kind of error tracking facility + for other functions and operators, though, if this were to have + any real use - e.g. a 'this is the rounding error from adding + these two floats' such that a + b == c + error (where error is + typically extremely small, consisting of the lost-through-shifting + bits of the smaller of a and b in the mantissa and an appropriate + exponent). + + However, such technicalities with floats are rarely of use in + float calculations - awareness of the issues and care when writing + sensitive expressions is the rule. Therefore I'd never suggest + imposing any of this on typical Python programmers. + + Therefore a float division with float, float -> float, float would + be just as pointless as the never-asked-for integer division with + int, int -> int, int. Discrete and continuous types, however, are fundamentally different things and should be kept as cleanly separate and unconfused as possible. That is done by using different data types for discrete and continuous data. If anything is broken, it is in the automatic erroneous 'promotion' of discrete quantities into continuous types in many # cases, which should arguably be treated as errors. # Such a change would of course cause breakage, but the breakage # would be immediately visible irrespective of the visibility of # warnings in the run-time environment (causing an exception) and # therefore trusted apps will never silently report wrong results. # This is therefore arguably a much more justifiable change than # changing the semantics of the division operator. From mnenadov at stclairc.on.ca Sat Jul 21 07:01:04 2001 From: mnenadov at stclairc.on.ca (Mark Nenadov) Date: Sat, 21 Jul 2001 11:01:04 GMT Subject: Help with PDF References: <mailman.995677535.12211.python-list@python.org> Message-ID: <20010721.071302.1704365084.1761@d150-169-166.home.cgocable.net> In article <mailman.995677535.12211.python-list at python.org>, "Greg & Janet LINDSTROM" <yuba at cyberback.com> wrote: > <DIV><FONT face=Arial size=2>What is available in Python to produce > Portable Document Format (PDF) files?  I have read through the > "Python Programming on Win32" book and searched the web-site, with > little result (the book is good, but eluded that new tools might be > available by the time the book had been published).  What is the > state-of-the-python on pdf?  Is it considered "the method of > choice" for "pretty" documents?</FONT></DIV> <DIV><FONT face=Arial The best solution for Python and PDF that I have found is PDF-Lib (www.pdflib.com). I have used it with Python, and it also work with a wide variety of other languages. ~Mark Nenadov (author/editor for http://www.coffeecode.com) From steve at lurking.demon.co.uk Mon Jul 23 17:34:05 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Mon, 23 Jul 2001 22:34:05 +0100 Subject: Future division patch available (PEP 238) References: <GNZwEiAJepW7Ew0F@jessikat.fsnet.co.uk> <mailman.995776716.24336.python-list@python.org> <mailman.995825018.9832.python-list@python.org> <9jfjd6$ad4$2@newshost.accu.uu.nl> <7u6nltoqdnqjjdiquu6ngtaruflhvbvdl5@4ax.com> <j4g0bof3jv.fsf@informatik.hu-berlin.de> <p8unltsi5qda8rpdavja4iemj6r1s2ak4a@4ax.com> <j48zhfgbny.fsf@informatik.hu-berlin.de> <ij7oltslop050daaj5amiqvepigolbn0kf@4ax.com> <mailman.995916121.12672.python-list@python.org> Message-ID: <pg3plt82nu7dljk2v8070sog71auc9pf80@4ax.com> On Mon, 23 Jul 2001 14:20:14 -0500, Skip Montanaro <skip at pobox.com> wrote: > > Steve> This isn't going to be a little problem. It's going to happen in > Steve> a lot of scripts - many of which are used in environments where > Steve> no-one is going the warning - and I don't know how many scripts I > Steve> wrote, or who has copies of them, or who has personally modified > Steve> versions or anything much that would allow me to sort the problem > Steve> out in advance. > >I think many of the warnings generated for integer division will just wind >up in Apache log files where nobody will see them. Not quite - in my case I quite often use a wxPython GUI interface - the warnings won't show *anywhere* because the CLI is not visible and there are no log files. Even if it becomes visible, the typical user response to warnings is to ignore them. From MarkH at ActiveState.com Thu Jul 12 21:38:20 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Fri, 13 Jul 2001 01:38:20 GMT Subject: Win32 ADO Connection not closing? References: <b3gskt8crat32ha1nqjd1m3vajcubmqc81@4ax.com> Message-ID: <3B4E5145.6030100@ActiveState.com> maxx at easynews.com wrote: > In the code example below, an ADO connection to a MS SQL Server database is not > closing. Even after the 'adoConn.Close()' statement, the SQL Server still has an > open connection to the database. The connection does release after the script > terminates. > > As part of the function of the script, I need it to release connections to the > database, before continuing. > > Is there a way to explicitly destroy the adoConn object in the following example > ? add "adoConn = None" at the end of the script. Adding "print pythoncom._GetInterfaceCount()" will tell you how many Python COM objects are still alive. There is no way to kill them other than to explicitly unbind them - assigning to None will generally unbind that reference (but keep in mind that other references to the same object may still existing somewhere in your program). Mark. From max at alcyone.com Tue Jul 24 14:13:28 2001 From: max at alcyone.com (Erik Max Francis) Date: Tue, 24 Jul 2001 11:13:28 -0700 Subject: PEP0238 lament References: <mailman.995814276.15005.python-list@python.org> <cp66clexxt.fsf@cj20424-a.reston1.va.home.com> <9jhbfj$79s$1@pea.uk.research.att.com> <mailman.995930743.17137.python-list@python.org> <9jjfts$9k2$1@pea.uk.research.att.com> Message-ID: <3B5DBAC8.4B89E271@alcyone.com> Duncan Grisby wrote: > I agree, by the way, that if we were discussing a new language, it > would be sensible to use / for fractional division and // for integer > division (and just as sensible to do the reverse). I'm amazed at the > passion behind people arguing about what, to me, is an arbitrary > language choice. But that isn't the issue here. We aren't designing a > new language, we're modifying an existing one. Agreed. If / were float (or rational) division from the beginning, then I would have no complaints, even if I personally would prefer int/int == int. The real problem here isn't whether or not float/rational division is or isn't a good idea, it's that what is being proposed will break existing code. The proponents of this PEP have been insisting there will be plenty of time to make the switch, which is fine, but it neglects preexisting code which has been passed around and is far afield from the original author, or worse yet, code which is in place at a client site and which isn't changed easily at all. I find it pretty horrifying that this change is even being seriously considered much less is evidently going forward. That I find the benefits (namely, making the language easier for novices to understand; integer division is not very hard to understand and have not known anybody learning programmer for which this was absolutely a deal breaker and totally inhibited their ability to learn a language) to be of dubious value only makes it more disturbing. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Nothing spoils a confession like repentence. \__/ Anatole France blackgirl international / http://www.blackgirl.org/ The Internet resource for black women. From nhodgson at bigpond.net.au Wed Jul 4 18:44:23 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Wed, 04 Jul 2001 22:44:23 GMT Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> <9hrj3q$cj1@news1.gtech.com> <bebbba07.0107031040.593143f8@posting.google.com> <20010704013238.2DC8A00.NOFFLE@niccolo.ke4.de> <p1f6ktc7qphfb5tg6c59kn4jeok9ndu1eq@4ax.com> Message-ID: <b%M07.2192$Ij5.16923@news-server.bigpond.net.au> Courageous: > typedef int plane_t; > > >Is this what you wanted to have in C ? > > No. What you're asking for doesn't work, although it might be > useful if it did. As it is, this will never get into the stanard, however. > It would break too much code. Linting tools can be used to enforce better static type safety than is normal with C. Gimpel's PC-lint with the -strong setting will warn about mixing variables of different typedef types even when the underlying types are the same. Neil From BPettersen at NAREX.com Wed Jul 18 13:09:11 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Wed, 18 Jul 2001 11:09:11 -0600 Subject: Language change and code breaks (fwd) Message-ID: <6957F6A694B49A4096F7CFD0D900042F27D554@admin56.narex.com> > From: Nick Efford [mailto:nde at comp.leeds.ac.uk] > > On Tue, 17 Jul 2001 20:09:05 -0400, > Lulu of the Lotus-Eaters <mertz at gnosis.cx> wrote: > > > I--one of those professional programmers--write a Python script for > > someone who runs a business, or a non-profit, or an agency, > to run on > > their CGI webserver. This client knows not the first thing > about Python > > or about programming, nor do they maintain the webserver, just rent > > space on it. But still, this script does something useful > for users of > > the website--order products, or request documents, or send data to a > > database. > > > > I go away, no longer available. The client's web hosting company > > upgrades the Python installation to Python 3.7 (this is in > the future > > :-)). Client's scripts break. > > Interesting scenario. > > Of course, this could happen with other s/w, too. This really > says more about the policy of the web hosting company w.r.t. > upgrades than it does about the wisdom or otherwise of breaking > compatibility in a future version of Python. > > Any web hoster worth its salt should at least run old and new > versions of the s/w in parallel and provide clients with the > opportunity to test programs in the new environment before > migrating. But being a web hoster, with no knowledge about Python, would _you_ expect a version change from 2.2 to 2.3 to fundamentally change semantics? If you're really unlucky with this proposed change, your program could continue to run but silently give you wrong answers. (I can understand being extra careful with going from e.g. 2.2 to 3.0 however...) -- bjorn From tjreedy at home.com Thu Jul 12 13:38:00 2001 From: tjreedy at home.com (Terry Reedy) Date: Thu, 12 Jul 2001 17:38:00 GMT Subject: Can anyone offer a suggestion? References: <9ikgpq$j1cff$1@ID-11957.news.dfncis.de> Message-ID: <Yfl37.1065$%6.216706@news1.rdc2.pa.home.com> "Emile van Sebille" <emile at fenx.com> wrote in message news:9ikgpq$j1cff$1 at ID-11957.news.dfncis.de... {posted and emailed} > I've been writing a business math class that allows for multiple precision > accuracy, and in testing stumbled on this behavior: ... > >>> print '%8.2f' % float(ab*cb) > 152.34 So BNum.__float__ exists and appears to work correctly (as does __str__ or __repr__). > >>> print '%8.2f' % ab*cb > 151.84 I would try various things before looking at the C source: insert print in __float__ to see if it is called, and if so, with what. wrap ab*cb in () and (,) change 8.2f to s find other values of ab or cb that give an erroneous result Terry J. Reedy From rjh at 3-cities.com Wed Jul 4 02:05:29 2001 From: rjh at 3-cities.com (Robert J. Harrison) Date: Wed, 04 Jul 2001 06:05:29 GMT Subject: Comment on PEP-0238 References: <3B3BE855.A6223E70@3-cities.com> <cp7kxvlake.fsf@cj20424-a.reston1.va.home.com> <Y4J%6.4084$Z6.2010194@news1.rdc2.pa.home.com> <mailman.994016102.30019.python-list@python.org> <7ef50c46.0107020554.31cc948b@posting.google.com> <mailman.994084684.19932.python-list@python.org> <7ef50c46.0107030657.2e0fc92b@posting.google.com> <mailman.994177387.31239.python-list@python.org> <9ht7ki$pao$1@nntp6.u.washington.edu> <mailman.994191428.24168.python-list@python.org> Message-ID: <3B42B707.9EF02768@3-cities.com> Paul Prescod wrote: > > I knew I shouldn't get dragged into this. :) > > The problems with the current situation are well-documented. Every > Python book introduces this feature with a statement along the lines of: > "this is something that's going to be different than you expect...be > careful." It is one of Guido's oldest regrets. Arguing about it isn't > really going to change anything. Either someone will step up and do the > implementation, in which case the behaviour likely will change, as Guido > wants it to, or nobody ever will, in which case the status quo will > remain. If a tree falls in the forest and the BDFL is not there to hear it, does it make a sound? Seriously, if the powers that be have a rigid opinion on this subject, I'd like to be put of our misery. Or is this discussion contributing to decision making? -- Robert J. Harrison (rjh at 3-cities.com) From speedy911 at mindspring.com Fri Jul 6 09:14:21 2001 From: speedy911 at mindspring.com (Charles Harrison) Date: 6 Jul 2001 06:14:21 -0700 Subject: webbrowser module reveals a Netscape bug. References: <mailman.994361230.19417.python-list@python.org> Message-ID: <6f78b8b.0107060514.7142ed34@posting.google.com> This is somewhat unrelated, but the -remote command can be a very fun one. If you are working in a school lab environment where you have the root password on the machines, here's what to do to one of your close friends: rsh to the person's machine that you wish to have fun with su to root on that person's machine from root, su to the user that is using x on the machine type: export DISPLAY=localhost:0.0 type: xhost + now the fun... if they already have netscape open type: netscape -remote "openURL(www.hotmale.com)" if they dont, open netscape first, then do the above command: netscape& Yeah, so we get bored at my school. Enjoy! From guido at python.org Wed Jul 25 11:55:52 2001 From: guido at python.org (Guido van Rossum) Date: Wed, 25 Jul 2001 15:55:52 GMT Subject: PEP0238 lament References: <5sdnlt072hm6hp17nluu6f0fqq4bvr6mj8@4ax.com> <mailman.995873261.11975.python-list@python.org> <916olt0p3kciv0evmotdg6jev9bl29l57i@4ax.com> <Xns90E77C7A1776Cjimpublishingresourc@207.126.101.100> <3B5C52EA.9430255E@alcyone.com> <cpofqaova7.fsf@cj20424-a.reston1.va.home.com> <Xns90E99AC16C87Bduncanrcpcouk@127.0.0.1> Message-ID: <cpzo9t80l7.fsf@cj20424-a.reston1.va.home.com> Duncan Booth <duncan at NOSPAMrcp.co.uk> writes: > I agree that it would make Python a different language. Neither better nor > worse. > > You arguably gain in meeting some peoples expectations of the division > operator, but you lose consistency in that previously (as far I can think), > the operators +, -, *, /, % when given two arguments of the same numeric > type always return a result of that same type. In future we have to be > prepared to explain to beginners that division can give a result of a > different type: in fact you cannot even predict the type of the result when > you know the types of the arguments, you have to know their values as well. In a farther future, when PEP 228 is fully implemented, Python may only have *one* (built-in) numeric type, "number". Then all operations will defined entirely on the mathematical value, and the different "types" as we know now are merely details of storage efficiency -- except that numbers will also have an indication of "exactness" or "approximateness", to acknowledge the fact that the number system may choose to give approximate results for some operations. We may end up deciding that rationals have too many problems, and replace binary floating point with decimal floating point to address a different set of confusions, and so maybe division of two exact numbers may not always yield an exact result -- just like the square root of 2 is conventionally calculated only to a limited precision. Or we may choose to represent rationals exactly -- in any case, 1/2==0 will be false, just as PEP 238 proposes. Such a (hypothetical!) world is just as consistent, yet it does not guarantee that the type of the result of an operation is the same as that of the operands, if by type you mean the storage type (int, long, float etc.). Also look at PEP 237, which proposes to unify ints and longs. Would you really prefer your "consistency" and see 1000000 * 1000000 raise OverflowError because the result cannot be represented as a 32-bit int, or would you prefer to drop the "consistency" in favor of getting a result at all? --Guido van Rossum (home page: http://www.python.org/~guido/) From aleaxit at yahoo.com Tue Jul 3 11:33:16 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 3 Jul 2001 17:33:16 +0200 Subject: Calculus References: <mailman.994164981.2922.python-list@python.org> Message-ID: <9hsojt02e5r@enews1.newsguy.com> "Andrew Todd" <aetodd at wm.edu> wrote in message news:mailman.994164981.2922.python-list at python.org... ... > that has functions commonly used in Calculus. For example, > the Simpsons Rule, and the formula that allows you to find I agree the Simpsons rule (my personal favourite is Lisa), but I didn't think they were now used in Calculus, too... Alex From peter at engcorp.com Tue Jul 17 09:32:54 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 17 Jul 2001 09:32:54 -0400 Subject: Is Python Dead? Long Live Python! References: <mailman.994803257.19598.python-list@python.org> <3b53fda0$0$151$9b622d9e@news.freenet.de> Message-ID: <3B543E86.5A0D5920@engcorp.com> Guido Stepken wrote: > > Kemp Randy-W18971 wrote: > > How can Python become as popular as Perl, Java, or PHP? > > I have been teaching python to kids ...12 years old .... they really had > fun ... that's the (only) reason for the extreme growing acceptance for > python over java or perl or php .... While I readily admit to the sheer fun of Python compared to the feeling of depression I get over using most other languages, I can't support the theory that's "the only reason" for the growing acceptance. Relatively to PHP, it seems likely Python is growing because it is not merely a crufty niche language. (But we've seen arguments PHP is growing faster anyway). Relative to Perl, Python is clearly more readable and even the author of Perl acts somewhat as a Python propagandist. Relative to Java, which is probably overhyped but at least represents a reasonable improvement to C++ in many areas, Python is probably growing faster because of its productivity, reasability, and the fact that with Jython one can hardly point to Java's many benefits without admitting that one can write Python code and not lose those most of the benefits. I'm sure fun factors into it, but the "only" reason? I doubt it. > python will be #1 in 2 years .....expecially for huge projects .... I predicted (to myself mainly :-) in about 1996 that in about three years Java would be used for most application development. I wasn't exactly right, but maybe I wasn't too far off the mark relative to what some others thought. I doubt Python will have the same growth, and I really doubt it will be "#1" (whatever that means) in only 2 years. I do believe it will continue to find roles in many diverse areas, including some large projects, but I'm quite sure the really large projects will manage to hold out for more traditional languages for a very long time. Maybe what we'll see will be Python be used, not exclusively but as one component, in the most projects. So if we measure "#1" in terms of number of projects using Python, it has a chance. If we measure it in terms of lines of code, of course, it has little chance of being number 1, for obvious reasons. :) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From michael at rcp.co.uk Tue Jul 31 04:56:29 2001 From: michael at rcp.co.uk (Michael Abbott) Date: Tue, 31 Jul 2001 08:56:29 +0000 (UTC) Subject: Typing system vs. Java References: <mailman.996524288.7635.python-list@python.org> <jonathan-D4822F.08343331072001@news.easynet.co.uk> Message-ID: <Xns90EF65598E954michaelrcpcouk@194.238.50.13> Jonathan Hogg <jonathan at onegoodidea.com> wrote in news:jonathan- D4822F.08343331072001 at news.easynet.co.uk: > I can though, think of plenty of places where strong static typing would > defeat intentional exploitation of the dynamic typing. Maybe this is > poor programming on my part, but I can't even think how one would type a > function like say: > > def f(zs): return reduce( lambda x, y: x + y, zs ) > > Python's dynamic typing has the most optimal type for this function: > > "A function that takes something looking like a sequence of > things that you can call "+" on, and returns something that > you might get back by "+"ing a bunch of such things together." > > I just don't ever see Python with a static type system. What's more I > don't think I'd want it. If you want static types then code in something > else. If you find Java/C++ too horrific, then I'd seriously recommend > O'Caml - though this is just from a cursory look, I did most of my FP in > Haskell but I don't think I could recommend it unless you're willing to > become a serious FP-head and want to get to grips with Monads ;-) Interesting example. I for one would like to see a strongly typed variant of Python: if for nothing else, I'd like to be able to compile my code. Giving your function a type really boils down to giving the function + a type, doesn't it? In Haskell, I guess we could type f thus: f :: Num a => [a] -> a but this is perhaps a little unsatisfactory, since the type a is then required to support all the other numeric operations as well. It would be nicer to be able to, for example, define: class SemiGroup a where (+) :: a -> a -> a f :: SemiGroup a => [a] -> a but this seems both clunky and really a bit misleading (since we don't actually require the + we're using to be associative). It's probably a good start to look at the type of reduce. This is easy enough in Haskell: reduce :: (a -> a -> a) -> [a] -> a (need to cook up a more Python friendly syntax for this). Ok, so the real problem is this: what is the type of + ?! In Haskell, + is definitely of type (+) :: Num a => a -> a -> a which simply means that it is a member of the class Num (which also contains -, * and some other stuff; seems to be an ordered Ring) and is a binary operation which returns a value of the same type as its arguments. The Haskell type model is too restrictive for Python, particularly since it is not possible for any global name to have more than one type (so, for example, we can *only* use + to name a method of the Num class). However, I do think that some of the principles of Haskell typing can be profitably applied to Python. Let me just observe this: statically typed Python would need to be a different language from standard Python, though hopefully close enough to interoperate and have the same name. Can anyone comment on the current status of ideas for statically typing Python? The SIG mailing list is only carrying spam at the moment, and several of the SIG links are broken, so things don't look promising... From michael at stroeder.com Fri Jul 6 16:06:03 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Fri, 06 Jul 2001 22:06:03 +0200 Subject: Python: Database to Web Part II References: <5174eed0.0107060820.ff90805@posting.google.com> Message-ID: <3B461A2B.5FDE1CB@stroeder.com> Edward Wilson wrote: > > I write applications which save peoples life's-public > safety systems. And then you are asking for an Oracle adaptor? You should review the recent thread "Python for air traffic control?": http://groups.google.com/groups?hl=de&safe=off&th=d3460cb8b82dc6d,118&ic=1 Ciao, Michael. From skip at pobox.com Mon Jul 16 18:56:04 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 16 Jul 2001 17:56:04 -0500 Subject: String Splice Assignment In-Reply-To: <4e3a8319.0107161357.690b5120@posting.google.com> References: <4e3a8319.0107161357.690b5120@posting.google.com> Message-ID: <15187.28932.301405.174144@beluga.mojam.com> nathan> Why don't strings support splice assignment, and what are some nathan> alternatives? Strings are immutable. Try: >>> a = 'asdf' >>> a = a[0:1] + 'EFGH' + a[2:] >>> a 'aEFGHdf' or >>> a = 'asdf' >>> a = list(a) >>> a ['a', 's', 'd', 'f'] >>> a[1:2] = ['EFGH'] >>> a ['a', 'EFGH', 'd', 'f'] >>> a = "".join(a) >>> a 'aEFGHdf' If you want to do lots of operations efficiently, the list variant may be more efficient assuming you leave it in list form for quite awhile and don't constantly convert back to the string form. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From ullrich at math.okstate.edu Mon Jul 16 09:57:29 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Mon, 16 Jul 2001 13:57:29 GMT Subject: Nested List Comprehension References: <9iss5k$2dcd$1@news.idiom.com> Message-ID: <3b52f295.746274@nntp.sprynet.com> On 15 Jul 2001 19:50:12 GMT, "James T. Dennis" <jadestar at idiom.com> wrote: > This is not a question but merely a comment from a > newbie. I'm reading Beazley's 2nd Ed. "Python Essential > Reference" and playing with things therein and I thought > "list comprehension, what a quick way to make a multiplication > table" > > multtab = [ [ x*y for x in range(13) ] for y in range(13) ] > > ... though I was surpirsed that I got the syntax correct > on the first try. (It still looks wrong, ??? It looks exactly right to me; I must be looking at it wrong. (What looks wrong about it? What would look righter?) > somehow but > [ x*y [x for x in range(13)] [y for y in range(13) ] ] looks > even more wrong). > > > David C. Ullrich From jessw at loop.com Fri Jul 27 20:22:15 2001 From: jessw at loop.com (Jesse W) Date: Fri, 27 Jul 2001 17:22:15 -0700 Subject: Launching Python from Python In-Reply-To: <wz66cefcph.fsf@sunshine.cs.uu.nl> Message-ID: <3B61A347.25682.6D52DA6@localhost> A non-text attachment was scrubbed... Name: not available Type: text/enriched Size: 1738 bytes Desc: not available URL: <http://mail.python.org/pipermail/python-list/attachments/20010727/d3ebe087/attachment.bin> From greg at cosc.canterbury.ac.nz Tue Jul 31 23:25:00 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 01 Aug 2001 15:25:00 +1200 Subject: PEP 238 (revised) References: <mailman.996260992.19535.python-list@python.org> Message-ID: <3B67768C.924526C9@cosc.canterbury.ac.nz> Christian Tanzer wrote: > > > How about Revising Division or even better Splitting the Division > > Operator. > > Dividing the Division Operator ??? Divide and Conquer? -- 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 emile at fenx.com Mon Jul 9 06:46:22 2001 From: emile at fenx.com (Emile van Sebille) Date: Mon, 9 Jul 2001 03:46:22 -0700 Subject: dummy/trash object References: <mailman.994671443.23621.python-list@python.org> <slrn.pl.9kj26i.nof.qrczak@qrnik.zagroda> Message-ID: <9ic29t$ib4b8$1@ID-11957.news.dfncis.de> As I read the OPs question, it has to do with the unneeded assignment being performed. I took this in part as a performance issue, in which case simple use of _ performs much better, as on my system I can to 10M assigns a second. -- Emile van Sebille emile at fenx.com --------- "Marcin 'Qrczak' Kowalczyk" <qrczak at knm.org.pl> wrote in message news:slrn.pl.9kj26i.nof.qrczak at qrnik.zagroda... > Mon, 9 Jul 2001 11:36:35 +0200 (CEST), Xavier Defrang <xavier at perceval.net> pisze: > > > I'm sure that someone already came with a question like : "why is > > there no real dummy or trash object in Python which could by used > > like the magic '_' in Prolog?" > > You can implement it yourself, but it will look a bit ugly: > > class trash: > def __setattr__(self, attr, val): pass > _ = trash() > > x, _.y, z, _.u = t > > -- > __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ > \__/ > ^^ SYGNATURA ZAST?PCZA > QRCZAK From tim.hochberg at ieee.org Mon Jul 23 12:07:45 2001 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Mon, 23 Jul 2001 16:07:45 GMT Subject: PEP0238 lament References: <mailman.995839419.19134.python-list@python.org> Message-ID: <lZX67.36860$Cy.4285646@news1.rdc1.az.home.com> "Tim Peters" <tim.one at home.com> wrote in message [SNIP] > Indeed, nobody with a keen interest in > numerics has bugged Guido about this except Moshe, that I know of; the most > visible repeated pressures have come from educators using Python as a means > to some other end. [SNIP] Hey, I'm one of those people with a keen interest in numerics who hasn't bugged Guido about this yet. Let me rectify the situation. First off a disclaimer, I don't claim to be a hard core numerical analysist of any sort -- I'm an engineer of sorts and I know just enough numerical analysis to get myself into trouble. I do use python almost entirely for numerical work and have been using it since way back in version 0.9.2 or so. Let me stray from the topic for a paragraph here: I'm astounded to discover the number of people pining for integer division that truncates towards zero. That sort of integer division is horriible. When programming in C, I always had to simulate Python's behaviour in order to get code that might take both positive and negative integral values to work correctly. Python gets this exactly right. Back to the topic, more or less: I've been astounded by way the arguments against this has played out. I expected the opposition to say more or less, "It's a small problem at worst, and it will break 10 zillion lines of code, and will be a huge pain to upgrade, so it's just not worth it". Instead, the talk of code breakage has been suprisingly small and there seems to be a fair number of people claiming that the current mixed behaviour is a _good_ thing. I couldn't disagree more. C-style division in a dynamically typed language is an accident waiting to happen. And does this mean that code breakage won't be as large and/or painful as I thought it might be? It also seems that a lot of the people most vociferously opposed to the PEP have very little idea what's actually in it. In particuluar, there seems to be many out there who seem horrifed at the prospect of integer division going away even though this was never proposed. Anyway, not being an educator, I'm not particularly concerned with whether integer division is easy or hard to learn. I like the proposal because there just isn't a good way currently to spell divide-these-two -numbers-using-normal-division. The fact that oponents of this proposal keep suggesting methods for doing this that are wrong only reveals that this is more difficult than generally supposed. Consider the completely unsafe function: def simple_func(x, y): return y / x**2 It has been suggested as recently as this morning, I believe, that this be rewritten: def simple_func(x, y): return y / float(x)**2 This is simple, clear and ... wrong, as Konrad Hinsen pointed out several days ago. At least it's wrong if complex numbers are ever a possibility. One could instead write it using complex(x), but one generally does not want to convert to a complex number unless the inputs are complex, so that solution is unsatisfactory. A more correct solution suggested by Konrad is: def simple_func(x, y): return y / (x+0.0)**2 This is correct, but can hardly be called simple or clear. Also, in the context of Numeric Python, where x and/or y may be an array, the above code may be inefficient in time and extremely inefficient in space. It's possible of course to work around this, but it becomes even less simple and clear. Time to stop before I get too inflamatory, -tim From rnd at onego.ru Mon Jul 9 00:55:40 2001 From: rnd at onego.ru (Roman Suzi) Date: Mon, 9 Jul 2001 08:55:40 +0400 (MSD) Subject: time.strftime BUG? In-Reply-To: <tb527.1692$h45.11400@news.uk.colt.net> Message-ID: <Pine.LNX.4.30.0107090855100.30316-100000@rnd.onego.ru> On Sun, 8 Jul 2001, Graham Ashton wrote: I've reported this BUG thru Sourceforge. >In article <mailman.994491312.28840.python-list at python.org>, "Roman Suzi" ><rnd at onego.ru> wrote: > >> >>> time.strftime("%Z", time.localtime(time.time())) >> 'MSD' >> >>> time.strftime("%z", time.localtime(time.time())) >> '+0000' > >> While I believe the later should be: >> '+0400' > >I'm a bit confused by this too. > Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Monday, July 09, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Useless Invention: Motorcycle seat-belts." _/ From guido at python.org Sat Jul 7 14:33:43 2001 From: guido at python.org (Guido van Rossum) Date: Sat, 07 Jul 2001 18:33:43 GMT Subject: PEP scepticism References: <mailman.994528591.28994.python-list@python.org> Message-ID: <cpy9q0iobo.fsf@cj20424-a.reston1.va.home.com> "Tim Peters" <tim.one at home.com> writes: > [Robin Becker] > > ... > > Dictators often assume they know best, but observation shows them > > to be uniformly wrong. > > Heh. Replace "Dictators" with "Humans", and I expect the truth-value of > that assertion would be unaffected. > > BTW, in case newcomers are wondering, Guido didn't become BDFL by > assassinating his predecessor, nor does he maintain Absolute Power by force > of arms. Although he's been thinking about it <wink>. The PSU has Robin's name and email address. Robin: be afraid, be very afraid. It is time that an example be set! --Guido van Rossum (home page: http://www.python.org/~guido/) From thomas at gatsoft.no Fri Jul 27 07:29:25 2001 From: thomas at gatsoft.no (Thomas Weholt) Date: Fri, 27 Jul 2001 11:29:25 GMT Subject: Distributed computing using SOAP. What about speed ? References: <LBA77.58$bXi.175168000@news.telia.no> <dc6f5c99.0107251655.f3c625b@posting.google.com> <3B5FC733.5186D588@tundraware.com> <dc6f5c99.0107261825.7e74fa89@posting.google.com> <3B60EEA0.70BC492A@tundraware.com> <dc6f5c99.0107270155.72f8c5aa@posting.google.com> Message-ID: <pgc87.237$bXi.178337280@news.telia.no> > Personally, I think this idea of using XML-RPC or SOAP over the Internet if > you want reliablity isn't a good idea. I believe these protocols can be useful > in the setting of a corporate network but within quite constrained ways. > If someone tells me they want something which provides gauranteed reliability > etc, then I will be the first to tell them to go use software from the likes > of Tibco, BEA or IBM. What do you mean by "reliability"? I think we're talking about different worlds here; I'm developing a system for normal users, who can accept infrequent failures and some downtime without ending in financial ruin. Companies spending millions on huge projects cannot. SOAP is supported by IBM, Microsoft etc. and would they risk promoting, even building complex systems like .NET on this technology if it wasn't suitable at all? Implementation and other factors like network load etc. would proably have a big impact on reliability too. Am I so terribly wrong?? Thomas From whats_really_hot at hotmail.com Sun Jul 1 08:19:25 2001 From: whats_really_hot at hotmail.com (whats_really_hot) Date: Sun, 1 Jul 2001 15:19:25 +0300 Subject: any books for python for downloading? References: <993939668.727430@athnrd02.forthnet.gr> <slrn9jt3hj.pt6.carlf@panix2.panix.com> Message-ID: <993989890.343644@athnrd02.forthnet.gr> "Carl Fink" <carlf at panix.com> wrote in message news:slrn9jt3hj.pt6.carlf at panix2.panix.com... > 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 hi there.thanks for ur response.so,i mean if there are any books in net (free of'course) for python and for downloading. of'course i have downloaded the tutorial tha u recommand.so, are there any sites with free books that u know? thanks in advance! From new_name at mit.edu Mon Jul 2 11:36:19 2001 From: new_name at mit.edu (Alex) Date: 02 Jul 2001 11:36:19 -0400 Subject: New PEP: Quality Guidelines For Standard Modules References: <mailman.994034642.25601.python-list@python.org> <t250ktcev8fp615ab7uanin3cq1rj9ga5j@4ax.com> Message-ID: <etd7kxrs5qk.fsf@lola-granola.mit.edu> > Perhaps you could make a better case for why you think this is even > important. If you want to subclass a class whose behaviour depends on a global in its module, getting the behaviour you want can become a bit messier. Alex. From loewis at informatik.hu-berlin.de Tue Jul 31 08:10:38 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 31 Jul 2001 14:10:38 +0200 Subject: how to use method in node(xml) References: <mailman.996549716.19083.python-list@python.org> Message-ID: <j4puahb8ox.fsf@artagnan.informatik.hu-berlin.de> "sdf" <wqh-2 at 263.net> writes: > I am a newbie to python with xml. there is a appendchild method in > Node(I know this from python Document), > but when I use > >>>dir(Node) > the result is > ['ATTRIBUTE_NODE', 'CDATA_SECTION_NODE', 'COMMENT_NODE', 'DOCUMENT_FRAGMENT_NODE', 'DOCUMENT_NODE', 'DOCUMENT_TYPE_NODE', 'ELEMENT_NODE', 'ENTITY_NODE', 'ENTITY_REFERENCE_NODE', 'NOTATION_NODE', 'PROCESSING_INSTRUCTION_NODE', 'TEXT_NODE', '__doc__', '__module__'] > > and no appendchild accur, > it is right to use Node.__doc__ > but how can I use appendchild (wrong appear when > use Nod.appendchild).please post an example,better in detail Where did you get Node from? It works for me: >>> from xml.dom.minidom import Node >>> dir(Node) ['__doc__', '__getattr__', '__init__', '__module__', '__nonzero__', '_debug', '_get_firstChild', '_get_lastChild', '_makeParentNodes', 'allnodes', 'appendChild', 'childNodeTypes', 'cloneNode', 'debug', 'hasChildNodes', 'insertBefore', 'isSameNode', 'namespaceURI', 'normalize', 'removeChild', 'replaceChild', 'toprettyxml', 'toxml', 'unlink'] xml.dom.Node is a base class of xml.dom.minidom.Node. Regards, Martin From tigra_564 at mail.ru Thu Jul 12 04:07:07 2001 From: tigra_564 at mail.ru (Tigra) Date: 12 Jul 2001 01:07:07 -0700 Subject: newbie xml+python question Message-ID: <aaf95f4f.0107120007.28b3c85c@posting.google.com> Hi Please, recommend what to use (and where to get a comprehensive doc) on an xml library which allows solving these tasks: 1. parse xml into dom (I mean into language specific xml tree struct) 2. roll a dom of my own and save it into xml (also update an existing dom) 3. check dom and/or xml against a dtd file/string/stream (at least string) 4. parse dtd into dom and reverse (I just want to create/parse dtds of my own) 5. transform an xml document with an xsl template. 6. have hooks on every step of operation. I.e. if a dtd validation fails, I'd like to get an exceptionm with info on where and why the error occured, not just "Validation error at xml line 14 (or node ...)". I guess that SAX isn't able of meeting all these requrements. Any help (or even advocacy) is appreciated. Thanks Sergey From nikander at mindspring.com Thu Jul 12 11:31:15 2001 From: nikander at mindspring.com (Rob Nikander) Date: Thu, 12 Jul 2001 11:31:15 -0400 Subject: eval() -- don't print to stdout References: <20010712.112138.213975407.8136@kanchenjunga.mindspring.com> Message-ID: <20010712.113115.1369321801.8136@kanchenjunga.mindspring.com> In article <20010712.112138.213975407.8136 at kanchenjunga.mindspring.com>, "Rob Nikander" <nikander at mindspring.com> wrote: > How do you prevent eval/exec from printing its result to the console? Oops. I figured it out 2 minutes after posting. Passing 'eval' to compile() rather than letting the third parameter default to 'single' seems to do the trick. From max at alcyone.com Fri Jul 20 22:27:39 2001 From: max at alcyone.com (Erik Max Francis) Date: Fri, 20 Jul 2001 19:27:39 -0700 Subject: Case insensitivity (fwd) References: <mailman.995663255.15727.python-list@python.org> Message-ID: <3B58E89B.65D2202B@alcyone.com> Lulu of the Lotus-Eaters wrote: > But the most annoying aspect of case-sensitivity is trying to *speak* > it > to beginners (or even to non-beginners): ... But why would one _ever_ try speaking code to someone else, beginner or not? -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ But we go on pretending / Stories like ours / Have happy endings \__/ The Russian and Florence, _Chess_ Esperanto reference / http://mirror/alcyone/max/lang/esperanto/ An Esperanto reference for English speakers. From greg at cosc.canterbury.ac.nz Mon Jul 23 20:48:42 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Tue, 24 Jul 2001 12:48:42 +1200 Subject: subclassing Exceptions References: <9ihklt8u0vvh1aa0mg6tadbmjo9mot47e0@4ax.com> <mailman.995773776.14791.python-list@python.org> <v3mklt0fcn31un5en9pr90lvnh44935qi4@4ax.com> <3B5B137E.3606B75D@alcyone.com> <9t6mltc0nhqt4enj7dq0n0c9s3u9ens4eb@4ax.com> <3B5B26F9.A2C71182@alcyone.com> <88gmltsdpn4brhtr7ng71b7c22qqlhlfac@4ax.com> <wklmlgcokf.fsf@mail.connact.com> Message-ID: <3B5CC5EA.25D87C98@cosc.canterbury.ac.nz> phawkins at spamnotconnact.com wrote: > > >>> raise strExceptionWithArg, "no thanks" Shouldn't that be raise strExceptionWithArg("no thanks") ? According to my reading of the docs, the first form is illegal, since if the exception is a class and a value is supplied it is supposed to be a subclass of the exception class. The real mystery is why it seems to work in some cases anyway... -- 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 Jul 10 04:11:39 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Tue, 10 Jul 2001 12:11:39 +0400 (MSD) Subject: curses woes In-Reply-To: <slrn9kl196.rts.sill@sill.silmarill.org> Message-ID: <Pine.LNX.4.33.0107101209540.4375-100000@phd.fep.ru> On Tue, 10 Jul 2001, Rainy wrote: > while 1: > c = win.getch() > if c == curses.KEY_BACKSPACE: > do_something() > > The problem is that backspace key shows up as ^? and doesn't match the above > test. I also tried doing c == 14 but also without luck. I'm using > curses.wrapper() here. Your terminal is incorrectly configured. man 5 terminfo man tic man stty Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From tatiana at exatas.unisinos.br Thu Jul 19 12:30:35 2001 From: tatiana at exatas.unisinos.br (Tatiana Evers) Date: Thu, 19 Jul 2001 13:30:35 -0300 Subject: Threads Message-ID: <001201c11070$235689a0$39a5100a@cg22898> Hi, I'm here again with more problems....;o) I need use threads in Python. How does interaction between threads work? How do they communicate? Thanks ;o) Tatiana --------------------------------------------------------------- Tatiana Figueiredo Evers Mestranda em Computa??o Aplicada (Computa??o Gr?fica) UNISINOS - S?o Leopoldo - RS tatiana at exatas.unisinos.br www.inf.unisinos.br/~tatiana From sholden at holdenweb.com Thu Jul 26 21:13:09 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 26 Jul 2001 21:13:09 -0400 Subject: Language change and code breaks References: <mailman.996173519.19391.python-list@python.org> Message-ID: <dc387.1404$Og1.117870@e420r-atl1.usenetserver.com> "Bruce Sass" <bsass at freenet.edmonton.ab.ca> wrote in message news:mailman.996173519.19391.python-list at python.org... > On Thu, 26 Jul 2001 maxx at easynews.com wrote: > > On Wed, 25 Jul 2001 05:29:41 GMT, Guido van Rossum <guido at python.org> wrote: > <...> > > >The number of symbols available is so much larger than the number of > > >distinct names you need that the reduction is irrelevant. > > > > Plus, the day that symbols become so numerous in code that the usage of case is > > necessary to differentiate them, then software development will have become > > truly too complex for mortals such as myseld. > > Sure, and we can generate as many identifiers as we need with only 2 > symbols, "0" and "1". > You had *two* symbols? You were lucky ... Of course you can get as many different identifiers as you want just using *one* symbol, but it might detract somewhat from readability. regards Steve -- http://www.holdenweb.com/ From chris at voodooland.net Mon Jul 9 09:31:33 2001 From: chris at voodooland.net (Chris Watson) Date: Mon, 9 Jul 2001 08:31:33 -0500 (CDT) Subject: license suggestions? In-Reply-To: <010f01c10837$c2a68140$0101010a@local> Message-ID: <20010709082058.D93525-100000@open-systems.net> > Wrong. The right to create derivative works does not include the right > to change the license. Note that I am not a lawyer, and this is based on > my layman's understanding of contract law, but this has been brought up > so many times I looked into it. You need to discuss this with a lawyer. > The BSDL doesn't *have* to mention that "further restrictions are > prohibited" > since that is the default. Yes it does. The license itself says nothing about not adding furhter restrictions. It's common knowledge you CAN GPL BSD code. > > Mr. G's app IS under the GPL, but the components (individual source files > no doubt) written by Mr. W will still have the BSDL license at the top > (unless Mr. G has violated the law, which of course is always possible > regardless of license). For Mr. K to avoid GPL "contamination" he would > have to carefully extract only the BSDL parts *or* go back to the original > software distribution from Mr. W. Yes you will have a the original 2 clauses of the bsdl + the entire GPL ammended to it. Creating a GPL work. > The GPL states how the creator of derivative works must behave. If the > creator of the derivative work cannot obey both the GPL and the law at the > same time, the law takes precedence always. > The main reason you hate it seems to be that you have seriously > overestimated > the power that the license gives to others. No matter what I or anyone else > wants to do, without your approval I can't change the license of your code. No, you simply either haven't read the GPL in its entire form, or you don't understand it, or you have never consulted a lawyer about it, or your simply ignoring the truth. When you take a copy of a 2 clause BSDL'ed piece of code, change a few lines of it and and add that NEW piece of code into a GPL work the whole work is GPL'ed. It ceased to be MY work the second you modified it. It is now an entirely new entity. The parts that are mine are still covered under the BSDL which doesnt prevent you from gpl'ing it, but the work as a whole is now GPL if you licensed the new derivative work under the GPL. > In the aggregate with GPL code, the aggregate must be distributed as if the > GPL covered the whole thing, but that aggregation still doesn't change the > license of non-GPL code in "the mix." Further, if the license of the non- > GPL code is GPL-incompatible you simply can't legally distribute the > aggregation at all. Your talking in circles now. Your admitting you can GPL bsd code. "The aggregate *must be* distributed as if the the GPL covered the whole thing." You are correct. The BSDL does NOT prevent someone from GPL'ing the code. It says nothing in the license at all about further restrictions, ammending the license etc.. It simply says 2 things, and 2 things only, if you build a binary of it you must include the (c) and this list of conditions. If you modify the src and release it you must include the (c) and this list of conditions. That is the only thing it says. No where there does it say "you may not relicense this work, add to this license, modify it, etc.." Chris From peter at engcorp.com Tue Jul 31 20:06:26 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 31 Jul 2001 20:06:26 -0400 Subject: Large pages using Zope References: <9k766t$dc0$04$1@news.t-online.com> Message-ID: <3B674802.C730D678@engcorp.com> Achim Domma wrote: > > Hi, > > I just finished the first step : I succeded in introducing Python as our > prefered scripting language, replacing JScript and VBScript in the future. > Now we need a way to script webpages with it. Presumably you are not talking about using Python in the browser? That's possible, of course, with IE (which Python can script via ActiveX), but it requires installing Python on each client machine and therefore is feasible only on an Intranet. > I would like to use Zope, Why? Are you sure you want to use Zope? What tasks are you trying to accomplish for which you believe Zope is the best solution, and why? (It sounds like you don't actually know anything about Zope, except that it is written in Python, but please correct me if I'm wrong.) Zope has a fairly steep learning curve, and it may or may not be the best solution for you. There _are_ simpler ways to go, but then again there are also advantages to using Zope. It all depends on what you really need. > but I have to answer questions like 'How do we know that > it's fast/stable enough ?'. Can anybody help ? > Are there any big references, which are using Zope ? There are many, including a dozen listed on the page at http://www.zope.org/Resources/CaseStudies . Have you visited zope.org yet? That might be a good place to start if you "would like to use Zope"... :-) (Note: we are using Zope quite successfully in the company I work for right now. It is fast enough, just as Python is, for our needs, and is *very* stable. You shouldn't take someone's word for it, however, as your own needs and standards may vary. Give it a test drive yourself, if you are interested.) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From skip at pobox.com Wed Jul 18 14:35:34 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 18 Jul 2001 13:35:34 -0500 Subject: how to save strings to a temporary buffer? In-Reply-To: <9j4kia+hmtu@eGroups.com> References: <9j4kia+hmtu@eGroups.com> Message-ID: <15189.55030.243351.99923@beluga.mojam.com> ed> How can I save string to a tempororay buffer and then write it to a ed> file afterwards? Take a look at the StringIO and cStringIO modules. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From alankarmisra at hotmail.com Fri Jul 13 08:31:45 2001 From: alankarmisra at hotmail.com (gods1child) Date: 13 Jul 2001 05:31:45 -0700 Subject: PyZipFile References: <25b2e0d9.0107122104.50347e10@posting.google.com> Message-ID: <25b2e0d9.0107130431.7be775ad@posting.google.com> forgot to mention the platform: I am working on Win2K, with Python 2.1. Tnx. From d.courtois at skynet.be Fri Jul 20 12:04:53 2001 From: d.courtois at skynet.be (d.courtois at skynet.be) Date: Fri, 20 Jul 2001 16:04:53 GMT Subject: FREE web hosting services with a cgi directory Message-ID: <3b5855ba.9008159@news.skynet.be> Quelqu'un connait-il un h?bergeur gratuit de sites, en Belgique ou en France, qui autorise les scripts en Python? Merci d'avance pour votre aide. From volucris at hotmail.com Thu Jul 12 14:27:48 2001 From: volucris at hotmail.com (Volucris) Date: Thu, 12 Jul 2001 13:27:48 -0500 Subject: Number::Spell References: <Pine.LNX.4.31.0107121615560.6412-100000@cb921.local> Message-ID: <3b4deb9b$0$326$6e49188b@news.goldengate.net> I know I've seen this somewhere. Check the Vaults of Parnassus: http://www.vex.net/parnassus/ -- Volucris (a) hotmail.com "Eu n?o falo uma ?nica palavra do portugu?s." "Campbell" <cb921 at voice.co.za> wrote in message news:Pine.LNX.4.31.0107121615560.6412-100000 at cb921.local... > Hello, > > This was something I once used from perl a long time ago. Does anyone > know of a function to return a list of words making up an english > number, from a normal set of digits? > > Thank you for any help, > > No one speaks and no one tries > No one flies around the sun.... > From aleaxit at yahoo.com Tue Jul 10 05:33:21 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 10 Jul 2001 11:33:21 +0200 Subject: import namespace issues References: <yv2lmlxgnji.fsf@lionsp093.lion-ag.de> Message-ID: <9iei5205pn@enews3.newsguy.com> "Harald Kirsch" <kirschh at lionbioscience.com> wrote in message news:yv2lmlxgnji.fsf at lionsp093.lion-ag.de... > > THE PROBLEM: > I have to separate a module's function into two .py-files. Now I would > like to import both in a way that they behave like they are one file. This is likely to lead to maintenance problem -- what is the advantage of splitting things in two if you then go out of your way to couple the two as strongly as possible? And mutual, aka cyclic, dependencies, too -- the worst kind... > FIRST TRY: > Suppose the files are called first.py and second.py. I put a > > from second.py import * No .py here -- just "from second import *". > into first.py. This does not work as necessary since functions in > second.py don't find functions defined in first.py. Same story when Perhaps you can synchronize the two dictionaries at this point by segue-ing with import second second.__dict__.update(globals()) but this will NOT ensure that any LATER changes to the __dict__ of either module are somehow "magically synchronized". > using __import__(). > > FINDINGS: > What I gathered from experiments is that even with `from ... import' > as well as when using __import__('second', my_globals, my_locals) > there will *always* be a *new* dictionary used for the globals() of > the imported functions. Example: To be precise: every module object has a __dict__ attribute that is NOT rebindable. globals() just returns the __dict__ of the module object from which globals() is being called. __import__ uses its dictionary arguments in different ways than you seem to believe it's using them. > QUESTION 1: > How can I achieve to merge two .py into one globals() as if the were > in one imported file while maintaining the file-search semantics of > `import'? I don't think you can ever possibly make any module object use a different dictionary than the one it was born with. You can try to fake it in several ways (e.g., an *instance* object does have a re-bindable __dict__ attribute), but I think there will be correct programs that behave otherwise under the fake-it scenarion than they would if the two modules were indeed one. > QUESTION 2: > Is there a detailed description somewhere in the docs about the > namespaces (or dictionaries) used/created/shuffled during an import? I think the documentation for __import__ is pretty clear about it, "the standard implementation does not use its locals argument at all, and uses its globals only to determine the package context of the import statement". Alex From machin_john_888 at hotmail.com Mon Jul 16 01:24:42 2001 From: machin_john_888 at hotmail.com (John Machin) Date: 15 Jul 2001 22:24:42 -0700 Subject: re Challenge: More Compact? References: <mailman.995247446.16415.python-list@python.org> Message-ID: <92ae279c.0107152124.4c049d5e@posting.google.com> "Tim Peters" <tim.one at home.com> wrote in message news:<mailman.995247446.16415.python-list at python.org>... > BTW, does it bother anyone that all of these solutions accept an IP ending > with a newline? > > regexps-are-surprising-ly y'rs - tim Straight out of the horse's mouth at http://python.sourceforge.net/devel-docs/lib/re-syntax.html (this is in section 4.2.1 of the Python Library Reference): <quote> "$" Matches the end of the string, and in MULTILINE mode also matches before a newline. foo matches both 'foo' and 'foobar', while the regular expression foo$ matches only 'foo'. </quote> But the real story only emerges two pages later (in section 4.2.3): <quote> M MULTILINE When specified, the pattern character "^" matches at the beginning of the string and at the beginning of each line (immediately following each newline); and the pattern character "$" matches at the end of the string and at the end of each line (immediately preceding each newline). By default, "^" matches only at the beginning of the string, and "$" only at the end of the string and immediately before the newline (if any) at the end of the string. </quote> I shall enter a bug report and leave it up to the powers_that_be to decide whether to change the behaviour or section 4.2.1 of the documentation. To answer Tim's question, yes it bothers me ... the solution of course always when you want to validate that the pattern matches the whole string (and not some leading substring) is to have \Z at the end of your pattern (not $). From wesc at deirdre.org Wed Jul 11 04:53:06 2001 From: wesc at deirdre.org (Wesley Chun) Date: Wed, 11 Jul 2001 01:53:06 -0700 (PDT) Subject: Any detailed tutor for python multi-thread programming? In-Reply-To: <Pine.LNX.4.31.0107110140340.5606-100000@emperor.deirdre.org> Message-ID: <Pine.LNX.4.31.0107110151550.5606-100000@emperor.deirdre.org> Eeek... the subject line got lost! Sorry for the duplicatation!! -wesley On Wed, 11 Jul 2001, Wesley Chun wrote: > Bill Bell wrote: > > > Xia Ziao-Qin wrote: > >> Hi, everybody, is there any detailed tutor for python multi-thread > >> programming? > > > > Some places to read about Python threads: > > http://starship.python.net/crew/aahz/IPC9/index.html chapter in Wesley > > Chun's "core Python" book (available via > > http://starship.python.net/crew/wesc/cpp/book/) articles in the help > > file for wxPython (http://www.wxpython.org) > > > > Enjoy. > > > Specifically for Core Python Programming, Chapter 17 is > devoted completely to multithreaded programming in Python. > > There is an introduction/motivation section first, followed > by a "process vs. threads" discussion, then talk about what > Python's thread model is, and then we go into a deep discus- > sion on how to use threads properly in Python. > > Throughout the chapter, we use one simple example and expand > on it as our knowledge of Python threading grows. The basics > are covered with the 'thread' module first, then we explain > why this isn't as useful or safe as the higher-level thread > support provided by the 'threading' module. After showing > you the 3 basic ways to create threads using the > threading.Thread class, we conclude the chapter with a more > complex example using the 'Queue' module. > > The link above just leads you to the chapter's code samples. > > Hope this helps! > > -wesley > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > Silicon Valley-SF Bay Area Python users group: http://baypiggies.org > > "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 tim.one at home.com Sun Jul 8 17:09:25 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 8 Jul 2001 17:09:25 -0400 Subject: Confusion about dictionaries - keys use value or identity? In-Reply-To: <roy-58C72C.12353708072001@news1.panix.com> Message-ID: <LNBBLJKPBEHFEDALKOLCMEBDKNAA.tim.one@home.com> [Roy Smith, contemplating dicts indexed by strings] > ... > Is there a way to force the comparison to be by identity? Not short of building a wrapper object that defines __cmp__ in terms of id() results (Paul's suggestion does that implicitly). An extreme variant is to pass every string thru the intern() function first (see the docs); that's "extreme" because intern'ed strings are immortal. > I'm contemplating building a cache (using a dictionary), and key > comparison by identity should be significantly faster than by > value, because I'm going to be using rather long strings as keys. That can't be determined without trying it both ways and measuring; the dict and string implementations are chock full o' subtleties. BTW, if you want, say, "aa" not to be the same key as "a"+"a", in what sense is this dict indexed by strings? That is, it's unclear what strings have to do with this. From slinkp23 at yahoo.com Tue Jul 10 11:21:01 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Tue, 10 Jul 2001 15:21:01 GMT Subject: Language Shootout References: <mailman.994742356.29669.python-list@python.org> Message-ID: <3B4B1BE7.1483F292@yahoo.com> Tim Peters wrote: > Apart from tricks specific to Fibonacci numbers, a general "good thing to > know" is that an order-N linear recurrence can be viewed as mapping > N-vectors to N-vectors via multiplication by a fixed NxN matrix M. N==2 in > this case, and if a,b,c are consecutive Fibonacci numbers then > > [b c] = [a b] * M > > where "*" is matmult and M is > > 0 1 > 1 1 For the mathematically challenged, what is matmult? Pointer to a FM to R would be fine. Thanks, PW -- ................... paul winkler .................... custom calendars & printing: http://www.calendargalaxy.com A member of ARMS: http://www.reacharms.com home page: http://www.slinkp.com From tjreedy at home.com Mon Jul 23 16:02:08 2001 From: tjreedy at home.com (Terry Reedy) Date: Mon, 23 Jul 2001 20:02:08 GMT Subject: A use for integer quotients References: <3B5BC73B.2D52E5E2@alcyone.com>, <3B5BA29B.E08FEEE9@alcyone.com>, <yCK67.17615$EP6.4467503@news1.rdc2.pa.home.com> <mailman.995860718.9550.python-list@python.org> <mailman.995862939.15013.python-list@python.org> <mailman.995883879.12071.python-list@python.org> <3B5C5665.8D41D1F1@tundraware.com> Message-ID: <4p%67.20546$EP6.5090891@news1.rdc2.pa.home.com> "> - If anything, the new // operator ought to apply to new behavior, not be > foisted upon existing code. If people desparately want integer division to > return floating point results, then the onus should be on them to use a > new operator. The PEP proposal is to separate the current mixed meaning of / into two new, unmixed meanings, one assigned to / and the other to //. The alternative suggested above and by others is not merely to switch meanings but to keep the mixed meaning while adding one and only one unmixed meaning. It does not break code but has other problems. From OlafMeding at noSpam.CompuServe.com Wed Jul 25 13:35:06 2001 From: OlafMeding at noSpam.CompuServe.com (Olaf Meding) Date: Wed, 25 Jul 2001 12:35:06 -0500 Subject: Auto Building MS VC6 Projects Message-ID: <9jn00e$j8g$1@news.chorus.net> Microsoft Visual C++ can be automated (COM, OLE) and I would like to use Python to automate nightly VC6 builds. Has anyone does this and is willing/able to share ideas or code? Is there any documenation on this somewhere? Olaf TomoTherapy Please remove "noSpam" to get my email address From roy at panix.com Thu Jul 12 22:23:07 2001 From: roy at panix.com (Roy Smith) Date: Thu, 12 Jul 2001 22:23:07 -0400 Subject: Comparison of different types does not throw exception References: <mailman.994953783.6278.python-list@python.org> <cphewh37av.fsf@cj20424-a.reston1.va.home.com> Message-ID: <roy-512CF3.22230712072001@news1.panix.com> Guido van Rossum <guido at python.org> wrote: > I haven't heard a peep from anyone who was bitten by the change in 2.1 > where we disallow "<" etc. for complex numbers. Although I guess it doesn't strictly make sense, I would assume a "<" operator applied to complex numbers would compare magnitudes. The problem with that, I suppose, is that "<", "==", and ">" would not cover the entire space of value pairs. > But then if we removed complex numbers, most folks wouldn't notice anyway I must admit, I've never actually written any python code which uses complex numbers, but I still think their inclusion as a fundamental data type is one of the real (!) cool things about the language, and would lament their loss. Takes me back to my fortran days, when I really did write that kind of code. It is especially awesome that python uses the "correct" imaginary unit of j. None of that i garbage the math weenies try to foist on us. "We're sorry, you have reached an imaginary extension. Please rotate your telephone 90 degrees and try your number again". From claird at starbase.neosoft.com Tue Jul 31 10:42:41 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 31 Jul 2001 09:42:41 -0500 Subject: Long: Python Is Really Middleware References: <3B667EBA.DA6C298@tundraware.com> Message-ID: <7D14D8CD61D19D74.5FA2D6F03A40B5FE.61BCD22CB6B984EC@lp.airnews.net> In article <3B667EBA.DA6C298 at tundraware.com>, Tim Daneliuk <tundra at tundraware.com> wrote: . . . >There has been an ongoing discussion about how Python, C, and >many other languages relevance as "systems" languages >here (comp.lang.python) recently. This started as a brief (Ha!) . . . Well, *that* narrows it down to sometime between 1992 and 2001. . . . > lifting. Crack some part of these two problems - and Python > is ideal for both, so long as the performance issues don't > get in the way - and you'll live Happily Ever After - or until > the CTO starts losing at golf and needs another "win". One of the happy Python features that your expo- sition didn't mention is that most Python performance issues are correctable. That is, if a pure Python XML parser is too slow (and it is, and will be--that's an issue with me), Python's facility for extension makes it feas- ible to "drop down" to C for a module. . . . -- Cameron Laird <claird at NeoSoft.com> Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From thomas at xs4all.net Tue Jul 10 06:40:53 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 10 Jul 2001 12:40:53 +0200 Subject: os.nice (or docs) BUG? In-Reply-To: <Pine.LNX.4.21.BCL.0107101425140.1573-100000@suzi.com.onego.ru> Message-ID: <20010710124053.G32419@xs4all.nl> On Tue, Jul 10, 2001 at 02:29:15PM +0400, Roman Suzi wrote: > On Tue, 10 Jul 2001, Thomas Wouters wrote: > > Yes, I guess it would. Care to submit a patch ? :-) > Not before I undestand Python's C API... It's dead easy, just look at posixmodule, and how, for instance, posix_nice is implemented. It's very straightforward, and a good excuse to learn it :) -- Thomas Wouters <thomas at xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From jerk at 163.net Mon Jul 9 03:46:42 2001 From: jerk at 163.net (jerk@163) Date: Mon, 9 Jul 2001 15:46:42 +0800 Subject: python startup memory size and memory leak In-Reply-To: <117483633808.20010709094309@163.net> References: <117483633808.20010709094309@163.net> Message-ID: <18317708433.20010709154642@163.net> Hello jerk, Monday, July 09, 2001, 9:43:09 AM, you wrote: j1> Hello python-list, j1> my app is a server that receive client's request in xml and query the mysql j1> database to response to client,I use python 2.0 on linux(2.2.13),with expat 1.95 j1> statically link into python and MySQLdb 0.3.5,as I am not so familary with xml j1> so I didn't call unlink() on those created xml document before they are j1> deleted,this is definitely a leak,right? j1> but this leak may show different behavior with different startup j1> environment.if all py is compiled into pyc and then start my app,top shows j1> that it takes about 2.8M memory at first,as client requests comes,memory goes up j1> very fast.then if I touch one of those py files and start my app again,top shows j1> that it takes about 5M memory at first,as client requests comes,memory goes up j1> very slow(althought it still leaking). j1> I don't know why python startup size is different when I just touching j1> one of those py files but seems it related to python compilation. there is one more different behavior in two different startup environment,there is a readline() call on a socket which will block when no data send to server,with 2.8M memory startup python when I ctrl-C when readline is waiting for input,instead of catching the keyboardInterrupt,python seg fault with just one message "Python Fatal Error, Interpreter not initialized( version mismatch)",but with the 5M memory startup python,it just catch the keyboardInterrupt and exit normally j1> Best regards, j1> jerk mailto:jerk at 163.net Best regards, My ICQ Number is:41597368 jerk mailto:jerk at 163.net From guido at zope.com Tue Jul 31 23:26:35 2001 From: guido at zope.com (Guido van Rossum) Date: Tue, 31 Jul 2001 23:26:35 -0400 Subject: Generator Comprehensions? was Re: a break for comprehensions In-Reply-To: Your message of "Tue, 31 Jul 2001 15:50:41 PDT." <010f01c11a13$3a930920$6501a8c0@pacbell.net> References: <3B66FFEC.5335E1C8@destiny.com> <3B670BB3.48D4A5A5@ActiveState.com> <010f01c11a13$3a930920$6501a8c0@pacbell.net> Message-ID: <200108010326.XAA18273@cj20424-a.reston1.va.home.com> > > How about if we combine your ideas: > > > > y = [yield x*2 for x in g()] > > Geeze, that's like, way obvious. Why didn't I say that in the first place? > Good stuff is always way obvious. Nice one Paul :-) > > What do you think Guido? => CVS? I don't think so. Generators are most useful when they do more than iterate over a pre-existing sequence, so I doubt that this would be a common pattern. Also I'm not sure I like overloading of the [...] brackets, which (to me) very strongly say "real concrete list here". --Guido van Rossum (home page: http://www.python.org/~guido/) From frdelarue2000 at yahoo.fr Thu Jul 26 03:42:21 2001 From: frdelarue2000 at yahoo.fr (=?iso-8859-1?q?franck=20delarue?=) Date: Thu, 26 Jul 2001 09:42:21 +0200 (CEST) Subject: ftp delete Message-ID: <20010726074221.92300.qmail@web14809.mail.yahoo.com> hi, I use python 2 on linux with the ftp lib. I have a cron that get a big file by ftp connection. After geting that file, I try to delete it ("ftp.delete(nameFile)") but an error occurs : "socket.error: (104, 'Connection reset by peer') ". Is it due to the ftp module of python ? Is it due only to the ftp connection ? What can I do ? Thanks a lot. ===== __________________________________ ___ \ \ | _ | \ \ F R A N C K D E L A R U E \ | |_ | | | / + - + - + - + - + - + - + / | _ | | | /_________________________________/ |_| |__/ ___________________________________________________________ Do You Yahoo!? -- Vos albums photos en ligne, Yahoo! Photos : http://fr.photos.yahoo.com From phd at phd.fep.ru Mon Jul 9 04:16:21 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Mon, 9 Jul 2001 12:16:21 +0400 (MSD) Subject: Integrating SimpleHTTPServer into asyncore In-Reply-To: <3B491961.12A83FE5@alcyone.com> Message-ID: <Pine.LNX.4.33.0107091216090.26783-100000@phd.fep.ru> On Sun, 8 Jul 2001, Erik Max Francis wrote: > Is there a standard way to integrate SimpleHTTPServer (and related > classes) into the asyncore poll loop, or is it just the rather obvious > process of creating a dispatcher that containers a SimpleHTTPServer and > delegates all the relevant asyncore methods to SimpleHTTPServer? http://sourceforge.net/projects/asynchttp/ Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From nas at python.ca Mon Jul 16 18:12:19 2001 From: nas at python.ca (Neil Schemenauer) Date: Mon, 16 Jul 2001 15:12:19 -0700 Subject: memory leak with dynamically defined functions? In-Reply-To: <15187.23983.562368.858629@beluga.mojam.com>; from skip@pobox.com on Mon, Jul 16, 2001 at 04:33:35PM -0500 References: <E15MEox-0004xG-00@imp.mad-scientist.com> <15187.23983.562368.858629@beluga.mojam.com> Message-ID: <20010716151219.A30652@glacier.fnational.com> Skip Montanaro wrote: > zooko> But if I allocate memory and store a reference to it in a default > zooko> argument to an inner function, like this: > > >>> def silliest_func(): > >>> x = [0] * (2**10) > >>> def inner_silliest_func(x=x): > >>> pass > >>> return inner_silliest_func > >>> > >>> blarg = {} > >>> for i in range(2**13): > >>> blarg[i] = silliest_func() > > zooko> and then remove the references to this memory, like this: > > >>> del blarg > > zooko> none of the memory is freed up! If I do this: while 1: blarg = {} for i in range(2**13): blarg[i] = silliest_func() the Python process size seems to remain constant. Are you sure this leaks memory? I'm testing with Python 1.5.2 BTW. Neil From paul at boddie.net Tue Jul 10 12:01:04 2001 From: paul at boddie.net (Paul Boddie) Date: 10 Jul 2001 09:01:04 -0700 Subject: Postgres support References: <gul1kts5l6aolk55o7vguk97uorjd08j9f@4ax.com> <5174eed0.0107061058.5446dac9@posting.google.com> <9i6vm3073b@enews3.newsguy.com> <3B4719E1.C5540B19@wwc.com> <9i7t0k01add@enews3.newsguy.com> <3B47C125.A65E5EAC@wwc.com> Message-ID: <23891c90.0107100801.14066af0@posting.google.com> Steve Williams <stevewilliams at wwc.com> wrote in message news:<3B47C125.A65E5EAC at wwc.com>... > Alex Martelli wrote: > > > Interbase has always taken SQL92 seriously, but nobody takes Interbase > > seriously. > > Nevertheless, I've managed to survive and prosper on a meager toolkit of > (Select, Insert, Delete, Update, Create, Drop, etc) on SQL-Server, Sybase, > Informix, DB2, and Oracle. If I'm not fastidious, I can even get by with it > in ACCESS. How do you manage to do different types of joins? Do any of the systems you mention use the explicit join syntax, for example? What about the statement parameter (bind variable) syntax? > > But most likely the usual crybabies will still be crying about "RAW" (sic) > > C-level interfacing (to a zillion incompatible proprietary idiotic API's, no > > doubt -- the fact that there IS a solid, well-developed standard doesn't > > count:-). So, naah, not worth the bother. > > I take no notice of that remark. Do you have an opinion on Corba? Which standard are we talking about now? ADO and COM aren't exactly there on most flavours of UNIX, if at all. Of course, there's always ODBC. ;-) Paul From peter at engcorp.com Thu Jul 26 20:20:37 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 26 Jul 2001 20:20:37 -0400 Subject: PEP 238 (revised) References: <cp4rrz5onj.fsf@cj20424-a.reston1.va.home.com> Message-ID: <3B60B3D5.664A3D7F@engcorp.com> Guido van Rossum wrote: > > Here's a completely revised version of PEP 238. [...] > Command Line Option > > The -D command line option takes a string argument that can take > three values: "old", "warn", or "new". The default is "old" in > Python 2.2 but will change to "warn" in later 2.x versions. The > "old" value means the classic division operator acts as described. > The "warn" value means the classic division operator issues a > warning (a DeprecatinWarning using the standard warning framework) > when applied to ints or longs. The "new" value changes the > default globally so that the / operator is always interpreted as > true division. The choice of command line options is inconsistent with the terminology used elsewhere in the updated PEP. To further reduce the potential for confusion, I suggest changing "old" and "new" to "classic" and "true". If that suggestion is accepted, "warn" might be better spelled more like "classic-warn". -- The updated PEP also makes no mention of a utility for scanning existing code to check for potential problems. Is this considered an intractable problem? Is there any commitment to doing this, eventually, as part of the implementation of this PEP? Or is the presence of the "warn" option considered sufficient (to allow for testing, rather than scanning)? -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From nospam at bigfoot.com Tue Jul 31 15:09:57 2001 From: nospam at bigfoot.com (Gillou) Date: Tue, 31 Jul 2001 21:09:57 +0200 Subject: Is Python a Good Choice for Web Programming? References: <9k6osc$jgp$1@slb7.atl.mindspring.net> Message-ID: <9k6vg2$1o84$1@norfair.nerim.net> Ted, There are lots of ways to web with Python, including "pythonic" servlets and JSP like stuffs. Follow this link to have a (non exhaustive) list. http://starbase.neosoft.com/~claird/comp.lang.python/web_python.html I have approximately the same skills in Python and Java and I'm sure I do the jobs twice faster in Python than in Java. And I don't remember having done something in Java that cannot be done in Python. Unfortunately, IT executives are addicted to marketing messages of Sun, Microsoft and others. And do not even consider that something else exists that's free, easy, secure. In addition, I don't think that BeOpen will offer triple star restaurants or weekends in Tunisia to their best customers. So, keep skilled in Java/JSP and Microsoft VBS/ASP technologies if you want a good job, and use Python when it fits and if you're free to choose the language. In France, less than 1% of IT jobs require Python or Zope skills. --Gillou "tszeto" <tszeto at mindspring.com> a ?crit dans le message news: 9k6osc$jgp$1 at slb7.atl.mindspring.net... > Hello, > > I don't know Python, but I know a little Java (little more than a years > worth working with Servlets and JSP). > > How is Python compared to Servlets and JSP? The language looks very nice, > but I'm hesitating because I don't see many jobs for Python and even less > for Zope. > > Is is better to use Zope or just go with cgi/mod_python? > > Thanks, > Ted > > > From ajm at enteract.com Thu Jul 5 18:06:24 2001 From: ajm at enteract.com (Alan Miller) Date: Thu, 5 Jul 2001 17:06:24 -0500 Subject: a gadfly SQL question --- table creation References: <n237ktc10fithjhm8vj4pfkmrq7k4fjop8@4ax.com> <Xns90D5704F23F1Catodddexterpinioncom@203.2.194.51> <qlk7kto6lcqqsm2dslsmvrp5eeu3bhpdf7@4ax.com> Message-ID: <MPG.15aea0cce4147d279897de@news-enteract> Joe Potter (jm7potter at hotmail.com) wrote: >On Thu, 05 Jul 2001 00:55:36 GMT, andy_todd at spam.free.yahoo.com (Andy Todd) wrote: >>SQL is a set based language. It is not a procedural (or OO) language and >>the most important aspect of this is that *order does not matter*. With set >>based operations (ie DML or DDL in SQL - is that enough TLAs ;-) you >>specify what you want to happen, not how to do it (with suitable exceptions >>for implementation specific hints, but that doesn't matter to use here). > >Even the tables! My God! Many databases store information in hidden internal tables that are identical in structure to the tables that are visible. After all, if you need to store information in a database, why not use the one that you already have? ajm From mal at lemburg.com Sat Jul 14 14:41:30 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Sat, 14 Jul 2001 20:41:30 +0200 Subject: DB-API 1.0 vs. 2.0 References: <AjW37.9662$e5.1281275@newsb.telia.net> <3B507210.AF4C1D1C@lemburg.com> Message-ID: <3B50925A.FA7F53A9@lemburg.com> "M.-A. Lemburg" wrote: > > Fredrik Lundh wrote: > > > > DB-API 1.0 (dated April 9, 1996) specifies that a connection object > > should provide "all Cursor Object attributes and methods". > > > > this requirement seems to have been dropped in the (undated) > > DB-API 2.0 specification -- but this fairly major change isn't listed > > under "Major Changes from Version 1.0 to Version 2.0"... > > > > what's the deal here? should a 2.0 implementation provide an > > implicit cursor, or not? > > It can, but is not required to. > The deal is: explicit is better than implict :-) BTW, you might want to join the DB-SIG mailing list if you're interested in the API spec and writing database API compliant modules: http://www.python.org/sigs/db-sig/ -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From tdelaney at avaya.com Thu Jul 19 20:22:22 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Fri, 20 Jul 2001 10:22:22 +1000 Subject: Language change and code breaks Message-ID: <B43D149A9AB2D411971300B0D03D7E8B0FC2BE@natasha.auslabs.avaya.com> > > begINNiNG with A lOwER caSE LettER CaN NO LongeR Be usED. > > Very funny (not). You misunderstood the intention. The programming > environment should be case-preserving, and automatically correct > identifiers to use the same case as used when they were defined. However, this *does* rely on the tools to do the case-preservation. I use a text editor for just about all my programming. The one I happen to like most is unable to warn me about inconsistent-case. Yes - it can be caught at compile-time ... Except (and here comes the meat of my argument against this) ... a = 1 def f() A = 2 print a What should happen here? Should there be a compile-time error? Does this mean that I can't have a local variable with the same name as a global variable, but differing only in case? But the following code is legal ... a = 1 def f() a = 2 print a What happens if I do 'from something import *' (no, I don't actually do that, but a lot of code does) and it imports into my global namespace a bunch of names which conflict with names in my functions *only in case*? Suddely my code breaks for no apparent reason. I think introducing this would be *very* dangerous. Tim Delaney From kamikaze at kuoi.asui.uidaho.edu Fri Jul 20 17:43:50 2001 From: kamikaze at kuoi.asui.uidaho.edu (Mark 'Kamikaze' Hughes) Date: 20 Jul 2001 21:43:50 GMT Subject: Case insensitivity References: <mailman.995506711.21636.python-list@python.org> <cpvgkofyru.fsf@cj20424-a.reston1.va.home.com> Message-ID: <slrn9lh9gm.1ah.kamikaze@kuoi.asui.uidaho.edu> Thu, 19 Jul 2001 20:30:15 GMT in <cpvgkofyru.fsf at cj20424-a.reston1.va.home.com>, Guido van Rossum <guido at python.org> spake: > Unfortunately there isn't a lot of scientific evidence to help decide > this. There may be old reports that case-sensitivity hurts beginners. > I know that many other designers of programming languages aimed at > non-programmers have consciously choses case-insensitivity > (e.g. hypertalk, REXX). I used to program in REXX, and you very quickly develop the habit of working entirely in lowercase so you don't mix up identifiers (you only try to debug that problem *once*, because it's so painful). Other than that, it didn't interfere with development at all. In software consulting, I also wrote a lot of code that integrated with OS/2 DLLs; you could write a library of common low-level tools and then use a REXX program to control everything. I did a lot of contracts in a few thousand lines of REXX and my standard C DLLs. In my hobby time, I wrote multi-thousand-line REXX applications like <http://kuoi.asui.uidaho.edu/~kamikaze/nwo.html> - the standard CircleMUD world file format is just unspeakably nasty (bitfields! Magic numbers! Augh!), so I wrote a parser for a nicer file format. While it's anecdotal evidence, I'd say case-insensitive coding is mostly harmless at worst, and *possibly* beneficial, even to professional programmers. > To me, the only real important question is, how can we introduce > case-sensitivity for novices without breaking the millions of lines of > existing Python code. One option could be: forget it, it's too late. > Another: put the case-insensitivity in the tools. A directive at the top of the module would probably satisfy everyone. The beginners would have to type one line of "nonsense computer stuff", and then could work case-insensitively. Current code, lacking that directive, would still work case-sensitively. -- <a href="http://kuoi.asui.uidaho.edu/~kamikaze/"> Mark Hughes </a> "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 jblazi at hotmail.com Tue Jul 24 12:57:37 2001 From: jblazi at hotmail.com (Janos Blazi) Date: Tue, 24 Jul 2001 18:57:37 +0200 Subject: Opening a file with Python References: <3b5be641_3@news.newsgroups.com> <9jhgm4$2mo$1@mtc1.mtcnet.net> <3b5d8947_5@news.newsgroups.com> <nzh77.543721$eK2.114049226@news4.rdc1.on.home.com> Message-ID: <3b5da934_2@news.newsgroups.com> Yes, thx. Can you tell me the difference between python.exe and pythonw.exe? And later I am going to use Tkinter in my program. Shall I need python.exe or pytjonw.exe? J.B. "Nick Perkins" <nperkins7 at home.com> schrieb im Newsbeitrag news:nzh77.543721$eK2.114049226 at news4.rdc1.on.home.com... > I have this associated with .py -> Open > > C:\Python21\python.exe "%1" %* > > and > C:\Python21\pythonw.exe "%1" %* > for .pyw > > ..using python.exe instead of pythonw.exe will give you > a dos window which will show any error messages > ( but it closes before you can read them -- very annoying ) > > > > "Janos Blazi" <jblazi at hotmail.com> wrote in message > news:3b5d8947_5 at news.newsgroups.com... > > Thx. > > Most unfortunately, this does not work. If I omit the double quotes it > seems > > that the file is not opened correctly (I am usinf pythonw.exe instead of > > winpy.exe as i do not have the latter). If I set the double quotes, I > cannot > > enter my program as i get the error message 'the application you have > > selected does not exist'. > > > > Janos Blazi > > > > "Kevin Riggle" <vj$ri^gg#guess#l55e at mt$*guess#&cn1e#t.!@n()et> schrieb im > > Newsbeitrag news:9jhgm4$2mo$1 at mtc1.mtcnet.net... > > > You have to associate the file-type with the program. > > > > > > Open up My Computer, click View...Folder Options, select the File Types > > tab, > > > and click on New Type. > > > > > > Fill in the description and extension you want to use, then click on the > > New > > > button beneath the Actions: list box. > > > > > > Fill in the Action Name (probably Open), and set 'Application used to > > > perform action:' to > > > > > > "c:\Program Files\MyPyProg\mypyprog.exe %1" if using py2exe, > > > > > > or "c:\Program Files\WinPy\winpy.exe c:\Program > Files\MyPyProg\mypyprog.py > > > %1", > > > > > > in both examples *including* the double-quotes. > > > > > > (I haven't actually used Python on Windows, so if the WinPy path is a > > little > > > off please forgive me.) > > > > > > Hope this helps... Kevin > > > > > > > > > "Janos Blazi" <jblazi at hotmail.com> wrote in message > > > news:3b5be641_3 at news.newsgroups.com... > > > > I'd like to write a Python program that starts when the user double > > clicks > > > > on a file name (in Win2K). I should be able to read the name of the > > file. > > > > What have I to do? > > > > This question has probably been asked many times, sorry. > > > > > > > > Janos Blazi > > > > > > > > > > > > > > > > > > > > -----= 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! =----- > > -----= 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 greg at electricrain.com Thu Jul 5 18:20:05 2001 From: greg at electricrain.com (Gregory P. Smith) Date: Thu, 5 Jul 2001 15:20:05 -0700 Subject: Getting data from DBIII In-Reply-To: <3B41CEFD.3BDB4F63@nettonettech.com>; from dpoulin@nettonettech.com on Tue, Jul 03, 2001 at 12:52:56PM +0000 References: <3B41CEFD.3BDB4F63@nettonettech.com> Message-ID: <20010705152005.A13982@zot.electricrain.com> > Anyway, our Sales people use ACT! for contact management. I have > created a small Python/Tkinter, so I got the forms looking pretty. But > I am having trouble using Python to get the data from the DB. ACT uses > DB3, so I'm looking for pointers. I use Linux (RedHat 7.0) and Python > 1.5.2. > > Any help? If you mean BerkeleyDB 3.x, see http://pybsddb.sourceforge.net/ From slinkp23 at yahoo.com Mon Jul 9 14:31:53 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Mon, 09 Jul 2001 18:31:53 GMT Subject: Language Shootout References: <mailman.994689198.3317.python-list@python.org> Message-ID: <3B49F724.1F3DF6B3@yahoo.com> Roman Suzi wrote: > One more point about shootout. If I understood correctly, advanced > features are banned. Not only that, but a number of the tests are explicitly testing how the languages fare at doing a task "The Same Way". The site made a lot more sense to me once I noticed that. For example, http://www.bagley.org/~doug/shootout/bench/fibo/ doesn't just compute fibonacci numbers; the implementation must be *recursive*. So this is really a test of how the languages fare at recursion. In python, there's usually a more idiomatic way to solve a problem. In this case, if all you really wanted was to compute fibonacci numbers, recursion is not the best approach; performance degrades exponentially with the size of the series. Doing it iteratively is much, much faster. So basically what that benchmark tells me is: "Don't write recursively in Python if performance is an issue". -- ................... paul winkler .................... custom calendars & printing: http://www.calendargalaxy.com A member of ARMS: http://www.reacharms.com home page: http://www.slinkp.com From rcena at epcor.ca Sat Jul 7 17:17:15 2001 From: rcena at epcor.ca (Resty Cena) Date: 7 Jul 2001 14:17:15 -0700 Subject: Is Python Dead? References: <MNS%6.355$Xs4.225014@news.pacbell.net> <458b194a.0107050711.72007607@posting.google.com> <TH%07.3499$i8.339613@e420r-atl3.usenetserver.com> <458b194a.0107060959.6bd34b3f@posting.google.com> <7sn17.7740$i8.679052@e420r-atl3.usenetserver.com> Message-ID: <458b194a.0107071317.508ef7e4@posting.google.com> I'll follow your leads. Thanks again. By the way, someone should rename this thread "Is Python Dead? Long Live Python!" or some such. "Steve Holden" <sholden at holdenweb.com> wrote in message news:<7sn17.7740$i8.679052 at e420r-atl3.usenetserver.com>... > "Resty Cena" <rcena at epcor.ca> wrote ... > > Well thank you for jolting me out of my comfortable position sitting > > with my hands tucked between my pants and the chair. I donwloaded > > cx_Oracle and, yes, it's up. Now, would you happen to have, or know > > of, some materials (sample code, tips, tricks, techniques, tutorials) > > on getting started on programming *forms* based applications in Oracle > > and Python? That would be just great. > > > Well done! Hope the install went OK ;-). I presume you are talking about > GUI-based programs using Oracle rather than Oracle Forms stuff? There is > some coverage in Hammond & Robinson's Programming Win32 in Python book, for > a start. Other people speak highly of Grayson's Python and Tkinter > programming, though it isn't my cup of tea. I'm not currently aware of > anything drag-and-drop which includes database awareness, but Boa > Constructor and BlackAdder GUI tools both have theie adherents. > > Since you've taken the effort to get started I am reasonably sure that the > c.l.py GUI community will be out in force to help you (right, guys?) - > you've probably seen the regular threads on "Which GUI is the best" and > realise there's a choice. > > I am currently working on a simple web-based framework for data editing, > which I plan to translate to one or other of the available GUIs, but that's > currently on the horizon. It will be open source when it's finished. > > regards > Steve From anamax at earthlink.net Mon Jul 2 12:28:00 2001 From: anamax at earthlink.net (Andy Freeman) Date: 2 Jul 2001 09:28:00 -0700 Subject: Is this a true statement: Part II References: <9hiifr$sjs$1@taliesin.netcom.net.uk> <mailman.993843346.4433.python-list@python.org> <fFD%6.19908$zT1.1099537@e420r-atl3.usenetserver.com> Message-ID: <8bbd9ac3.0107020827.18c8ad8e@posting.google.com> > >You could write an operating system that could only be directly > >programmed in Python. > > I'm not sure how. Nobody has yet come up with an operating system that > could only be directly programmed in C, or Lisp, or Algol, or Java, > despite implementing operating systems in all four. Symbol seems to qualify. (The compiler was in hardware....) However, that level of theoretically pure "only" ignores systems where the only reasonable way to program the OS is in some "high level" language, and the vastly more popular systems where the only reasonable way to do most things in the OS is in some "high level" language. After all, the fact that one can drive nails with a socket wrench doesn't make it useful exercise. -andy From sholden at holdenweb.com Fri Jul 6 13:40:18 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 6 Jul 2001 13:40:18 -0400 Subject: Comment on PEP-0238 References: <mailman.994427714.26169.python-list@python.org> <cpsngaja4g.fsf@cj20424-a.reston1.va.home.com> Message-ID: <gIm17.7341$i8.668552@e420r-atl3.usenetserver.com> "Guido van Rossum" <guido at python.org> wrote ... > > The warning framework and the future statement are there to make the > transition easier. Here's my plan, "new division in four phases": > > 1. First we introduce a new function div() and a future statement that > makes integer division return a float result for a specific module. > > 2. In a following revision, we add a warning when / is used on two int > or long arguments, recommending to use div() instead. (It is > important not to start warning in phase 1, so folks have time to > switch to div() voluntarily first; maybe phase 1 could have a > command line option to warn about integer division.) > > 3. A revision later, we change all plain integer divisions to be an > error, *forcing* folks to use div() or use the future statement to > specify floating point division. > > 4. Finally we can implement the "future" behavior by default. > This seems a reasonable approach. > I haven't picked dates yet; if folks agree, I would like to add div() > and a future statement to 2.2 and space the other steps a single > revision apart, so phase 4 would be at Python 2.5 (April 2003, if we > keep the current release schedule up). Is that too aggressive? > If you're going to do it, you might as well make a start. Almost two years before something breaks should be good enough for most organizations. > I currently favor div(x, y) over x//y and x div y. Maybe also add > mod(x, y) for symmetry (that would also explain divmod() as a > messenger from the future :-). > That seems sensible. > I'm not sure how to spell the future statement. Here are some > choices: > > from __future__ import float_division > from __future__ import real_division > from __future__ import new_division > from __future__ import division > > --Guido van Rossum (home page: http://www.python.org/~guido/) from __future__ import unified_field_theory from __future__ import unified_division regards Steve -- http://www.holdenweb.com/ From doug_bartholomew99 at yahoo.com Mon Jul 16 22:07:14 2001 From: doug_bartholomew99 at yahoo.com (doug) Date: 16 Jul 2001 19:07:14 -0700 Subject: newbie question: what does "<...>" or "<input>" signify? Message-ID: <e71960c5.0107161807.5fe749eb@posting.google.com> i am new to python and i have seen references in its documentation and code to name strings with greater-than and less-than signs, such as filename="<input>". i have looked high and low for an explanation of what a string with < and > on both ends means, but have found none. can someone give me a reference to some resource that explains why some strings need < and > around them. Thanks. doug (doug_bartholomew99 at yahoo.com) From gs at styrax.com Fri Jul 13 13:51:36 2001 From: gs at styrax.com (Garry Steedman) Date: Fri, 13 Jul 2001 17:51:36 +0000 Subject: Book count test In-Reply-To: <E566B020833BD311B6610008C791A39705CA5242@il93exm04.css.mot.com> Message-ID: <3B4F3528.8871.56F6E9AD@localhost> Randy, are you trying to prove to us that quantity = quality? the fact that python emits less CO2 than java means we dont have to kill the trees! ;-) garry On 13 Jul 2001, at 11:22, Kemp Randy-W18971 wrote: From: Kemp Randy-W18971 <Randy.L.Kemp at motorola.com> To: "'python-list at python.org'" <python-list at python.org> Subject: Book count test Date sent: Fri, 13 Jul 2001 11:22:16 -0400 > I went to www.amazon.com and counted the number of books in these > categories > Python - 136 (including snake books) > Java - 1621 > Perl - 430 > C++ - 1341 > PHP - 38 > ASP - 172 > Oracle - 682 > > > -- > 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 dougfort at dougfort.net Thu Jul 5 09:05:20 2001 From: dougfort at dougfort.net (Doug Fort) Date: 5 Jul 2001 14:05:20 +0100 Subject: pausing a thread References: <3d8d3c0.0107050135.ff84ead@posting.google.com> Message-ID: <3b44660f_2@news5.uncensored-news.com> Daniel Nuriyev wrote: > Hello > This is a Java programmer's question > How do you say: > class QQQ extends Thread{ > public void run(){ > ... > sleep(ms); > } > } > in Python? Thank you all. > I have a little pattern, or idiom that I use on many threads. I like to wait on the threading 'Event' object rather than the 'sleep' timer, because it gives me the ability to break out without waiting for the full interval. import threading class QQQ(threading.Thread): def __init__(self): threading.Thread.__init__(self, name="QQQ") self._stopevent = threading.Event() def run(self): while not self._stopevent.isSet(): # do some stuff self._stopevent.wait( s ) def join(self, timeout=0.0): self._stopevent.set() threading.Thread.join(self, timeout) -- Doug Fort <dougfort at dougfort.net> 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 cer at tutopia.com Mon Jul 2 01:26:28 2001 From: cer at tutopia.com (Cristian Echeverria) Date: Mon, 2 Jul 2001 01:26:28 -0400 Subject: Is Python Dead? References: <MNS%6.355$Xs4.225014@news.pacbell.net> Message-ID: <9hp08v$f6kq4$1@ID-44371.news.dfncis.de> "Edward B. Wilson II" <ed at ewilson.com> wrote news:MNS%6.355$Xs4.225014 at news.pacbell.net... > I have been following Python for five years now, and I am still just as > frustrated with it as I was in 1996. > > Python still doesn't have good database support... Of cource I don?t agree with this, because I sell database solution implemented with python with great results. With Python you have great ODBC support and a choice for almost any vendor out there. From grumble at usa.net Thu Jul 12 09:44:45 2001 From: grumble at usa.net (jcm) Date: 12 Jul 2001 13:44:45 GMT Subject: Python speed References: <roG27.666914$166.13798179@news1.rdc1.bc.home.com> <pXG27.1312$M9.140003@typhoon.we.rr.com> <9ifjjh$1e3$1@news.mathworks.com> <3B4B562F.77C1B79@yahoo.com> <9ifo90$4hh$1@news.mathworks.com> <TfQ27.328548$p33.6645853@news1.sttls1.wa.home.com> <9ihjfu$3ls$1@news.mathworks.com> <RV837.333819$p33.6744825@news1.sttls1.wa.home.com> Message-ID: <9ik9kd$nch$1@news.mathworks.com> Greg Jorgensen <gregj at pdxperts.com> wrote: > I guess I don't know WHAT you want. If your point is that CPU-bound programs > are slow, we can agree and leave it at that. As I've said before, I don't want anything from this discussion except to express my opinion to the original poster. If you'd like, reread my point as "muds are likely to be CPU-bound programs". From crombie88 at yahoo.com Wed Jul 11 19:27:17 2001 From: crombie88 at yahoo.com (crombie) Date: Wed, 11 Jul 2001 16:27:17 -0700 Subject: newbie question Message-ID: <NGEHILHDGMAFAKFOELIJIELOCEAA.crombie88@yahoo.com> so, i wanna learn python. i read the docs on python.org. what do i do now? is there like a website with a list of starter projects that need to be done in python to prove you know it and help you learn it? at a complete loss, will appreciate direction. any direction -tc -------------- next part -------------- A non-text attachment was scrubbed... Name: winmail.dat Type: application/ms-tnef Size: 1488 bytes Desc: not available URL: <http://mail.python.org/pipermail/python-list/attachments/20010711/c54c6609/attachment.bin> From tjreedy at home.com Thu Jul 19 12:28:51 2001 From: tjreedy at home.com (Terry Reedy) Date: Thu, 19 Jul 2001 16:28:51 GMT Subject: Immutable list reverse function References: <mailman.995543208.24170.python-list@python.org> Message-ID: <7VD57.4114$EP6.1255448@news1.rdc2.pa.home.com> "Martin Sj?gren" <martin at strakt.com> wrote in message news:mailman.995543208.24170.python-list at python.org... >Is there a "good" way to write a fast reverse function for immutable lists? Lists are mutable. That is why you can reverse them in place. Three possible questions: Q1. How reverse an immutable sequence? def tup_reverse(tup): ans = [] for i in range(len(tup)-1, -1, -1): ans.append(tup(i)) return tuple(ans) or def tup_reverse(tup): ans = list(tup) ans.reverse() return tuple(ans) and similarly for str_reverse. In 2.2a I believe we could write a more generic def seq_reverse(seq): t = type(seq) ... return t(ans) Lutz *Programming Python* p492 gives (with slight renaming) this generic version which will even work for sequence-like classes: def reverse(seq): ans = seq[:0] # empty seq of same type for i in range(len(seq)): ans = seq[i:i+1] + ans return ans Q2. How reverse a list and get return value to chain in call sequence? def reverse(lisp): # 'list' is builtin function; bad habit to use as name lisp.reverse() return lisp Note 1: GvR decided to have list methods that modify in place NOT return the list because he did not want people to introduce bugs in programs by forgeting that list IS modified in place. Note 2: One can reverse this decision by deriving a class from UserList. In the just released Python 2.2a1, one derive the value-returning list class directly from type list. Q3. How get a reversed copy copy of list without modifying original? You already answered this with: def reverse(list): l = len(list) return [ list[l-i-1] for i in range(l) ] >It works, but it's obviously not backwards compatible. Any suggestions? See Q1 answer. But Q3 seem not to really be your question. >What I want to do is basically this: foo(reverse(create_a_list())) If reverse returns a copy rather than the original, then the original list is uselessly tossed away. So see the Q2 answer. >Instead of having to: >>> list = create_a_list() >>> list.reverse() >>> foo(list) Since this does not create two lists, it is more effecient than your original alternative. Terry J. Reedy From tim.one at home.com Wed Jul 25 17:06:17 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 25 Jul 2001 17:06:17 -0400 Subject: Norton AV 2001 + popen + WinMe = crash In-Reply-To: <u8zhceomr.fsf@ctwd0143.fitlinxx.com> Message-ID: <LNBBLJKPBEHFEDALKOLCIEDILBAA.tim.one@home.com> [Kirby Urner] > So how does IDLE invoke the browser if not with popen and if > it uses popen, then why can't I from the IDLE shell? The kind > of question that keeps me up at night. [David Bolen] > At least this can be answered by looking at the source, and let you > get some sleep :-) > > It looks like IDLE uses either the standard library webbrowser module > (2.1+) or some internal browser support in the BrowserControl.py > module (2.0) to launch the browser. > > Under Windows, this is accomplished using the ShellExecute() win32 api > call (in 2.0 via the win32api module, or via the os.startfile() > library function in 2.1+). > > So there's no popen() involved. Almost all correct. Thanks, David! The 2.0 truth is hairier than it looks, because win32api doesn't ship with the base Python distribution: 2.0 also uses webbrowser and os.startfile(), and indeed the latter function was introduced at the last second for 2.0 precisely so that IDLE wouldn't have to use MS popen(). From ChuckEsterbrook at yahoo.com Tue Jul 3 09:39:16 2001 From: ChuckEsterbrook at yahoo.com (Chuck Esterbrook) Date: Tue, 03 Jul 2001 09:39:16 -0400 Subject: Fixed mx.DateTime or alternative? Message-ID: <5.0.2.1.0.20010703093458.02498dc0@mail.mindspring.com> eGenix mx.DateTime 2.0.1 has a problem under Python 2.1. DateTime objects cannot be compared to None: C:>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. >>> from mx import DateTime >>> dt = DateTime.now() >>> if dt==None: print 1 ... Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: can't coerce DateTime to the other type >>> Does anyone have an eGenix build for Windows that is compatible with Python 2.1? Reference: http://www.lemburg.com/files/python/eGenix-mx-Extensions.html#Download-mxBASE -Chuck From quinn at regurgitate.ugcs.caltech.edu Wed Jul 25 13:22:12 2001 From: quinn at regurgitate.ugcs.caltech.edu (Quinn Dunkan) Date: 25 Jul 2001 17:22:12 GMT Subject: How to telnet to other unix machines and grep log files etc? References: <fa7108b0.0107250742.7b38c678@posting.google.com> Message-ID: <slrn9lu024.vpg.quinn@regurgitate.ugcs.caltech.edu> On 25 Jul 2001 08:42:44 -0700, Chris <bit_bucket5 at hotmail.com> wrote: >Relative unix newbie. Would like to write a python script to do what >I do manually--telnet to two different unix machines from a third unix >machine. Grep through some log files, gather the grep results from >the different machines and spit them out. I think I need to do >something with popen, or popen2, or ??? I don't know where to start. >Any pointers much appreciated. This is a shell task: (ssh machine1 'grep foo /sys/log/bar'; ssh machine2 'grep baz /sys/log/faz') >results Create an RSA key with no passphrase if you don't want to have to type passwords all the time. From piet at cs.uu.nl Fri Jul 27 05:16:47 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 27 Jul 2001 11:16:47 +0200 Subject: PEP 238 (revised) References: <cp4rrz5onj.fsf@cj20424-a.reston1.va.home.com> <3B60B448.78DBC7D0@home.net> Message-ID: <u66ceenpc.fsf@cs.uu.nl> >>>>> Chris Barker <chrishbarker at home.net> (CB) writes: CB> Guido van Rossum wrote: >> >> Here's a completely revised version of PEP 238. CB> Very nice. Let's hope this calms the waters some... >> - Use a directive (or some other way) to specify the Python >> version for which a specific piece of code was developed. This >> requires future Python interpreters to be able to emulate >> *exactly* every previous version of Python, and moreover to do >> so for multiple versions in the same interpreter. This is way >> too much work. A much simpler solution is to keep multiple >> interpreters installed. CB> I think this has been dismissed a little too quickly. I suppose I can't CB> comment on what "way too much work" is, as I really don't know how much CB> work it will be, and I'm unlikely to be doing any of it. I do think that CB> it is a lot of work for system administrators to keep all the old CB> interpreters around (particularly on new systems, it could be a fair bit CB> of work to get a working copy of Python 2.1 on RedHat 13.2 a few years CB> from now!) It seems to me that the worst case is that we end up with a CB> somewhat bloated interpreter that is essentially two (or three, or four) CB> completely separate interpreters that happen to be bundled together. CB> Given how cheap memory and disk space is these days, the bloat shouldn't CB> be a big deal, and you could always turn off the old code with a compile CB> option if you didn't need the backwards compatible interpreter. I agree with Chris, including the stuff I have cut away. Having different interpreters installed is a pain, and doesn't solve the problem of using old modules that you got somewhere mixed with new code. If the modules were not written by yourself and too complicated to adapt them you are stuck. See also my proposal for a `module' statement. Developers could add a parameter with the python version for which the module was written, e.g. module mymodule(2.4) or module mymodule(version=2.4) So this would be a possibility for `eternal programming'. -- Piet van Oostrum <piet at cs.uu.nl> URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From jm7potter at hotmail.com Wed Jul 11 11:01:50 2001 From: jm7potter at hotmail.com (Joe Potter) Date: Wed, 11 Jul 2001 11:01:50 -0400 Subject: MySQL-python-0.9.0 setup problems under windows98 References: <hniokt4u4365lf475ci469lbidsnhl0gfa@4ax.com> <3B4C5A47.50D8E366@nokia.com> <42noktok3h9cbo3757kg8hoavhnjjsc478@4ax.com> <9ihog4$itjqb$1@fu-berlin.de> Message-ID: <ofqokt8st2fdf4afibnmudv21mgs8o4krr@4ax.com> On Wed, 11 Jul 2001 16:40:03 +0200, "Matthias Huening" <mhuening at zedat.fu-berlin.de> wrote: > >Joe Potter <jm7potter at hotmail.com> wrote: >> >> I must be very dense. I downloaded "MySQL-python-0.9.0-win32-2.zip (this >archive is >> for Python 1.5.2/2.0/2.1)" from that very url. >> >> Now what? >> > >Just extract the files to an empty directory. >Open a DOS-box, go to that directory and run: >python setup.py install > >That's all. >After that you should be able to "import MySQLdb" > Matthias, Well that was easy enough! Thanks much. Regards, Joe From sill at optonline.net Tue Jul 31 07:14:56 2001 From: sill at optonline.net (Andrei Kulakov) Date: Tue, 31 Jul 2001 11:14:56 GMT Subject: Listing directorycontent in python References: <1aa68e6e.0107302231.dd024a2@posting.google.com> Message-ID: <slrn9md4hi.2g6.sill@sill.silmarill.org> On 30 Jul 2001 23:31:55 -0700, andreas <wpt2097 at hotmail.com> wrote: > Hello. > > I have a simple question, I want to have a list of all files/dirs in a > certain directory. > > An example would be that I want to know all filenames that end with > "*.JPG" in the directory "/var/www/". > > I have not succeeded in doing this myself with "os.path"-module, so I > am now asking for tips, hints, examples or pointers to answers of > previous similar posts. > > I am using Python v1.5 most of the time. > > TIA > > Andreas os.dirlist(dirpath) -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: http://silmarill.org/cymbaline From rnd at onego.ru Wed Jul 18 02:54:40 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 18 Jul 2001 10:54:40 +0400 (MSD) Subject: Defining Python Source Code Encodings In-Reply-To: <er957.3$EP6.133@news1.rdc2.pa.home.com> Message-ID: <Pine.LNX.4.21.BCL.0107181033310.704-100000@suzi.com.onego.ru> On Wed, 18 Jul 2001, Terry Reedy wrote: > > > 3. Python's tokenizer/compiler combo will need to be updated to > > work as follows: > > > > 1. read the file > > 2. decode it into Unicode assuming a fixed per-file encoding > > 3. tokenize the Unicode content > > 4. compile it, creating Unicode objects from the given Unicode data > > and creating string objects from the Unicode literal data > > by first reencoding the Unicode data into 8-bit string data > > using the given file encoding > > > > To make this backwards compatible, the implementation would have to > > assume Latin-1 as the original file encoding if not given (otherwise, > > binary data currently stored in 8-bit strings wouldn't make the > > roundtrip). > > If I understand this, you would translate (my) ascii code files into > Unicode, compile, and translate literal strings back to the ascii form they > started as. Can this be done without lengthening the compile time 'too > much'. > > > Issues that still need to be resolved: > > > - what to do with non-literal data in the source file, e.g. > > variable names and comments: > > > > * reencode them just as would be done for literals > > * only allow ASCII for certain elements like variable names > > etc. > > I strongly suspect that people who do not write any Latin alphabet language > would strongly prefer to write names and comments in their native script. > This would open Python to millions who are presently excluded. > Mixed-alphabet texts are pretty common in some non-Latin alphabet > countries. As I was said in c.l.p earlier, this is very bad idea and Python Style Guide says that if you expect to other people from other countries read your code, write your comments in English. Exchange of programs will be nearly impossible if variable names will be in native tongues! In Russia programmers who do not know English (do those exist?) write var name using transliteration. For (self-explanatory) example: slovar = {'spisok': 'list', 'slovar': 'dictionary', 'element': 'item', 'perevod': 'translation', } spisok = ['element', 'perevod'] for element in spisok: try: perevod = slovar[element] print perevod except: print element, "???" This is ugly, of course, but having native names will cause more problems. I, for example, can navigate faster in English versions of software, because translations differ. And even simple "Edit" has several variants. So, this "interoperability" will actually make interoperability harder, at least for Open Source. For anything else I do not care. Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From smnordby at yahoo.com Sat Jul 21 19:40:09 2001 From: smnordby at yahoo.com (SteveN) Date: Sat, 21 Jul 2001 16:40:09 -0700 Subject: Language change and code breaks References: <mailman.995378792.16515.python-list@python.org> <cpvgkq1f2b.fsf@cj20424-a.reston1.va.home.com> <9j9i19$p96$1@panix2.panix.com> <3B596D95.C87DFFCD@mac.com> Message-ID: <3B5A12D9.7836217E@yahoo.com> jorjun wrote: > > Aahz Maruch wrote: > > i'M aFraId i doN't UnDerStaNd wHy YoU THinK caSE-InsENsitIvitY miGhT bE > > A gOoD idEA. > > -- > Currently if I import a module and the identifiers lOoK_lIkE_ThIs > then I have to precisely follow the ugly conventions in my own code. Or import uGlY_mOdUlE as pretty_module -SteveN- From aleaxit at yahoo.com Wed Jul 18 10:07:12 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 18 Jul 2001 16:07:12 +0200 Subject: how saving/retreiving python code from DB ? References: <3B559274.6B66A372@yahoo.com> Message-ID: <9j457f07jv@enews4.newsguy.com> "vincent delft" <vdelft at itmasters.com> wrote in message news:3B559274.6B66A372 at yahoo.com... > I'm looking for a module that allow us to store/import python code into > DB (bsddb for example) instead of a file. > > like "import" retreives coding in flat files, is there a way to retreive > coding for a DB ? You can write your own version of __import__ and set it as the thus-named attribute of the __builtin__ module -- statements import and from will thereafter use your version rather than the built-in kind. Is this what you want...? Alex From llothar at mailandnews.de Sun Jul 1 16:27:47 2001 From: llothar at mailandnews.de (Lothar Scholz) Date: Sun, 01 Jul 2001 22:27:47 +0200 Subject: GUI Builder for Python ? References: <aknrjt8j3cm3qcnpu6qsgvu313rlmi8emg@4ax.com> <3B3DE732.660AF0E1@earthlink.net> Message-ID: <3l1vjtg9cu1jcr78hdgnchmp8bt53cuhbi@4ax.com> On Sun, 01 Jul 2001 14:40:34 GMT, Ron Stephens <rdsteph at earthlink.net> wrote: Perhaps you have missed that i was asking for an verion > alpha. I think Pythoncard will not be useable for some years. I like commercial software if it is worth the money you pay. After hacking a lot with "Free Software" i more and more hate this kind, specially for things as complex as good GUI interfaces. Where nearly all "Freeware" sucks at least at one point. The Problem is that Freeware killed any cheap alternatives. Perhaps i really must take "Black Adder". >A major new project is underway, called Pythoncard, see >http://groups.yahoo.com/group/pythoncard . Maybe you can contribute ;-)))) > >Lothar Scholz wrote: > >> Is there something other then "Black Adder" which is behind an alpha >> version ? From grahamd at dscpl.com.au Fri Jul 27 06:07:57 2001 From: grahamd at dscpl.com.au (Graham Dumpleton) Date: 27 Jul 2001 03:07:57 -0700 Subject: Distributed computing using SOAP. What about speed ? References: <LBA77.58$bXi.175168000@news.telia.no> <dc6f5c99.0107251655.f3c625b@posting.google.com> <3B5FC733.5186D588@tundraware.com> <dc6f5c99.0107261825.7e74fa89@posting.google.com> <3B60EEA0.70BC492A@tundraware.com> Message-ID: <dc6f5c99.0107270207.24b57cf0@posting.google.com> Tim Daneliuk <tundra at tundraware.com> wrote in message news:<3B60EEA0.70BC492A at tundraware.com>... > In an ideal world, you's have a layering scheme something like this: > > > Chunk of distributed application. > | and/or | > ------------------------------------------- > tx Queuing API | Direct Message Passing API > ------------------------------------------- > tx Q Manager M| | M > ---------------- | > Reliable Messaging Layer > -------------------------------------------- Where, "M" is a pluggable > Reliable Comms Transport M management & security > -------------------------------------------- facility for each layer > Speeds, Feeds, & Wire M in question > -------------------------------------------- > > > (You'll notice that my picture is a bit different than the usual > one in which Q management lives *below* the messaging layer. This > is a matter of taste because you can accomplish the same things > either way. In any case, if you need message persistence as a > class of service (almost all enterprises need this on occasion), > you will end up implementing a disk-based Q under the Messaging > Layer above and beyond what the Transactional Q Manager has to do.) I'll say now that I sent my last message without properly understanding what you have written. Even now I still have to read it properly as am trying to respond to this all quite quickly. Anyway, it seems you model may be quite close to how OSE is structured. OSE has a base reliable messaging layer (subject to processes not being shutdown or crashing), with a direct message passing API being exposed. OSE doesn't currently have a transactional queing mechanism. If it was done, I also saw it sitting out the side, or maybe partially also using the direct messaging API. I definitely didn't see things as being dependent on transactional queuing. OSE doesn't necessarily address issues of security to much degree as it is being seen as best suited to closed corporate networks. Will now have to sit down and look at your paper and other comments when I get a chance as I can understand where you are coming from. From claird at starbase.neosoft.com Mon Jul 23 11:34:52 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 23 Jul 2001 10:34:52 -0500 Subject: Parsing TCL? References: <roy-8EF99A.21173519072001@news1.panix.com> <mailman.995597193.26785.python-list@python.org> <yv24rs82ipr.fsf@lionsp093.lion-ag.de> Message-ID: <CE341682C584C2CB.E0DC7ACAB29A61B8.6B64A453470DF3AF@lp.airnews.net> In article <yv24rs82ipr.fsf at lionsp093.lion-ag.de>, Harald Kirsch <kirschh at lionbioscience.com> wrote: >Skip Montanaro <skip at pobox.com> writes: > >> Roy> I know this is probably a strange request, but does anybody know of >> Roy> a python module which parses TCL files? >> >> No, but isn't Tcl essentially just >> >> command arg arg arg arg >> >Except that arg may be "arg" or {arg} or [arg] or $arg and those special >characters as well as backslash and some others have to be treated >within. In fact even command may be "command" or [command] or >{command} or $command, but this is not for beginners:-) > >> ? I thought it was designed to be extremely easy to parse. Shouldn't be >> hard to write a parser for it I wouldn't think. > >Nevertheless you are right. The whole syntax *plus evaluation >semantics* is described in 11 points in a man-page of 208 lines. . . . Does someone seriously want to pursue this? A quick fix would be to use one of the Tcl-Python combinations, and let the Tcl part do the pars- ing (or lexification, as one might argue is closer to the point). -- Cameron Laird <claird at NeoSoft.com> Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From ajs at ix.netcom.com Tue Jul 31 03:52:53 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Tue, 31 Jul 2001 03:52:53 -0400 Subject: Changing the Division Operator -- PEP 238, rev 1.12 Message-ID: <000001c1199a$3bbd3c40$a9e1fea9@carol> Mark writes - >Somewhere in one of the posts on the many PEP 238 threads was the >following link to a discussion in a google group: ><http://groups.google.com/groups?hl=en&safe=off&th=1d9d3c24ba2f933d> Thanks for that. I found that thread actually very interesting, and am sorry I missed the cite the first time it came around in the PEP238 thread. But what I found interesting, as a novice, was discussion and advise from some of the Big Guys about doing mission (life) critical work within the limitations of *any* implementation of floating point numerics. The "/" issue was a digression from the meat of the conversation - which was really about testing techniques, and in general belts and suspenders when traversing the floating point minefield. Tim writes - >If you have a programmer who, e.g., assumes that x+y-x equals y, or thinks >(-b + sqrt(b**2 - 4*a*c))/(2*a) >is a good way to find a root of a quadratic equation, they'll eventually >kill someone regardless of programming language. And regardless of division sematics. No? That is what is trying to be tackled with Unified Numeric model. Correct ? A Big Thing. Will be interesting to watch develop. ART From qrczak at knm.org.pl Sat Jul 28 14:50:47 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 28 Jul 2001 18:50:47 GMT Subject: The Evolution Of Python References: <8beb91f5.0107280407.5a30341d@posting.google.com> <3B62FAFF.BB987077@Lugoj.Com> Message-ID: <slrn.pl.9m62c7.ja8.qrczak@qrnik.zagroda> Sat, 28 Jul 2001 10:48:47 -0700, James Logajan <JamesL at Lugoj.Com> pisze: > In what language Python would have been written had 'C' not existed, if it > had come to exist at all, would make for entertaining "what if" scenarios. It depends what language would be used for what C is used in our reality. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From bsass at freenet.edmonton.ab.ca Tue Jul 31 16:01:21 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Tue, 31 Jul 2001 14:01:21 -0600 (MDT) Subject: Non-Programmers (was: Changing the Division Operator) In-Reply-To: <XZw97.5001$9i1.471725@e420r-atl1.usenetserver.com> Message-ID: <Pine.LNX.4.33.0107311400100.649-100000@bms> On Tue, 31 Jul 2001, Steve Holden wrote: <...> > How about "incidental programmers", since the programming is largely > incidental to the real goals of their activities? sound about right From philh at comuno.freeserve.co.uk Tue Jul 17 08:07:04 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Tue, 17 Jul 2001 13:07:04 +0100 Subject: Python, C++, Java, Smalltalk, Eiffel,... References: <9is8rm$46d$1@panix3.panix.com> <mailman.995210391.3651.python-list@python.org> <4as5lt82h2oc47fl72mkb8i21ppf6lboop@4ax.com> Message-ID: <slrn9l8aj8.8in.philh@comuno.freeserve.co.uk> On Mon, 16 Jul 2001 15:56:30 +0200, Lothar Scholz <llothar at mailandnews.de> wrote: >> >>The problem is that there isn't one "better", just "better in the eyes of >>the author", > >I believe that this not really true, for example you must accept that >Common Lisp is much more powerful than any other language. Define powerful >The problem is that most people are not very open minded - mostly >because there intellectual skills are to low to capture more. >Sorry this seems to be arogant - but its the truth. Are you trolling? -- #===== Philip Hunt == philh at comuno.freeserve.co.uk ======# Herbivore: effort-free public key encryption. See: <http://www.vision25.demon.co.uk/oss/herbivore/intro.html> ** First software release coming soon! ** From db3l at fitlinxx.com Wed Jul 4 15:59:23 2001 From: db3l at fitlinxx.com (David Bolen) Date: 04 Jul 2001 15:59:23 -0400 Subject: newbie question References: <mailman.994227967.18236.python-list@python.org> Message-ID: <uofr079es.fsf@ctwd0143.fitlinxx.com> Roman Suzi <rnd at onego.ru> writes: > If you are working under UNIX, you do not need to program it: > > $ find . -name '*.py' | xargs wc > > (this brokes only when there are too large number of files, but then you > could read man find to see how to call a command for each file.) Unless you need an overall total for all files (as opposed to the per file count request) this shouldn't break at all. xargs will chunk the file list out of find into smaller pieces to avoid overflowing command line arguments to wc. Thus, for long lists you'll execute wc more than once, so you'll end up with more than one set of final totals. (Or you could use "-l 1" with xargs and it'll run wc for each file so you'll never see total lines :-)) -- -- 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 martin at strakt.com Fri Jul 20 03:09:24 2001 From: martin at strakt.com (Martin Sjögren) Date: Fri, 20 Jul 2001 09:09:24 +0200 Subject: Immutable list reverse function In-Reply-To: <7VD57.4114$EP6.1255448@news1.rdc2.pa.home.com> References: <mailman.995543208.24170.python-list@python.org> <7VD57.4114$EP6.1255448@news1.rdc2.pa.home.com> Message-ID: <20010720090924.A5274@strakt.com> On Thu, Jul 19, 2001 at 04:28:51PM +0000, Terry Reedy wrote: > > "Martin Sj?gren" <martin at strakt.com> wrote in message > news:mailman.995543208.24170.python-list at python.org... > >Is there a "good" way to write a fast reverse function for immutable > lists? > > Lists are mutable. That is why you can reverse them in place. Three > possible questions: Yeah I meant immutable sequences. Or rather, an immutable reverse function? That is, not changing the parameter. [snip Q1] > and similarly for str_reverse. In 2.2a I believe we could write a more > generic > > def seq_reverse(seq): > t = type(seq) > ... > return t(ans) Yea that'd be nice, but I want it to work with py1.5 :-) > Lutz *Programming Python* p492 gives (with slight renaming) this generic > version which will even work for sequence-like classes: > > def reverse(seq): > ans = seq[:0] # empty seq of same type > for i in range(len(seq)): > ans = seq[i:i+1] + ans > return ans That could work, but it looks pretty slow creating new sequences all the time. Still, if the sequence is immutable that's the way it has to be done. > Q2. How reverse a list and get return value to chain in call sequence? This is not what I wanted to do from a puristic view, but seeing as the sequencce I want to reverse often is a 'range(N)' list that'd work. > >What I want to do is basically this: foo(reverse(create_a_list())) > > If reverse returns a copy rather than the original, then the original list > is uselessly tossed away. So see the Q2 answer. > > >Instead of having to: > > >>> list = create_a_list() > >>> list.reverse() > >>> foo(list) > > Since this does not create two lists, it is more effecient than your > original alternative. You know, I never thought of that, *sigh*, I think I'll stick to this, or maybe write a small revret() function that reverses and returns. I miss Haskell :/ Martin -- Martin Sj?gren martin at strakt.com ICQ : 41245059 Phone: +46 (0)31 405242 Cell: +46 (0)739 169191 GPG key: http://www.strakt.com/~martin/gpg.html From shredwheat at mediaone.net Wed Jul 18 23:23:57 2001 From: shredwheat at mediaone.net (Pete Shinners) Date: Thu, 19 Jul 2001 03:23:57 GMT Subject: One Worry for 2.2 References: <ENi57.22469$M9.7022637@typhoon.we.rr.com> <3B55CFFD.C805B34A@bioreason.com> Message-ID: <hps57.22773$M9.7385422@typhoon.we.rr.com> > B does have a foo method. The problem is that C is derived > from A, not from B. So an instance of C shouldn't be > allowed to pass itself to B.foo. ah, thanks for spotting that. (last time i try to get my brain in gear before breakfast). well then i am all relieved then 2.2 looks good to me :] From shriek at gmx.co.uk Sun Jul 29 22:26:47 2001 From: shriek at gmx.co.uk (Stephen) Date: 29 Jul 2001 19:26:47 -0700 Subject: Going from webscripting to server-client software. References: <6572890e.0107251014.47e07810@posting.google.com> <9jop6k$l2d$2@pea.uk.research.att.com> <97ae44ee.0107262210.795d3e0e@posting.google.com> <9jrfva$dhj$1@pea.uk.research.att.com> Message-ID: <97ae44ee.0107291826.427a8b3c@posting.google.com> Thank you for demystifying this for me Duncan. Have since been searching the web for layman's (or at least novice programmer) guides to CORBA and just in case anybody else finds themselves having to follow the same steps, one of the best I've found is http://developer.java.sun.com/developer/onlineTraining/corba/ don't worry about it being written for Java, it's the most simplified I've found, assuming no prior knowledge of CORBA and accompanying jargon. Now, in order to test your example, I've downloaded OmniOrbpy and am about to install OmniOrb 3.x, as described at http://www.uk.research.att.com/omniORB/omniORB_3/README_win32.html It specifies that the pre-built binaries work for winNT/98 and uses Python 1.52. Will try with win2000 and Python 2.1 but was wondering if you know of any changes/differences ? Thank you again for the example you provided, Stephen. > In article <97ae44ee.0107262210.795d3e0e at posting.google.com>, > Stephen <shriek at gmx.co.uk> wrote: > > [...] > >Thank you very much, Duncan. After looking around for a couple of days (hence > >my late followup. sorry), it does seem like my options are > >(a) CORBA > >(b) SOAP > >(c) XMLRPC > >(d) Pyro > > You might want to add DOPY, which is along the same lines as Pyro: > > http://www.users.cloud9.net/~proteus/dopy/welcome.html > > I don't know anything about it, though. > > >CORBA has always been intimidating. So much work just to do "hello world", > >let along build a full app. > > People often say this, but it just isn't true, especially if you use > Python. "Hello world" doesn't make a lot of sense in a distributed > application, but here's the full code for a "fortune cookie" service. > > First, declare the interface in IDL: > > // fortune.idl > module Fortune { > interface CookieServer { > string get_cookie(); > }; > }; > > Now convert it to Python declarations with your chosen ORB's IDL > compiler, for example with omniORBpy: > > $ omniidl -bpython fortune.idl > > [ orbit-python doesn't have the IDL compiler step -- it always > compiles it on the fly. ] > > First the client, on the Python command line: > > >>> import CORBA, Fortune > >>> orb = CORBA.ORB_init() > >>> o = orb.string_to_object("corbaloc::spud.uk.research.att.com/fortune") > >>> o = o._narrow(Fortune.CookieServer) > >>> > >>> print o.get_cookie() > Objects are lost only because people look where they are not rather than > where they are. > > >>> print o.get_cookie() > "I'd love to go out with you, but I'm staying home to work on my > cottage cheese sculpture." > > > There really is a fortune cookie server running on > spud.uk.research.att.com, so you can run this example. > > > Now the server: > > #!/usr/bin/env python > > import sys, os > import CORBA, Fortune, Fortune__POA > > FORTUNE_PATH = "/usr/games/fortune" > > class CookieServer_i (Fortune__POA.CookieServer): > def get_cookie(self): > pipe = os.popen(FORTUNE_PATH) > cookie = pipe.read() > if pipe.close(): > # An error occurred with the pipe > cookie = "Oh dear, couldn't get a fortune\n" > return cookie > > orb = CORBA.ORB_init(sys.argv) > poa = orb.resolve_initial_references("RootPOA") > > servant = CookieServer_i() > poa.activate_object(servant) > > print orb.object_to_string(servant._this()) > > poa._get_the_POAManager().activate() > orb.run() > > > That's it. Note that about half the lines of code are nothing to do > with CORBA -- they're just getting the fortune cookie. When you run > the server it prints a long hex string like: > > IOR:010000001d00000049444c3a466f7274756e652f436f6f6b69655365727665723 > a312e300000000001000000000000005c000000010102000d0000003135382e313234 > 2e36342e330000f90a07000000666f7274756e6500020000000000000008000000010 > 0000000545441010000001c0000000100000001000100010000000100010509010100 > 0100000009010100 > > which can be given to orb.string_to_object (without the line breaks). > That IOR string is also the server running on spud.uk.research.att.com. > > A version of the server that can be used with the corbaloc URI is just > as simple, but omniORB specific, so I haven't shown that. > > Cheers, > > Duncan. From qrczak at knm.org.pl Mon Jul 23 14:01:22 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 23 Jul 2001 18:01:22 GMT Subject: PEP0238 lament References: <mailman.995839419.19134.python-list@python.org> <9jgvbc$dos$1@newshost.accu.uu.nl> Message-ID: <slrn.pl.9lopjh.308.qrczak@qrnik.zagroda> 23 Jul 2001 10:47:08 GMT, Martijn Faassen <m.faassen at vet.uu.nl> pisze: > "+" does two different things depending on what you pass in (strings or > numbers). "*" does so too. They both can be said to lose information. The difference between '+' and '/' is that ints aren't implicitly converted to strings, so one wouldn't use an int instead of a string expecting '+' to do the conversion and concatenation. But ints *are* implicitly converted to floats when needed in about all contexts except '/', so it would be reasonable to expect them to be converted in the '/' case too. In languages where ints are implicitly converted to strings, addition and concatenation are typically different operators. Like in Perl: '+' and '.'. Python does treat ints and floats as different parts of the same concept by letting them compare equal and convert as needed. So real division and integer division should be distinguished by the operator. To help with migration there can be old_div(x,y) function. That way old / can be unconditionally replaced with old_div for a quick fix, and it can be made nicer by saying explicitly which division is meant when somebody has time to do it properly. I still favor 'x div y' and 'x mod y', with '/' on ints giving rationals, and with mixed rationals with floats giving floats. Literals like 1.2 would continue to mean floats, so each type has nicely spelled constants: 7 - int (unified with long in the future) 7/3 - rational 7.2 - float Each time a float is expected, a rational would give the same answer (perhaps in a different type or accuracy). Each time a rational is expected, an integer would give the same answer (perhaps in a different type). '"%.02f" % a_rational' is a good way to output currency amounts. 'rational(a_string)' is a good way to input them. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From tjreedy at home.com Wed Jul 25 23:03:20 2001 From: tjreedy at home.com (Terry Reedy) Date: Thu, 26 Jul 2001 03:03:20 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <LNBBLJKPBEHFEDALKOLCEEIJLAAA.tim.one@home.com> <mailman.995949762.26287.python-list@python.org> <cp66chbobw.fsf@cj20424-a.reston1.va.home.com> Message-ID: <YLL77.29942$EP6.7426923@news1.rdc2.pa.home.com> "Guido van Rossum" <guido at python.org> wrote in message news:cp66chbobw.fsf at cj20424-a.reston1.va.home.com... > "Chris Gonnerman" <chris.gonnerman at newcenturycomputers.net> writes: > > 4. Difficulty in writing backwards-compatible code is bad > > (thus, code to implement partitioning of a dataset would > > naturally use the // operator in 2.2+ but would not be able > > to in pre-2.2, so the div() function would have to be > > religiously used, hurting readability). > Hm, #4 is relatively new in this discussion (for me, anyway). I will > have to adapt to this new requirement, which I find reasonable > (although I wish it didn't exist -- but I understand the motivation). My solution for this: Since int/int and float//float will have new meanings, don't use them. Write float(int)/int and floor(float/float) instead to get the new meaning. Only write int//int or float/float. With the tokenizer module, it will then be easy to change all instances of int//int to int/int (old meaning). It should even even be possible to have package installers check sys.version and do this conversion on site as needed. This is not the same as having *one* file that is cross-compatible, but since the generation of the second is automated, it is certainly close. A version check could be inserted in both versions (and automatically modified) to make sure that each version of the file only runs on versions of the interpreter it is compatible with. For newly written code, the harder problem will be to not use any of the other neat new features, which mostly *cannot* be automatically back converted. Terry J. Reedy From steve at lurking.demon.co.uk Mon Jul 23 23:33:54 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Tue, 24 Jul 2001 04:33:54 +0100 Subject: A use for integer quotients References: <mailman.995866298.23496.python-list@python.org> <cpzo9veuml.fsf@cj20424-a.reston1.va.home.com> <8rdoltsi3fcph86pnkgckmiqich6d9qqng@4ax.com> <mtn15v2wiw.fsf@astron.berkeley.edu> <2b6plts93l46r4aip12u0veqfab01sfsau@4ax.com> <mtvgkj19rw.fsf@astron.berkeley.edu> Message-ID: <o1opltcbdg9h00pvqtu7a46g60hlttlmtk@4ax.com> I've been getting seriosly ratty - reading what I wrote shows that it really is time to take that rest Tim suggested. Sorry for that. I wish I could afford to just shrug it off and move on - unfortunately that's not the position I'm in. There's only one new thing I can probably say, and that is... On 23 Jul 2001 16:54:43 -0700, Johann Hibschman <johann at physics.berkeley.edu> wrote: >> They are *NOT* the right thing from a mathematical point of view - >> integer division in mathematics gives an integer quotient and integer >> remainder as any five-year-old knows. > >Well, most mathematicians I know would disagree. Division is not >well-defined on integers, unless you want "5 / 2" to return "(2, 1)". >It's just not a property integers have. Or, well, you can define the >operation, but they'll stop being a group under it, so all hell breaks >loose. :-) > >Five year olds don't know much maths. But 99% of programming arithmetic is at this level, or maybe up to ten-year-old at best. We don't even do algebra - we do the 'rub out the x, write in *this* number and then work out the answer' thing children learn as a prelude to algebra. Professional pride may make this a hard thing to accept, but mathematics above the ten-year-old level is rarely needed in programming except in particular applications tackled by people with specialist knowledge. From jkn at nicorp.f9.co.uk Mon Jul 16 05:39:39 2001 From: jkn at nicorp.f9.co.uk (Jon Nicoll) Date: 16 Jul 2001 02:39:39 -0700 Subject: windows port access References: <3b520bcb@news.cybertours.com> Message-ID: <8351bb33.0107160139.7af4f9af@posting.google.com> oops! Having posted my link, I see from checking it that the version I put up there is an early version, without the Linux compatability I later added. I'll update this in the next few days, or you could email me for an updated copy. It might force me to pull my finger out and re-test it under 2.x ;-/ Jon N "Bryan Brannigan" <bbrannigan at cybertours.com> wrote in message news:<3b520bcb at news.cybertours.com>... > I am looking for a way to send data to certain ports on a custom ISA card. > The card is addressed as 280h. Is this possible with Python? Is the code > compatible with Linux as well? > > Bryan From philipp at salomon.at Mon Jul 9 08:15:32 2001 From: philipp at salomon.at (Philipp Jocham) Date: 9 Jul 2001 12:15:32 GMT Subject: Python on Tandem/NonStop Himalaya? Message-ID: <slrn9kj835.34h.philipp@sapc079.salomon.at> Anybody got experiences on compiling and running Python on a Compaq NonStop Himalaya architecture? They claim to be a 90% POSIX.1, XPG4 and Unix 98 System, so it seems feasible. http://nonstop.compaq.com/view.asp?IOID=5187 Philipp -- Philipp Jocham SALOMON AUTOMATION GmbH mailto: philipp.jocham at salomon.at A-8114 Friesach bei Graz From emile at fenx.com Tue Jul 3 14:56:41 2001 From: emile at fenx.com (Emile van Sebille) Date: Tue, 3 Jul 2001 11:56:41 -0700 Subject: Alternate Syntax for dictionary elements References: <3b421046.1836046@news.t-online.de> Message-ID: <9ht4oi$frnab$1@ID-11957.news.dfncis.de> You can get this effect now by leveraging a minimal class: class Dict: def __init__(self, **kwargs): self.__dict__.update(kwargs) dict = Dict( type = 'button', id= 32, name = 'some name' ) if dict.type == 'button': print "This works!" dict.newType = 2 if dict.newType == 2: print "So does this" print repr(dict.__dict__) If you don't need to initialize the object with named parameters, you can simplify to using: class Dict: pass HTH, -- Emile van Sebille emile at fenx.com --------- "Gerson Kurz" <gerson.kurz at t-online.de> wrote in message news:3b421046.1836046 at news.t-online.de... > Please consider the following: > > dict = { 'type' : 'button', 'id': 32, 'name' : 'some name' } > ... > if o['type'] == 'button': > # do something for objects of type button > > Now, take a look at > > if o.type == 'button': > # do something for objects of type button > > A dictionary can in many cases be interpreted as a dynamically created > object. And an object should have members; or rather, you should be > able to access its data in a member-style fashion. > > This change doesn't save you much type overhead - but it makes the > code look more readable for those uses for which it makes sense to > treat dictionarys as dynamic objects (and I have lots of uses for > these). > > I realize that there are possible dictionary keys (such as tuples) for > which such a syntax is improper; it should be sufficient to make the > following restrictions: > > - the syntax is only possible for string-typed keys that *qualify as > valid identifiers* > - the syntax is only possible for keys that are not part of dir({}). > > The implementation would be a hack that extendes the {}.__methods__ > lookup. > > Worthwile pursuit or total crap ? > From skip at pobox.com Mon Jul 9 10:56:17 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 9 Jul 2001 09:56:17 -0500 Subject: Bug in rfc822 In-Reply-To: <cp66d2i59b.fsf@cj20424-a.reston1.va.home.com> References: <slrn9khcjv.c7q.philh@comuno.freeserve.co.uk> <QFc27.8798$e5.1167735@newsb.telia.net> <2ih27.49242$he.3402812@e420r-atl1.usenetserver.com> <cp66d2i59b.fsf@cj20424-a.reston1.va.home.com> Message-ID: <15177.50705.483826.728871@beluga.mojam.com> Guido> I think Barry's mimelib may have a replacement already. Guido> http://mimelib.sourceforge.net/ The astute observer would be tempted to ask why Barry hasn't been able to sneak mimelib into the core yet: >>> import mimelib Traceback (most recent call last): File "<stdin>", line 1, in ? ImportError: No module named mimelib I won't ask however, as I don't want to show up on the PSU's radar screen. Has anyone seen Barry recently? Skip From rnd at onego.ru Fri Jul 13 14:18:45 2001 From: rnd at onego.ru (Roman Suzi) Date: Fri, 13 Jul 2001 22:18:45 +0400 (MSD) Subject: More on "with" statement In-Reply-To: <3b4f3600$0$15367@wodc7nh6.news.uu.net> Message-ID: <Pine.LNX.4.30.0107132215520.8976-100000@rnd.onego.ru> On Fri, 13 Jul 2001, Rufus V. Smith wrote: >I went to the FAQ to check the entry about a "with" statement >that is available in other languages. I can only think of two >reasons to use it. > > 1) You're a lazy typist. (Or haven't learned to cut and paste) > > 2) You are generally concerned that multiple references to the > same object with complex, multilevel access might be confusing > to the reader or not optimized by the compiler. Programmers must be lazy to some degree. So, they tend to write a*(b+c+d+e) instead of a*b+a*c+a*d+a*e I think, the same applies to "with". It is also better from maintainance point of view: you have one point to change: (a+1)*(b+c+d+e) while: (a+1)*b+(a+1)*c+(a+1)*d+(a+1)*e However, with is a border case... Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Friday, July 13, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Useless Invention: Open Toed Safety Shoes." _/ From erno-news at erno.iki.fi Tue Jul 24 16:46:06 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 24 Jul 2001 23:46:06 +0300 Subject: Advice wanted: asynch I/O on unix References: <owen-66B4BF.09573623072001@nntp4.u.washington.edu> <ku4rs3yueb.fsf@lasipalatsi.fi> <9jk65h$dto$1@nntp6.u.washington.edu> Message-ID: <kuelr6awdt.fsf@lasipalatsi.fi> In article <9jk65h$dto$1 at nntp6.u.washington.edu>, "Russell E. Owen" <owen at astrono.junkwashington.emu> writes: | The main problem is going to be how to buffer data until it can be read. | the parallel port card has no buffering of its own. Hence the complex | process outlined above. i am not sure what you mean by buffering here. select() will tell you as soon as it can be read. until you do the data is likely being buffered by the device driver... [...] | P.S. Any advice regarding using "aioread", etc. vs "aio_read", etc.? | This is on Solaris 8. "aio_read", etc. seems to be the standard Posix | way of doing asynch I/O. I have no idea where "aioread", etc. come from, | but it's what the existing C code uses. At first glance, the interface | to aio_read looks a bit better, but I'd hate to pick something that was | buggy or deprecated. yes, aio_read is posix. i have not used it. it may be better to ask about it on another newsgroup (eg comp.unix.programmer). standard python does not expose these functions, but having a python module that does would be interesting... -- erno From dsh8290 at rit.edu Mon Jul 2 14:32:30 2001 From: dsh8290 at rit.edu (D-Man) Date: Mon, 2 Jul 2001 14:32:30 -0400 Subject: GUI Builder for Python ? In-Reply-To: <slrn9jvbc6.pdh.carlf@panix2.panix.com>; from carlf@panix.com on Sun, Jul 01, 2001 at 11:08:54PM +0000 References: <aknrjt8j3cm3qcnpu6qsgvu313rlmi8emg@4ax.com> <3B3DE732.660AF0E1@earthlink.net> <3l1vjtg9cu1jcr78hdgnchmp8bt53cuhbi@4ax.com> <slrn9jvbc6.pdh.carlf@panix2.panix.com> Message-ID: <20010702143230.B22536@harmony.cs.rit.edu> On Sun, Jul 01, 2001 at 11:08:54PM +0000, Carl Fink wrote: | In article <3l1vjtg9cu1jcr78hdgnchmp8bt53cuhbi at 4ax.com>, Lothar Scholz wrote: | > | > Perhaps you have missed that i was asking for an verion > alpha. | > I think Pythoncard will not be useable for some years. | | The current _Linux Journal_ has an article on Glade as a Python GUI | builder. It surely looks impressive to me, but I haven't tried it. | You'd end up with a GTK program (no native Windows/Mac look and feel) | if that matters to you. I used glade on Linux (my machine) for a C++ project for school about a year ago to run on Solaris (the lab). It was excellent. If I had understood how to build a well-designed (modular) app around libglade I would have used it instead of glade-- (the C++ source generator/backend ; it had a few issues but nothing that took major patching of the generated code). I highly recommend Glade. IMO learning how to build from the source is a very good idea to be sure works on windows -- GTK, glade, pygtk, etc, with the different compilers and linkers there are (ie MSVC++ vs. mingw vs. gcc and windows vs ld). I don't know if libglade has been ported or not. (PS. I like GTK's LnF better than MSW anyways :-)) | (I suppose you could use a GTK widget set that looks like WinX or | Mac?) Sawfish (a window manager intended for use with GNOME) has an "Aqua" theme that looks similar to Mac OS X. (GTK is themeable, BTW) -D From Peter.Mayne at au1.ibm.com Thu Jul 26 06:42:47 2001 From: Peter.Mayne at au1.ibm.com (Peter Mayne) Date: Thu, 26 Jul 2001 20:42:47 +1000 Subject: Future division patch available (PEP 238) References: <GNZwEiAJepW7Ew0F@jessikat.fsnet.co.uk> <mailman.995776716.24336.python-list@python.org> <mailman.995825018.9832.python-list@python.org> <9jfjd6$ad4$2@newshost.accu.uu.nl> <7u6nltoqdnqjjdiquu6ngtaruflhvbvdl5@4ax.com> <j4g0bof3jv.fsf@informatik.hu-berlin.de> <p8unltsi5qda8rpdavja4iemj6r1s2ak4a@4ax.com> <j48zhfgbny.fsf@informatik.hu-berlin.de> <23891c90.0107230531.4fb02b12@posting.google.com> <cpd76qqfow.fsf@cj20424-a.reston1.va.home.com> <0ilsltgmrc2eg39jf8cg2i4tam5ujqld0f@4ax.com> Message-ID: <9jqfqs$ns8$1@news.btv.ibm.com> "Stephen Horne" <steve at lurking.demon.co.uk> wrote in message news:0ilsltgmrc2eg39jf8cg2i4tam5ujqld0f at 4ax.com... > > How about inference by looking at the extension of the input file. $ app_that_prints_python_code_on_stdout | python What extension? PJDM -- Peter Mayne IBM GSA (but the opinions are mine) Canberra, ACT, Australia This post is covered by Sturgeon's Law. From mal at lemburg.com Tue Jul 10 07:17:05 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Tue, 10 Jul 2001 13:17:05 +0200 Subject: basic (mx) ODBC question References: <994236193.821045@nntp01.uskonet.com> <23891c90.0107050122.6aed9455@posting.google.com> Message-ID: <3B4AE431.CB1C4153@lemburg.com> Paul Boddie wrote: > > "Hanna Joo" <hanna at chagford.com> wrote in message news:<994236193.821045 at nntp01.uskonet.com>... > > Hi all > > > > I don't understand ODBC well. From the little that I understand - postgresql > > has its ODBC driver (on linux). I am connecting from windows. mxODBC is a > > module I can use. mxODBC suggests that if I am connecting from windows, I > > should (from here mad rambling because I don't know what the doc is saying) > > compile using VC compiler on windows. > > That may depend on binary availability of the package for Windows. I > don't remember anyone releasing binaries for mxODBC recently. eGenix.com provides binaries for Windows and all major Python releases starting from Python 1.5.2. You don't have to have a VC compiler to use mxODBC on Windows. > > I thought ==> > > > > ODBC python talks to on windows -- ODBC manager on Win machine -- ODBC > > module of pgsql. > > (on win machine) (between win machine and > > linux server) (linux server) > > The problem with ODBC by itself is that, as far as I am aware, it > doesn't address the issue of communication between client and server, > program and database system, or whatever. Therefore, you need to > choose drivers which will let you have the distributed communication > that you desire. In the past, I have used drivers for an obscure, > proprietary database system which can be installed in the Windows ODBC > driver manager and which can be configured to communicate with remote > servers running the database instances. > > I don't know whether there are any such drivers for postgresql, but > then I have never used it on Windows or UNIX (or both!). You normally install an ODBC driver on Windows, configure the data source using this driver in the Windows ODBC manager and then talk to the Windows ODBC manager using the mx.ODBC.Windows subpackage. Whether the driver support multi-tier setups (client and server on different machines), depends on the driver you use, but I think that the postgresql driver does support this. > > mxODBC has many subpackages for various DBs.. how does it work then? Does it > > work like the following? > > > > python talks (or uses) to mxODBC that is postgresql specific -- ODBC module > > of pgsql > > (same machine) > > Going from my experiences with mxODBC on UNIX [1], one can compile > mxODBC with a specific subpackage which knows about a particular ODBC > implementation. In my case, I compiled it with knowledge of the Sybase > Adaptive Server Anywhere ODBC library. This meant that mxODBC linked > directly to that library at run-time. You can do basically the same on Windows, but I would not recommend it since it requires a lot of knowledge about how ODBC and the specific driver work. > > Or... > > > > python talks to mxODBC that creates an entry for win ODBC that is postgres > > specific -- ODBC module of pgsql > > Well, this would mean compiling the Windows subpackage, which I > presume is aware of the details of the Windows ODBC driver manager. If > you have a postgresql driver for the Windows ODBC driver manager, then > mxODBC doesn't need to know explicitly that it's using postgresql, but > the postgresql driver obviously needs to integrate with the driver > manager. > > > or... > > > > python talks to ODBC on linux -- iODBC on same machine -- ODBC module of > > pgsql > > (same machine) > > This can also be done, although you're removing Windows from the > architecture, unless you are suggesting that Python is talking across > a network to the Linux host where iODBC resides; this would involve > you inventing or discovering a protocol which lets this happen, since > ODBC doesn't mandate such protocols itself. I have seen an ODBC > network gateway package, but this exported Windows-resident database > systems to other hosts, not the other way around. > > > mxODBC has different subpackages as I said, one being Windows.. I don't > > understand how that works.. different packages for different databases and > > one for windows? > > Well, there's an iODBC subpackage, if I remember correctly, so you > could say that there are "different packages for different databases, > one for Windows and one for UNIX". ;-) But the most pertinent detail > is the "point of integration" between mxODBC and the ODBC drivers. > Either one integrates mxODBC with a driver manager (Windows or iODBC), > or one integrates it with a particular database system's own driver > (Sybase ASA). > > The advantage of integrating with a driver manager is the lack of need > to recompile mxODBC should you change or add database systems. The > advantage of integrating with a specific implementation is, in > practice, increased functionality, performance (I would think) and > reliability. > > > (realizing post lacks focus as a result of pathetic lack of understanding) > > > > Can sombody direct me to a site where I may be able to find out more about > > this ODBC issue? > > The mxODBC site may provide some detail, but you might want to visit > my "mxODBC Configuration Guide" [1] which provides links to software > which may let you achieve your distributed environment ambitions. Great summary, Paul ! > Regards, > > Paul > > [1] http://www.paul.boddie.net/Python/mxODBC.html -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From jwbaxter at spamcop.com Thu Jul 26 01:28:20 2001 From: jwbaxter at spamcop.com (John W. Baxter) Date: Wed, 25 Jul 2001 22:28:20 -0700 Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <mailman.996045152.25643.python-list@python.org> Message-ID: <250720012228204930%jwbaxter@spamcop.com> In article <mailman.996045152.25643.python-list at python.org>, Tim Peters <tim.one at home.com> wrote: > [Tim Roberts] > > The average child's IQ these days is 100. That is the very definition > > of IQ. > > Except in Virginia. Jealous of the rumor that the Tennessee legislature had > defined pi to be 3 on the nose, the VA legislature defined *every* child's > IQ to be 120. The VA school system subsequently saved a lot of money on > now-useless tests, and by most accounts the kids didn't actually get any > dumber. It's also a great source of amusement that the Maryland legislature > sought to get even by mandating that all its childrens' IQs were 80. > That's the news from Lake Woebegone, where all the women are strong...all the men are good looking...and all the children are above average. --John From ykingma at accessforall.nl Sat Jul 21 11:42:19 2001 From: ykingma at accessforall.nl (Ype Kingma) Date: Sat, 21 Jul 2001 16:42:19 +0100 Subject: [Q] Python, GUI, and Java References: <sAj57.1758$oz3.22749@vixen.cso.uiuc.edu> Message-ID: <3B59A2D1.35B602D8@accessforall.nl> Young-Jin Lee wrote: > > Hi, all. > I'm new to Python. I heard many applause on Python, especially ease of > programming, and I want to use Python. I read the python tutorial on the > python home page, but it didn't have all I wanted to know. > From my first expression on Python, it is better for server side > programming. Can I use Pythong to develop a client application with a GUI? > It looks like I should you Tkinter. How powerful is it? How easy is it? > And is there any way to connect Python application and Java application? I > have been developing a Java application (it's quite large) and I don't want > to rewrite it with JPython. >From Jython/JPython you can use any java code on the class path, so instead of rewriting your Java app you can reuse it. See 'Interaction with Java packages' on http://www.jython.org/docs/index.html Basically this allows you to keep your app almost as it is and do new developments for it in Jython. Have fun, Ype -- email at xs4all.nl From new_name at mit.edu Fri Jul 20 23:54:24 2001 From: new_name at mit.edu (Alex) Date: 20 Jul 2001 23:54:24 -0400 Subject: whats this mean? References: <20010720213533.19217.00000446@ng-fb1.aol.com> <etdhew754i4.fsf@lola-granola.mit.edu> Message-ID: <etdelrb543z.fsf@lola-granola.mit.edu> Sorry, that was misleading. "why" gets assigned the exception that was raised, as Sean pointed out. In the example, replace "print why" with "print repr(why)" :) Alex. From paoloinvernizzi at dmsware.com Mon Jul 30 06:28:57 2001 From: paoloinvernizzi at dmsware.com (Paolo Invernizzi) Date: Mon, 30 Jul 2001 10:28:57 GMT Subject: Python Windows installer: good news! References: <mailman.996447416.25799.python-list@python.org> Message-ID: <JFa97.68$Nq1.2992@nreader1.kpnqwest.net> Request... is possible to provide also a MSI package? Actually in our company we are using python21 standard installation distributed to developers as a zap, would be nice to have a MSI ( as ActiveState does with its python implementation... <wink> ) Tnkz in advance... Paolo Invernizzi DMSWare.com "Tim Peters" <tim at zope.com> wrote in message news:mailman.996447416.25799.python-list at python.org... > Wise Solutions generously offered PythonLabs use of their InstallerMaster > 8.1 system. Every PythonLabs Windows installer produced to date used Wise > 5.0a, and while that's done a great job for us over the years, some of you > have noticed <wink> that it was starting to show its age. > > I've completed upgrading our Windows installation procedures to > InstallerMaster 8.1, and we'll release the next alpha of Windows Python 2.2 > using it. Even if you have no interest in *testing* 2.2a2 at that time, if > you're running on a Windows system please download the installer (when it's > released) just to be sure it works for you! As always, we have direct > access to only a few Windows boxes, so we rely on cheerful volunteerd to > uncover surprises. From loewis at informatik.hu-berlin.de Thu Jul 26 04:07:26 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 26 Jul 2001 10:07:26 +0200 Subject: New User Question: extension types and python 2.2/class/type References: <758d4715.0107251821.3ee9dda4@posting.google.com> Message-ID: <j4itggglkx.fsf@informatik.hu-berlin.de> thomas_barket at yahoo.com (tom barket) writes: > Having followed the class/type unification discussions somewhat and > read Guido's "Unifying types and classes in python 2.2" tutorial, it > seems to me that chapter 2 "Defining New Types" in the "Extending > and Embedding the Python Interpreter" doc is about to become > obsolete (in the sense that what it describes will shortly *not* be > the prefered way to define/import new types). Not at all. PyType objects won't go away. Instead, additional slots are added, to accomodate the extensibility. > Since this was going to be my guide for my own extension type > endeavor, I would like to ask how can i get instructions for > correctly writing an "extension type" under the new (or actually > soon-to-be-new) regime. I'd recommend to define the type using the current API; the additional API is not completely documented yet. Furthermore, you will only ever need it if you want to inherit Python classes from your type. Regards, Martin From gregj at pdxperts.com Wed Jul 11 00:05:07 2001 From: gregj at pdxperts.com (Greg Jorgensen) Date: Wed, 11 Jul 2001 04:05:07 GMT Subject: Python speed References: <roG27.666914$166.13798179@news1.rdc1.bc.home.com> <pXG27.1312$M9.140003@typhoon.we.rr.com> <9ifjjh$1e3$1@news.mathworks.com> <3B4B562F.77C1B79@yahoo.com> <9ifo90$4hh$1@news.mathworks.com> Message-ID: <TfQ27.328548$p33.6645853@news1.sttls1.wa.home.com> "jcm" <grumble at usa.net> wrote in message news:9ifo90$4hh$1 at news.mathworks.com... > Well, I say this because I've written a mud engine in Python and it's > slow. I drove my motorcycle around Laguna Seca, and it was slow. Maybe if I bought a different brand of motorcycle I could go around the track faster. Greg Jorgensen PDXperts LLC Portland, Oregon, USA From web2ed at yahoo.com Wed Jul 11 09:54:46 2001 From: web2ed at yahoo.com (Edward Wilson) Date: 11 Jul 2001 06:54:46 -0700 Subject: Long Live Python! References: <E566B020833BD311B6610008C791A39705CA5230@il93exm04.css.mot.com> <mailman.994804336.23495.python-list@python.org> Message-ID: <5174eed0.0107110554.af5a044@posting.google.com> Paul Prescod <paulp at ActiveState.com> wrote in message news:<mailman.994804336.23495.python-list at python.org>... > Kemp Randy-W18971 wrote: > > > > So an interesting question is raised. If PHP and Ruby are gaining > > acceptance because they address business needs, what needs to be done to > > carry Python in that direction? And while Java may be slow, Sun pushing it > > for business solutions also gives that language acceptance. How can Python > > become as popular as Perl, Java, or PHP? > > Perl, Java and PHP all grew popular by solving a particular problem at a > particular time, better than any other language. (I'm thinking of system > administration/CGI, Applets and web page generation). Perl and Java grew > into general purpose languages over time. The jury is still out on PHP. What about shipping Python with optimized niche extensions along with the standard distribution? -- ed From johann at physics.berkeley.edu Wed Jul 4 18:20:42 2001 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 04 Jul 2001 15:20:42 -0700 Subject: batch generation of keypairs by GnuPG References: <slrn9k71fq.707.philh@comuno.freeserve.co.uk> Message-ID: <mtelrwcp51.fsf@astron.berkeley.edu> phil hunt writes: > It uses public-key encryption. As the encryption engine, > I am using GnuPG, which I am calling from my program using > the system() call. I have written a python wrapper for GPGME as part of my work towards a Mac OS X wrapper for GPG, which should make this sort of thing easier; it also means that you don't have to make tempfiles, which are a bit of a security hole, to say the least. Currently, I don't have the key generation parts working at all, but that's just because I'm lazy. It should follow straightforwardly. I don't have it online or available yet, but I can arrange to have it posted somewhere, if you're interested. It will take me a bit of work to get it in a form where I'd want to give it to others, but not more than a few hours' worth. If you're interested, send me email. -- Johann Hibschman johann at physics.berkeley.edu From aleaxit at yahoo.com Sun Jul 8 11:24:11 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 8 Jul 2001 17:24:11 +0200 Subject: There's got to be an easy way to do this (fwd) References: <mailman.994355168.2401.python-list@python.org> <9i2jv703cm@enews2.newsguy.com> <slrn9kgsj4.csq.scarblac@pino.selwerd.nl> Message-ID: <9iaglp016li@enews1.newsguy.com> "Remco Gerlich" <scarblac at pino.selwerd.nl> wrote in message news:slrn9kgsj4.csq.scarblac at pino.selwerd.nl... ... > > filter(string.isdigit, '(123)/456-7890') > > > > is six fewer characters and IMHO more readable still. > > That version would certainly be best, if string had a isdigit function. You're right -- for some unfathomable version it's in module curses.ascii instead. Oh well, filter(curses.ascii.isdigit &tc &tc, then. Alex From cfelling at iae.nl Tue Jul 31 13:39:43 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 31 Jul 2001 19:39:43 +0200 Subject: FEEDBACK WANTED: Type/class unification References: <mailman.996524757.8311.python-list@python.org> Message-ID: <9k6qgv$8ru$1@animus.fel.iae.nl> Sam Penrose <sam at ddmweb.com> wrote: > Guido van Rossum wrote: >>> One minor suggestion: >>> I think it would help if you set a convention for the name >>> of the first argument in classmethods. Like self for standard >>> methods. Well, even self can "work" here, too. >> I think 'self' would be confusing. I'd like to propose 'cls'. > How about an English word or phrase in lieu of YATATL (yet another > terse acronym to learn)? Insofar as "self" derives from the notion of > an instance, we want somethign that derives from the notion of one's > classification. At first a thought of what I want to propose as a joke on case, but then, if you buy the argument for case sensitivity to be usefull to distinguish instances and classes (I do) it might just be right. So I propose Self, the class spelling of self, like in: def class_function(Self, args...) As a bonus, this is in accordance with the Jungian view of life, where self is used to point to the personal (lower) self, and Self denotes the person transcending (higher) self. Against it is that it would promote case sensitivity into the language as a sanctioned convention, but then that's what has been decided, hasn't it:) If the case sensitivity is a real show stopper we might settle for "class self", like in: def class_function(class self, args...) [in retrospect, I think I like a combination best, so "class Self"] Now that we are talking case, I seem to remember that the Alice people found that second guessing the spelling of library names was the real problem. So I was a bit surprised at first that the dictionary type was lowercased, were as the names in the types module are uppercased. (Later i realised that that was in accordance with int/long/str.) I very much applaud your endeavour to heal the type/class split, but I sure hope the end result will become simpler then what you have now. My brain being of limmited capacity since the crash has problems with things as two distinct method lookup behaviours. I understand your explanation allright, but I fear I've to lookup the rules often, like I can't get the corner cases of the new scoping rules fully into my head:( Whereas the other pecularities of the language are so well hidden that I think I've grasped the language:) I even hope the healing result get so simple that I really can do the Meta Class Programming I've been dreaming about lately. -- groetjes, carel From chris.gonnerman at newcenturycomputers.net Tue Jul 17 23:17:40 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Tue, 17 Jul 2001 22:17:40 -0500 Subject: windows port access References: <3b520bcb@news.cybertours.com> <3B522E98.BAAA9E93@engcorp.com> <mailman.995288852.27369.python-list@python.org> <3B5390BC.C5FFCD2A@engcorp.com> <mailman.995346569.21423.python-list@python.org> <3b5480f5@news.cybertours.com> Message-ID: <00ae01c10f38$da9a1200$0101010a@local> Motor control is not *real* timing sensitive (compared with the speed of the computer IMHO) so the winioport module should work for you. Note the prerequisite software when downloading and installing. Peter Hansen's module (whatever it is) might also be a good choice if he publishes it. ----- Original Message ----- From: "BRYAN BRANNIGAN" <BBRANNIGAN at CYBERTOURS.COM> Newsgroups: comp.lang.python To: <python-list at python.org> Sent: Tuesday, July 17, 2001 1:16 PM Subject: Re: windows port access > Thanks for the responses, > > This card is going to send small voltages to relays to control motors and is > the only way I have found to accomplish this task. The address on the card > is flexible. > > Bryan > "Chris Gonnerman" <chris.gonnerman at newcenturycomputers.net> wrote in message > news:mailman.995346569.21423.python-list at python.org... > > ----- Original Message ----- > > From: "Peter Hansen" <peter at engcorp.com> > > > > > > > Chris Gonnerman wrote: > > > > > > > > Unfortunately what Bryan is asking is not what you are answering. He > > wants > > > > to access the I/O port 0x280, which he states is assigned to a "custom > > ISA > > > > card" which (I assume) is not using the standard parallel port > > interface, > > > > nor serial, etc. and for which he evidently has no driver. > > > > > > I admit I didn't actually look at the winioport stuff proposed in the > > > "parallel port?!?" thread, but given that it was called winioport > > > and not winparallelport, I assumed it was a way of providing generic > > > access to IO ports under Windows. If I was wrong, then you are right > > > to correct me! (Do you know winioport would not work or were you just > > > tricked by the name of the thread?) > > > > Whups. Evidently the low-level package in use by winioport DOES support > > generic > > access. My mistake... I was going by the commentary on the main winioport > > page, > > where he says "I am now able do printer port IO." I assumed that was the > > entire > > scope of the package, but evidently not. > > > > > Of course, it's probably moot given Jon Nicoll's response which suggests > > > a perfectly viable alternative. > > > > Indeed... to wit: > > > > ----- Original Message ----- > > From: "Jon Nicoll" <jkn at nicorp.f9.co.uk> > > > > > This is exactly what my code can be used for - you can set it up to > > > get access to arbitary IO ports (via the ioperm mechanism in Linux), > > > and then read or write etc. as you like. Admittedly, it doesn't > > > currently cater for interrupts. > > > > Which could be vitally significant or totally unimportant. > > > > > I originally started writing this to drive an ISA 8255/8253 card, and > > > although this project-ette is currently in limbo, the basics are all > > > there and working, if Bryan wants to do eg. polled access to an A/D > > > card etc. > > > > > > You don't need a VxD (for W95 at least), although it's probably the > > > 'better' way of doing things. My code is in C and turns into a little > > > '.PYD' (= .DLL) file. In NT, you need a kernel mode driver, which I > > > haven't yet got around to looking at. > > > > Here the winioport module (and the underlying DriverLYNX package) might > > be better for Bryan. > > > > > I've just resurrected my code and am looking at using distutils to get > > > it in a form more easily distributed. Email me if would be of use to > > > you in the meantime. > > > > Bryan hasn't responded since he initially requested this information... > > are you out there, Bryan? > > > > > > > > > -- > http://mail.python.org/mailman/listinfo/python-list > > From aleaxit at yahoo.com Sat Jul 14 04:42:44 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 14 Jul 2001 10:42:44 +0200 Subject: Long Live Python! References: <mailman.995052624.21992.python-list@python.org> <slrn9kuvac.vde.philh@comuno.freeserve.co.uk> Message-ID: <9ip0io010ke@enews4.newsguy.com> "phil hunt" <philh at comuno.freeserve.co.uk> wrote in message news:slrn9kuvac.vde.philh at comuno.freeserve.co.uk... > On Fri, 13 Jul 2001 12:29:32 -0700, James_Althoff at i2.com <James_Althoff at i2.com> wrote: > > > >Granted, I used "only". On the other hand, if someone says "good for short > >programs <100 lines" -- mentioning a specific number ("100" in this case) > >-- wouldn't common sense dictate that the intention was also to indicate > >something like "Python is something *different than good* for programs > > >=100 lines (or let's say *significantly* greater than 100 lines -- to be > >reasonable and fair)? > > No it would not. If I say "my car is convenient for journeys <10 miles", > it doesn't mean it is inconvenient for journeys >10 miles, does it? Sure, and if I say "I never strangle British citizens on Saturdays", that cannot be taken as meaning that you are at risk on other days of the week, nor that people of other nationalities are at risk today -- however, depending on context, there is a *fair inference* (in human language usage, although not in the Aristotelic logic simplification thereof) that I'm likely to have a specific reason for what would be overqualification of my sentence IF I never strangled anybody at all on any day of the week. It takes a small but non-zero amount of effort to append to a general statement some specific qualification, thus, the general assumption that effort is not purposelessly spent affords the fair inference of some motivation behind this effort-expenditure (assuming, a different but similar simplificating working-hypothesis to Aristoteles', that the speaker behaves 'sensibly' by the usual definitions applied in economics -- of course, enough of us like 'hearing the sound of our own voices', or the Usenet equivalent thereof, that the hypothesis is fairly suspect when applied to Usenet postings). Alex From smarsh at hotmail.com Tue Jul 24 17:58:56 2001 From: smarsh at hotmail.com (scott) Date: Tue, 24 Jul 2001 21:58:56 GMT Subject: 2.2 features References: <gER67.534750$eK2.111982758@news4.rdc1.on.home.com> <slrn.pl.9lo6uq.ss0.qrczak@qrnik.zagroda> <cpg0bmqfzs.fsf@cj20424-a.reston1.va.home.com> <slrn.pl.9lrln1.aq.qrczak@qrnik.zagroda> <cpwv4yoyd8.fsf@cj20424-a.reston1.va.home.com> Message-ID: <3B5DEFA2.FCE4B85B@hotmail.com> Guido van Rossum wrote: <snip> I will definitely give this plenty of time (like I will with > all incompatibilities I introduce). > I will retire in 2018 so I humbly suggest: plenty_of_time = 16.5 years (Note the use of a float to minimize 2019 / - // problems for those who follow) :-) P.S I hope they don't use Python in my Pension scripts... From rossi at earthling.net Fri Jul 13 11:35:42 2001 From: rossi at earthling.net (Thorsten Roskowetz) Date: Fri, 13 Jul 2001 17:35:42 +0200 Subject: FrameMaker exposed in Python (PyMaker anyone)? Message-ID: <9in4dk$eap$06$1@news.t-online.com> Hi, is there a Python extension that allows scripting of the FrameMaker API. Google (and www.python.org) pointed me to a project called PyMaker but the link is dead (http://home.t-online.de/home/Ulrich.Herold/). Regards, Thorsten From skip at pobox.com Thu Jul 5 19:07:57 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 5 Jul 2001 18:07:57 -0500 Subject: Best method for updating pickled data objects? In-Reply-To: <79179cf5.0107051214.19990222@posting.google.com> References: <79179cf5.0107051214.19990222@posting.google.com> Message-ID: <15172.62285.701306.94097@beluga.mojam.com> Rupert> Deleting and recreating the pickle file, then writing out the Rupert> data object from memory each time seems horribly inefficient to Rupert> me (especially for large data objects). You can just open the file for writing. No need to delete it (well, expect perhaps for OS's like VMS that automatically create new file versions). -- Skip Montanaro (skip at pobox.com) (847)971-7098 From new_name at mit.edu Fri Jul 6 22:29:13 2001 From: new_name at mit.edu (Alex) Date: 06 Jul 2001 22:29:13 -0400 Subject: I'm Sure There's A Better Way References: <3B465858.CB7F38E8@tundraware.com> Message-ID: <etd7kxlfp52.fsf@x15-cruise-basselope.mit.edu> I may still be missing some cases, I did this a bit carelessly, but I hope you get the idea. import re def isNum(s): try: float(s) except ValueError: # Python couldn't convert it to a number, so it's not in the # requested format. return None # Check that the precision is correct if '.' in s: l = list(s) assert l.count('.') == 1, \ "Can't have more than one '.' in a number" if l.index('.') != len(s) - 3: # Wrong precision return None # Check that it begins with a number or '-' (it could start with a # '.') if not re.match('[-0-9]', s): return None return 1 if __name__ == '__main__': for s in ['9', '-1', '2.30', '-2.39',]: assert isNum(s) for s in ['.01', '1.234', 'bub', '1.', '--1']: assert not isNum(s) HTH. Alex. From roy at panix.com Fri Jul 13 22:11:25 2001 From: roy at panix.com (Roy Smith) Date: Fri, 13 Jul 2001 22:11:25 -0400 Subject: converting from perl: variable sized unpack Message-ID: <roy-B2459F.22112513072001@news1.panix.com> What's the best way to translate this perl snippet into python: ($f1, $f2, $f3, $f4, $f5, $f6) = split ('\s+', $line); The obvious translation would be: [f1, f2, f3, f4, f5, f6] = string.split (line) but the problem is that line may have fewer than 6 fields on it. Perl handles this smoothly by leaving the "extra" variables undefined, whereas python raises a ValueError exception. What I'd like to do is have the extra field variables left as null strings. From sholden at holdenweb.com Tue Jul 17 23:13:11 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 17 Jul 2001 23:13:11 -0400 Subject: Nested List Comprehension References: <9iss5k$2dcd$1@news.idiom.com> <etdelrh29w1.fsf@quiche-lorraine.mit.edu> Message-ID: <N6757.28920$d4.889960@e420r-atl1.usenetserver.com> "Alex" <new_name at mit.edu> wrote in message news:etdelrh29w1.fsf at quiche-lorraine.mit.edu... > > Yeah, I mucked around a bit with nested list comprehensions when I > started using them. It causes the same sort of miserable readability > problems that excessive use of the functional programming facilities > do. I think LC's are pretty neat, not that that's likely to sway anyone's opinion one way or the other. Like many techniques it can be abused by overuse. regards Steve -- http://www.holdenweb.com/ From dgrisby at uk.research.att.com Thu Jul 26 05:51:16 2001 From: dgrisby at uk.research.att.com (Duncan Grisby) Date: 26 Jul 2001 09:51:16 GMT Subject: Going from webscripting to server-client software. References: <6572890e.0107251014.47e07810@posting.google.com> Message-ID: <9jop6k$l2d$2@pea.uk.research.att.com> In article <6572890e.0107251014.47e07810 at posting.google.com>, Stephen <Shriek at gmx.co.uk> wrote: [...] >I know there's lots to learn here and would prefer to go read up >rather than trouble you so any helpful resources will see me on my way. >Should I be looking at SOAP/.Net or Visual Basic or Java/CORBA instead >or is Python up to it? What other caveats are there ? This is the ideal kind of application for CORBA. You could model both the booking server and each of your client applications as CORBA objects. They would then easily communicate with each other so everything is kept up-to-date. Python is the easiest language in which to develop CORBA applications, and there are a number of CORBA implementations available. This page has a list of them: http://www.faqts.com/knowledge_base/view.phtml/aid/4930 I won't recommend one. I wrote omniORBpy so I'm biased. Cheers, Duncan. -- -- Duncan Grisby \ Research Engineer -- -- AT&T Laboratories Cambridge -- -- http://www.uk.research.att.com/~dpg1 -- From tim.one at home.com Fri Jul 13 15:11:52 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 13 Jul 2001 15:11:52 -0400 Subject: Language Shootout In-Reply-To: <3b4eed03.298292@nntp.sprynet.com> Message-ID: <LNBBLJKPBEHFEDALKOLCCEEEKOAA.tim.one@home.com> [Tim] > Here's another fun one: you can also write a long-int multiplication > routine in Python that runs significantly faster than the builtin > long *! Hint: recursion <wink>. [David C. Ullrich] > I give up, howdaya do that? > > (When I read this I said aha, you're getting at something like > using > > [*] (a*2**k+b)*(c*2**k+d) = a*c*2**(2*k) + (a*d+b*c)*2**k + b*d. > > But when I think about it I don't see why that would give any > improvement - it _seems_ to me that vanilla long multiplication > should be quadratic (a*b takes time "len"(a) * "len"(b), where > "len" is the number of "digits".) If that's correct then using > [*] wouldn't improve things at all as far as I can see. Right, it's not "clever" enough: that reduces an NxN mult to four (N/2)x(N/2) mults. NxN takes N**2 "elementary" (1x1->2) mults, and (N/2)x(N/2) N**2/4, so four of the latter is no savings over the former. The trick is to reduce it to three (N/2)x(N/2) multiplications (and recursively too for those in turn). Then the overall complexity drops from O(N**2) to O(N**log2(3)) ~= O(N**1.58). > Can't decide: > > You're hinting at [*] and I'm analyzing it wrong? (Like > if vanilla multiplication is actually worse than quadratic > in the sense above then [*] will speed things up...) You'll figure it out <wink>. "An answer" is spelled out in Knuth vol 2, or search for "Karatsuba multiplication" on the web. > You're hinting at something kinda like [*] but with clever > rearrangents that does give improvement, like that > Strassen(?) thing for matrix multiplcation? Yes, but not nearly *that* clever. > You're talking about using an FFT-based multiplication? > (One can certainly write a recursive FFT. But surely if > _this_ is what you meant then the hint would be "FFT" > instead of "recursion"...) I'm not sure you can write one of those *in Python* that's actually faster than the builtin long *, unless the longs are so large nobody would care. See http://groups.yahoo.com/group/python-list/message/63188 and followups for Christian Tismer's last known stab at implementing Karatsuba in Python. It pays for ints short enough that somebody *might* care. OTOH, anyone who cares a lot should be using one of the GMP wrappers (GMP also uses this trick, but in excruciatingly long-winded and platform-optimized C). From tim.one at home.com Thu Jul 26 02:33:32 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 26 Jul 2001 02:33:32 -0400 Subject: Use of iterators for state machine (was Re: 2.2 features) In-Reply-To: <3B5FAF50.9AC8912C@engcorp.com> Message-ID: <LNBBLJKPBEHFEDALKOLCGEFHLBAA.tim.one@home.com> [Peter Hansen] > I like the potential for iterators for infinite sequences of several > kinds (where the ability to "get out of a loop early" is an absolute > requirement :-). > > I'm especially looking forward to using them to implement state machines. > > I suspect they will greatly simplify the readability of several > different state machine patterns I tend to use. Has anyone with more > of a background in the whole iterator concept (in other languages > of course) tried this before? Any comments? Have you read PEP 255 ("Simple Generators")? There's a long section at the start discussing exactly that. Generators are great for programming state machines, for reasons explained there in some detail (briefly that state can often be left implicit in control flow and local bindings rather than explicitly materialized into masses of stacks and persistent vrbls). They're not as powerful as full-blown coroutines (a 255-flavor generator can only suspend to its immediate invoker, and that's what's "Simple" about them), but you may be surprised at how far you can get despite that limitation. What you can't do is, in a generator G, yield directly back to G's invoker from a routine called *by* G. But if the routine called by G is also a generator, it can yield whatever it likes whenever it likes back to G, and G can in turn yield that back to its invoker. Both routines are suspended then, and resuming G will as a matter of course resume the generator it invoked too. If you don't think about it too much <wink>, it all works the way you expect; if you do think about it too much, it takes an "aha!" (or maybe even two) to figure out *why* it all works. It took me about 8 years to explain it to Guido <wink> -- although, in his defense, he may wish to protest that the first time he actually paid attention to what I was screaming at him, he "got it" in about one minute flat. pretty-good-for-a-malevolent-dutch-guy-ly y'rs - tim From beazley at cs.uchicago.edu Tue Jul 17 21:11:51 2001 From: beazley at cs.uchicago.edu (David Beazley) Date: Tue, 17 Jul 2001 20:11:51 -0500 (CDT) Subject: Augmented Assignment in Python (PER) In-Reply-To: <OFC5914650.7A1267FB-ON88256A8C.0082F4D3@i2.com> References: <OFC5914650.7A1267FB-ON88256A8C.0082F4D3@i2.com> Message-ID: <15188.57943.434555.429691@gargoyle.cs.uchicago.edu> James_Althoff at i2.com writes: > > David, > > There was a fairly lengthy and animated exchange (which you might have > seen) recently on python-list at python.org concerning augmented assigment. > Unless I'm very mixed up, it appears that your book presents augmented > assignment according to the way that many folks seem to think it works, > which according to Thomas -- and verified easily with Python test cases -- > is, in fact, *not* the way it actually works. > > Thought you might want to know (you might already be very aware of this). > > Jim > > > Thomas Wouters wrote: > <snip> > >No, that's the *whole intent* of the thing. If x += y was supposed to be > >*exactly* the same as x = x + y, it would have been spelled as 'x = x + > y'. > >It isn't, and it's not. It's not supposed to be syntactic sugar for normal > >addition, it's supposed to be syntactic sugar for a method call. > > > >Thomas Wouters <thomas at xs4all.net> > > >From "Python Essential Reference", Second Edition, David M. Beazley > pages 48 - 49: > > " > Python provides the following set of augmented assignment operators: > --------- ----------- > Operation Description > --------- ----------- > x += y x = x + y > > <snip> > > Augmented assignment doesn't violate mutability or perform in-place > modification of objects. Therefore, writing x += y creates an entirely new > object x with the value x + y. > " Well, I seem to have gotten in on this fray rather late. However, to clarify the contents of the Python Essential Reference, the book does discuss the fact that the augmented assignment operators are mapped to a certain set of special methods such as __iadd__() and that user defined classes/types can override these methods (p. 37-38, p.49). Admittedly, this presentation is rather terse--keeping in style with other parts of the book. I think the above sentence would make a lot more sense if it was worded as follows: "For the built-in types, augmented assignment doesn't violate mutability or perform in-place modification of objects. Therefore, writing x+=y creates an entirely new object x with the value x + y. User defined types and classes may choose to implement different behavior by redefining special methods such as __iadd__(), __isub__(), and so forth." Note: I still stand by the statement for built-in types. I looked through the Python sources when writing the book and couldn't find any use of augmented assignment for built-in types. I am not aware of any counter-example where x += y is not equal to x = x + y for the standard built-in types (if there is such an example, please enlighten me!). I'll see if I can add some clarification on this issue in the second printing. Cheers, Dave From gregj at pdxperts.com Mon Jul 9 02:11:43 2001 From: gregj at pdxperts.com (Greg Jorgensen) Date: Mon, 09 Jul 2001 06:11:43 GMT Subject: Eiffel better than Python ? References: <f20ea932.0107030100.6c740683@posting.google.com> Message-ID: <zWb27.320251$p33.6439312@news1.sttls1.wa.home.com> "I read that Burger King is better than McDonalds. Should I stop eating at McDonalds and jump on the Burger King bandwagon?" Are you able to learn more than one programming language? I find that knowing a variety of languages, and learning new ones that look promising, is a most practical approach. To feed myself and my family I find SQL, Visual Basic, VBScript, C/C++, and Java very useful things to know. When I am free to choose the implementation language (which frequently means I'm not getting paid) I choose Python almost all of the time. I used to make good money and even have some fun with Fortran, COBOL, and x386 assembly language, but demand for those has fallen off recently, so I'm glad I "jumped on the C bandwagon" when I did. If I had to choose one language to use for the rest of my life I would certainly put Python on the short list. Fortunately the world is bigger than that, and I'm blessed with the ability to program capably in several programming languages at a time. Greg Jorgensen PDXperts LLC Portland, Oregon, USA gregj at pdxperts.com "Tomasz Stochmal" <tom at peresys.co.za> wrote in message news:f20ea932.0107030100.6c740683 at posting.google.com... > I have read the following book which gives C/C++ heavy bashing > > http://www.elj.com/cppcv3/ > > Conclusion is to use Java or even better choice is Eiffel > > Should I stop using Python and jump on Eiffel wagon ? > > Anybody that tried both languages ? > > How do they compare ? From lisowski.tomasz at sssa.NOSPAM.com.pl Thu Jul 12 03:52:37 2001 From: lisowski.tomasz at sssa.NOSPAM.com.pl (Tomasz Lisowski) Date: Thu, 12 Jul 2001 09:52:37 +0200 Subject: ActivePython word wrap in Shell or PythonWin during list printout References: <3b4cc844$0$172@wodc7nh6.news.uu.net> Message-ID: <9ijkqo$m49$1@news.tpi.pl> U?ytkownik "Rufus V. Smith" <nospam at nospam> napisa? w wiadomo?ci news:3b4cc844$0$172 at wodc7nh6.news.uu.net... > I am running the latest Python from ActiveState and I have a > problem that when I print a long list (Like dir()), the entire list > prints out on one line and I have to scroll over to read it. > > Is there an environment setting to force word wrap at > a certain line length? > > Or is there a list function that can take a list and > pretty print it with word wrap. > > (Not having one gave me an opportunity to learn > some Python scripting as I wrote my own, but > if there was a library standard, that might be better. ) > > > def marginprint(L,margin=80): > b="" > for a in L: > if len(str(a)+b)+3 >= margin : > print b > b = "'"+str(a)+"'" > else: > if b: b+="," > b += "'"+str(a)+"'" > if b: print b > b="" > > > With this function, I just type marginprint(dir()) > and it will respect the margins. > > Only I have to load this into my environment every time > I bring it up. You could possibly add the statement: from my_print_utils import marginprint to your site.py file I have not tried that, but it is supposed to work fin, as far as I know. Regards, Tomasz From qrczak at knm.org.pl Mon Jul 23 14:27:43 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 23 Jul 2001 18:27:43 GMT Subject: PEP0238 lament References: <mailman.995814276.15005.python-list@python.org> <3B5BC1C3.41330762@cosc.canterbury.ac.nz> <jt4oltg3ekdlig096677p295f7mnbumteu@4ax.com> <slrn.pl.9loi9e.2il.qrczak@qrnik.zagroda> <menolto49gnuqp06jgusrpn6nf4d47iede@4ax.com> Message-ID: <slrn.pl.9lor4v.j55.qrczak@qrnik.zagroda> Mon, 23 Jul 2001 19:15:35 +0100, Steve Horne <sh at ttsoftware.co.uk> pisze: > Ever worked with a chaotic system? Remember the butterfly and the > hurricane? That small error can get big very quick using nothing but > multiplies and additions - division is nowhere near as special as > people think it is. If I want approximations I'll ask for them. That's why I want '/' to return a rational, not int or float. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From peter at engcorp.com Sun Jul 29 03:59:14 2001 From: peter at engcorp.com (Peter Hansen) Date: Sun, 29 Jul 2001 03:59:14 -0400 Subject: Let's exclude behind the usable printers, but don't burst the lost opinions. References: <E71BD296.CE8FA110@oxiqi.net> Message-ID: <3B63C252.47ED74A3@engcorp.com> A Walter Dupuis bot wrote: > When will you authenticate the clear slow emails before Grover does? Someone just posted a patch to sendmail.py which does just that, I think. > I'd rather kick compleatly than close with Jimmie's sly warning. Jimmy's been getting on our nerves around here too. Time the jerk stopped posting to comp.lang.python, is what I say. And you prob'ly meant "complete". > My minor Java won't defile before I dig it. The bug unbelievably builds the > idle IRC server. Don't go starting another language war! Java has its uses, but please discuss problems in comp.lang.java, not here. If you want to talk about Java in this group, make it a question about Jython. > The flat messy advertisement shoots over Walter's sticky firewall. > What did James transport to all the librarians? We can't > learn robots unless Eddie will regularly load afterwards. Go > persevere a FORTRAN! The insecure modem rarely disconnects Pamela, it > questions Terrance instead. Sounds like you're a newbie. RTFM. This is all clearly documented in the module index. Try http://www.python.org for a start, and next time make sure you specify which platform you're using so we don't have to make wild guesses. (_Somebody_ had to say it. ;) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From rwallace at esatclear.ie Thu Jul 26 23:06:51 2001 From: rwallace at esatclear.ie (Russell Wallace) Date: Fri, 27 Jul 2001 03:06:51 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <mailman.995989601.30748.python-list@python.org> <cp3d7lbo89.fsf@cj20424-a.reston1.va.home.com> <ubsm8epr5.fsf@ctwd0143.fitlinxx.com> <cp7kww92ph.fsf@cj20424-a.reston1.va.home.com> <m266cg73ig.fsf@mycroft.actrix.gen.nz> Message-ID: <3b60d65e.219212588@news.eircom.net> On 26 Jul 2001 15:50:15 +1200, Paul Foley <see at below> wrote: >But rationals _are_ already in the language. Integers are rationals. >"/" should definitely return an integer when the result can be >represented in an integer. E.g., 4/2 should return 2, not 2.0. The way it works right now is that the _type_ of the result depends on the _type_ of the operands. You could argue about whether the specific case of the current / operator is a bit too error prone, but generally speaking this is reasonable behavior. You want the _type_ of the result to depend on the _value_ of the operands. My reaction to that is ***NO!!!*** It would make the division operator for integer operands so error prone as to be unusable. If that's the intent, much better to have it be an error to use integer operands, that way you wouldn't get silently and inconsistently wrong answers. -- "How many roads must a man walk down?" mailto:rwallace at esatclear.ie http://www.esatclear.ie/~rwallace From deltapigz at telocity.com Sun Jul 29 12:35:42 2001 From: deltapigz at telocity.com (Adonis Vargas) Date: Sun, 29 Jul 2001 12:35:42 -0400 Subject: Slightly off-topic... (sending HTML data through a Python socket) Message-ID: <3B643B5D.E62C6669@telocity.com> I am attempting to send HTML data back to a browser which connected to X port. I have goen over the the HTML RFC and just can not get it to work. What I am attempting to do is send a redirect back to the browser. So far I have something as follows: c.send(""" <HTML> <HEAD> <META HTTP-EQUIV=\"Refresh\" Content=0;Host=\"http://www.python.org/\">" </HEAD> </HTML> """) Any help would greately be appreciated. Adonis From skip at pobox.com Wed Jul 25 09:33:42 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 25 Jul 2001 08:33:42 -0500 Subject: Language change and code breaks In-Reply-To: <Xns90E975194FDD5duncanrcpcouk@127.0.0.1> References: <Pine.LNX.4.33.0107191316390.24983-100000@bms> <mailman.995571273.18192.python-list@python.org> <9j7gv8$9mg@dispatch.concentric.net> <cppuawfqbm.fsf@cj20424-a.reston1.va.home.com> <mailman.995734717.26373.python-list@python.org> <3B5DF101.9B2E4631@earthlink.net> <cpofq9a858.fsf@cj20424-a.reston1.va.home.com> <Xns90E975194FDD5duncanrcpcouk@127.0.0.1> Message-ID: <15198.51894.568840.715658@beluga.mojam.com> Duncan> It might be an idea though to change some of the error messages Duncan> when a NameError or AttributeError is uncaught if a name could Duncan> have matched with different case (although I'm not sure how much Duncan> overhead this might cause). Duncan> NameError: name 'x' is not defined Duncan> could become: Duncan> NameError: name 'x' is not defined, nearest match was 'X' Interesting idea. Performance in exception handling is generally not a big issue, because most often the program is going to exit anyway. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From jwelby at waitrose.com Sun Jul 8 17:04:24 2001 From: jwelby at waitrose.com (Julius Welby) Date: Sun, 8 Jul 2001 22:04:24 +0100 Subject: csv to XML converter crash and burn References: <tkgnj6feescc0d@xo.supernews.co.uk> <mailman.994606693.28411.python-list@python.org> Message-ID: <tkhilaesrc8d6c@xo.supernews.co.uk> A very sensible suggestion. I'll keep it simple. Thanks. Julius "Skip Montanaro" <skip at pobox.com> wrote in message news:mailman.994606693.28411.python-list at python.org... > >>>>> "Julius" == Julius Welby <jwelby at waitrose.com> writes: > > Julius> I just got all public spirited and posted this: > Julius> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66003 > > Julius> It's a module for transforming csv to XML. It works fine for cvs > Julius> strings where no escaped commas or "" appear but..... > > Julius> Unfortunately I now realise I didn't have a sufficient grasp of > Julius> the csv format. > > Julius, > > You might want to take a look at Dave Cole's recently announced CSV parser: > > http://groups.google.com/groups?q=CSV&hl=en&group=comp.lang.python.*&safe=of f&rnum=3&ic=1&selm=mailman.992813221.29993.clpa-moderators%40python.org > > Use that for parsing, then restrict your code to generating XML. > > -- > Skip Montanaro (skip at pobox.com) > (847)971-7098 > From jkraska1 at san.rr.com Sat Jul 7 13:05:28 2001 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 07 Jul 2001 17:05:28 GMT Subject: Comment on PEP-0238 References: <mailman.994427714.26169.python-list@python.org> <cpsngaja4g.fsf@cj20424-a.reston1.va.home.com> <FFv17.1178$Y6.656565@news1.rdc2.pa.home.com> <cpelrskgrr.fsf@cj20424-a.reston1.va.home.com> <9i7a7k$h9ks6$1@ID-11957.news.dfncis.de> Message-ID: <9ngektgqnrl17er73ukukqids95p5158dp@4ax.com> On Sat, 7 Jul 2001 08:31:10 -0700, "Emile van Sebille" <emile at fenx.com> wrote: > >"Guido van Rossum" <guido at python.org> wrote in message >news:cpelrskgrr.fsf at cj20424-a.reston1.va.home.com... ><snip> >> >> (Hm. For various reasons I'm very tempted to introduce 'yield' as a >> new keyword without warnings or future statements in Python 2.2, so >> maybe I should bite the bullet and add 'div' as well...) If one is going to add keywords to a language, I suggest that a list of possible future keywords -- even ones that aren't planned on being supported any time soon -- be reserved at the same time. C// From hostmaster at bemarnet.es Wed Jul 4 03:48:46 2001 From: hostmaster at bemarnet.es (Antonio Navarro Navarro) Date: Wed, 4 Jul 2001 09:48:46 +0200 Subject: Phonebook entry in windows Message-ID: <1885336186.20010704094846@bemarnet.es> Hi all, I need to write a stand-alone Python application that will run like a daemon (started at windows boot) to create a Phonebook entry on a Windows 95 machine, start up a connection, make some FTP transfers and then hang up and delete the connection. I have been reading the mailing list and have found several references to win32ras.CreatePhonebookEntry, EditPhonebookEntry, etc, but I don't know if this functions are fully functional. Where can I find more info, for example a working script that creates-connect-disconnect-deletes a phonebook entry in Python ? Do you think It will be better to use a different approach ? (I prefer not to use rasdial.exe, because I need to obtain full control of the connection process). Thank you in advance, best regards, Antonio Navarro Navarro BemarNet Management http://www.bemarnet.es hostmaster at bemarnet.es -- http://mail.python.org/mailman/listinfo/python-list From nhodgson at bigpond.net.au Mon Jul 30 19:06:00 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Mon, 30 Jul 2001 23:06:00 GMT Subject: Typing system vs. Java References: <mailman.996258291.15055.python-list@python.org> <psog0besc97.fsf@jekyll.curl.com> <3b65a820_7@Usenet.com> <9k4l5c$o985@news1.gtech.com> Message-ID: <sLl97.75231$Xr6.349962@news-server.bigpond.net.au> Peter Milliken: > Sorry Tom, Just can't let the statement "The ideal > language would support both strong and weak > typing." go by :-). As soon as you allow "both" (and > damned if I know how you would do that! :-)), then > your typical C/C++ programmer (unfair there, I > should say "programmer") will choose the loose > typing everytime, because he "knows" what he > means, even if the compiler can't work it out, > doesn't he? :-) So all the benefits that you just > acknowledged for strong typing are lost :-). The way I see a strong/weak language working well is with separate layers that use one or the other technique. In my work I'd like to see the low level data structure layer using strong typing both for correctness and performance. The higher level policy and UI layers would be weakly typed for development speed. Currently, this can be achieved by using C++ for the lower layers and Python for the upper but this separates the code bases too much. An ideal language would allow development of a feature to start as weakly typed and then be migrated to strongly typed when and if required. Neil From kosh at aesaeion.com Tue Jul 24 11:45:58 2001 From: kosh at aesaeion.com (kosh) Date: Tue, 24 Jul 2001 16:13:58 +0028 Subject: PEP238 and zope References: <3B5DE0F7.9070001@nospiced.ham.devis.com> Message-ID: <nvrkj9.hc9.ln@192.168.0.1> Tom Jenkins wrote: > We're a zope shop. Its quite possible that the work we do now will be > still in use for many years (not guaranteed but we still use code now > that we wrote 2 years ago - before it was zope ;) ) > > We use Python Methods in Zope... python snippets stored directly in > zope's zodb. grepping *.py won't find any of these snippets. I don't > believe zope will surface any warnings that PEP238 stipulates (tho I may > be wrong). How do we code _now_ so as to minimize our pain? > > Tom We are a zope shop also so I really feel your pain on this one. My current suggestion is to use the search tool from the root of the ZODB and see if you can find them from there. Thankfully so far zope does not track python versions very fast. I hope it stays with python 2.1 for a good while. Now that Zope 2.4 requires 2.1 maybe zope could almost be frozen at the 2.1 state for a while until python comes up with a good method not to change the behavior of existing code. I have no idea how much code I would have to search through to try and fix some of our ZODBs since I have python products that allow python to be executed in them also and they store that python individually so that a change to the master product that is screwed up can't take out many instances of the product. My feeling is that some kind of upgrader will need to be written to port those objects. What pissed me off is that it will become necessary to do that because the meaning of a language feature changed. Also in zope you will need to check all your dtml for this kind of problem since python is often embedded in the dtml. On the whole I don't think this will be just a few hour cleanup problem. This could take a long time to clean up and while I might do it once, twice will see me off the language for something else. The biggest problem I can see is that this will fail silently and lead to incorrect results. From quinn at yak.ugcs.caltech.edu Mon Jul 16 19:06:58 2001 From: quinn at yak.ugcs.caltech.edu (Quinn Dunkan) Date: 16 Jul 2001 23:06:58 GMT Subject: String Splice Assignment References: <4e3a8319.0107161357.690b5120@posting.google.com> Message-ID: <slrn9l6ssi.i27.quinn@yak.ugcs.caltech.edu> On 16 Jul 2001 14:57:06 -0700, eAndroid <gervaserules at yahoo.com> wrote: >Why don't strings support splice assignment, and what are some Because strings are immutable. >alternatives? Make a new string: >>>> a = 'asdf' >>>> a[1:2] = "EFGH" >>>> a >'aEFGHf' a = 'aoeu' b = a[:1] + 'HTNS' + a[2:] b #-> 'aHTNSeu' (note that even were strings mutable, your above code would not produce 'aEFGHf' since a[1:2] addresses a single character) or: a.replace('o', 'HTNS') Check the docs for the string module for more. >I have a long string (~1000 chars) that I would like to do multiple >splice assignments on. I am now interested alternatives to do this, >especially efficient ones. 1000 bytes is not a long string. Go ahead and make copies. And now is not the time to make sacrifices to the tin god efficiency. If some day you do have a really long string (say, 1 million characters), you can break it up into chunks and store the chunks in a list. When you want the whole thing you use string.join. From aahz at panix.com Tue Jul 31 20:31:28 2001 From: aahz at panix.com (Aahz Maruch) Date: 31 Jul 2001 17:31:28 -0700 Subject: 2.2 features References: <mailman.996258542.15795.python-list@python.org> <slrn9m61bs.atb.quinn@retch.ugcs.caltech.edu> <slrn.pl.9m6a5m.kmu.qrczak@qrnik.zagroda> <cpae1lzio7.fsf@cj20424-a.reston1.va.home.com> Message-ID: <9k7il0$7dv$1@panix2.panix.com> In article <cpae1lzio7.fsf at cj20424-a.reston1.va.home.com>, Guido van Rossum <guido at python.org> wrote: >Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl> writes: >> >> Now thow in 'isinstance' as an old way to spell a specific membership >> test (for types and classes) which doesn't have to be learned about >> at all. > >I love it. 'x in type' as a shorthand for isinstance(x, type). >Checked into CVS! After seeing all the confusion about whether 'x in type' means isinstance() or issubclass(), my preference is for ripping this change out of CVS. The only way in which I think the 'in' operator makes sense is if you're trying to do if x in [int, long]: which starts being rather ugly as the only reason for an idiom's existence. -- --- 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 "activist for accuracy" --SJM From aito at carenet.co.jp Sun Jul 15 19:38:29 2001 From: aito at carenet.co.jp (Akio Ito) Date: 15 Jul 2001 16:38:29 -0700 Subject: Compatibility between MySQLdb and Py2EXE References: <9i54qr01hc9@drn.newsguy.com> Message-ID: <82399a9.0107151538.2c36ca28@posting.google.com> Nigel Linnett <Nigel_member at newsguy.com> wrote in message news:<9i54qr01hc9 at drn.newsguy.com>... > Hi Gang, > > I have just finished writing an application for use at work, and went to compile > it to a Windows EXE using Py2EXE version 0.2.5 (I have upgraded to 0.2.6 and it > didn't help). > > The application is database dependant, so I am uising the MySQLdb module, and > the whole thing works like a charm if I run it from my development directory. > > When I compile the code, and go to run the resulting .exe file, this is the > output... > > > Any ideas? > > Nigel See: http://www.lemburg.com/files/python/mxODBC.html (Freezing mxODBC using py2exe) From plakal-nospam at nospam-cs.wisc.edu Thu Jul 26 22:42:04 2001 From: plakal-nospam at nospam-cs.wisc.edu (Manoj Plakal) Date: Fri, 27 Jul 2001 02:42:04 GMT Subject: PEP 238 (revised) References: <cp4rrz5onj.fsf@cj20424-a.reston1.va.home.com> <mailman.996196255.10345.python-list@python.org> Message-ID: <0y487.183329$mG4.86470993@news1.mntp1.il.home.com> Ken Seehof <kens at sightreader.com> wrote on Thursday 26 July 2001 20:08: > I like quotient too just because the word hasn't been used yet. Yes, > this truncates towards zero, but I don't really think of it in those > terms. > That's an algebraic way of looking at things. I think of this "quotient" > concept as a companion to "modulus". It's a nice clean concept that > maintains closure for integers, rather than a truncation of something. > The term "floor division" to distinguish from "true division" seems > somehow less pure, since the concept is dragged in from the world of > real numbers. > > Hmm, does this mean we rename divmod to quomod? :-) How about quasimodo :) Is Quasi-Modulus defined in math? Manoj From guido at python.org Thu Jul 26 09:44:41 2001 From: guido at python.org (Guido van Rossum) Date: Thu, 26 Jul 2001 13:44:41 GMT Subject: Language change and code breaks References: <Pine.LNX.4.33.0107191316390.24983-100000@bms> <mailman.995571273.18192.python-list@python.org> <9j7gv8$9mg@dispatch.concentric.net> <cppuawfqbm.fsf@cj20424-a.reston1.va.home.com> <mailman.995734717.26373.python-list@python.org> <3B5DF101.9B2E4631@earthlink.net> <cpofq9a858.fsf@cj20424-a.reston1.va.home.com> <3B5FCDC3.C8A2AF9E@unice.fr> Message-ID: <cp1yn3954u.fsf@cj20424-a.reston1.va.home.com> Jerome Alet <alet at unice.fr> writes: > Guido van Rossum wrote: > > But never mind, I'm giving up on making *Python* case-insensitive. > > The hostility of the user community is frightening. > > Don't forget than Dictators, Benevolent of not, often die in a lot of > blood because their "user community" is angry ;-) > > (just a joke, of course) Given the very real and insistent complaints and threats in this group by others referring my "dictatorship", I don't find your joke funny. I didn't choose the title, and I have never done anything to force anyone to use Python. In fact, I have fought (you have no idea how hard) over a license that is so liberal that at any point in time anybody can start a code fork of their own. --Guido van Rossum (home page: http://www.python.org/~guido/) From akuchlin at mems-exchange.org Tue Jul 31 09:34:47 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 31 Jul 2001 09:34:47 -0400 Subject: Tangent on wireless hysteria (was: Language Niches (long)) References: <8beb91f5.0107280407.5a30341d@posting.google.com> <mailman.996429234.13926.python-list@python.org> <BEDD41E8FBB8D77F.D3FD7D805E4BEA41.1A906D050F601417@lp.airnews.net> <3B65FD2B.39BA0A95@engcorp.com> <CE671DDD22B40C3E.25CDBEE912BDD9F9.C0CD28D28A68C3E3@lp.airnews.net> Message-ID: <3dwv4pjk7c.fsf@ute.cnri.reston.va.us> claird at starbase.neosoft.com (Cameron Laird) writes: > My scant contact with WAP has given me no > reason to doubt that it's diving rapidly to > extinction, as Andrew Odlyzko describes in > <URL: http://www.firstmonday.dk/issues/issue6_2/odlyzko/ >. Rohit Khare wrote an interesting analysis of WAP in the July/August 1999 issue of IEEE Internet Computing that's worth tracking down. It seems to be online at http://www.ics.uci.edu/~rohit/IEEE-L7-WAP.html. I was surprised to find out that the WAP people reinvented ICMP, adding 50 to all the error codes for no clear reason. --amk From sill at optonline.net Thu Jul 12 16:05:37 2001 From: sill at optonline.net (Rainy) Date: Thu, 12 Jul 2001 20:05:37 GMT Subject: How popular is Python, anyway? (was: Long Live Python!) References: <E566B020833BD311B6610008C791A39705CA5230@il93exm04.css.mot.com> <mailman.994804336.23495.python-list@python.org> <slrn9koofo.mjk.philh@comuno.freeserve.co.uk> <slrn9kpr3e.527.sill@sill.silmarill.org> <Gzj37.13006$B7.2564502@ruti.visi.com> Message-ID: <slrn9ks0mh.9oi.sill@sill.silmarill.org> On Thu, 12 Jul 2001 15:42:30 GMT, Grant Edwards <grante at visi.com> wrote: > In article <slrn9kpr3e.527.sill at sill.silmarill.org>, Rainy wrote: > >>I doubt I'll find a job using python any time soon. :/ > > Probably not if you wait around for management to tell you to > start using it. > > I use Python on my job because I decided to. I'm probably > luckier than most when it comes to being able to choose my > tools. > whoops.. i posted this followup to a wrong message. "I meant more like sending somewhere my resume saying I know python and did this and that, and getting hired. I actually did use some python at my previous job (some cgi/image manipulation). I was then asked to redo it in perl :-/." -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: http://silmarill.org/cymbaline From sill at optonline.net Sat Jul 28 12:51:35 2001 From: sill at optonline.net (Andrei Kulakov) Date: Sat, 28 Jul 2001 16:51:35 GMT Subject: Colon and underscores References: <39506f84.0107280205.1638011@posting.google.com> Message-ID: <slrn9m5r4n.2ue.sill@sill.silmarill.org> On 28 Jul 2001 03:05:21 -0700, Igor <igor at arzamas.nnov.ru> wrote: > It would be really nice to know the reasons behind some syntax > features. > > What is the real purpose of the colon ":" after each if, def, etc... > Is it really required and cannot be made optional? if something: do_something() Besides, editors detect that : and autoindent for you. Imagine for instance that you are 5 levels of indentation to the right, if there were no colons you'd have to hit enter and then <tab> 5 times! No thanks :P > > Why__ do __Python__ programs __need to __look__ like __swarms__ of > __underscores ? Is it OK that one must dig in underscores instead of > having a normal English word for private symbols, for example? Because they are different from normal functions and variables - so they should look different, too! - Andrei -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: http://silmarill.org/cymbaline From quacko at lists.postmastergeneral.com Mon Jul 9 11:04:00 2001 From: quacko at lists.postmastergeneral.com (Quacko Lotto) Date: Mon, 09 Jul 2001 11:04:00 EDT Subject: GETTING BIGGER AND BETTER! Message-ID: <200107091513.JAA41028@s0225.pm0.net> ******************************************** QUACKO LOTTO.....GETTING BIGGER AND BETTER! http://lotto.quacko.com ******************************************** Dear Lotto Player - We have made some MORE improvements to the site this week, that hopefully makes the game even that much more fun to play! If you haven't played lately, you really should check us out. NOBODY on the net has an easier lotto game to play and NOBODY has better odds of winning a Grand Prize! Quacko Lotto continues to strive to be on the cutting edge of lotto games. Have you played YOUR Free Tickets today? Win up to $1,000,000.00 in Cash! http://lotto.quacko.com *********************************************************** RED CARPET REWARDS AT GRAND BANKS CASINO http://www.grandbankscasino.com/default.asp?from=1072 *********************************************************** Red Carpet Rewards! The best way to earn free credits! Grand Banks casino is rolling out the Red Carpet for our patrons! For every $10 in real bets that you place, Grand Banks will credit your account with one comp point. Collect 100 comp points and you will receive one casino credit! It's so simple and calculated automatically for you. Example: Place a $100 wager on one hand of Blackjack and receive 10 Red Carpet Reward points. Do this 10 times & regardless of the outcome you will have amassed 100 Red Carpet Points. These 100 points now automatically convert to a FREE Grand Banks Casino credit! http://www.grandbankscasino.com/default.asp?from=1072 The Red Carpet Rewards Premier Program: For our more serious players we offer an even more aggressive plan to help you amass points more quickly! The structure is the same, but you will receive 1 Red Carpet point for every $7.50 placed in bets! Please note that Grand Banks reserves the right to invite patrons into the Premier program only. http://www.grandbankscasino.com/default.asp?from=1072 <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> * 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 aleaxit at yahoo.com Mon Jul 2 01:41:44 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 2 Jul 2001 07:41:44 +0200 Subject: Is Python Dead? References: <MNS%6.355$Xs4.225014@news.pacbell.net> <mailman.994049882.30354.python-list@python.org> Message-ID: <9hp1f002dp6@enews4.newsguy.com> "Chris Gonnerman" <chris.gonnerman at newcenturycomputers.net> wrote in message news:mailman.994049882.30354.python-list at python.org... ... > When am I forced? Sadly it seems that integrating any other language > directly into MS Access is out of the question. (Am I wrong? Someone > please tell me if I am!) Depends what you mean by "directly". With COM and ActiveScripting, it's generally not a problem to use Python or other AS-compliant languages with any Office or other Automation-enabled app, albeit with a simple passage through VBA or VBScript. > The only other time is when I must work with dBase tables... but I would > hardly typify that as not being "good database support". http://www.stud.ifi.uio.no/~larsga/download/python/ or mxODBC + the dBase/clipper/foxpro ODBC drivers, or...? Alex From greg at cosc.canterbury.ac.nz Mon Jul 9 23:40:25 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Tue, 10 Jul 2001 15:40:25 +1200 Subject: Comment on PEP-0238 References: <mailman.994630754.21755.python-list@python.org> Message-ID: <3B4A7929.6036BE07@cosc.canterbury.ac.nz> Tim Peters wrote: > > The last time we solved a "it's *hard* to make sure temporary context > changes get undone!" problem in Python was via adding ">>" to "print" <0.8 > wink>. In other words, the solution was to get rid of the context and make it a parameter to the operation instead. I think there is an important lesson to be learned there somewhere <0.000 wink>. -- 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 mirko.liss at web.de Wed Jul 11 04:12:00 2001 From: mirko.liss at web.de (Mirko Liss) Date: Wed, 11 Jul 2001 10:12:00 +0200 Subject: BASIC or Python? In-Reply-To: <slrn9klpsc.ipj.philh@comuno.freeserve.co.uk> References: <3d157fa0.0107051904.7ec368b8@posting.google.com> <slrn9kcfuq.2b7g.kamikaze@kuoi.asui.uidaho.edu> <0t_17.14670$Fk7.131382@news.indigo.ie> <slrn9kkgfp.dj6.kamikaze@kuoi.asui.uidaho.edu> <uBt27.15141$Fk7.136713@news.indigo.ie> <slrn9klpsc.ipj.philh@comuno.freeserve.co.uk> Message-ID: <20010711081201.172D211D.NOFFLE@niccolo.ke4.de> > On Tue, 10 Jul 2001 02:17:31 GMT, Gerry Quinn <gerryq at indigo.ie> wrote: > >>>> for n in range(2, 10): > >.. for x in range(2, n): > >.. if n % x == 0: > >.. print n, 'equals', x, '*', n/x > >.. break > >.. else: > >.. print n, 'is a prime number' > >.. > > > >Now some people may very well find that lovable, but I certainly don't. > >Note how the clever language design means that the 'else' must be > >level-indented with the 'for'. No doubt longer programs are even more You expect the 'else' being level indented with the 'if' conditional, don't you? Well, it's not an 'if...else' structure but a 'for...else' structure. The 'else' clause will be skipped if you leave the 'for' loop with 'break'. There are several weird things in Python, but this isn't one of those. I suppose there's no perfect language. > >fun. The FAQ on increasing speed helpfully notes that function calls > >are expensive... You can write slow code in C and fast programs in Python. Speed often depends on the algorithm. And C programmers tend to write simpler code. Python is often very slow, though. Maybe you should try Perl. I used logfile analyzers in Perl and Python (radiusreport and radiuscontext) and the perl program was much faster. But it used up much memory. When working with large logfiles, memory quickly got exhausted. The other analyzer needed less memory. I think that's because Python often copies a reference and not the actual data. Not wanting to use the swap partition all the time, I switched to the python code. Maybe I should have tried and optimized the perl program. This is just an example, not a benchmark. So don't draw general conclusions. On Tue, 10 Jul 2001, phil hunt wrote: > I don't wish you to know either. Python is far too sensible a > language for the likes of you to be using it. I remember you being a very nice and helpful person, Phil. Too much coffee ? Friendly regards, Mirko Liss From Peter.Mayne at au1.ibm.com Mon Jul 30 07:13:38 2001 From: Peter.Mayne at au1.ibm.com (Peter Mayne) Date: Mon, 30 Jul 2001 21:13:38 +1000 Subject: PEP 238 (revised) References: <cp4rrz5onj.fsf@cj20424-a.reston1.va.home.com> <3B60B3D5.664A3D7F@engcorp.com> <23891c90.0107270138.6bb70413@posting.google.com> <3B61E456.78DFE802@sneakemail.com> Message-ID: <9k4nf2$g70$1@news.btv.ibm.com> "Joshua Macy" <l0819m0v0smfm001 at sneakemail.com> wrote in message news:3B61E456.78DFE802 at sneakemail.com... > Paul Boddie wrote: > > > > But possibly the first thing anyone with any investment in the > > language should be thinking upon starting to read the PEP is: "How on > > Earth am I going to know what needs changing, and how much time and > > money am I going to be spending to adapt to this?" > > > > It seems to me that if upon reading the PEP someone thinks "How on > Earth am I going to know what needs changing?", he is almost guaranteed > to have bugs in his code that relate to the very issue that the PEP > addresses. How could he not, since he's obviously never thought about > it before? Someone who thinks this way should be thanking his lucky > stars ... Suppose a programmer who has used "/", knowing perfectly well what it does, has written a heap of code. Suppose he's just left the job, and you've taken his place. Since he has (not unreasonably) not documented his use of the arithmetic operators, because for some strange reason he didn't expect them to change, then "How on Earth am I going to know what needs changing?" is exactly what you're going to think. Would you be thanking your lucky stars? PJDM -- Peter Mayne IBM GSA (but the opinions are mine) Canberra, ACT, Australia This post is covered by Sturgeon's Law. From tjreedy at home.com Fri Jul 13 17:01:59 2001 From: tjreedy at home.com (Terry Reedy) Date: Fri, 13 Jul 2001 21:01:59 GMT Subject: Python speed References: <roG27.666914$166.13798179@news1.rdc1.bc.home.com> <9ik9kd$nch$1@news.mathworks.com> <9ikc0m$bmg$1@panix2.panix.com> <9ikee9$rpv$1@news.mathworks.com> <9iluu2$bmb$1@panix2.panix.com> <9imtg8$bqe$1@news.mathworks.com> Message-ID: <blJ37.2848$p7.765325@news1.rdc2.pa.home.com> ... > Go back and read the first post in this thread. Someone wanted to > know if Python's speed would be an issue in writing a mud. And, in my > experience, the answer is "maybe". ... 'Maybe' is certainly correct. Enough users sending enough imputs per second requiring whatever average response time will eventually overwhelm any fixed capacity system -- regardless of what language it is written in, and regardless of the type of system. You previously said 'likely' rather than 'maybe'. That requires a bit more discussion to define a context (number of users, complexity of response, etc) and substantiate a claim with respect to that context. When programming in Python, an important part of the context includes the available native code modules (some are part of the standard distribution). The first/third person 3d action game Blade of Darkness works as a Python program because it calls on a (proprietary) native code geometry engine which in turn relies on graphics board processors. Use of the Numerical Python extensions is standard for other computation-intensive applications When playing text muds (over a dial-up connection), I have noticed that response time is quite variable. I have wondered whether delays are mostly due to everyone deciding at once to race out and bash monsters, internet congestion, the program stopping to collect garbage and save state to disk, or maybe the program looping in buggy code. If you have any experience as a system operator, I would be interested to know. I have read that many text muds are scripted with an interpreted C-like language. I expect Python to be competitive with this. If not, reprogramming the bottleneck functions in C might make up the difference. Terry J. Reedy From quinn at yak.ugcs.caltech.edu Tue Jul 10 03:16:55 2001 From: quinn at yak.ugcs.caltech.edu (Quinn Dunkan) Date: 10 Jul 2001 07:16:55 GMT Subject: [OT] Eternal programming References: <mailman.994519931.6264.python-list@python.org> <3B4A7E95.B4AB2F71@cosc.canterbury.ac.nz> Message-ID: <slrn9klav7.rp0.quinn@yak.ugcs.caltech.edu> On Tue, 10 Jul 2001 16:03:33 +1200, Greg Ewing <greg at cosc.canterbury.ac.nz> wrote: >Roman Suzi wrote: >> >> What is left: >> >> Data storage, 8 bit bytes, latin letters, 10 digits, some computers with >> some formal programming languages, and some programmers ;-) who are >> capable to program very simple core interpreter in the language they will >> have at hands. (Even mathematicians will be enough). > >If the English language has changed too much, and >there's no-one left who can understand the spec, >you might have a bit of a problem... Let alone latin letters. Or even utf8. Or 8 bit bytes. I think the real problem will be building a machine that can read old fashioned hard drives. And if they do, will they still work? Consider all the 9 track tape rotting away in closets. I think it's good that old software rots away. If it's gone it's because nobody needed it anymore. A lot of other software which would still be interesting is interesting because of the specific platform it ran on and the time at which it ran (consider Amiga demos). A language won't help for those, you need a museum. From piotrlg at sci.pam.szczecin.pl Wed Jul 25 04:57:34 2001 From: piotrlg at sci.pam.szczecin.pl (Piotr Legiecki) Date: Wed, 25 Jul 2001 10:57:34 +0200 Subject: Methods of setting class attributes Message-ID: <3B5E89FE.DAE10265@sci.pam.szczecin.pl> Hi I'm C++ user and new to Python. I don't know what is the proper method of setting attribute value in a class. I thought that this is ok: class a: atr1=0 atrb=1 ..... Well, after a little tour through python source codes I have changed my point of view. 1. There is no explicit attributes declarations (hm...) 2. I'v found such a information in python's docs: ...... __setattr__(s, name, val) called when setting an attr (inside, don't use "self.name = value" use "self.__dict__[name] = val") ..... This method (among others) has any class. So setting any attribute should always be done by __setattr__() and not smiple self.name = value? Why? -- Regards Piotr Legiecki From qrczak at knm.org.pl Sun Jul 22 14:13:18 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 22 Jul 2001 18:13:18 GMT Subject: Future division patch available (PEP 238) References: <mailman.995776716.24336.python-list@python.org> <slrn.pl.9lkvah.sin.qrczak@qrnik.zagroda> <2kdllt08g3mveg9ojpls6jfe2pfr3j1227@4ax.com> Message-ID: <slrn.pl.9lm5tu.vqe.qrczak@qrnik.zagroda> Sun, 22 Jul 2001 12:55:31 +0100, Stephen Horne <steve at lurking.demon.co.uk> pisze: >>Why div= wouldn't work? (Lexed as two tokens.) > > Because div doesn't exist as a keyword, I meant: if it existed, it would be as easy to form augmnented assignment syntax as for //. There might be other reasons to use // instead of div, but augmented assignment is not a good argument, because it works well with either. IMHO div is more clear. It's used with this meaning in other languages. > If you do add a capability like that, I'd propose $mod and $rem as > new operators - modulo and remainder. After a slight change that they don't introduce new keywords but turn identifiers into operators, you did the same thing as Miranda did over 10 years ago :-) Haskell uses `mod` and `rem` syntax instead of $mod and $rem. It works for all identifiers, possibly qualified by a module name. But Python already uses operators looking as identifiers: or, not, is, in. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From b.e.n. at .r.e.h.a.m.e...c.o.m Tue Jul 3 18:42:14 2001 From: b.e.n. at .r.e.h.a.m.e...c.o.m (Ben) Date: Wed, 04 Jul 2001 08:42:14 +1000 Subject: Language Shootout Message-ID: <ldi4ktoc90c8kbeqq7epkq2dskp99etc3i@4ax.com> http://www.bagley.org/~doug/shootout/ From new_name at mit.edu Fri Jul 20 11:10:40 2001 From: new_name at mit.edu (Alex) Date: 20 Jul 2001 11:10:40 -0400 Subject: newbie pipes question References: <3B58494D.C82965AD@raqia.com> Message-ID: <etditgnljpr.fsf@opus.mit.edu> Check out os.popen. Alex. From not-a-real-address at usa.net Sun Jul 15 04:18:27 2001 From: not-a-real-address at usa.net (those who know me have no need of my name) Date: 15 Jul 2001 08:18:27 GMT Subject: How popular is Python, anyway? (was: Long Live Python!) References: <E566B020833BD311B6610008C791A39705CA5230@il93exm04.css.mot.com> <mailman.994804336.23495.python-list@python.org> <slrn9koofo.mjk.philh@comuno.freeserve.co.uk> <slrn9kpgtq.5ug.gergo.barany@hold.otthon.at> <slrn9kpv3p.ooh.philh@comuno.freeserve.co.uk> Message-ID: <9irjkj31h16@enews1.newsguy.com> <slrn9kpv3p.ooh.philh at comuno.freeserve.co.uk> divulged: >On 11 Jul 2001 21:20:02 GMT, Gergo Barany <gergo.barany at gmx.net> wrote: >>phil hunt <philh at comuno.freeserve.co.uk> wrote: >>> [snip flamebait crap] >> >>If anyone is going to to respond to this thread, *please* take >>comp.lang.c out of the Newsgroups: list. We don't do advocacy here. >>Followups set. > >My post was an entirely objective statistical summary, and contained >no subjective or opinion-based data at all. whether or not that is true, the subject isn't appropriate for most of the groups to which it was posted. -- okay, have a sig then From brian at sweetapp.com Sat Jul 7 12:27:57 2001 From: brian at sweetapp.com (Brian Quinlan) Date: Sat, 7 Jul 2001 09:27:57 -0700 Subject: Selectively importing correct extension module version In-Reply-To: <Pine.BSI.4.21.0107061848540.546-100000@SPIELZEUG.HASENTALER.THOUSAND-OAKS.CA.US> Message-ID: <000501c10701$c8897d60$445d4540@D1XYVL01> Hi all, I'm writing a Python extension module that wraps a large C++ project. For the Windows distribution, I was planning on wrapping my extension module in a package to hide all of the nasty DLLs that I need i.e. Pyana\ __init__.py Pyana.pyd (my extension module) nasty1.dll nasty2.dll ... nastyn.dll My next thought was that I should put both the Python20 and Python21 versions of my extension in the same module since it is tiny (40K) compared to the rest of the package (2.6MB). So I wrote a new __init__.py file: version_info = (0,1,0) __version__ = "0.1.0" import sys major, minor, micro, releaselevel, serial = sys.version_info if major == 2 and minor == 0: from Pyana20 import * elif major == 2 and minor == 1: from Pyana21 import * elif major < 2: raise ImportError("Pyana requires Python 2.0 or later to run") elif major >= 2: raise ImportError("Pyana cannot be run on your Python version.") Then I made a nice ifdef system in my extension to make my module initializer work correctly i.e. initPyana(20|21)?. Finally I realized that I would have to change a lot of internal strings to reflect the correct module name e.g. XSLError = PyErr_NewException("Pyana(20|21)?.XSLError", PyanaError, NULL); Does this seem like a good idea? Right now I am not sure if the additional coding effort justifies the nice packaging. From cbarber at curl.com Tue Jul 31 13:09:27 2001 From: cbarber at curl.com (Christopher Barber) Date: 31 Jul 2001 13:09:27 -0400 Subject: Typing system vs. Java References: <mailman.996540777.8399.python-list@python.org> Message-ID: <pso66c9rpo8.fsf@jekyll.curl.com> <brueckd at tbye.com> writes: > On 30 Jul 2001, Christopher Barber wrote: > > This is a bad example because the code is doing runtime, not compile-time > > checking. I was talking about the advantages of compile-time checking. > > ?? Please review the example - that's compile-time checking there. No it isn't! The (Integer) cast is not performed until run-time. > > Here is how this would be written in Curl: > > > > let v:{Array-of String} = {new {Array-of String}} > > let s:String = "hi" > > {v.append s} > > let i:int = v[0] || ERROR: can't assign a String to an int > > But what benefit have I gained? You have detected a bug at compile-time instead of run-time and you didn't have to write a unit-test to find it. > The only reason it's an error to begin > with is because the language is forcing me to name the type. The language does not force you to specify types, this would also be legal, but you would not see the problem until you actually executed the code: let v = {Array} let s = "hi" {v.append s} let i = v[0] || runtime error It is your choice. If type declarations were added to Python in a similar fashion, then it would not have to impose any burden on developers who don't want to use them. > The fact that the compiler can detect my breakage of the > language-specific rules doesn't really advance the notion that > strict compile-time checking is beneficial. Sure it does. You might not believe that it is worth the trouble, but it clearly has some benefits. Another definite benefit is that knowledge of compile-time types can allow the compiler to generate much better code. We know this is true from our experience on the Curl language. Obviously it would be a lot of work for Python to actually deliver this benefit, but it > What is a real world problem that would not have existed if Python had > strict compile-time checking, and how common is such a problem? Here is a real-world problem: a developer wants to use a language with compile-time type checking and rejects Python because it doesn't have it. > The few times I've had this sort of conversation I've kind of felt that > people's reasoning was like "I use language X. Language X without strict > compile-time checking would make big programs a mess. Therefore, big > Python programs would be a mess." Well, I actually used Python on a number of projects a couple of years ago and did spend more time than I would have liked writing tests to detect type consistency. I found myself writing comments next to variables indicating their intended type. I would much have preferred turning those comments into actual type declarations. I don't think that lack of static type declarations makes Python at all messy. It is still an interesting and useful language. I just think that it would be better with the ability to use static typing when you want to. - Christopher From sh at ttsoftware.co.uk Mon Jul 2 10:27:15 2001 From: sh at ttsoftware.co.uk (Steve Horne) Date: Mon, 02 Jul 2001 15:27:15 +0100 Subject: PEP scepticism References: <mailman.993760063.4583.python-list@python.org> <3dels41dhs.fsf@ute.cnri.reston.va.us> Message-ID: <19v0kt462nkvid15t0fnrpclmem3epc61g@4ax.com> On 28 Jun 2001 17:49:35 -0400, Andrew Kuchling <akuchlin at mems-exchange.org> wrote: >Roman Suzi <rnd at onego.ru> writes: >> I think improving Python itself is also improving what you've >> just mentioned. > >No it isn't. It might make some libraries easier and quicker to write, and perhaps even less prone to bugs. Though of course there is a balance to be maintained. Perhaps I should confess to being biassed. I rarely use more than the basic string and file handling libraries - you know, doing scripting and glue style things. I'll bet that describes a lot of what Python is used for. Python (or rather Jython) is no doubt extremely useful in combination with Java - but I'm not sure there's any value to trying to compete directly with Java. Sometimes I think that the drive to proove that Python can do anything that other languages can do misses an essential point - Python is extremely good (and getting better) at scripting and glue style tasks. That is where its main strength lies. Being good at everything is a pretty tall order. -- Steve Horne Home : steve at lurking.demon.co.uk Work : sh at ttsoftware.co.uk From tanzer at swing.co.at Fri Jul 13 11:51:46 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Fri, 13 Jul 2001 17:51:46 +0200 Subject: not safe at all In-Reply-To: Your message of "Fri, 13 Jul 2001 07:32:28 GMT." <mm8tkt4te3qnbpv3nh5nhsi591o1osln73@4ax.com> Message-ID: <m15L5EI-000wcEC@swing.co.at> Dennis Roark <denro at earthlink.net> wrote: > For amusement, run this little script which demonstrates a > near ultimate in the lack of type safety in the language. > (Perhaps there is a bit of type safety in that you can't do > this: 4 + "one") But look at what you can do in the > following script: > > x = 3 > x = x + 2 > print "x =", x > x = "now I'm a string" > print x > x = [ 5, x ] > print "and now a list:", x > > If you don't believe it, run it. Should any language allow > x to be such a chameleon, to where it can even be a > different type on two sides of an assignment? You're out of your depth here. Lets run your code and then some and look what's unsafe in there: >>> x = 3 >>> x = x + 2 >>> print "x =", x x = 5 >>> x.sort() Traceback (most recent call last): File "<stdin>", line 1, in ? AttributeError: 'int' object has no attribute 'sort' >>> x.upper() Traceback (most recent call last): File "<stdin>", line 1, in ? AttributeError: 'int' object has no attribute 'upper' Currently, x is bound to an integer object and thus doesn't accept calls to string or list methods. It complains loudly about trying to force them on it. >>> x = "now I'm a string" >>> print x now I'm a string >>> x.sort() Traceback (most recent call last): File "<stdin>", line 1, in ? AttributeError: sort >>> x.upper() "NOW I'M A STRING" >>> x = x + 2 Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: cannot add type "int" to string After the rebinding, x refers to a string object and accepts calls to string methods, but complains just as loud as the former int-binding when called with int or list methods. >>> x = [ 5, x ] >>> print "and now a list:", x and now a list: [5, "now I'm a string"] >>> x.sort() >>> x.upper() Traceback (most recent call last): File "<stdin>", line 1, in ? AttributeError: upper >>> x = x + 2 Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: can only concatenate list (not "int") to list And for a binding to a list object, just the same applies -- it will gladly perform list methods but refuses to do any string or int stuff. In Python, objects are typed, not references. If you are used to languages where variables are (more or less) strongly typed but objects aren't, you'll have to shed some old habits and acquire a new point of view to appreciate Python's object model. I'd recommend you go for it. Learning Python's object model will open a new world for you and probably make you a better programmer in your current language(s) of choice, too. A good start for this might be http://effbot.org/guides/python-objects.htm Cheers, Christian -- 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 rnd at onego.ru Mon Jul 2 15:05:06 2001 From: rnd at onego.ru (Roman Suzi) Date: Mon, 2 Jul 2001 23:05:06 +0400 (MSD) Subject: Python and DB support (was: Re: Is Python Dead?) In-Reply-To: <9hq62g0kiq@enews4.newsguy.com> Message-ID: <Pine.LNX.4.30.0107022249170.4650-100000@rnd.onego.ru> It seems I start to understand database concerns of Mr. Wilson the second. Once we tried 3 databases (MySQL, PostgreSQL, Interbase) to suit our task. And for every database (we stopped at Interbase) there was Python support. However, my collegues were not satisfied with it. One somplain was that in ASP/IIS it is "very easy" to receive a "recordset" from database and then apply it in different situations in the ASP-page, because recordset is an object and even subqueries could be made without quering DB again. >From this and also from my own experience with PostgeSQL queries from Python, I could say that DB support in Python exists, but need enhancement and standartization. Probably, higher level more or less common object-oriented interfaces could help this. I must also say, that I myself am completely satisfied with Python DB support, but I do not use DB extentensively and routinely to judge. However, I think that including some more DB support, at least for open source databases like Postgresql and MySQL + ODBC/JDBC, could be a good idea and will give a standard. (Yes, I know about Python DB API). Are there licensing problems or what stops from letting RDB support modules into standard library? Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Monday, July 02, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Catalyze: To lie while looking cute." _/ From clpy at snakefarm.org Fri Jul 13 03:35:55 2001 From: clpy at snakefarm.org (Carsten Gaebler) Date: Fri, 13 Jul 2001 09:35:55 +0200 Subject: Regural expression puzzle for gurus References: <3B4EA0C8.9F697D06@vip.fi> Message-ID: <3B4EA4DB.EED60B0B@snakefarm.org> Pekka Niiranen wrote: > original string: xx:yy:#AAA.!:-#BBB:2324:#CCC:!"?% > > after replacement: xx:yy:#AAA#.!:-#BBB#:2324:#CCC#:!"?% > > How can I do replacement with a single regural expression line ? >>> import re >>> text = 'xx:yy:#AAA.!:-#BBB:2324:#CCC:!' >>> re.sub(r'#\w+', lambda m: m.group(0)+'#', text) 'xx:yy:#AAA#.!:-#BBB#:2324:#CCC#:!' >>> cg. From deedsmis at aculink.net Mon Jul 9 10:03:07 2001 From: deedsmis at aculink.net (SoloCDM) Date: Mon, 09 Jul 2001 08:03:07 -0600 Subject: Language Shootout References: <ldi4ktoc90c8kbeqq7epkq2dskp99etc3i@4ax.com> Message-ID: <3B49B99B.4E496A0C@aculink.net> Ben stated the following: > > http://www.bagley.org/~doug/shootout/ I'm not bashing Python, I'm only commenting on what I saw. The tests, from my previous experience, are legitimate; therefore, the tests raised many unanswered questions. Theses numbers produced at this URL site are very real to me. I noticed a balanced and small memory and cpu usage for most of the Python tests, but C/C++ out weighed most other languages. Would anyone care to comment? -- Note: When you reply to this message, please include the mailing list/newsgroup address and my email address in To:. ********************************************************************* Signed, SoloCDM From kwoeltje at mail.mcg.edu Sat Jul 7 10:24:54 2001 From: kwoeltje at mail.mcg.edu (Keith F. Woeltje) Date: Sat, 07 Jul 2001 14:24:54 GMT Subject: the center of the world (was Re: Check out O'Reilly's Open Source Convention Highlights) References: <cpvglilpzl.fsf@cj20424-a.reston1.va.home.com> <3B3AA82D.1A0FE860@seebelow.org> <Xns90CE99B1A22D9atodddexterpinioncom@203.2.194.51> <3B3B2DED.5303198A@seebelow.org> <9hhri7019jd@enews2.newsguy.com> Message-ID: <3B471BA4.7050306@mail.mcg.edu> Saw this on slashdot and thought of this thread. Here's what the Debian folks did. My trig is pretty rusty, so I'm not sure the method is correct. http://people.debian.org/~edward/average/ digging-up-old-threads-to-put-off-real-work-a-few-minutes-longer-ly yours >K Alex Martelli wrote: > "Grant Griffin" <not.this at seebelow.org> 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-<wink>-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 phawkins at connact.com Fri Jul 20 16:06:01 2001 From: phawkins at connact.com (phawkins at connact.com) Date: 20 Jul 2001 16:06:01 -0400 Subject: Most efficient solution? References: <mailman.995289809.28477.python-list@python.org> <slrn9l5urp.nto.alf@leo.logilab.fr> <OeF47.11959$p7.3571067@news1.rdc2.pa.home.com> Message-ID: <wkk813nz6e.fsf@mail.connact.com> >>>>> "TR" == Terry Reedy <tjreedy at home.com> writes: >> C = {} >> for item in B: >> C[item]=None TR> This sort of makes me wish we had dict comprehensions to match list TR> comprehensions: TR> C = {item:None for item in B} TR> or TR> C = {item:1 for item in B} TR> as revised and then discarded So what's wrong with list comprehensions? Observe, grasshopper: 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 time a = [str(i) for i in range(7500)] b = [str(i) for i in range(0, 7500 * 5, 5)] c = {} for item in b: c[item] = 1 def dict(a,c): start = time.clock() for item in a: d = filter(c.has_key, a) stend = time.clock() print "get: %6.2f"%(stend-start) def comp(a,b): start = time.clock() out = [i for i in a if i not in b] stend = time.clock() print "get: %6.2f"%(stend-start) >>> >>> >>> ... ... >>> ... ... ... ... ... ... >>> ... ... ... ... ... >>> ... ... ... ... ... ... ... >>> >>> >>> >>> >>> comp(a,b) get: 19.78 >>> dict(a,c) get: 154.77 >>> -- Patricia J. Hawkins Hawkins Internet Applications, LLC From ddusa at ziplip.com Thu Jul 26 12:07:54 2001 From: ddusa at ziplip.com (ddusa) Date: Thu, 26 Jul 2001 12:07:54 Subject: $12 Investment...$10,000 Return!!! Message-ID: <UTC200107262110.XAA08050@bacchus.cwi.nl> THIS IS THE SUPER FAST ONE!!!!! While you're waiting for the others to work, this little gem will put $10,00 in your pockett in as little as two weeks!!..I guarantee it!! Your only cost is a couple hours of your time and $10 or $20. That's it. THE GIFTING CLUB (please take two min. to read this) If you want to make several thousand dollars really quick, then please take two minutes to read and understand the program I am sharing with you. No this is not what you think. You do not have to send $5 to five people to buy a report, receipt, or get their mailing list. Nor will you need to invest more money later to get things going. THIS IS THE FASTEST EASIEST PROGRAM YOU"VE EVER SEEN Complete this in a couple hours and you'll never forget the day you received it. If you are doing other programs, by all means stay with them. The more the merrier...please read on. First, there are only three levels, not four, five or even nine like some other programs. This three level program is much more realistic and much, much faster because it is so easy. The response to this program is VERY HIGH and VERY FAST!! You receive your money in a couple weeks, not a couple months. TRUE STORY: Cindy Allen ran this summation four times last year. The first time she received $3,000 in two weeks and $7,000 the next three weeks. When this program is continued, as it should be, EVERYONE PROFITS!! Don't be afraid to gift a stranger. There's an old saying that gifts will come back to you ten fold. THE DETAILS: You only need to mail out 20 copies, not 200 or more like other programs. Mail them to friends, relatives, poeple who send you their programs, people who you know will continue the process. Even if you're now in another program, stay with it by all means, but do yourself a favor, do this one as well!! It is very simple and takes a very small ( $10 to $20 ) investment. This will be big before the others even trickle in. Just give ONE person $5. That's it!! Follow the simple instructions and in a couple weeks you'll have $10,000 because most people will respond to the low investment high speed and huge profit potential. So lets's help each other by keeping it going!! 1. On a blank piece of paper write your name, address, and email address LEGIBLY and wrap it around a FIVE dollar bill. Send it to the FIRST person on the list below ( #1 ). ONLY THAT PERSON ON THE LIST GETS YOUR NAME AND A $5 BILL!! 2. Retype the list, REMOVE the FIRST NAME ( #1 ) from the list. Move the other two names up and add your name in the ( #3 ) position. 3. If you're using snail mail, make however many copies you're sending out, ( at least 20 ) and send them out today!!! If you're using email, make your initial mailing now and save it. Every time you recieve an opportunity letter, mail them this. There is no more to do. When your name reaches the first position, it will be your turn to collect all your gifts. Can you do it?? Of course you can. Get creative. Each time you recieve a "Get Rich Quick" or "MLM" offer in the mail or your email, respond with THIS LETTER. Your name will climb to the #1 position at dizzying rates. Some of you may want to purchase mailing lists or send out hundreds or even thousands of letters. That's great. The sky really is the limit with this unique GIFTING CLUB. ACT FAST AND GET PAID FAST! Honesty and Integrity make this plan work. Send $5 to the first name only. Remove that name and move the other two up one position. Add your name to position ( #3 ). Copy names and addresses EXACTLY. #1. Daniel Weaver, P.O. Box 7, Clarksburg, MO 65025 #2. S. Denyer, P.O. Box 406, Triangle, VA 22172 #3. Bayberry Store, 114 S. Main #305, Fond du Lac, WI 54935 This is a one time mailing so no need to remove. If you wish we will remove your name from our data base. Type remove in the subject line and email ddusa at ziplip.com . From des.small at bristol.ac.uk Wed Jul 25 12:29:04 2001 From: des.small at bristol.ac.uk (Des Small) Date: Wed, 25 Jul 2001 16:29:04 GMT Subject: A few things :) References: <mailman.996068624.2375.python-list@python.org> Message-ID: <m6bsm8lxmd.fsf@maelstrom.maths.bris.ac.uk> Lee Nutter <leenutter at australia.edu> writes: > Also, I was just wondering, Why do you use python? To me its a > hobby. Why do some of you use it over other languages? I love the > language, don't get me wrong, I was just curious :) I use it for number crunching with NumPy. Having a clean 'interpreted' language, with good object-oriented facilities and the ability to handle large arrays efficiently is a Good Thing. Des. -- Dr Des Small, Scientific Programmer, School of Mathematics, University of Bristol, Tel: 0117 9287984 From gustafl at algonet.se Sat Jul 7 10:31:13 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 7 Jul 2001 14:31:13 GMT Subject: Empty sys.path[0] Message-ID: <Xns90D7A828A9E8Dgustaflalgonetse@194.213.69.152> I have a script that I run from the command line in Windows. I need to feed it with configuration settings from an external file. I decided that this file must be in the same directory as the python script. The problem is that I can't find a way to get this directory. The docs say that sys.path[0] should be used for this, but that does only return an empty string. A second question: In the future, I'll use py2exe to make a DOS binary of this script. Will this make any difference when retrieving the script directory? Regards, Gustaf Liljegren From junkster at rochester.rr.com Sun Jul 1 10:11:30 2001 From: junkster at rochester.rr.com (Benjamin Schollnick) Date: Sun, 01 Jul 2001 14:11:30 GMT Subject: Unable to reach Python.org? Message-ID: <junkster-459471.10125001072001@typhoon1-0.nyroc.rr.com> Anyone know of a outage @ Python.org? Netscape is returning that the site is too busy to fullfill my request... - Benjamin From roy at panix.com Sun Jul 15 21:42:50 2001 From: roy at panix.com (Roy Smith) Date: Sun, 15 Jul 2001 21:42:50 -0400 Subject: converting from perl: variable sized unpack References: <roy-B2459F.22112513072001@news1.panix.com> <mailman.995081424.8581.python-list@python.org> <slrn9l4esk.885.quinn@yak.ugcs.caltech.edu> Message-ID: <roy-E01423.21425015072001@news1.panix.com> quinn at yak.ugcs.caltech.edu (Quinn Dunkan) wrote: > Even without that, I argue that a bad pattern match should throw an > exception and not assign None I have to admit, that would be somewhat consistant with the way the rest of the language works, but it sure would make it more complicated to do something like: if re.match (pattern1, string): do stuff elif re.match (pattern2, string): do other stuff elif re.match (pattern3, string): etc, etc, etc. From sholden at holdenweb.com Mon Jul 2 08:38:04 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 2 Jul 2001 08:38:04 -0400 Subject: Singleton classes (with no such thing as static variables) References: <MdY%6.168$iF.4908@news.lhr.globix.net> Message-ID: <kUZ%6.20165$he.986898@e420r-atl1.usenetserver.com> http://www.faqts.com/knowledge_base/view.phtml/aid/1667/fid/242 -- http://www.holdenweb.com/ "Giles Constant" <gilesc at hyperlink-interactive.co.uk> wrote in message news:MdY%6.168$iF.4908 at news.lhr.globix.net... > Hi there, > > Being a C++ head, it's probably more a problem with my design than a python > problem, but I figured you guys would be able to help. > > I'm trying to make a class called "Environment" which will store some > global data such that all instances of the class have access to it. The > alternative is to create a single instance and pass it around every single > object in the entire project, but it gets used so frequently that it would > be rediculous. > > Is there a way of doing this, or do I need a new paradigm? :-) > From peter at engcorp.com Wed Jul 11 18:09:07 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 11 Jul 2001 18:09:07 -0400 Subject: Is Python Dead? Long Live Python! References: <mailman.994883788.13491.python-list@python.org> Message-ID: <3B4CCE83.94DC6521@engcorp.com> Kemp Randy-W18971 wrote: [snip] > But it is hard to get others at my company on > that bandwagon. I have a hard enough time selling Perl. If you are trying to sell both Perl and Python, maybe you're just confusing your audience with a mixed message. Are you trying to promote them on the same basis? If anyone tried to tell me I should be using Perl for a task, although I could also consider using Python because that would be just as effective, I'd have to laugh... (and then apologize and all that stuff, which I really hate. ;-) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From paulsid at home.com Tue Jul 24 13:54:29 2001 From: paulsid at home.com (Paul Sidorsky) Date: Tue, 24 Jul 2001 11:54:29 -0600 Subject: Importing from Another Path Message-ID: <3B5DB655.C830877B@home.com> I'm working on a client/server project (in Python 2.1) and I've got it organized in the familiar structure of client, server, and common subdirectories. What is the correct (i.e. simplest and fastest) way to import modules from the common directory into the client or server? Right now I'm doing it by putting this at the top of each module: import sys sys.path.append("..\\common") del sys This works, but a) I don't need sys so importing it seems like a waste, b) it's obviously not portable (and using os.path.join() would add more wastage), and c) it just seems ugly. Is there a better way? (I'm aware of PYTHONPATH but it would be a pain to use in this case.) I haven't been able to locate any information on doing this. -- ====================================================================== Paul Sidorsky Calgary, Canada paulsid at home.com http://members.home.net/paulsid/ From greg at cosc.canterbury.ac.nz Mon Jul 30 00:37:10 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Mon, 30 Jul 2001 16:37:10 +1200 Subject: [OT] Number theory [Was: A use for integer quotients] References: <yCK67.17615$EP6.4467503@news1.rdc2.pa.home.com> <mailman.995860718.9550.python-list@python.org> <mailman.995862939.15013.python-list@python.org> <mailman.995883879.12071.python-list@python.org> <3B5C5665.8D41D1F1@tundraware.com> <slrn.pl.9los0f.jh4.qrczak@qrnik.zagroda> <3B5C749A.59F97320@tundraware.com> <JDa77.97061$Rr4.549007@ozemail.com.au> <Xns90E97C9849AD5robindotgarneratinam@172.18.25.3> <IjA77.97824$Rr4.589251@ozemail.com.au> <3b602afa.930850@nntp.sprynet.com> <slrn9m121m.e6f.Gareth.McCaughan@g.local> <3b617133.1013412@nntp.sprynet.com> <slrn9m3ssq.1c5.Gareth.McCaughan@g.local> <3b62c8c4.2448381@nntp.sprynet.com> <slrn9m61e6.1jof.Gareth.McCaughan@g.local> <3b6409e0.2079581@nntp.sprynet.com> <3b645f76.747435355@wa.news.verio.net> Message-ID: <3B64E476.F63A0BCD@cosc.canterbury.ac.nz> Bengt Richter wrote: > > So what is the best way to talk about a binary-represented integer > in the abstract? A set of integers in range(n), where n is the number of bits? -- 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 Tue Jul 31 15:44:24 2001 From: bokr at accessone.com (Bengt Richter) Date: Tue, 31 Jul 2001 19:44:24 GMT Subject: 2.2 features References: <mailman.996258542.15795.python-list@python.org> <cpwv4u16rx.fsf@cj20424-a.reston1.va.home.com> <mailman.996270412.11895.python-list@python.org> <cpofq524lr.fsf@cj20424-a.reston1.va.home.com> <slrn9m61bs.atb.quinn@retch.ugcs.caltech.edu> <slrn.pl.9m6a5m.kmu.qrczak@qrnik.zagroda> <cpae1lzio7.fsf@cj20424-a.reston1.va.home.com> <15206.48884.18637.676324@beluga.mojam.com> <mailman.996599433.9583.python-list@python.org> Message-ID: <3b6709dc.922129512@wa.news.verio.net> On Tue, 31 Jul 2001 13:05:06 -0400, Guido van Rossum <guido at zope.com> wrote: >> Guido> I love it. 'x in type' as a shorthand for isinstance(x, type). >> Guido> Checked into CVS! >> >> How about 'x in type' as a shorthand for 'issubclass(x, type)' if x is a >> type or class instead of an instance? > >No, that would be ambiguous. A subclass is not an instance. A class >or type represents a set of instances, so 'in' is justified in a >sense. > 'x of type' for 'issubclass(x, type)' ? Another .02 USD new kw though. From chrishbarker at home.net Thu Jul 5 17:04:43 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 05 Jul 2001 14:04:43 -0700 Subject: There's got to be an easier way to do this References: <mailman.994354039.27054.python-list@python.org> Message-ID: <3B44D66B.E6A2DD6D@home.net> Ryan LeCompte wrote: > Try this: > > 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 > >>>import string > >>>f = string.maketrans('', '') > >>>string.translate('hello99there', f, string.letters) > '99' This only gets rid of letter, not any other character: >>> string.translate('hello9-9there', f, string.letters) '9-9' If I understood correctly, what the poster wanted was to remove everything that isn't a number. this works, however: >>> remove = f.replace("0123456789","") >>> string.translate('hello9-9there', f, remove) '99' -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 noselasd at frisurf.no Mon Jul 2 07:50:46 2001 From: noselasd at frisurf.no (Nils O. Selåsdal) Date: Mon, 2 Jul 2001 13:50:46 +0200 Subject: Unix Scripting Host References: <slrn9jt7s3.a56.gerhard.nospam@lilith.hqd-internal> <9hnaat$284$02$1@news.t-online.com> <slrn9jud7l.111.gerhard.nospam@lilith.hqd-internal> <9hneb9$ca0$00$1@news.t-online.com> <slrn9juj38.ptc.gerhard.nospam@lilith.hqd-internal> Message-ID: <LdZ%6.2052$Jp5.35256@news1.oke.nextra.no> "Gerhard H?ring" <gerhard.nospam at bigfoot.de> wrote in message news:slrn9juj38.ptc.gerhard.nospam at lilith.hqd-internal... > On Sun, 1 Jul 2001 17:08:45 +0200, Thorsten Roskowetz wrote: > >"Gerhard H?ring" <gerhard.nospam at bigfoot.de> wrote: > >> On Sun, 1 Jul 2001 16:00:18 +0200, Thorsten Roskowetz wrote: > >> >You might want to look at KDE's DCOP. > >> > >> Well, I did already. It looks cool and I even got the KSpread > >> example to work, but it's tied to C++ and Qt. > > > >Not entirely true. There are DCOP bindings for C (dcopc) and Python > >(AFAIK only proof of concept at the moment) and even a XML-RPC to DCOP > >bridge (KXMLRPC) which could be used from Python, Java, Perl or any > >other language that provide an XML-RPC implementation. > >There are even native java bindings to DCOP in developement. > > Sorry for not being clear. I have just finished rebuilding the kdebindings and > PyQt RPMs for Python 2.1 to try out the Python examples. They work fine so far. > What I meant was that the DCOP server AFAIK can currently only be written in > C++. I also couldn't find anything that describes the APIs that are exported Probably, but is that a problem ? The DCOP server is already written&working. > via DCOP, but I'd better ask for this in a KDE group. Do that. you might want to get kdevelop (a KDE IDE) which comes with a bunch of documentation , www.kdevelop.org From aleaxit at yahoo.com Mon Jul 2 12:53:28 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 2 Jul 2001 18:53:28 +0200 Subject: python as plugin language References: <993529827.54981@newsmaster-04.atnet.at> <tjh5isq58hk8dc@corp.supernews.com> <tjhc8d7gjuohe8@news.supernews.com> <tji6ftsb4dlla3@corp.supernews.com> <tjiok16g2asmc7@news.supernews.com> <9hhkpq010gl@enews2.newsguy.com> <tk16lbm516pmfc@news.supernews.com> Message-ID: <9hq8ui0o4m@enews4.newsguy.com> "John Roth" <johnroth at ameritech.net> wrote in message news:tk16lbm516pmfc at news.supernews.com... ... > > 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 ... > > So, WHAT am I missing...? > > The fact that my C:\Python21 directory doesn't contain any directory > named "Demo"? Where do I get it? It wasn't in my "typical" Win32 > installation. Darn, you're right -- the Demo directory only comes when you install the *source* distribution (which is why I have it under D:\Python-2.1, where I have the sources installed, rather than on D:\Python21, where I have the normal installation). I do apologize for wrongfully believing you were missing something "under your nose" -- sorry: it's *NOT* among the stuff one routinely gets -- ONLY with the sources-package. Let's say: if you're going to do any embedding or extending of Python with C, it's a *VERY GOOD* idea to install the source distribution of Python too. This should probably be emphasized in the docs AND in the download page too, I guess! You don't need to *build* the source distribution (though it can't hurt, and if you set the options right in VC++ it gives you the .PDB files pointing to your installed sources which can help debug your extensions/embeddings), but having it around as a huge working collection of examples is a VERY good idea anyway. Alex From peter at engcorp.com Sun Jul 29 01:30:27 2001 From: peter at engcorp.com (Peter Hansen) Date: Sun, 29 Jul 2001 01:30:27 -0400 Subject: Problem with timing, again: References: <%QM87.438$k9.52157@e3500-atl1.usenetserver.com> Message-ID: <3B639F73.78E37C2B@engcorp.com> Jeremy Moles wrote: > > It works, but it won't respond, and it won't let the > button go. What am I doing wrong? Classic mistake. > ____________________________________________ > > def dostuff(self): [...] > def domorestuff(): > z=ftplib.FTP(host='ahost') > z.login(user='asuer',passwd='apassword') > z.cwd('public_html') > z.storlines('STOR IP.html',open('D:\\Python\\IP.html','r')) > z.close() > while 1: > domorestuff() > time.sleep(15) > > _______________________________________________ > > Anyways, the program works - but the gui itself freezes up - it's as if the > button is stuck. You guys were so helpful last time, any advice this time? It is typical in GUI programs to have to release the CPU quickly in order to keep responsiveness in the user interface. There is generally a way of having a function called periodically to do some work (e.g. your domorestuff()) but you have to use some feature of the GUI toolkit to set this up, not implement it yourself with time.sleep() as you have done. Sorry, I'm not Tk expert so I can't point you to the specific answer -- only generalities here. :) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From peter at engcorp.com Tue Jul 17 23:09:53 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 17 Jul 2001 23:09:53 -0400 Subject: web interface to c program running on different server References: <3B53B116.86535A3@usa.net> <mailman.995377053.13982.python-list@python.org> Message-ID: <3B54FE00.26071ECF@engcorp.com> Fran?ois Pinard wrote: > > All of this was surprisingly fast to implement. [...] > And merely to please myself, I managed to clean out internals > and to get some more speed: not really that we needed it, > but because I feel better that way. :-) Conditions for optimization: (program-works AND program-is-not-fast-enough) OR programmer-wants-endorphin-rush :) From db3l at fitlinxx.com Mon Jul 23 17:00:14 2001 From: db3l at fitlinxx.com (David Bolen) Date: 23 Jul 2001 17:00:14 -0400 Subject: PEP0238 lament References: <3B5B37B9.4D7A80CD@Lugoj.Com> <LNBBLJKPBEHFEDALKOLCMECPLAAA.tim.one@home.com> <mailman.995900686.5170.python-list@python.org> <Xns90E7C8E2038DDmichaelrcpcouk@194.168.222.8> Message-ID: <ur8v79x9d.fsf@ctwd0143.fitlinxx.com> Michael Abbott <michael.g.abbott at ntlworld.com> writes: > 1. Scientific programs, where presumably the bulk of the work can be done > using floating point numbers. > 2. System control (I use this phrase *very* broadly) programs where > floating point *never* makes an appearance (except, perhaps, for friendly > display to the user). > > (Of course, someone might pipe up, what about all that graphical > programming?) Perhaps I should add a third category of task: > > 3. Graphical programming can, perhaps, be characterised as a mixture of > scientific calulations and discrete control. (Please don't take this too > seriously!) > > > Anyway, my point is this: integers are used for discrete computation and > control, and when I perform arithmetic on integers I expect to continue > working on integers. The idea that a floating point number might magically > appear in the middle of my calculations (because I was foolish enough to > write a/b) does not make me happy. > Of course, the argument seems to be that I should be happy to use // > throughout my code. Perhaps. Perhaps not. But what about all that broken > code, eh? It's the breakage concern that's what really does it for me, and I'm pretty much all system control or GUI in my own uses at this point of Python. I think the only place I've cared about floating point division is when computing percentage complete of some operations for display to a user. Personally, my threshold for this discussion is different in the abstract than in the reality of a pre-existing implementation decision. I buy the arguments for the functionality difference, and maybe even for which makes the most default sense. If Python had started with / for float, and // for integer division, I would just just be using // about everywhere in my code. But it didn't, and I haven't, and once we introduce the idea of changing this for existing code my threshold for which makes the most sense to use for "/" raises quite a bit, for which the current discussions/arguments no longer sway me. In such a case, I'm more in favor of stability of the existing code base. And as pointed out elsewhere, my systems and installed base are not incrementing through each release as they occur because of the cost of doing so. I'm still managing a base of 1.5.2, and will likely jump from that right to a release like 2.1 (or maybe 2.2 depending on my timing and availability of dependent extensions), so it's all too easy to end up skipping over the "warning" release right into the "break" release. -- -- 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 Wed Jul 25 11:07:48 2001 From: max at alcyone.com (Erik Max Francis) Date: Wed, 25 Jul 2001 08:07:48 -0700 Subject: Language change and code breaks References: <Pine.LNX.4.33.0107191316390.24983-100000@bms> <mailman.995571273.18192.python-list@python.org> <9j7gv8$9mg@dispatch.concentric.net> <cppuawfqbm.fsf@cj20424-a.reston1.va.home.com> <mailman.995734717.26373.python-list@python.org> <3B5DF101.9B2E4631@earthlink.net> <cpofq9a858.fsf@cj20424-a.reston1.va.home.com> <23891c90.0107250210.2e37ca61@posting.google.com> <Xns90E97A202990duncanrcpcouk@127.0.0.1> Message-ID: <3B5EE0C4.64716F28@alcyone.com> Duncan Booth wrote: > If I remember correctly, the domain name (after the '@') is not case > sensitive. The user name (before the '@') *may* be case sensitive, but > it > varies from system to system. That's absolutely correct. -- 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 public is a fool. \__/ Alexander Pope Maths reference / http://www.alcyone.com/max/reference/maths/ A mathematics reference. From rajarshi at seed.chem.psu.edu Tue Jul 31 11:28:12 2001 From: rajarshi at seed.chem.psu.edu (Rajarshi Guha) Date: Tue, 31 Jul 2001 11:28:12 -0400 Subject: sleep command/function & searching the python docs Message-ID: <9k6ilm$2sed8$1@ID-91520.news.dfncis.de> Hi, is there a sleep function in the Python library. I've beens earching throught the modules but could'nt seem to find one. BTW, is there any way to search the Python docs for a specific function/module etc? Or is there any resource on the web that provides a searchable interface? TIA, -- -- Rajarshi Guha From wjdandreta at worldnet.att.net Sat Jul 28 09:07:25 2001 From: wjdandreta at worldnet.att.net (William Dandreta) Date: Sat, 28 Jul 2001 13:07:25 GMT Subject: Python, mysql, roundoff problem? Message-ID: <hOy87.24265$gj1.2251802@bgtnsc05-news.ops.worldnet.att.net> mysql stores numbers as strings. I discovered that when converted to floats in Python they are not exactly the same which can cause roundoff errors. The floats represent money and I need to be sure there is no roundoff errors. What is normally done to deal with this situation? I am considering using mysql 64 bit integers to eliminate any roundoff errors. What kind of performance problems might his cause? Bill From aleaxit at yahoo.com Wed Jul 18 11:32:29 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 18 Jul 2001 17:32:29 +0200 Subject: Language change and code breaks References: <mailman.995378792.16515.python-list@python.org> <cpvgkq1f2b.fsf@cj20424-a.reston1.va.home.com> <_bh57.32695$d4.1090608@e420r-atl1.usenetserver.com> Message-ID: <9j4a6e0cpu@enews4.newsguy.com> "Steve Holden" <sholden at holdenweb.com> wrote in message news:_bh57.32695$d4.1090608 at e420r-atl1.usenetserver.com... ... > In the CP4E world, do you feel it is better to educate everybody to > understand that capitaisation has meaning, or dumb down the systems to allow > those without a finer appreciation of language to get what *they* expect, > thereby annoying the literate minority? I've never been quite sure how I consider myself a member of the literate minority (well within the upper centile on all relevant demographics), and having a recently-invented typographic prettiness, such as letter-cd tcase, affect meaning, has always struck me as a deeply flawed idea. I hated it when I first met it in C and Unix, and a quarter of a century hasn't reconciled me to it. Alex From com-nospam at ccraig.org Tue Jul 17 08:25:12 2001 From: com-nospam at ccraig.org (Christopher A. Craig) Date: 17 Jul 2001 08:25:12 -0400 Subject: Most efficient solution? References: <mailman.995289809.28477.python-list@python.org> <slrn9l5urp.nto.alf@leo.logilab.fr> <6qae252b15.fsf@abnoba.intevation.de> <slrn9l60i2.o0p.alf@leo.logilab.fr> Message-ID: <871ynfu4if.fsf@elbereth.ccraig.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 alf at leo.logilab.fr (Alexandre Fayolle) writes: > I suppose that the first loop could also be rewritten using map, in order > to squeeze some more juice out of the beast: > > C={} > map(lambda item,dic = C: dic[item]=1, B) I doubt this would save you anything because the cost of that lambda function will most likely be greater than the savings from the for loop. - -- Christopher A. Craig <com-nospam at ccraig.org> "How does a project get to be a year late? - -- One day at a time" - Frederick Brooks, Jr. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: Processed by Mailcrypt iEYEARECAAYFAjtULqgACgkQjVztv3T8pztPCQCfUEcjOUN7cdjQBX8GuRieA3Dr pZ4AnRo9TobmYzQTQmRRWhNKn/JmFn2U =IF0V -----END PGP SIGNATURE----- From qrczak at knm.org.pl Thu Jul 26 11:42:26 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 26 Jul 2001 15:42:26 GMT Subject: a break for comprehensions References: <9jpadd$s5k$1@news.duke.edu> Message-ID: <slrn.pl.9m0ej2.o3q.qrczak@qrnik.zagroda> Thu, 26 Jul 2001 10:44:55 -0400, Kevin Lacker <kdl4 at acpub.duke.edu> pisze: > Can you do this: > > answer = [] > for x in my_list: > if not is_good(x): > break > answer.append(process(x)) > > with a list comprehension somehow? The pattern can be wrapped in a function. It's quite nice in Python 2.2: def take_while(p, l): for x in l: if not p(x): break yield x answer = [process(x) for x in take_while(is_good, my_list)] > I think it would be cool to be able to reuse the while keyword > inside comprehensions like > > answer = [process(x) for x in my_list while is_good(x)] Looks nice for me. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From vvainio at karhu.tp.spt.fi Wed Jul 18 02:02:09 2001 From: vvainio at karhu.tp.spt.fi (Ville Vainio) Date: 18 Jul 2001 09:02:09 +0300 Subject: TK + cmd.cmdloop() in threads (was Re: howdoI: Exception in thread - terminating the program? References: <yox7kx83xzf.fsf@karhu.tp.spt.fi> <u7kx74dmd.fsf@ctwd0143.fitlinxx.com> Message-ID: <yox1yneojvi.fsf_-_@karhu.tp.spt.fi> David Bolen <db3l at fitlinxx.com> writes: > If your main thread isn't going to be doing anything but spinning up > the other threads, then having it wait on such an event is fine - > although you may want to consider having it read from a queue, and > thus be able to not only receive information from failing threads (the > failing thread could even send over the traceback object through the > queue so the main thread could handle printing/logging duties for all > operational threads), but also completion or other communication from > properly working threads. The architecture is indeed such that the main thread is just waiting there. Having the main thread do the exception saving/printing sounds like a good idea, I think I will do that in addition to the mentioned event. > If you're going to encapsulate this in a GUI at some point, then the > threads can likely generate events to the main GUI thread which can > also serve to communicate such information. I haven't done any UI stuff (apart from cmd and toy GTK/TK examples) in python yet, is it ok to have TK mainloop running in one thread and still perform normal cmd.cmdloop() operation in another? I can't quickly think of any reason why it wouldn't be, but I can't figure out why it hasn't been explicitly suggested... Having a TK window doing the data browsing/drawing while still having a straightforward, versatile cmd.cmdloop() running on a console sounds like an extremely potent combination. Anyone done it? Are there some subtle gotchas that make it a bad idea? > if you need to permit them to perform cleanup, you may actually want a > path from the main thread to the worker threads (e.g., have them check > a terminate flag or event periodically in their execution path) as well. Having a terminate flag is problematic with some threads that are doing something that blocks... if they are reading from a socket you have to kill the socket under their feet to make them go over the read instruction. They may also be blocking on a mutex or a semaphore, which makes things harder. -- 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 duncan at NOSPAMrcp.co.uk Wed Jul 25 06:52:55 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Wed, 25 Jul 2001 10:52:55 +0000 (UTC) Subject: HTML to formatted text conversion function References: <79179cf5.0107241216.7345d345@posting.google.com> Message-ID: <Xns90E97731532B9duncanrcpcouk@127.0.0.1> rupe at metro.yak.net (Rupert Scammell) wrote in news:79179cf5.0107241216.7345d345 at posting.google.com: > Recently I've been using a call like os.system("/usr/bin/lynx -dump > http://www.sample.com > /tmp/site-text.txt") to grab formatted text > versions of pages (without HTML) for subsequent processing. However, > I don't like the fact that this technique introduces an additional > dependency into my code (lynx). I was wondering if anyone could > recommend an equivalent Python function or module that lets me do this > without introducing a platform specific dependency? > > urllib.urlretrieve() gets back the raw HTML page, so it's not really > helpful to me, except as a starting point for processing. > Is this what you need? --- begin strip.py --- # This example will convert a simple HTML file into a plain text # equivalent. This is useful for readme files etc. import sys,formatter,StringIO,htmllib,string from urllib import urlretrieve,urlcleanup # Strip all HTML formatting. class MyParser(htmllib.HTMLParser): def __init__(self): self.bodytext = StringIO.StringIO() writer = formatter.DumbWriter(self.bodytext) htmllib.HTMLParser.__init__(self, formatter.AbstractFormatter(writer)) def gettext(self): return self.bodytext.getvalue() def GetPage(url): try: fn, h = urlretrieve(url) text = open(fn, "r").read() finally: urlcleanup() return text if __name__=='__main__': arg = sys.argv[1] if arg[:7]=='http://': data = GetPage(sys.argv[1]) else: data = open(arg, 'r').read() p = MyParser() p.feed(data) p.close() text = string.replace(p.gettext(), '\xa0', ' ') print text anchors = p.anchorlist for i in range(len(anchors)): print "[%d]: %s" % (i+1, anchors[i]) --- end strip.py --- -- 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 ngps at madcap.dyndns.org Sat Jul 28 10:54:55 2001 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 28 Jul 2001 14:54:55 GMT Subject: Distributed computing using SOAP. What about speed ? References: <LBA77.58$bXi.175168000@news.telia.no> <mailman.996167570.6366.python-list@python.org> <9js13u$c80$1@dahlia.singnet.com.sg> <4Jh87.1292$e%4.30029@news3.oke.nextra.no> Message-ID: <9jujnv$4g$1@clematis.singnet.com.sg> According to Thomas Weholt <t-weh at online.no>: > > - a Medusa-based soap_handler that does HTTP/1.1 server-side > > A quickie: Doesn't medusa provide far better performance than > BaseHTTPServer? Does anybody know? Dunno. But as I keep saying on this newsgroup ;-), Medusa does HTTP/1.1 which provides persistent HTTP connections. BaseHTTPServer (really BaseHTTPRequestHandler) is HTTP/1.0. If network latency is your app's hotspot, this will make a difference. > ( Ng Pheng Siong, you're a life-saver. This is exactly what I need. > Thanks!! :-)) Glad to be of service! ;-) -- Ng Pheng Siong <ngps at post1.com> * http://www.post1.com/home/ngps Quidquid latine dictum sit, altum viditur. From bsass at freenet.edmonton.ab.ca Thu Jul 19 18:08:32 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Thu, 19 Jul 2001 16:08:32 -0600 (MDT) Subject: Case Insensitivity (was Language change and code breaks) In-Reply-To: <%%G57.15495$Cy.1928702@news1.rdc1.az.home.com> Message-ID: <Pine.LNX.4.33.0107191553430.24983-100000@bms> On Thu, 19 Jul 2001, Tim Hochberg wrote: <...> > CaseMismatchError: Case of 'has_spam' doesn't match previous usage (did you > mean 'HAS_SPAM'). That looks case-sensitive to me. If it was case-insensitive... hi == Hi == hI == HI so, has_spam == HAS_SPAM By generating an error you are recognizing case, and enforcing rules about the allowed case of a label... clearly, not being case-insensitive. - Bruce From Tom_Good1 at excite.com Fri Jul 13 19:27:17 2001 From: Tom_Good1 at excite.com (Tom Good) Date: 13 Jul 2001 16:27:17 -0700 Subject: not safe at all References: <mm8tkt4te3qnbpv3nh5nhsi591o1osln73@4ax.com> <slrn9ku3c3.mrk.9nick9m@localhost.localdomain> <u26ukt4vot7b1qu02hkp8l1pnmdi0sfp3l@4ax.com> Message-ID: <ac677656.0107131527.6519cd88@posting.google.com> Dennis Roark <denro at earthlink.net> wrote in message news:<u26ukt4vot7b1qu02hkp8l1pnmdi0sfp3l at 4ax.com>... > Python is an attractive language. But for a large program I > would still rather be forced to declare the name of a > variable (and its type) rather than risk misspelling or > misuse 500 lines later in the program. My original note was > not intended to be an indictment of Python, but only to > bring up some reasons that for me make more strongly typed > languages like C++ or Object Pascal better at coding very > large projects. People who are new to Python sometimes worry about dynamic typing and assume that it will make for unreliable code. I remember wondering about the same thing at one point. On the other hand, I have never heard a Python veteran complain about dynamic typing based on actual experience. Nobody seems to ever step forward and say, "after years of using Python, I eventually gave up on it and went back to C because of all the bugs I kept having related to dynamic typing." :-) If you like Python, I would encourage you to try it out and see for yourself what happens. Though it is easy to contrive examples where such bugs might occur, in my experience with Python I very rarely encounter them. When I do, they are very easy to find and fix because of Python's excellent traceback feature. Tom From dedalus at yifan.net Sun Jul 29 17:54:02 2001 From: dedalus at yifan.net (Duilio Foschi) Date: Sun, 29 Jul 2001 21:54:02 GMT Subject: importing modules References: <mailman.996439858.7059.python-list@python.org> Message-ID: <3b6484c1.131075601@news.libero.it> Hans, >I can send this executable to you if you want to. it would be great. Thank you Duilio From sholden at holdenweb.com Sun Jul 29 21:22:42 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sun, 29 Jul 2001 21:22:42 -0400 Subject: doctest x idle problem? References: <mailman.996103607.3926.python-list@python.org> <b8c015b9.0107271956.3661a8a0@posting.google.com> Message-ID: <5C297.544$WD1.106193@e420r-atl2.usenetserver.com> "Jon Schull" <jonschull at yahoo.com> wrote in message news:b8c015b9.0107271956.3661a8a0 at posting.google.com... > "Tim Peters" <tim.one at home.com> wrote in message > > ...I have no idea why you're doing "Run Script" on doctest to begin > > with. That's not a sensible thing to do -- doctest is a library module in > > 2.1, and you shouldn't need to load it into IDLE at all, let alone ever run > > it on itself. > > > > Well, I was hoping to develop and test some modules within the idle > environment. (I'm wondering how well IDLE serves as a primary > Interactive Development Environment.) > > I ran into this "problem" (it's not unique to doctest) and thought I > was doing something wrong. I figured doctest's use of docstrings for > testing would be exemplary, so I tried doctest. > > In a way, doctest *was* exemplary... > > But it seems that its going to be awkward to do interactive > development in IDLE of modules that employ doctest. That seems a > shame; routine use of doctest and IDLE would be a good practice. Well, it really doesn't seem excessively demanding to test in a separate process when you want to run doctest. Surely you don't do that except when you want to be sure you have a stable new version which is compatible (as dictated by regression tests) with the previous one? regards Steve -- http://www.holdenweb.com/ From db3l at fitlinxx.com Wed Jul 11 20:31:37 2001 From: db3l at fitlinxx.com (David Bolen) Date: 11 Jul 2001 20:31:37 -0400 Subject: Language change and code breaks References: <wuN27.13377$Y6.4240331@news1.rdc2.pa.home.com> <cplmlvh6dx.fsf@cj20424-a.reston1.va.home.com> <6A%27.454703$eK2.93741234@news4.rdc1.on.home.com> <m3k81fb7jc.fsf@chinon.cnrs-orleans.fr> <un16bcibu.fsf@ctwd0143.fitlinxx.com> <zP337.4881$z21.497530@newsc.telia.net> Message-ID: <uelrn3s46.fsf@ctwd0143.fitlinxx.com> "Fredrik Lundh" <fredrik at pythonware.com> writes: > David Bolen wrote: > > > > > And a//b definitely beats (a+0.)/b, which does the trick, but is not > > > at all evident. > > > > Well, I'd probably suggest using "float(a)/b" instead which at least > > makes it a little easier to see what's going on :-) > > except that it doesn't do the right thing if a is a complex > number. Hmm, good point - I hadn't thought of that. Of course, if a was complex then we wouldn't be worried about a/b truncating anything either. But definitely something to keep in mind if working on code that might receive either complex or integer parameters. -- -- 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 steve at lurking.demon.co.uk Tue Jul 24 00:43:26 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Tue, 24 Jul 2001 05:43:26 +0100 Subject: PEP0238 lament References: <mailman.995839419.19134.python-list@python.org> <cEN67.17775$EP6.4652917@news1.rdc2.pa.home.com> <cp3d7ngazy.fsf@cj20424-a.reston1.va.home.com> <mailman.995944063.12608.python-list@python.org> Message-ID: <vbuplto32kls0kvc4caadom1osb6rimlm3@4ax.com> On Tue, 24 Jul 2001 06:11:36 +0300, Kirill Simonov <kirill at xyz.donetsk.ua> wrote: >Hello, > >Please tell me, how to write a correct program that uses integer >division and must work on Python 2.1 and Python 2.4. There is a simple workaround to keep in mind for new software, and for software that you get get hold of to change in advance. It ain't pretty though... def intdiv (a, b) : return divmod (a, b) [0] Not too bad where it's an option. From peter.milliken at gtech.com Wed Jul 4 18:56:54 2001 From: peter.milliken at gtech.com (Peter Milliken) Date: Thu, 5 Jul 2001 08:56:54 +1000 Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> <9hrj3q$cj1@news1.gtech.com> <bebbba07.0107031040.593143f8@posting.google.com> <9htgsb$ck3@news1.gtech.com> <9huo4n01jfl@enews1.newsguy.com> Message-ID: <9i072s$ck8@news1.gtech.com> Hi Alex, Thanks for sharing that information. Have a look at http://www.rational.com/products/whitepapers/337.jsp for the productivity paper I was referencing. As for the productivity data, I apologise, my original comment was in the very narrow and strict proviso of real-time applications and using a "normal" real-time language. So I am venturing out of my experience depth somewhat here in some of my comments :-). Please correct me where you feel the urge :-). I wouldn't use/choose Python in a true real-time application because (usually) interpreted languages just can't compare in terms of speed performance with languages that have been designed with lower level capabilities in mind i.e. C. (Another interesting URL is this one: http://dblp.uni-trier.de/db/conf/sigada/triada92.html#LawlisE92 - sorry, you will need an ACM membership to get access to the paper though, it used to be freely available but I couldn't find any valid references other than this). Now, I know that computers are "faster than light" now and "this is nolonger a consideration" in this day and age. But it still is for large scale systems. The problem domain almost invariably stretches the current hardware (remember, at some stage you have to choose the hardware platform and commit yourself to it, you can't develop an application over the course of several years without making that commitment relatively early in the piece - it used to be a lot worse in the "good old days", you bought the target hardware at the start of the project and drooled over what the current state of the art was by the end of the project but were forced to watch your dream creation running on a, by then, dinosaur :-)). Python shines at manipulation of things like strings, dictionary searches, list manipulation etc etc but these are rarely requirements or useful features in a real-time problem domain (I have worked on projects that lasted years where most of the programmers didn't know how to do basic IO or manipulate strings in the language because the portions of the system architecture they were in didn't require any interface to the user!). I believe that Python is being used in some high performance areas, so don't get me wrong, I wouldn't necessarily rule it out for those reasons but any interpreted language *automatically* becomes less of a consideration when I think of what language to do a real-time application in. The mere fact that you can drop into an underlying language (C or whatever) when you require speed is one of Pythons strengths, but also supports my idea that it is one of its weaknesses when it comes to real-time. Most real-time systems don't have a lot of data handling required ie read string processing, Python (and such languages) are optimised for this kind of situation. So, any situation that requires manipulation of data in these forms are going to benefit from using Python. But surprisingly, the majority of real-time systems aren't called on to manipulate these kind of data structures. As for "have only the BEST programmers. How to insure THAT is left as an exercise for the reader:-)." Well, that's not possible when you have to staff a project with large numbers of programmers. Most managers get so desparate to have "bums on seats" that they take what they can get and tell the team leads to "make the most of it" :-). There is no doubt, that if you are lucky enough to work with a small, good group of people then you can do very good work. But generally, even when I have worked in teams as small as 4 people, the 25%-50% rule has still been evident i.e. at least one of those 4 was a "waste of space", another was only "so-so" the other two did all the real work and helped pull the others across the finish line through plan old hard work :-). This has to be an important factor (IMO :-)) when choosing a language/development environment i.e. you need "tools" to help *force* that 25%-50% to produce better quality work - but even that is only an *aid* there is no "silver bullet" that will solve the problem. One of Pythons strengths is the freedom it offers - with poor programmers this becomes one of its greatest *weaknesses* (I can hear the howls of outrage from here in Sydney :-)). With this element of your work force (and you have to plan for them as well, because you will have them, no doubt about it! :-)) then something (language, process, whatever) that will "funnel" them down the right path is what you have to aim for. As for the "superstar" concept - don't believe it to the extent you imply :-) Yes, research *can* show productivity factors like that and I can tell you stories of people who were placed on third shift where they were "out of sight" - all they did was get their sleep and did *no* work (one that comes to mind was they couldn't sack her because she would have cried racial discrimination - and so when her work was due they just reassigned it to another programmer). So productivity when compared to these people *can* achieve factors of 1000:1. But in a normal world, I believe very much in the lower published figures (languages aside here) of anywhere from 2:1 to 15-20:1 (which is still pretty high and is a direct result of my 25%-50% rule i.e. they shouldn't *even* be in the industry! :-)). That is not to say that companies shouldn't reward the high performers but how do you measure that performance? :-) The minute you talk about metric gathering (code review, bugs per KLOC, resubmittal rate etc etc) you hear the howls of outrage - "how dare you measure my performance", "how dare you criticise my code" - it's almost like when we leave University we somehow drop the mantle of engineer/computer scientist and take up the mantle of artist/prima donna :-) Anyway, thanks for sharing the reference, hope you enjoy mine :-). BTW, they give away the hint of what language I *would* use to program an ATC :-) Peter "Alex Martelli" <aleaxit at yahoo.com> wrote in message news:9huo4n01jfl at enews1.newsguy.com... > "Peter Milliken" <peter.milliken at gtech.com> wrote in message > news:9htgsb$ck3 at news1.gtech.com... > ... > > There are studies that indicate that productivity in strongly typed > > languages is higher (2:1 in one study I read - unfortunately, they are > > "thin" on the ground because you need two identical ability teams doing > the > > same application in two different languages to get meaningful > comparisions - > > but it has been done and that was the result) than loosely typed > languages. > > I'll appreciate some URL's, thanks. In exchange, please look at > Lutz Prechelt et al's 1999 "phonecode" study -- e.g. at > http://wwwipd.ira.uka.de/~prechelt/documents/jccpp_tr.pdf. > > 80 implementations of the same specs, some in "scripting languages" > (Perl, Python, Tcl, Rexx), some in "system languages" (Java, C, > C++). As it happens, Python was the only language for which NONE > of the submitted programs was 'unusable' (11 of the original 91 > were not further evaluated, being completely unusable). Overall > results (my biased summary): programmer productivity is highest > (by far) in Perl or Python (no statistically significant > differences between Perl and Python). Program performance is > highest in C and C++, followed by Perl and Python, followed > by Java, with Tcl and Rexx far slower yet. Many of Prechelt's > conclusions are invalidated by grouping Tcl and Rexx together > with Perl and Python, but fortunately he also supplies raw data > so you can redo the analysis. > > > > Agreed, but one of my original points was about programmer ability. A > > The difference between the best and worst programmers in any single > given language is far larger than any difference among languages, > as evidenced in Prechelt's study -- in both productivity, and in > correctness and performance of the resulting programs. E.g., > the fastest Python and Perl programs are *HUNDREDS* of times > faster than the slowest C and C++ ones, incredible as that may > seem for what was a rather simple overall task. > > > successful. There is no one single factor that anyone can point to and say > > "if you do that or use this" then you will be successful in your > > Oh yes there is -- have only the BEST programmers. How to insure > THAT is left as an exercise for the reader:-). > > > Unfortunately, language choice is a very sensitive issue, and generally > > doesn't come down to any rational factors - a lot of times it is "because > I > > like it" or "this is the newest, popular language, if I learn that one > then > > I can enhance my employment prospects" :-). > > The latter is a perfectly-rational factor. If you want to swing > programmers' motivations towards "doing the best we possibly can > on THIS one product", you have to make that compatible with their > overall motivation of "have an interesting and financially rewarding > career". Stock options, cash prizes for specific targets, whatever. > Non-financial forms of recognition can also be very important...! > > If you want/need to treat your programmers as interchangeable parts, > don't be surprised if they treat your project as just one short step > within a long career. My impression is that most development shops > underestimate the importance of keeping their best programmers and > attracting other super-performers -- because it's not acknowledged > yet that the individual performance variation between the best > programmer in the best environment, and a mediocre programmer in > a mediocre environment, is MANY orders of magnitude (easily a > factor of 1,000 -- look at those *hundreds of times performance > ratios* above-quoted for best-Python vs worst-C...!!!). Once this > little fact does start to be realized, we may move into a kind of > "superstar economy" for developers, as is currently in force in > sports, show-business, CEO's, traders, and some professions (lawyers, > doctors), where top performers earn _disproportionately_ more than > mediocre counterparts -- which will have its own problems (and how!), > but very different ones from today's relative "flattening" (where a > performance that's 1,000 times better is only rewarded 10 or 20 > times better, if that). > > > Alex > > > From francis.meyvis at sonycom.com Mon Jul 30 05:17:53 2001 From: francis.meyvis at sonycom.com (Francis Meyvis) Date: Mon, 30 Jul 2001 09:17:53 GMT Subject: 100,000 messages celebration? References: <25b2e0d9.0107291052.7780d1f8@posting.google.com> <3B64BA49.C105612B@student.gu.edu.au> Message-ID: <5D997.52$Nq1.2409@nreader1.kpnqwest.net> This would be great! I remember in the very very beginning a lot of people were posting silly jokes on the list. I think they thought this list was about the Monty Python thing. Much to the frustration of some "serious" clerics. At that time it were my first experiences with the "net". Very enjoyable it was! --- Kind regards, best wishes, francis meyvis Joal Heagney <s713221 at student.gu.edu.au> wrote in message news:3B64BA49.C105612B at student.gu.edu.au... > gods1child wrote: > > > > All this heated discussion over floats has led me to wonder if we need > > to lighten up a little bit and celebrate the fact that were close to > > 100,000 (94,100 as of this moment) messages on this news-group which > > IMHO is some sort of a mile-stone for this neat little group. > > Suggestions for celebrations? > > A memorial post? --> Drag some of the classic posts out of archives and > repost them? > -- > Joal Heagney is: _____ _____ > /\ _ __ __ _ | | _ ___ | > /__\|\ || ||__ |\ || |___|/_\|___] | > / \ \_||__ ||___| \_|! | | \ \ ! From klaus-gerd.meyer at de.bosch.com Wed Jul 25 04:41:24 2001 From: klaus-gerd.meyer at de.bosch.com (Klaus-G. Meyer) Date: Wed, 25 Jul 2001 10:41:24 +0200 Subject: Any Suggestions for an Editor with MS-Windows ? References: <92757716C8BFF476.D432477A795DB759.E2FB05E062137965@lp.airnews.net> Message-ID: <9jm0p6$rk8$1@proxy.fe.internet.bosch.com> Try http://www.fixedsys.com/context. It is a nice Editor for Windows. Has syntax coloring for many languages (also Python) and it's freeware! Klaus From quinn at hork.ugcs.caltech.edu Fri Jul 27 06:18:18 2001 From: quinn at hork.ugcs.caltech.edu (Quinn Dunkan) Date: 27 Jul 2001 10:18:18 GMT Subject: re Challenge: More Compact? References: <3B51E6B1.47E25214@tundraware.com> <92ae279c.0107151429.398e6e9e@posting.google.com> <slrn9l4fob.p58.tim@vegeta.ath.cx> <slrn9l4rck.rlt.quinn@regurgitate.ugcs.caltech.edu> <roy-50ACE3.07435116072001@news1.panix.com> Message-ID: <slrn9m2fva.gti.quinn@hork.ugcs.caltech.edu> On Mon, 16 Jul 2001 07:43:51 -0400, Roy Smith <roy at panix.com> wrote: >quinn at regurgitate.ugcs.caltech.edu (Quinn Dunkan) wrote: >> for o in '.'.split(ip_addr): >> assert 0 <= int(o) <= 255, 'ip octet not a byte in "%s"' % ip_addr > >Don't you also have to catch the ValueError you'll get if o is not a valid >integer? The whole point is to raise an exception if ip_addr is invalid, right? And ValueError is probably the right one. In fact, you should probably catch the AssertionError and convert that to a ValueError. But, as others have pointed out, this will still pass a lot of invalid ip addresses. From nospam at newsranger.com Mon Jul 2 07:51:22 2001 From: nospam at newsranger.com (Levente Sandor) Date: Mon, 02 Jul 2001 11:51:22 GMT Subject: File-like objects for reading zip files? References: <9hks27$549$1@slb2.atl.mindspring.net> Message-ID: <_eZ%6.4201$Kf3.33223@www.newsranger.com> wxPython -- http://wxpython.org -- has a wxZipFSHandler class with FindFirst, FindNext and OpenFile methods. I hope this will help you. Levi In article <9hks27$549$1 at slb2.atl.mindspring.net>, Greg Landrum says... > >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 tjreedy at home.com Fri Jul 27 11:02:37 2001 From: tjreedy at home.com (Terry Reedy) Date: Fri, 27 Jul 2001 15:02:37 GMT Subject: Ints and performance (was Re: PEP0238 lament) References: <mailman.996211014.7234.python-list@python.org> <3B6109E3.624BE2B0@engcorp.com> Message-ID: <hof87.34031$EP6.8711809@news1.rdc2.pa.home.com> > That is my point, though. These integer optimizations are, as we > agree, a clear win. Are these optimizations in danger of being impacted > as a result of this unification, or will we still be able to count > on integer performance being significantly better than that of > less frequently used types. I agree with this concern. I would say it thus (especially for Tim and Guido), with some rough numbers: We agree that the 10 to 1 gain in programming speed often to usually makes up for the 100 to 1 loss in execution speed (or we would not be using Python). But it would not as often make up for a 10000 to 1 loss (if such resulted from some fancy unification scheme). Since we love Python so much, we would *prefer* not to have to recalculate the tradeoff and have to choose between options such as a) convert more code to embedded C, which for many would be a first-time experience; b) stick with the last 'fast' Python; c) support a parallel 'fast' Python version; or d) (gasp!) investigate other languages. Terry J. Reedy From web.mail at lycos.com Thu Jul 12 19:46:03 2001 From: web.mail at lycos.com (Alan Green) Date: 12 Jul 2001 16:46:03 -0700 Subject: Long Live Python! References: <E566B020833BD311B6610008C791A39705CA5230@il93exm04.css.mot.com> <mailman.994804336.23495.python-list@python.org> <slrn9kokj6.mjk.philh@comuno.freeserve.co.uk> <3B4CC986.A5C8E605@engcorp.com> Message-ID: <270c68fe.0107121546.249b9efa@posting.google.com> Peter Hansen <peter at engcorp.com> wrote in message news:<3B4CC986.A5C8E605 at engcorp.com>... > I tend to think of Python more as an extremely effective and maintainable > general-purpose programming language, which happens also to work > very well when applied as a "scripting language" (whatever that means). <soapbox> Until it reaches the mythical "mindshare critical mass", Python is going to have to take over the world just one project at a time. For those of us who want to work in Python in the typical IT shop, this means doing some advocacy. To be an effective advocate of Python, you need to: a) deeply understand what the people you are advocating to understand, b) have the respect of the people you are advocating to, and c) deeply understand why Python is better at the kinds of problem being solved, and be able to express it. (a) might be a lot of work, depending on your background, but it certainly helps with (b). (b) is critical to the success of your argument - how often do you find yourself swayed by the argument of someone for who you have no respect?. (c) is definitely a lot of work - reading and coding. If you can do all of these, then you will be well on the way to making an argument that is effective both on the technical and person-to-person levels. In an IT shop, the audience for your advocacy needs to include: the programmers that would need to work on Python code, the technical management and possibly your client or end-user. I plan for the process to take 12 months before expecting to see significant results. And remember: it might not work, but then again, there is no fun in a guarantee. </soapbox> Enjoy! Alan. From henken at seas.upenn.edu Tue Jul 31 13:43:11 2001 From: henken at seas.upenn.edu (Nicholas Henke) Date: Tue, 31 Jul 2001 13:43:11 -0400 (EDT) Subject: decent syslog replacement? In-Reply-To: <20010801011857.A8795@Vetinari.home> Message-ID: <Pine.LNX.4.33L2.0107311342150.2256-100000@roughneck.mydomain.org> Thanks...I forgot about the syslog - thing...The main problem is the syslog disk thrashing...I guess I wasnt really clear about that. Are there any clean options to buffer even more than syslog might do? Nic On Wed, 1 Aug 2001, Malcolm Tredinnick wrote: > On Tue, Jul 31, 2001 at 12:43:11PM -0400, Nicholas Henke wrote: > > Hello, I am in the process of writing a Metakit database wrapper. I am > > running into performance problems when I try to log a ton of debug > > messages. The system with thrash the disk when logging. I have tried using > > syslog, replacing stdout with a file, etc. None of these seem to help much. > > The only luck I have had is to just use print and have bash redirect to a > > file. This causes problems in other servers that are trying to log to the > > same file. > > Well, you have just described a number of _different_ problems here (for > example, replacing stdout with a file will not work if you are using > system() or os.pipe() calls). > > As far as your original problem goes, syslog attempts to be reliable > even in case of crashes. So, by default, it flushes every message to > disk as it is written. > > It is possible to turn off this flushing to disk after each right, by > prepending the filename in /etc/syslog.conf with a '-'. See the > syslog.conf(5) man page for details. Note, however, that this is only > valid for Linux (it was added in the port from BSD sources originally), > but if you aren't running Linux, then there's just not much point to > programming, really. :-) > > Cheers, > Malcolm > > -- Nicholas Henke Undergraduate - SEAS '02 Liniac Project - University of Pennsylvania http://clubmask.sourceforge.net ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ work: 215-873-5149 cell/home: 215-681-2705 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There's nothing like good food, good beer, and a bad girl. From nperkins7 at home.com Fri Jul 20 04:08:24 2001 From: nperkins7 at home.com (Nick Perkins) Date: Fri, 20 Jul 2001 08:08:24 GMT Subject: greenbeen seeks advice (24 recommended exercises) References: <E15N2SE-00058T-00@mail.python.org> <mailman.995542832.23503.python-list@python.org> Message-ID: <YFR57.510933$eK2.107354493@news4.rdc1.on.home.com> ok, but what do i do *after* lunch?? "Mike Brenner" <mikeb at mitre.org> wrote in message news:mailman.995542832.23503.python-list at python.org... > Mike Brenner wrote: > > > ... most programmers don't write programs that meet specs. Most > > > programmer define greatness to be having fun while making money. > > > To be great in that sense, instead of meeting specs, write the > > > following Python programs (and for extra credit, do each program > > > twice -- once using wxPython graphics, and once using Jython.) > > > > [snip list of trivial first-year programs ;-)] > > > > I think you left out one small thing. How, by writing those programs, > > fun it may be, would I make some money? > > > > Peter Hansen, P.Eng. peter at engcorp.com > > Hi Peter! > > I agree that the majority of those exercises are first year exercises. > > The 24 recommended exercises were for a person who stated they would > like to BEGIN a career in programming. Upon completion of about 20 out > of the 24 exercises they should be able to support themselves as a > computer programmer. > > That is because they would have developed the basic Python and web > skills required. They would also be able to transfer those Python skills > over to Java or various mega-corporate languages. > > You appear to be a different case, because you put "P.Eng." after your > name. People who have a degree or a professional license after their > name ALREADY have a resource that can make them money. Therefore, a > different set of recommended exercises would be needed to raises you to > the next level of YOUR game. > > So, here are some exercises that you could probably sell to make money > for yourself at your level. Each exercise suggests who you could sell > the software to. > > > RECOMMENDED ADVANCED EXERCISES FOR PROFESSIONAL ENGINEERS > > 1. FAA. Do a multi-player Air Controller game with 50 Air Traffic > Controllers controlling 10,000 aircraft in the sky over the country at > one time flying 10,000,000 people between the airports and airstrips of > a large country, preventing collisions and near collisions, both on the > ground, while in the neighborhood of an airport, and in between > airports. Maximize safety and Minimize passenger waiting time both on > the ground and in the air. > > 2. NASA. Do a multi-object simulation game with 1,250,000 representing > all of the space junk, meteors, asteroids and comets that might hit the > earth as they bounce off all the gravitational fields of the planets. > Determine when and if each object will hit the Earth or leave meteor > trails. > > 3. Army. Program the BOLO Tank, fully autonomous weapon system, which > according to the famous science fiction novel was invented by General > Motors in 1990 and in 1997 rebelled against the Army and determined that > the human race was the enemy and exterminated it. EXCEPT, program it to > not exterminate the human race. Using satellite sensors, the Bolo will > fly itself to any part of the world and shoot its target. > > 4. Space Com. Do a satellite game that shows the portions of the Earth > covered by each satellite. Automatically pick the best satellites to > communicate with, to sense the earth with, to send signals across from > other satellites, etc. > > 5. Air Force. Do an advanced three dimensional pilot station for a new > type of air-space fighter craft that acts like an airplane when in the > atmosphere but like a space craft above 80,000 feet. Track the pilot's > eyeballs to see what he is looking at on the radar scope. Read the > pilot's blood pressure helmet to see when she is emotionally angry, to > know when to fire the missiles. Integrate a bunch of radars, weapons, > defenses, escape mechanisms, communication systems, control systems, > backup systems, reentry systems, scientific research systems, satellite > repair systems, and atmospheric measurement systems into the game. > > 6. CIA. Program a robot that understands English and obeys orders with > the intelligence of an 8 year old, but who never gets bored. > > 7. Department of Clone Wars. Program a biological simulation of all the > genes in a DNA molecule that predicts what kind of monsters or diseases > will come out if you switch around a given set of genes. > > 8. Mobile-Phone Companies. Program an interface that lets mobile phones > run applets, commercial windows software, commercial linux software, > Python programs, http, ftp, etc., SECURELY on wearable internet phones. > > 9. Mobile-Phone Companies. Program a method of surfing the internet > anonymously (including statistical anonymity) from mobile-phones. > > 10. Proprietorship. Make a much better Internet Search Engine that > really understands natural language and finds what you wish. > > > Hope everyone who reads this finds a project that raises them to the > next level! > > From rcena at epcor.ca Fri Jul 6 13:59:26 2001 From: rcena at epcor.ca (Resty Cena) Date: 6 Jul 2001 10:59:26 -0700 Subject: Is Python Dead? References: <MNS%6.355$Xs4.225014@news.pacbell.net> <458b194a.0107050711.72007607@posting.google.com> <TH%07.3499$i8.339613@e420r-atl3.usenetserver.com> Message-ID: <458b194a.0107060959.6bd34b3f@posting.google.com> Well thank you for jolting me out of my comfortable position sitting with my hands tucked between my pants and the chair. I donwloaded cx_Oracle and, yes, it's up. Now, would you happen to have, or know of, some materials (sample code, tips, tricks, techniques, tutorials) on getting started on programming *forms* based applications in Oracle and Python? That would be just great. "Steve Holden" <sholden at holdenweb.com> wrote in message news:<TH%07.3499$i8.339613 at e420r-atl3.usenetserver.com>... > "Resty Cena" <rcena at epcor.ca> wrote in message > news:458b194a.0107050711.72007607 at posting.google.com... > > "Edward B. Wilson II" <ed at ewilson.com> wrote in message > news:<MNS%6.355$Xs4.225014 at news.pacbell.net>... > > > I have been following Python for five years now, and I am still just as > > > frustrated with it as I was in 1996. > > > > > > Python still doesn't have good database support, > > > > I, too, have been following Python since 1996, waiting all the while > > to make it easy for me to do database programming. What I'd call good > > database support is where I download a file or set of files into a > > directory under my Python directory, perhaps run an install program, > > then start Python, import a package, issue a command to connect to > > Oracle, and start playing around with the scott/tiger database. I > > don't want, nor do I have the time, to compile anything, nor muck > > around with the Windows registry, nor manually set paths -- I just > > want to try the product, not install it for production use. Ideally, > > I'd like the IDE to do this for me. I'm a database programmer, and I > > want to write applications right away. I'm also lazy and I expect much > > from my tools. > > Of course, one of the reasons why support isn't better is the huge ratio of > consumers to producers. That's not necessarily a bad thing, but most of the > best parts of Python have been the results of individuals providing what > they needed for their own purposes and then opening up the resulting code. > > Continue to sit on your hands by all means. What you need should be along in > another five years or so. But simply posting to complain that things aren't > as you want is unlikely to change in the next six months what nothing else > has changed in the last five years. > > There are lots of people doing much good database work with Python. The > mxODBC package (free for non-commerical use) and the cx_Oracle package > (free) do indeed let you do what you describe (i.e. download, unpack, run an > install script and connect to a database). So I suggest you look a little > harder and complain a little less. Normally I try to include URLs in > postings such as this, but you know, somehow I get the impression that > clicking on a link in a news posting might just be too much trouble ;-) > > Come on in, the water's lovely. > > regards > Steve From dirck at pacbell.net Thu Jul 12 03:07:59 2001 From: dirck at pacbell.net (Dirck Blaskey) Date: Thu, 12 Jul 2001 00:07:59 -0700 Subject: Language change and code breaks References: <wuN27.13377$Y6.4240331@news1.rdc2.pa.home.com> <cplmlvh6dx.fsf@cj20424-a.reston1.va.home.com> <Sa137.1466$zv2.51843@news.pacbell.net> <3B4D3622.5B4FC76E@cosc.canterbury.ac.nz> Message-ID: <n1c37.177121$qv3.44584072@nnrp5-w.sbc.net> "Greg Ewing" <greg at cosc.canterbury.ac.nz> wrote in message news:3B4D3622.5B4FC76E at cosc.canterbury.ac.nz... > Dirck Blaskey wrote: > > > > In all the examples cited that show why this is a problem, > > it's not integer division that causes the confusion, > > it's division of integer *literals*. > > That's only because the examples have deliberately > been made very concise, to show the essence of > what's going on. > > The problem occurs when / is applied to integer > *objects*, which can arise from any number of > sources. The problem occurs when the programmer doesn't realize there is a problem, not because of something fundamentally wrong with integer math. It's a problem with expectations and the law of least astonishment. Which audience would you rather astonish, and how much? After I thought about it some more: "of course the examples show literals, or they wouldn't be very good examples, would they?" though I still assume this example: (x+y)**(1/2) is verbatim. Detecting and reporting the case for literals wouldn't break code, and might provide enough help to some novice programmers so they would realize this is something they have to be aware of, and perhaps learn, and maybe even remember in the cases where they're not using literals. It is a burden. "Might"+"some"+"perhaps"+"maybe" is far too vague for Guido's tastes. Of course, it was just a thought, if not necessarily a good one. d From guido at python.org Fri Jul 27 13:49:52 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 27 Jul 2001 17:49:52 GMT Subject: PEP 238 (revised) References: <cp4rrz5onj.fsf@cj20424-a.reston1.va.home.com> <q%f87.34136$EP6.8735302@news1.rdc2.pa.home.com> Message-ID: <cphevy2rf1.fsf@cj20424-a.reston1.va.home.com> "Terry Reedy" <tjreedy at home.com> writes: > > Title: Non-integer Division > > Now that I look at it, the title seems rather odd, given that at least > half of the PEP and the discussion is/has been about integer division. > How about Revising Division or even better Splitting the Division > Operator. Good point. Done. --Guido van Rossum (home page: http://www.python.org/~guido/) From owen at astrono.junkwashington.emu Tue Jul 24 15:14:05 2001 From: owen at astrono.junkwashington.emu (Russell E. Owen) Date: Tue, 24 Jul 2001 12:14:05 -0700 Subject: question about handling pointers in C extensions Message-ID: <9jkhdv$r3o$1@nntp6.u.washington.edu> I would like a bit of help with handling pointers in C extensions. I hope this is a simple question. I want to write a Python interface to a device driver library. One starts by opening the device and getting a particular kind of pointer, e.g. (simplified): DevType *dev_open() Is the following reasonable, or is there a better way to do this? static PyObject *open (PyObject *self, PyObject *args) ) { PyObject *py_dev_p; DevType *dev_p; /* call the C routine to open the device */ dev_p = dev_open(); if (dev_p == NULL) { PyErr_SetString(PyExc_RuntimeError, "open failed"); return NULL; } /* convert device pointer to a Python Long object */ py_dev_p = PyLong_FromVoidPtr ((void *) dev_p); if (py_dev_p == NULL) { return NULL; } /* increment reference and return the PyLong */ Py_INCREF (py_dev_p); return Py_BuildValue("O", py_dev_p); } Also, are there any tricks or gotchas to passing the pointer in to device control functions? I am assuming the inverse functions are the ticket (parse "O" format to extract the PyLong, then use PyLong_AsVoidPtr). "O!" sounded interesting to get a void* in one step, but what are the "Python type objects" one can pass? Anyone have a simple example of a converter function for "O%"? I assume: - there is no need to INCREF or DECREF the PyLong pointer (so long as my extension only uses it locally, i.e. doesn't store it) - eventually the user should call a Python interface to dev_close and at that time the PyLong should be DECREFed. Any advice or warnings would be appreciated. I have been reading "Extending and Embedding" and "Python/C API", but I still have doubts I've got the pointer handling right. Regards, -- Russell From aleaxit at yahoo.com Sat Jul 14 18:20:32 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 15 Jul 2001 00:20:32 +0200 Subject: How to run codeobjects in Python? References: <mailman.995024902.7812.python-list@python.org> <9imphr015u5@enews1.newsguy.com> <3B4FBBD8.45F56742@engcorp.com> <9iorv60pj2@enews4.newsguy.com> <3B50421E.F00DBFD@engcorp.com> <9ipkp501mop@enews4.newsguy.com> <3B50716F.2A9C12CA@engcorp.com> Message-ID: <9iqgmp0hdj@enews1.newsguy.com> "Peter Hansen" <peter at engcorp.com> wrote in message news:3B50716F.2A9C12CA at engcorp.com... ... > What kind of water is just right? I've lived in Guelph, Ontario, > much of my life, where the water is extremely hard but very > little treated and so relatively devoid of mystery chemicals. > Pray tell, where must I go for the water I need to improve > the state of my pasta? Will only bottled Italian water combine > in the right way with the One True Durum Wheat? :-) Bologna has very hard water too, alas (we get very pretty 'calanchi' in the nearby hills, but then we get to drink and wash with the calcium escavated away by rainwater to form those pretty forms:-), so most everybody drinks bottled water, and those who care also use it for many cooking tasks -- but I'll admit that, to the best of my knowledge, that doesn't extend to cooking ordinary (hard) pasta (it _might_ matter for freshly made egg-based pasta, but you're not likely to get that anyway in Ontario, I fear -- it doesn't travel well...!). Since it's important to use very abundant amounts of water when cooking pasta, the price of what is still a very cheap dish would skyrocket if that abundant water had to be costly bottled mineral water. One thing that has basically disappeared from Italian usage since Goethe wrote admiringly about it a couple centuries ago is the idea of cooking ordinary pasta in broth (then after straining it, season it with nothing but lots of grated cheese, since it's savoury enough not to need any sauce). Fresh egg-based pasta IS still often cooked in broth, though (tortellini in particular, one of Bologna's most famous specialties, really need to be cooked in _chicken_ soup to be perfect). But not spaghetti or other kinds of hard-pasta. I'm desperately straining to think of some Python related hook to avoid this being woefully OT, but am miserably failing, so I apologize to all non-pasta eaters in the audience...:-( Alex From bokr at accessone.com Thu Jul 12 04:37:52 2001 From: bokr at accessone.com (Bengt Richter) Date: Thu, 12 Jul 2001 08:37:52 GMT Subject: Light Speed Socket Connections References: <d01baf67.0107112132.34e70d03@posting.google.com> Message-ID: <3b4d6184.1698299906@wa.news.verio.net> On 11 Jul 2001 22:32:16 -0700, tangell at kicker.com (T Angell) wrote: >I wrote some code to test how long it takes to make socket connections >and ran it against several hosts around the world, here are some >sample times: > >socket time: 0.0047459602356 >socket time: 0.00469899177551 >socket time: 0.00404000282288 >socket time: 0.00537407398224 > [...] > t1 = time.time() For accurate timing, time.clock() is recommended, I believe: """ clock() Return the current CPU time as a floating point number expressed in seconds. The precision, and in fact the very definition of the meaning of ``CPU time'', depends on that of the C function of the same name, but in any case, this is the function to use for benchmarking Python or timing algorithms. """ """ time() Return the time as a floating point number expressed in seconds since the epoch, in UTC. Note that even though the time is always returned as a floating point number, not all systems provide time with a better precision than 1 second. """ From aleaxit at yahoo.com Tue Jul 31 09:16:37 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 31 Jul 2001 15:16:37 +0200 Subject: simple question:the count of array References: <mailman.996583454.15942.python-list@python.org> Message-ID: <9k6b3n027ib@enews4.newsguy.com> "sdf" <wqh-2 at 263.net> wrote in message news:mailman.996583454.15942.python-list at python.org... > >>> a=['a','b','c'] > >>> b=a.count() > Traceback (most recent call last): > File "<pyshell#9>", line 1, in ? > b=a.count() > TypeError: count() takes exactly 1 argument (0 given) > >>> > > then how I get the number of a,I mean how much > values in a,in this case it should be 3 len(a) is 3. Alex From slinkp23 at yahoo.com Mon Jul 9 16:53:41 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Mon, 09 Jul 2001 20:53:41 GMT Subject: Language Shootout References: <mailman.994689198.3317.python-list@python.org> <3B49F724.1F3DF6B3@yahoo.com> <3B4A0C34.C64202C2@Lugoj.Com> Message-ID: <3B4A185D.7C9EC4A5@yahoo.com> James Logajan wrote: > > Paul Winkler wrote: > > So basically what that benchmark tells me is: "Don't write recursively in Python > > if performance is an issue". > > Well yes, this is what benchmarks are useful for. Right. I didn't know that before I looked at the site, so I'm glad I did. I just wanted to prevent other people from making my initial mistake - assuming that the tests only had to produce the same result. I was surprised how far down the list python was on the fibonacci test until I started playing around with alternative implementations and realized it was the recursion that was slowing it down. -- ................... paul winkler .................... custom calendars & printing: http://www.calendargalaxy.com A member of ARMS: http://www.reacharms.com home page: http://www.slinkp.com From pinard at iro.umontreal.ca Thu Jul 12 11:13:47 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 12 Jul 2001 11:13:47 -0400 Subject: list and implicit continuation may cause bugs in Python programs In-Reply-To: <07cb01c10ae4$64a3c440$9865fea9@SUXLAP> References: <Pine.LNX.4.21.BCL.0107121756210.14873-100000@suzi.com.onego.ru> <07cb01c10ae4$64a3c440$9865fea9@SUXLAP> Message-ID: <oqvgkyrxhw.fsf@lin2.sram.qc.ca> [Andreas Jung] > From: "Roman Suzi" <rnd at onego.ru> > > Do not forget commas: > > > > list =[ "update", "y", "m", "d", "y1", "m1", "d1", "event", "url", > > "preview" ] > > > > list =[ "update", "y", "m", "d", "y1", "m1", "d1", "event", "url" > > "preview" ] > > > > Or Python will silently make: > > ['update', 'y', 'm', 'd', 'y1', 'm1', 'd1', 'event', 'urlpreview'] > > > > Does PyChecker check for these kind of things? > For what reason should it check ? Both is valid Python code. In the > second case 'url' and 'preview' are concatenated. This is dedicated > behaviour. It should check because this is poor writing style to have concatenation of strings written with such a vertical alignment. "url" and "previews" have no kind of logical vertical alignment, and a good checker should consider this as suspicious. > Also the following is correct Python code: > print "url" "preview" > print "url","preview" > So there is no way to determine the programmers intention at this point. This time, we have a comma not followed by a space, which is dubious style. My ideal checker would tell me if do such stylistic mistakes. :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From moshez at zadka.site.co.il Sun Jul 22 15:05:17 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Sun, 22 Jul 2001 22:05:17 +0300 Subject: PEP0238 lament In-Reply-To: <LNBBLJKPBEHFEDALKOLCIECDLAAA.tim.one@home.com> References: <LNBBLJKPBEHFEDALKOLCIECDLAAA.tim.one@home.com> Message-ID: <E15OOXV-0003x3-00@darjeeling> I'm the last person to avoid going off on a tangent. On Sun, 22 Jul 2001 14:22:21 -0400, "Tim Peters" <tim.one at home.com> wrote: > I wish the definition of continuity were > easier to teach too, but that doesn't mean I'll settle for an easier > definition that doesn't actually work <wink>. Here is one that is easier to teach, if you just reverse the order of teaching calculus and first-order logic and basic set theory. A function is continuous at c if, when embedding the world of Reals into a saturated model (or, say, 2^{Beth_omega} saturated, if you don't want to get into subtle assumptions), for every infinitesimal x, f(c+x)-f(c) is an infintesimal. Of course, you might think that teaching about saturation is hard -- well, it might be ;-) i-always-blamed-cauchy-and-weirstrass-for-tormenting-the-world- with-epsilons-and-deltas-ly y'rs, Z. -- gpg --keyserver keyserver.pgp.com --recv-keys 46D01BD6 54C4E1FE Secure (inaccessible): 4BD1 7705 EEC0 260A 7F21 4817 C7FC A636 46D0 1BD6 Insecure (accessible): C5A5 A8FA CA39 AB03 10B8 F116 1713 1BCF 54C4 E1FE From ymor at checkpoint.com Sun Jul 29 04:54:24 2001 From: ymor at checkpoint.com (Yossi Mor) Date: Sun, 29 Jul 2001 10:54:24 +0200 Subject: Creating package in Python ??? Message-ID: <3b63c20c$1@news.barak.net.il> Hello I am new with Python and I would like to ask several questions: 1. For creating a package I have to create a *.py script that will group selected modules and contain the following script __init__.py. -> Can you elaborate on this script definition. 2. I have tried to create a package that contains 2 modules and succeeded in importing the package itself but not a module inside the package for example 'import pkg.fib1' - what was wrong ? Thanks Yossi From pwos at home.com Tue Jul 3 11:06:38 2001 From: pwos at home.com (Wostenberg) Date: Tue, 03 Jul 2001 15:06:38 GMT Subject: zope's acquisition inheritance Message-ID: <3B41E221.CE23D83E@home.com> This Smalltalker has been studying Zope, the Opensourced python product for internet deployment (see http://www.zope.org), to learn. It has an unusual model of interitance called acquisition, which blends class heiarchy with containment. Read http://www.zope.org/Members/Amos/WhatIsAcquisition for introduction. Basically "objects automatically gather. services from their containers.". Everything is potentially a collector-class, and if I drop objects into a collection, they inherit behavior from the container. Weird, but somehow natural in this Web environment which organises content around a tree-structured containment plan. Anybody heard of acquisition outside Zope, or is it a new contribution to OO modelling? -Alan From emmanuel.astier at winwise.fr Wed Jul 4 08:46:23 2001 From: emmanuel.astier at winwise.fr (Emmanuel Astier) Date: Wed, 04 Jul 2001 12:46:23 GMT Subject: Python for Commercial Games? References: <9haoiv$jnv$1@mtc1.mtcnet.net> <tjq5huamq17k11@news.supernews.com> <slrn9k21pe.aqd.kamikaze@kuoi.asui.uidaho.edu> <87d77iw6vi.fsf@gabriel.heim6.tu-clausthal.de> Message-ID: <3b430e21.14825517@news.iway.fr> On 03 Jul 2001 14:10:25 +0200, Patrick Bothe <Patrick.Bothe at ePost.de> wrote: >Hi, > >> However, you're not going to do any modern, graphics intensive >> game completely in Python. >Hmm ... >I do not know how much of "Severance - Blade of Darkness -" >is written in Python, but I think this game is a good >argument against your statement. >And where's the difference between using C++ >and for example OpenGl (or any other powerful toolkit) and >Python and OpenGl? >I think i did not get the point. > >bye, > Patrick > > >-- This game is a good example of how to use Python for any modern commercial game : all the engine is made in C / C++ ( Visual, sound, IA CPU eater functions like A*, ... ) Python is used on top of this, to change Finite State machine of the game, ie things that does not require CPU, but is a real big and important part of the game. It's a real win to use a interpreted, hight level language for this part. To use your sentence, there's no difference between using a engine with C++ and using a engine with python ( python is easier). OpenGl and a real engine are _REALLY_ different things... BTW, pygame is aiming in this direction : creating an engine that would be used in Python. But the CPU eater parts are still made in C/C++.... From tjreedy at home.com Wed Jul 25 11:16:51 2001 From: tjreedy at home.com (Terry Reedy) Date: Wed, 25 Jul 2001 15:16:51 GMT Subject: PEP0238 lament References: <5sdnlt072hm6hp17nluu6f0fqq4bvr6mj8@4ax.com><mailman.995873261.11975.python-list@python.org><916olt0p3kciv0evmotdg6jev9bl29l57i@4ax.com><Xns90E77C7A1776Cjimpublishingresourc@207.126.101.100><3B5C52EA.9430255E@alcyone.com><cpofqaova7.fsf@cj20424-a.reston1.va.home.com><slrn9ls92t.eia.philh@comuno.freeserve.co.uk> <mailman.996031845.16386.python-list@python.org> Message-ID: <DpB77.27338$EP6.6897772@news1.rdc2.pa.home.com> "Barry A. Warsaw" <barry at zope.com> wrote in message news:mailman.996031845.16386.python-list at python.org... > Modulo the micro-release number, which is guaranteed to only include > patches (but no guarantee that such patches won't break your code :), > why not just symbolically link oldpython -> python2.0 and newpython -> > python2.2 ? Or just make sure that your old applications, for which > you cannot afford even the possibility of code breakage, always and > explicitly use python1.5 or whatever? Interesting point. A 'change' in the interpreter by definition changes the behaviour of some non-empty set of program texts. So if one wants to be Six Sigma safe, one should test thoroughly with one or more versions of the interpreter and then restrict the program to run under that or those versions. Something like, I suppose, import sys if sys.hexversion not in [17105648] # Python 1.5.2 print "This critically important program has not been tested to run correctly under", sys.version print "Exiting ..." sys.exit() I recently realized that a seemingly-safe change that gives semantic meaning to a syntactically valid but previously meaningless construct (given the state of the vars) will break code that relies on the previously resulting exception. Consider ... def sq(a): return a*a ... def user(b): try: c=sq(b) except TypeError: return None return number_func(c) # we know c is a number ... Now make seq*seq mean crossconcatenation and the program may break. This raises the issue of whether an exception, in any particular circumstance, is defined behavior (which referably should not be changed) or the result of undefined behavior (which we should feel free to define). Terry J. Reedy From chris.gonnerman at newcenturycomputers.net Sat Jul 14 15:02:26 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Sat, 14 Jul 2001 14:02:26 -0500 Subject: parallel port?!? References: <3B513D42.933A0445@iinet.net.au> Message-ID: <00a101c10c97$89731460$0101010a@local> ----- Original Message ----- From: "Richard B" <boegli at iinet.net.au> > I would like to know how to communicate with the parallel port under > python. Is this possible? If so can it be done under all operating > systems that support python. Ouch. That's gotta hurt. Do you REALLY need cross-platform? > I need to interface with the parallel port to send commands to a board > connected to it. I have just come to grips with python, it is my first > language, so I think this is what I should use to communicate with the > parallel port so that I can implement new features latter on. If it is > not possible to communicate directly with the parallel port, are there > any open source communication programs which work under Windows and > Linux which I could communicate to through python. > Sorry for long message but this is kind of important. For the Win32 platform, look at: http://www.geocities.com/dinceraydin/python/indexeng.html specifically the winioport module. For Linux, you will need a module providing abstractions for the lp(4) ioctl's. AFAIK there is no such module currently... somebody tell me if I am wrong. For any other OS, who knows? > Thanks in advanced. Hope this helps... From rnd at onego.ru Fri Jul 13 11:33:41 2001 From: rnd at onego.ru (Roman Suzi) Date: Fri, 13 Jul 2001 19:33:41 +0400 (MSD) Subject: Book count test In-Reply-To: <E566B020833BD311B6610008C791A39705CA5242@il93exm04.css.mot.com> Message-ID: <Pine.LNX.4.21.BCL.0107131932410.704-100000@suzi.com.onego.ru> On Fri, 13 Jul 2001, Kemp Randy-W18971 wrote: > I went to www.amazon.com and counted the number of books in these categories > Python - 136 (including snake books) ;-) > Java - 1621 Including geography book ? ;-) > Perl - 430 > C++ - 1341 > PHP - 38 > ASP - 172 > Oracle - 682 Including Ancient Greece books ;-) Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From bill-bell at bill-bell.hamilton.on.ca Fri Jul 20 20:54:59 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Fri, 20 Jul 2001 20:54:59 -0400 Subject: Unusual minidom behaviour In-Reply-To: <995673835.372.38971.l6@yahoogroups.com> Message-ID: <3B589AA3.1884.23541C5@localhost> "Victor Bazarov" <vAbazarov at dAnai.com> wrote, in part: > ... My colleagues called the situation "maybe there's a race > condition". Could it be minidom has problems multi-tasking? I know nothing about 'minidom'. FWIW, it sounds like it might be a race condition to me too. Is there any way to put it in a thread by itself, protected by a lock or within a critical section? (And, forgive me, does the code use CoInitialize/CoUninitialize?) > I would be grateful for any, no matter how crazy, suggestion. As you read my response just remember that you included this final sentence. :o) Good luck! Bill From joonas.paalasmaa at nokia.com Thu Jul 12 09:50:28 2001 From: joonas.paalasmaa at nokia.com (Joonas Paalasmaa) Date: Thu, 12 Jul 2001 13:50:28 GMT Subject: 'import' error in csh References: <c8fd1ef9.0107120544.20e2bec@posting.google.com> Message-ID: <3B4DABBE.D176B14F@nokia.com> Jerry Olup wrote: > > Howdy all, > > I am using py 1.5.2 on sunos 5.6. > > When I run this code (snip below) from csh, I get the following > errors: > import: command not found > badly placed ()'s > > When I run the code from the interpreter, however, it runs just fine. > >>> import xilcorelib > > Any ideas? I searched the group and found a '97 thread (Strange > import error ... how?), but no conclusions therein. > > # !/usr/bin/local/python > import re, string, os # regexp, string handling, system calls > > # xilinx core library parse script. > # > # ... other drivel > # > > # file opening and sizing. > compfile = open('vhdl_analyze_order', 'r'); > outfile = open('xilinxcorelib_comp.tcl', 'w') > list_lines = compfile.readlines() > linecount = len(list_lines) > #<etc...> That code hasn't gone thru Python interpreter, because the error message comes from csh. Try to fix the first line from '# !/usr/bin/local/python' to '#!/usr/bin/local/python' ^ Note that space You can also try 'python myscript.py' From markus at kepler.ibp.de Tue Jul 31 12:08:05 2001 From: markus at kepler.ibp.de (markus at kepler.ibp.de) Date: 31 Jul 2001 18:08:05 +0200 Subject: sleep command/function & searching the python docs References: <9k6ilm$2sed8$1@ID-91520.news.dfncis.de> Message-ID: <m3bsm1hyje.fsf@kepler.ibp.de> Rajarshi Guha <rajarshi at seed.chem.psu.edu> writes: > Hi, > is there a sleep function in the Python library. time.sleep() > I've beens earching > throught the modules but could'nt seem to find one. BTW, is there any way > to search the Python docs for a specific function/module etc? Or is there > any resource on the web that provides a searchable interface? Would be nice, but I don't know. - Markus From urner at alumni.princeton.edu Wed Jul 25 02:30:41 2001 From: urner at alumni.princeton.edu (Kirby Urner) Date: Tue, 24 Jul 2001 23:30:41 -0700 Subject: Norton AV 2001 + popen + WinMe = crash Message-ID: <vmpsltscvqqp8helkrd8aovnn8f497lt89@4ax.com> Wondered if others have this problem: when I try any of the popens in the os module, and leave NAV 2001 enabled, I get various freeze, VxD or other errors necessitating hard boot. Disabling NAV 2001 ends the problem i.e. popen variants work as advertized (to the extent of my testing anyway). Running Python 2.1.1. Kirby cc email appreciated From oconnor at bioreason.com Fri Jul 27 16:29:23 2001 From: oconnor at bioreason.com (Jay O'Connor) Date: Fri, 27 Jul 2001 14:29:23 -0600 Subject: Launching Python from Python References: <3B619A9E.9E940B28@bioreason.com> <Xns90EBDB73DC54Dcliechtimailsch@62.2.32.50> Message-ID: <3B61CF23.D5FEACA7@bioreason.com> chris liechti wrote: > > do you realy need separate python interpreters? > you could "import" the other module and run the main function in a thread > look at the module "Threading". Yes. Because the two processes communicate by sockets. They are essentially in a client/server relationship and eventually be potentially on seperate machines with. However, for now they are running on one machine with and the 'client' just launching the 'server' (as part of its own startup) before opening the communication. Eventually, I will remove the launching code as it will be assumed the server is running semi-continously Take care, Jay O'Connor oconnor at bioreason.com From mal at lemburg.com Fri Jul 13 08:04:16 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 13 Jul 2001 14:04:16 +0200 Subject: PEP: Unicode Indexing Helper Module Message-ID: <3B4EE3C0.9875AB3D@lemburg.com> Please comment... -- PEP: 0262 (?) Title: Unicode Indexing Helper Module Version: $Revision: 1.0 $ Author: mal at lemburg.com (Marc-Andr? Lemburg) Status: Draft Type: Standards Track Python-Version: 2.3 Created: 06-Jun-2001 Post-History: Abstract This PEP proposes a new module "unicodeindex" which provides means to index Unicode objects in various higher level abstractions of "characters". Problem and Terminology Unicode objects can be indexed just like string object using what in Unicode terms is called a code unit as index basis. Code units are the storage entities used by the Unicode implementation to store a single Unicode information unit and do not necessarily map 1-1 to code points which are the smallest entities encoded by the Unicode standard. These code points can sometimes be composed to form graphemes which are then displayed by the Unicode output device as one character. A word is then a sequence of characters separated by space characters or punctuation, a line is a sequence of code points separated by line breaking code point sequences. For addressing Unicode, there are basically five different methods by which you can reference the data: 1. per code unit (codeunit) 2. per code point (codepoint) 3. per grapheme (grapheme) 4. per word (word) 5. per line (line) The indexing type name is given in parenthesis and used in the module interface. Proposed Solution I propose to add a new module to the standard Python library which provides interfaces implementing the above indexing methods. Module Interface The module should provide the following interfaces for all four indexing styles: next_<indextype>(u, index) -> integer Returns the Unicode object index for the start of the next <indextype> found after u[index] or -1 in case no next element of this type exists. prev_<indextype>(u, index) -> integer Returns the Unicode object index for the start of the previous <indextype> found before u[index] or -1 in case no previous element of this type exists. <indextype>_index(u, n) -> integer Returns the Unicode object index for the start of the n-th <indextype> element in u. Raises an IndexError in case no n-th element can be found. <indextype>_count(u, index) -> integer Counts the number of complete <indextype> elements found in u[:index] and returns the count as integer. <indextype>_start(u, index) -> integer Returns 1 or 0 depending on u[index] marks the start of an <indextype> element. <indextype>_end(u, index) -> integer Returns 1 or 0 depending on u[index] marks the end of an <indextype> element. Used symbols: <indextype> one of: codeunit, codepoint, grapheme, word, line u is the Unicode object index the Unicode object index n is an integer Copyright This document has been placed in the public domain. Local Variables: mode: indented-text indent-tabs-mode: nil End: -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From com-nospam at ccraig.org Fri Jul 20 15:00:51 2001 From: com-nospam at ccraig.org (Christopher A. Craig) Date: 20 Jul 2001 15:00:51 -0400 Subject: The unPEP: List-Tuple Unification In-Reply-To: <3B587279.A225AC51@javanet.com> References: <3B586A1E.B037349D@javanet.com> <aTZ57.5911$qh7.379822@e420r-atl2.usenetserver.com> <3B587279.A225AC51@javanet.com> Message-ID: <873d7rs9wc.fsf@elbereth.ccraig.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Raymond Hettinger <othello at javanet.com> writes: > The big advantage comes from deprecating tuples, simplifying the > language, getting rid of (,) and eliminating the need to remember > which things require tuples, which require lists, and which allow > both So then you will have some code that only accepts list which have their immutable flag set to "0" and some code that will change that flag transparently. So we get this behavior >>> t = [5] >>> a = t >>> t += [2] >>> a == t 1 >>> d = {t: 3} >>> t += [2] >>> a == t 0 Despite the fact that I have made no obvious changes to how "t" is treated. I think the fact that using a list as a dictionary key fundamentally changes the behavior of the list is far more confusing than the current system. I also fail to see how this makes the tutorial any simpler. I went and read section 5.3 of the tutorial (Tuples and Sequences) and imagined how it would look if you took out all of the tuple/list distinctions, but added the rules for mutable/immutable changes and I think it would be a great deal more complex. Why do this at all? Why not keep existing tuples and modify existing code to use anything that supports the sequence interface (maybe PEP245, maybe just implementing the needed functions)? Then you could support not just native lists and tuples, but also user extensions. Obviously modification requires mutability, but modifying an immutable list would fail even with your suggestion. Use as dictionary keys is the only place I can think of in the language where immutability is required, and it isn't really required there. >>> class foo: ... def __hash__(self): return hash(self.n) ... >>> t = foo() >>> t.n = 23 >>> d = {t: 5} >>> t.n = 47 >>> d[t] Traceback (most recent call last): File "<stdin>", line 1, in ? KeyError: <__main__.foo instance at ff3bc> So lists _could_ support tp_hash and then they could be used as keys, but I don't suggest this. Better to just say that dictionaries require immutable keys. > (quick, what does the % formatting operator require?). tuples, but it would be preferable if they supported any sequence and recognized when they got a string and expected a single item (so that ("%s" % "foo") would work) - -- Christopher A. Craig <com-nospam at ccraig.org> "No one has ever called us untrustworthy" -- Steve Balmer -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: Processed by Mailcrypt iEYEARECAAYFAjtYf+MACgkQjVztv3T8pzvcYACgsHQkcUWKa/TZWeuBXTiS2156 psAAoMzKbRbsC0+VzivPCcS6G6Ll4w5r =MZOu -----END PGP SIGNATURE----- From grante at visi.com Tue Jul 3 11:22:11 2001 From: grante at visi.com (Grant Edwards) Date: Tue, 03 Jul 2001 15:22:11 GMT Subject: problem with sending email References: <mailman.994139704.17222.python-list@python.org> Message-ID: <Dql07.7618$B7.1406045@ruti.visi.com> In article <mailman.994139704.17222.python-list at python.org>, Haris Lekatsas wrote: >This works thanks! > >Unfortunately it makes my scripts less portable as the path to >sendmail has to be specified (not always at /usr/sbin/sendmail) >but this seems to be the only solution I have so far. >I wonder if python's smtplib is broken. Works for me. All of my incoming e-mail at work goes through Python's smtplib (on a Win32 system). I did a fair amount of testing under Linux and it seems well-behaved there also. -- Grant Edwards grante Yow! I'm EXCITED!! I want at a FLANK STEAK WEEK-END!! I visi.com think I'm JULIA CHILD!! From aleaxit at yahoo.com Tue Jul 10 17:38:45 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 10 Jul 2001 23:38:45 +0200 Subject: Python Idiom Question References: <3B4A4126.7AD3CDD0@tundraware.com> <8Zr27.2394$vA6.115437@e420r-atl1.usenetserver.com> <mks27.2166$xf7.122975@e420r-atl3.usenetserver.com> <3B4B2E5E.AB3C94BD@home.net> Message-ID: <9ifsqc015fr@enews2.newsguy.com> "Chris Barker" <chrishbarker at home.net> wrote in message news:3B4B2E5E.AB3C94BD at home.net... > Steve Holden wrote: > > > > The approved idiom is > > while 1: > > x = raw_input() > > if not x: > > break > > DoSomethingInteresting() > > This is the approved idiom, but I never use it. I always use: > > x = raw_input() > while x: > x = raw_input() > DoSomethingInteresting() > x = raw_input() So you always throw away 50% of the raw input you receive? Peculiar indeed! > I really don't like any "while 1" constructs, you have to then go > looking for the "break" to find out what is controlling the loop. I > don't like having to put "x = raw_input" in two places either, but it's Above, you're using it in three places. I think your preferred construct is error-prone, as evidenced here:-). Alex From maxx at easynews.com Thu Jul 26 13:29:56 2001 From: maxx at easynews.com (maxx at easynews.com) Date: Thu, 26 Jul 2001 17:29:56 GMT Subject: Language change and code breaks References: <Pine.LNX.4.33.0107191316390.24983-100000@bms> <mailman.995571273.18192.python-list@python.org> <9j7gv8$9mg@dispatch.concentric.net> <cppuawfqbm.fsf@cj20424-a.reston1.va.home.com> <mailman.995734717.26373.python-list@python.org> <3B5DF101.9B2E4631@earthlink.net> <cpofq9a858.fsf@cj20424-a.reston1.va.home.com> Message-ID: <08k0mtc2lftoon7eii2jo43qj1tt76256c@4ax.com> On Wed, 25 Jul 2001 05:29:41 GMT, Guido van Rossum <guido at python.org> wrote: >"Joseph A. Knapka" <jknapka at earthlink.net> writes: > >> FWIW, I am a relative newcomer to Python, with a lot of general >> programming experience (C,C++,Java,Tcl,Prolog,LISP,Perl...). I >> really love Python, but making it case-insensitive would put a >> very significant damper on my enthusiasm. Why would you want >> to intentionally reduce the symbol space available for names? > >The number of symbols available is so much larger than the number of >distinct names you need that the reduction is irrelevant. Plus, the day that symbols become so numerous in code that the usage of case is necessary to differentiate them, then software development will have become truly too complex for mortals such as myseld. >> Everyone knows that in normal usage, case carries meaning (bob >> vs Bob). How could it possibly benefit the beginner to violate >> that naive expectation? Because writing code is a completely different function than "normal every day writing." Learning to write code means beginners must learn to structure their thoughts, and organize tasks, so that their code is not a potential jumble of ideas, as normal every day writing can be. Creative writing and code writing are like apples and oranges. To expect that beginners do not need this distinction is to doom them to failure. In fact, some of the restrictions that Python places on users, forcing them to indent code for example, is what makes the language a great training tool. Most every piece of problematic code I have dealt with in my career has been difficult to work with primarily because it is poorly formatted and structured. More often than not, I find code that does not work because novices just put commands down in the order that they think of them, not bothering to design the proper process flow first. Then they wind up with a malfunctioning mess that even they cannot decipher. If they learned on languages like Python first (instead of the popular stream of conciousness messes like VB), then they would develop "good habits", and be more successful. >But never mind, I'm giving up on making *Python* case-insensitive. >The hostility of the user community is frightening. Hear, hear! We do not want this group to become like comp.lang.perl.misc (no flame towards the perl folks, I just could not resist a little ribbing). From richardSPAM at geotek.co.uk Wed Jul 18 08:12:26 2001 From: richardSPAM at geotek.co.uk (Richard Chamberlain) Date: Wed, 18 Jul 2001 13:12:26 +0100 Subject: WINDOWS PROGRAMMING References: <mailman.995453435.10145.python-list@python.org> Message-ID: <51f57.14$Ow4.1053@news.dircon.co.uk> Well as I haven't got time to write a whole book in this post, you gonna have to narrow it down a bit, or read a book like: Python Programming on Win32 which discusses windows gui programming. If you don't want to do that then do a search for tk, wxPython, QT and look for some examples, hth, Richard "noverius pinem" <noveriuspinem at yahoo.com> wrote in message news:mailman.995453435.10145.python-list at python.org... > How we do "WINDOWS PROGRAMMING" with Python? > - making the windows > - create the controls > - etc > - etc > - etc > HELP... > Please. > > __________________________________________________ > Do You Yahoo!? > Get personalized email addresses from Yahoo! Mail > http://personal.mail.yahoo.com/ > From roy at panix.com Mon Jul 23 08:30:51 2001 From: roy at panix.com (Roy Smith) Date: Mon, 23 Jul 2001 08:30:51 -0400 Subject: PEP0238 lament References: <mailman.995873261.11975.python-list@python.org> Message-ID: <roy-2E6A21.08305123072001@news1.panix.com> "Tim Peters" <tim.one at home.com> wrote: > Good thing you stopped before mentioning Perl (yes, 1/2 is 0.5 there) Well, heck, in perl, "1"/2 is 0.5 as well. I'm sure there are lots of people new to programming who gets confused when they discover that numbers and strings are different too. Perhaps we should add auto-conversion of strings to numbers to python as well? :-) The thing that scares me most about this idea is that it breaks existing code. And, the idea that there will be conversion tools, and auto-warnings generated, don't impress me. You still need to touch all the old code. What about code that you've shipped to customers already? Are we going to demand that they not upgrade their python installation, or that they maintain a new version for their own work and an old version to keep our stuff going? While, I happen to like the way integer division works, I could be convinced that auto-promotion from int to float might be a good thing, if that's the way the language had been defined in the first place. Too late to go back now, however. From gerhard.nospam at bigfoot.de Mon Jul 16 20:35:40 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Tue, 17 Jul 2001 02:35:40 +0200 Subject: MySQLdb - possible without install? References: <3b4d0ea7.11581823@news1.on.sympatico.ca> <slrn9kqr2k.p1.gerhard.nospam@lilith.hqd-internal> <3b4d7a61.39160079@news1.on.sympatico.ca> <slrn9krt7k.nj.gerhard.nospam@lilith.hqd-internal> <3b4e2495.82731972@news1.on.sympatico.ca> <slrn9ksrdc.sa.gerhard.nospam@lilith.hqd-internal> <3b50d5dd.47261648@news1.on.sympatico.ca> Message-ID: <slrn9l704c.8s2.gerhard.nospam@lilith.hqd-internal> On Sat, 14 Jul 2001 23:40:24 GMT, Ken <ken_chiba at hotmail.com> wrote: >Ok. > >Still no luck! In case I'm just missing something... here is a >listing of various files/directories: Sorry, I'm out of ideas, too. The "ImportError: File not found" is the thing I don't get. If I had to debug, I would check if you can import a file "mysql.py" in the cgi-bin directory instead. (One, very improbable thing could be that the provider disabled dynamic loading of extension modules. But they would have had to do this explicitly on Linux.) I'd perhaps contact the provider and ask if they could install the module. What I have done one time, is install my own copy of Python in the cgi-bin directory. But this is normally more difficult than installing MySQLdb and it really sucks if you don't have access via ssh. Gerhard -- mail: gerhard <at> bigfoot <dot> 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, [chr(ord(x)^42) for x in list('zS^BED\nX_FOY\x0b')]) From pfenn at mmm.com Thu Jul 12 09:54:43 2001 From: pfenn at mmm.com (pfenn at mmm.com) Date: Thu, 12 Jul 2001 08:54:43 -0500 Subject: Language change and code breaks Message-ID: <OF2ADE4F59.057273B2-ON86256A87.004BE386@mmm.com> FWIW, I'm a chemist and use Python at work in bursts. I'll spend maybe one week coding every few months. I *always* forget the 1/3 == 0 thing between programming bursts. OTOH, I also quickly remember after making the mistake the first time. It's not a problem when I'm using C, because I'm more conscious of type when I'm working in C. But, I think it's very unpythonic to have to worry about integer vs float types when doing simple math. Tom Fenn From gustafl at algonet.se Sat Jul 14 21:18:52 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 15 Jul 2001 01:18:52 GMT Subject: Importing XML modules in py2exe or Installer? References: <Xns90DE9C2957BDgustaflalgonetse@194.213.69.152> <9iq4oc$kme5j$1@ID-59885.news.dfncis.de> Message-ID: <Xns90DF21CFC7984gustaflalgonetse@194.213.69.152> "Thomas Heller" <thomas.heller at ion-tof.com> wrote: >The correct py2exe command line would be (assuming your script is >named setup.py): >'python setup.py py2exe -p _xmlplus' >to include the whole _xmlplus package. > >Hope this helps, It did, but I encountered a horrible thing instead (scary, dissonant music starts) -- an encoding problem! (screams) I'm don't know how to continue, and not much of an idea about what pieces of information you would need to solve it. The script works from Python, but not from the execuable... If you read the Installer thread, you read this: -- My script needs a special config file, written in XML, in the same directory as the script itself. I was happy to see that before I had added the XML file to this directory, jane.exe complained in the right way: E:\python\gustaf\dist_jane>jane No profiles file found. -- This accounts to py2exe aswell. But when adding the XML file, I get this error: E:\jane>jane Traceback (most recent call last): File "<string>", line 54, in ? File "friend.pyc", line 22, in __init__ File "friend.pyc", line 49, in getName LookupError: unknown encoding This has probably something to do with the fact that the XML modules use UTF-8 by default. But the class that import info from this XML file, converts everything to 'latin1' before sending it further to the other functions (how nice it would be if Python could handle this transparently), so this error must take place before this conversion. Could it be that my Windows 98 doesn't know about UTF-8? Regards, Gustaf Liljegren From ajd111 at york.ac.uk Wed Jul 25 04:46:27 2001 From: ajd111 at york.ac.uk (Anthony J Doggett UG) Date: 25 Jul 2001 09:46:27 +0100 Subject: 2.0b2: SystemError: frexp() result out of range References: <vktpuaqnuu0.fsf@pc153s.cs.york.ac.uk> <mailman.995995722.15658.python-list@python.org> Message-ID: <vktae1to0po.fsf@pc153s.cs.york.ac.uk> > Yeah, I believe so: > >>>> float('inf') > inf <snip> >>>> cPickle.dumps(float('inf')) > 'Finf\n.' I get the same when working in ascii mode - it is /binary/ that's the problem. It seems a horrible hack to have to change infinities before binary-pickling them:( >>> cPickle.dumps(float('inf')) 'Finf\012.' >>> cPickle.dumps(float('inf'), 1) Traceback (most recent call last): File "<stdin>", line 1, in ? SystemError: frexp() result out of range Anthony. -- Anthony Doggett *** Pick up a book, and enter a different world. But remember, it is unhealthy to spend too much time in any one world, and worlds of the word come in concentrated form. *** From gerhard.nospam at bigfoot.de Wed Jul 11 17:56:54 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Wed, 11 Jul 2001 23:56:54 +0200 Subject: PgSQL.py / mxDateTime Question References: <fuX27.261628$Z2.3142231@nnrp1.uunet.ca> Message-ID: <slrn9kpgut.ot.gerhard.nospam@lilith.hqd-internal> On Wed, 11 Jul 2001 08:17:36 -0400, Rod MacNeil wrote: >I am installing PyPgSQL v1.2 and have a question about mxDateTime. >The DBAPI2 module PGSQL.py does not appear to updated for use with the >newest version of >mxDateTime (mxBase 2.0.1) which installs using a different directory >structure (mx/DateTime). > >I can certainly edit the PgSQL.py module or tweak the directories around but >I was wondering if anyone >knows if PgSQL.py works correctly with the DateTime in the new mxBase >package? >The docs for PgSQL.py don't mention any DateTime version info. Try changing the import to this one: try: from mx import DateTime except: import DateTime and it will work with older versions of mxDateTime and the current one. Gerhard -- mail: gerhard <at> bigfoot <dot> 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 maxm at normik.dk Thu Jul 5 09:33:21 2001 From: maxm at normik.dk (=?iso-8859-1?Q?Max_M=F8ller_Rasmussen?=) Date: Thu, 5 Jul 2001 15:33:21 +0200 Subject: Not enough Python library development [was PEP scepticism] Message-ID: <7BD10B680501D411B9DF009027E06F32197DA9@exchange> > From: Paul Prescod [mailto:paulp at ActiveState.com] > Zope is certainly part of the solution. But Zope isn't where > you want to > store a bunch of large archives. I don't have the impression that Python modules are large archives. I would assume that most are in th KB range some in the 100KB range and a few in the MB range. That should be a nice fit for Zope. > It would be better to use the file > system. And Zope doesn't itself manage the interdependencies. That > information has to come from the module. But we have no way to define > those interdependencies right now. I imagined that the interdependencies would be set manual when uploading the modules. So far that would be the only way to do it anyway. Something like this (Very rough):: http://maxm.normik.dk/pypan/ > And as you said, Zope doesn't help > much with the client app. And Zope doesn't really help you to build > binary modules in a safe way. And what categorization scheme (not > technology) do you use? Some kind of tree structure naturally. pypan Internet html html-module n version n version n+1 email Structured Tex Then using the Catalog to search across the tree. > So Zope is a good start (just as Distutils is a good start). It would be really good for making something work quickly on the server side instead of just talking about it endlesly ;-) It could simply talk to the client through webdav of xml-rpc. Regards Max M From thomasadunham at yahoo.co.uk Tue Jul 3 16:46:57 2001 From: thomasadunham at yahoo.co.uk (Tom Dunham) Date: 3 Jul 2001 13:46:57 -0700 Subject: python2.1 and RedHat7.1 References: <mailman.993580729.681.python-list@python.org> <flZ_6.1112$tD1.139245@news3.oke.nextra.no> <mailman.993885826.30310.python-list@python.org> Message-ID: <182ecd7e.0107031246.32e7f1b7@posting.google.com> Has anyone who installed in this way tried "import socket"? (I get a library can't be found error) Cheers, Tom Michael Ackerman <ack at nethere.com> wrote in message news:<mailman.993885826.30310.python-list at python.org>... > 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" <ack at nethere.com> 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 eppstein at ics.uci.edu Fri Jul 27 00:12:08 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Thu, 26 Jul 2001 21:12:08 -0700 Subject: Nasty typo in PEP 238 (revised) References: <cp4rrz5onj.fsf@cj20424-a.reston1.va.home.com> <eppstein-D847A7.18400826072001@news.service.uci.edu> <3B60D432.5060109@nospiced.ham.devis.com> Message-ID: <eppstein-7014B5.21120826072001@news.service.uci.edu> In article <3B60D432.5060109 at nospiced.ham.devis.com>, Tom Jenkins <tjenkins at nospiced.ham.devis.com> wrote: > >> A. Use x*1.0/y for true division, divmod(x, y)[0] for int > >> division. Especially the latter is best hidden inside a > >> function. You may also write floor(x)/y for true division if > >> you are sure that you don't expect complex numbers. > >> > > > > > > Shouldn't this be float(x)/y ? > > > > I still don't like the phrase "true division", it implies a value judgement > > that quotients are somehow an inferior thing to want to compute. > > > > David, > I'm not sure. I thought so to, but decided to try it in the interpreter > first (since I never used floor before) floor converts ints to floats???? This seems exactly backwards from what I would expect. And while it is certainly documented that way in the library reference (section 5), it is contradicted by the footnote in section 2 about using floor and ceil for "well-defined conversions" from float to int, as well as the claim in the reference manual that integer-division is the same as applying floor to the result of mathematical division. I have to consider this a big wart. Especially with the proposed changes to /, I would likely want to write code like i = floor(a/b) and j = ceil(c/d) but apparently this is going to need added coercions to get an integral type. Anyway, back to the PEP, I don't think calling floor(x) is a very clear way of writing an int-to-float coercion, and it's still a bug because it will give you incorrect results if x is a non-integral float. -- 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 Mon Jul 2 08:20:41 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Mon, 02 Jul 2001 12:20:41 GMT Subject: win32gui References: <9hpg2o$f4pdk$1@ID-59885.news.dfncis.de> Message-ID: <3B406737.1030707@ActiveState.com> Thomas Heller wrote: > All this (basically) works, the window is shown, > but nothing is printed from the test function. > Wading with the debugger through the code, it seems > the 'test' function is never called. > The reason seems to be that the default window-proc > from win32gui is called, and SetClassLong() is never > called with 'test' as the parameter. > Has anyone got this to work? Am I doning something wrong? It is supposed to work, but I can't find any example code. Internally it shouldn't be calling SetClassLong(); there is lots of magic in win32gui that finds the correct WndProc to call - which may be either a function or message-map. The win32gui taskbar demo has a message map. Looking in the debugger at references to "obFuncOrMap" should give you a clue - in the standard sample this will be a dictionary, and in your example it should be a simple function. Mark. From jochen at riekhof.de Thu Jul 19 11:11:04 2001 From: jochen at riekhof.de (Jochen Riekhof) Date: Thu, 19 Jul 2001 17:11:04 +0200 Subject: ActivePython ASP comobject.getCOMObject() does not work Message-ID: <9j6tac$b96$00$1@news.t-online.com> Hello... I am trying to convert some of my VBScript ASPPages to python, but I hang on this one: I need to use an existant registered dbaccess com object to get ADODB.Recordsets back. The retrieval of my dbaccess object works fine: import win32com.client def getRecordset(): pctRead = win32com.client.Dispatch("OrboPCT.OrboPCTRead") return pctRead.QryMeasurementsByMachineTypeID(Application("OrboPCTConnection"), 2) rst = getRecordset() Now, I want to use the recordset: rst.MoveFirst() and get the following error: Python ActiveX Scripting Engine (0x80020009) Traceback (innermost last): File "<Script Block >", line 5, in ? rst.MoveFirst() AttributeError: 'tuple' object has no attribute 'MoveFirst' /OrboPCT/pytest.asp, Zeile 15 rst.MoveFirst() What can I do to access the Recordset object properly? Thanks ...Jochen Riekhof From n_d_gangadhar at yahoo.com Sun Jul 22 14:47:49 2001 From: n_d_gangadhar at yahoo.com (NANDYALA D Gangadhar) Date: 22 Jul 2001 11:47:49 -0700 Subject: Name space quirk? References: <7b9380ca.0107220419.add15d1@posting.google.com> <etdzo9x16ck.fsf@opus.mit.edu> Message-ID: <7b9380ca.0107221047.43a4e97@posting.google.com> Alex <new_name at mit.edu> wrote in message news:<etdzo9x16ck.fsf at opus.mit.edu>... > Hi, Nandyala. Yeah, that's the correct behaviour. When it can't find > "myfile" bound to anything in "hello"'s namespace, it looks in the > module namespace. > > See the table at http://python.org/doc/ref/execframes.html for more > details. Thanks, Alex, for the answer and the reference. Is there any advantage in such a behaviour? I see much disadvantage. While at it, now, I cannot get it recognise myfile as a global in the interactive mode (of course, it works as a script): nspaces.py: #!/usr/bin/env python from os import sys def hello (outfile = sys.stdout): # We are writing to what should be an # unknown file descriptor: global myfile # <------- Added myfile.write ("Hello, world!\n") if __name__ == '__main__': f = sys.argv[0] + ".out" myfile = open (f, 'w') hello (myfile) I try: >>> from nspace import * >>> dir() ['__builtins__', '__doc__', '__name__', 'hello', 'sys'] >>> myfile = sys.stdout >>> global myfile >>> dir() ['__builtins__', '__doc__', '__name__', 'hello', 'myfile', 'sys'] >>> hello() Traceback (most recent call last): File "<stdin>", line 1, in ? File "nspace.py", line 11, in hello myfile.write ("Hello, world!\n") NameError: global name 'myfile' is not defined What am I missing? Thanks for the patience and help! Gangadhar Aside: We Telugu speaking people can be addressed __formally__ also by our given names! From emile at fenx.com Tue Jul 3 08:35:07 2001 From: emile at fenx.com (Emile van Sebille) Date: Tue, 3 Jul 2001 05:35:07 -0700 Subject: Fetching multiple items from a list References: <3B41B778.6BD422C1@nokia.com> Message-ID: <9hsed2$fp8k9$1@ID-11957.news.dfncis.de> Probably because it's so easy to create that functionality: class MyList: def __init__(self,l): self.lst = l def __call__(self,*args): return [self.lst[i] for i in args] mylist = MyList(list(string.lowercase)) print mylist(18,15,0,12) -- Emile van Sebille emile at fenx.com --------- "Joonas Paalasmaa" <joonas.paalasmaa at nokia.com> wrote in message news:3B41B778.6BD422C1 at nokia.com... > Why doesn't Python support fetching and setting multiple items > at the same time for lists and tuples. > > For example in the example below multiple fetching would be > much better way than the ordinary way. > > >>> import string > >>> mylist = list(string.lowercase) > >>> mylist[18],mylist[15],mylist[0],mylist[12] > ('s', 'p', 'a', 'm') > >>> mylist[18,15,0,12] > Traceback (most recent call last): > File "<pyshell#23>", line 1, in ? > mylist[18,15,0,12] > TypeError: sequence index must be integer > >>> From gerhard.nospam at bigfoot.de Wed Jul 18 13:22:31 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Wed, 18 Jul 2001 19:22:31 +0200 Subject: RELEASED: Python 2.2a1 References: <mailman.995464538.29395.python-list@python.org> Message-ID: <slrn9lbhen.22q.gerhard.nospam@lilith.hqd-internal> On Wed, 18 Jul 2001 09:58:56 -0400, Guido van Rossum wrote: >[...] In the mean time, for those of you using the CVS tree, these changes are >not checked in on the trunk, but on a branch tagged "descr-branch". Btw. is there a description of what the various CVS branches mean? Most of the names are pretty obvious, like "release21-maint", but others aren't. If such a page doesn't exist, I think it would be a good idea to write a short dscription for each branch and put it in "Python @ Sourceforge FAQ". Gerhard -- mail: gerhard <at> bigfoot <dot> 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, [chr(ord(x)^42) for x in list('zS^BED\nX_FOY\x0b')]) From sholden at holdenweb.com Mon Jul 16 08:40:51 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 16 Jul 2001 08:40:51 -0400 Subject: Naked function call syntax References: <3b4fa037.1845423078@wa.news.verio.net> Message-ID: <XdB47.1546$PF1.114830@e420r-atl2.usenetserver.com> "Bengt Richter" <bokr at accessone.com> wrote in message news:3b4fa037.1845423078 at wa.news.verio.net... > Interactively, I find myself writing little things like: > > def pd(x): > try: > print x.__doc__ > except: > print '(no doc string)' > > so that, e.g., I can type > > pd(vars) > > and get formatted info. But I'm lazy enough that > I would like to to type just > pd vars > > Is there an existing pythonic way to do this? > > If not, would there be breakage if python were modified to make > > foo whatever-up-to-EOL > > equivalent to > > foo(whatever-up-to-EOL) > > when it would be a syntax error otherwise? I.e., I'm wondering > if the grammar could be modified to do this by changing trailer > to accept arglist NEWLINE if _all_ else fails, and treat a match > as if it was an arglist. Leading '(' or '[' ambiguity would be > resolved in favor of normal arglist or subscriptlist. > Python is not Perl. Nor should it try to be. Not even to increase typing convenience! regards Steve -- http://www.holdenweb.com/ From martin at strakt.com Thu Jul 5 10:59:47 2001 From: martin at strakt.com (Martin Sjögren) Date: Thu, 5 Jul 2001 16:59:47 +0200 Subject: system exec ? In-Reply-To: <9i1moe02fou@enews1.newsguy.com> References: <9i1er4$mth$1@news.businessobjects.com> <9i1ffe029cm@enews1.newsguy.com> <9i1npl$160$1@news.businessobjects.com> <9i1moe02fou@enews1.newsguy.com> Message-ID: <20010705165947.A5945@strakt.com> On Thu, Jul 05, 2001 at 02:32:12PM +0200, Alex Martelli wrote: > "alphaZeta" <NOSPAM.hnguyen421 at NOSPAM.hotmail.com> wrote in message > news:9i1npl$160$1 at news.businessobjects.com... > > > > Thanks, I was also planning to use the readlines() method. > ... > > > a = os.popen("ls -l").read() > > > > > > may be what you want (but you may also prefer to call .readlines() > > That's good in most cases, just one further thing: if there > is the possibility that the output of the command is vaster > than will comfortably fit in memory, you may want to import > xreadlines and rather than storing said output in your > memory all at one loop over it line by line: It is at these times you really wish you had lazy evaluation, like in Haskell :) I miss Haskell... Martin -- Martin Sj?gren martin at strakt.com ICQ : 41245059 Phone: +46 (0)31 405242 Cell: +46 (0)739 169191 GPG key: http://www.strakt.com/~martin/gpg.html -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 248 bytes Desc: not available URL: <http://mail.python.org/pipermail/python-list/attachments/20010705/1a5d58a8/attachment.sig> From sholden at holdenweb.com Thu Jul 5 11:54:04 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 5 Jul 2001 11:54:04 -0400 Subject: Is Python Dead? References: <MNS%6.355$Xs4.225014@news.pacbell.net> <458b194a.0107050711.72007607@posting.google.com> <3B448C81.4DAC7DD@wwc.com> Message-ID: <D2017.3540$i8.346893@e420r-atl3.usenetserver.com> "Steve Williams" <stevewilliams at wwc.com> wrote in message news:3B448C81.4DAC7DD at wwc.com... > Resty Cena wrote: > > > "Edward B. Wilson II" <ed at ewilson.com> wrote in message news:<MNS%6.355$Xs4.225014 at news.pacbell.net>... > > > I have been following Python for five years now, and I am still just as > > > frustrated with it as I was in 1996. > > > > > > Python still doesn't have good database support, > > > > I, too, have been following Python since 1996, waiting all the while > > to make it easy for me to do database programming. > > [snip] > > How about this little jewel returned by a Google search on "Python DB2 AIX"? > > From > > http://webevents.broadcast.com/ibm/developer/050901/display_qa.asp > > > Question 10: > DB/2 can be used whit PHP or Pyton ? > Answered by Nanda Pilaka: > DB2's supports C/C++/Java/COBOL/REXX/Basic/Perl/Fortran currently. > Python is not supported. > > > We now return you to the whitespace discussion currently in progress. . . > The DB SIG does list a DB/2 module, but the ftp server it links to doesn't allow access. Does anyone actually USE DB/2 with Python? The DB SIG module list seems a little out of date, and a monthly mail archive of over 20KB seems to be the exception rather than the rule. regards Steve -- http://www.holdenweb.com/ From markus at kepler.ibp.de Tue Jul 17 04:04:55 2001 From: markus at kepler.ibp.de (markus at kepler.ibp.de) Date: 17 Jul 2001 10:04:55 +0200 Subject: Nice graphs from class hierarchies? References: <mailman.995345248.18915.python-list@python.org> Message-ID: <m3itgsyo9k.fsf@kepler.ibp.de> Roman Suzi <rnd at onego.ru> writes: > I want to have nice graphs from Python class hierarchies. The daVinci > package can do it (see the program below for Exception class tree), but > the quality is not good enough. > > Does anyone know any other tool which can help automatically draw graphs > (or only trees) with ability to output to PS? Dot (see http://www.graphviz.org/) is a powerful program that produces reasonably beautiful output. - Markus From jknapka at earthlink.net Thu Jul 26 13:31:40 2001 From: jknapka at earthlink.net (Joseph A. Knapka) Date: Thu, 26 Jul 2001 17:31:40 GMT Subject: Language change and code breaks References: <Pine.LNX.4.33.0107191316390.24983-100000@bms> <mailman.995571273.18192.python-list@python.org> <9j7gv8$9mg@dispatch.concentric.net> <cppuawfqbm.fsf@cj20424-a.reston1.va.home.com> <mailman.995734717.26373.python-list@python.org> <3B5DF101.9B2E4631@earthlink.net> <cpofq9a858.fsf@cj20424-a.reston1.va.home.com> Message-ID: <3B6053FC.2998D839@earthlink.net> Guido van Rossum wrote: > > "Joseph A. Knapka" <jknapka at earthlink.net> writes: > > > FWIW, I am a relative newcomer to Python, with a lot of general > > programming experience (C,C++,Java,Tcl,Prolog,LISP,Perl...). I > > really love Python, but making it case-insensitive would put a > > very significant damper on my enthusiasm. Why would you want > > to intentionally reduce the symbol space available for names? > > The number of symbols available is so much larger than the number of > distinct names you need that the reduction is irrelevant. > > > Everyone knows that in normal usage, case carries meaning (bob > > vs Bob). How could it possibly benefit the beginner to violate > > that naive expectation? > > I know plenty of people who *sometime* write their name with a > lowercase letter. I even know someone who writes the personal pronoun > "I" as "i", convinced that the form "I" would be pretentious. > > You would be very surprised if email to JKnapka at EarthLink.Net was sent > to a different user than email to jknapka at earthlink.net. There are > plenty of situations where one only has one case available, e.g. WHEN > CAPITALIZING FOR EMPHASIS or when typing with one finger. In American > usage, the first letter of most words in section and chapter titles > are capitalized without changing the semantics. > > For beginning typists, hunt-and-peck style, the shift key is one > complication they can do without, so beginners tools are often > case-forgiving. > > But never mind, I'm giving up on making *Python* case-insensitive. > The hostility of the user community is frightening. > > --Guido van Rossum (home page: http://www.python.org/~guido/) Oh my. I'm sorry if my very first post to c.l.py came off as hostile. I'm more just perplexed, I don't understand how a move to case insensitivity could be beneficial, and I guess that's my problem (but I'm glad you've changed your mind :-). In any case, I am in awe of what you have accomplished with Python. It is without doubt the most usable general-purpose language I have come across. Thank you. -- Joe Knapka "You know how many remote castles there are along the gorges? You can't MOVE for remote castles!" -- Lu Tze re. Uberwald // Linux MM Documentation in progress: // http://home.earthlink.net/~jknapka/linux-mm/vmoutline.html 2nd Lbl A + 1 = 2nd Pause 2nd Prt GTO 2 R/S From quacko at lists.postmastergeneral.com Fri Jul 13 14:40:00 2001 From: quacko at lists.postmastergeneral.com (Quacko Lotto) Date: Fri, 13 Jul 2001 14:40:00 EDT Subject: WOW! WHAT A WEEK AT QUACKO-LOTTO! Message-ID: <200107131849.MAA47319@s0226.pm0.net> ******************************************** WOW! WHAT A WEEK AT QUACKO-LOTTO! http://lotto.quacko.com ******************************************** Thanks to all the players who came out and took advantage of our daily $1,000,000 draw! Over 250,000 tickets have been played this week with over 3,000 Winning Tickets! http://lotto.quacko.com ALSO, -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 ******************************************************* Go to SUPREMECASINO NOW and get a $75 Cash Bonus! ******************************************************* http://www.supremecasino.com Play SupremeCasino's hottest casino games with Free Money. Get a 100% Bonus up to $75 FREE!! You're closer than ever to winning. Valid for All Valued Customers, with every Visa, MasterCard, PayPal or NETeller deposit, we will give you up to $75 FREE! Incredible! Register now and get in the game!! http://www.supremecasino.com *************************************************************** RED CARPET REWARDS AT GRAND BANKS CASINO!! http://www.grandbankscasino.com/default.asp?from=1072 *************************************************************** Red Carpet Rewards!! The best way to earn free credits! Grand Banks casino is rolling out the Red Carpet for our patrons! For every $10 in real bets that you place, Grand Banks will credit your account with one comp point. Collect 100 comp points and you will receive one casino credit! It's so simple and calculated automatically for you! Stop by and Play For Free! http://www.grandbankscasino.com/default.asp?from=1072 <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> * 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 ehagemann at home.com Sat Jul 14 18:24:01 2001 From: ehagemann at home.com (Eric Hagemann) Date: Sat, 14 Jul 2001 22:24:01 GMT Subject: converting from perl: variable sized unpack References: <mailman.995092164.12281.python-list@python.org> Message-ID: <5E347.10457$Ek3.3444795@news1.rdc1.md.home.com> I have a lot of code to parse logs as well -- neat trick (at least I think it neat !) to overcome this "problem" is name_of_field0 = 0 name_of_field1 = 1 name_of_field2 = 2 . f = line.split() . then access the elements as foo = f[name_of_field1] in my applications I can use the len(f) to determine the type of line I am parsing (by its length) This way you get variable length parsing as well as "named" arguments Cheers "Roman Suzi" <rnd at onego.ru> wrote in message news:mailman.995092164.12281.python-list at python.org... > On Fri, 13 Jul 2001, James Logajan wrote: > > >Roy Smith wrote: > >> > >> What's the best way to translate this perl snippet into python: > >> > >> ($f1, $f2, $f3, $f4, $f5, $f6) = split ('\s+', $line); > >> > >> The obvious translation would be: > >> > >> [f1, f2, f3, f4, f5, f6] = string.split (line) > >> > >> but the problem is that line may have fewer than 6 fields on it. Perl > >> handles this smoothly by leaving the "extra" variables undefined, whereas > >> python raises a ValueError exception. What I'd like to do is have the > >> extra field variables left as null strings. > > > >This may not be the most elegant or efficient, but how about this: > > > >[f1, f2, f3, f4, f5, f6] = (string.split (line) + 6*[None])[:6] > > My variant is: > > f1, f2, f3, f4, f5, f6 = map(lambda x, y: x, string.split(line), 6*[None]) > > (maybe 6*[None] could be written as xrange(6), but I am not sure if > xrange will allow it after stripping down) > > - this is VERY common problem when analysing logs. I will be grateful > if somebody could point me to how to give names to log fields > in efficient manner (logs are long, you know!). Probably, this > is better done in C. > > Maybe, some kind of support from string module or Python itself > could be had, for example: > > f1, f2, f3, f4, f5, f6 = pad(string.split(line), 6, None) > > (where None could be omitted to be default value) > > There could also be rpad to pad from right. > > * > > re module could also be used, with named groups which > name fields. But I wonder how efficient it is to use re > where split is enough... > > > Sincerely yours, Roman Suzi > -- > _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ > _/ Saturday, July 14, 2001 _/ Powered by Linux RedHat 6.2 _/ > _/ "A mainframe: The biggest PC peripheral available." _/ > > From jcollins at boulder.net Thu Jul 26 19:09:32 2001 From: jcollins at boulder.net (Jeffery Collins) Date: Thu, 26 Jul 2001 17:09:32 -0600 Subject: Python for Palm OS In-Reply-To: <3B5EF3AC.E7627338@bioeng.ucsd.edu>; from cjensen@bioeng.ucsd.edu on Wed, Jul 25, 2001 at 09:28:28AM -0700 References: <20010725.4442652@mis.configured.host> <3B5EF3AC.E7627338@bioeng.ucsd.edu> Message-ID: <20010726170932.A7862@boulder.net> When I return from vacation, I'll accelerate the development of the documentation. Jeff -- On Wed, Jul 25, 2001 at 09:28:28AM -0700, Curtis Jensen wrote: > Robert Roberts wrote: > > > > I have heard several times that there is a version of Python for the palm > > os. Have palm version 3.5. Can anyone direct to the proper download? > > > > Thanks in advance. > > Is there documentation or a reference manual for pippy? A friend of > mine, installed it on his palm, but we couldn't find documetation for > it. > > -- > Curtis Jensen > cjensen at bioeng.ucsd.edu > http://www-bioeng.ucsd.edu/~cjensen/ > FAX (425) 740-1451 > -- > http://mail.python.org/mailman/listinfo/python-list From mal at lemburg.com Mon Jul 2 06:13:59 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Mon, 02 Jul 2001 12:13:59 +0200 Subject: [Python-Dev] PEP 261, Rev 1.3 - Support for "wide" Unicode characters References: <3B3F8095.8D58631D@ActiveState.com> Message-ID: <3B404967.14FE180F@lemburg.com> Paul Prescod wrote: > > 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 > > Abstract > > Python 2.1 unicode characters can have ordinals only up to 2**16 > -1. > This range corresponds to a range in Unicode known as the Basic > Multilingual Plane. 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. Please add: also known as "code unit". > Code point > > A code point is an integer between 0 and TOPCHAR. > If you imagine Unicode as a mapping from integers to > characters, each integer is a code point. But the > integers between 0 and TOPCHAR that do not map to > characters are also code points. Some will someday > be used for characters. Some are guaranteed never > to be used for characters. > > Codec > > A set of functions for translating between physical > encodings (e.g. on disk or coming in from a network) > into logical Python objects. > > Encoding > > Mechanism for representing abstract characters in terms of > physical bits and bytes. Encodings allow us to store > Unicode characters on disk and transmit them over networks > in a manner that is compatible with other Unicode software. > > Surrogate pair > > Two physical characters that represent a single logical Eeek... two code units (or have you ever seen a physical character walking around ;-) > character. Part of a convention for representing 32-bit > code points in terms of two 16-bit code points. > > Unicode string > > A Python type representing a sequence of code points with > "string semantics" (e.g. case conversions, regular > expression compatibility, etc.) Constructed with the > unicode() function. > > 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 use 4 bytes per character. > 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 the 4-byte implementation 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 on wide Python builds. On narrow builds it will > raise ValueError. > > ISSUE > > Python currently allows \U literals that cannot be > represented as a single Python character. It generates two > Python characters known as a "surrogate pair". Should this > be disallowed on future narrow Python builds? > > Pro: > > Python already 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. It is also > somewhat logical considering that the Unicode-literal syntax > is basically a short-form way of invoking the unicode-escape > codec. > > Con: > > Surrogates could be easily created this way but the user > still needs to be careful about slicing, indexing, printing > etc. Therefore some have suggested that Unicode > literals should not support surrogates. > > ISSUE > > Should Python allow the construction of characters that do > not correspond to Unicode code points? Unassigned Unicode > code points 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? > > Pro: > > If a Python user thinks they know what they're doing why > should we try to prevent them from violating the Unicode > spec? After all, we don't stop 8-bit strings from > containing non-ASCII characters. > > Con: > > Codecs and other Unicode-consuming code will have to be > careful of these characters which are disallowed by the > Unicode specification. > > * ord() is always the inverse of unichr() > > * There is an integer value in the sys module that describes the > largest ordinal for a character in a Unicode string 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.unicodewidth which can take the > values 'wide' and 'narrow'. > > * every Python Unicode character represents exactly one Unicode code > point (i.e. Python Unicode Character = Abstract Unicode > character). > > * codecs will be upgraded to support "wide characters" > (represented directly in UCS-4, and as variable-length sequences > in UTF-8 and UTF-16). This is the main part of the implementation > left to be done. > > * There is a convention in the Unicode world for encoding a 32-bit > code point in terms of two 16-bit code points. These are known > as "surrogate pairs". Python's codecs will adopt this convention > and encode 32-bit code points as surrogate pairs on narrow Python > builds. > > ISSUE > > Should there be a way to tell codecs not to generate > surrogates and instead treat wide characters as > errors? > > Pro: > > I might want to write code that works only with > fixed-width characters and does not have to worry about > surrogates. > > Con: > > No clear proposal of how to communicate this to codecs. No need to pass this information to the codec: simply write a new one and give it a clear name, e.g. "ucs-2" will generate errors while "utf-16-le" converts them to surrogates. > * 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 from files, but you could construct them using string > literals or unichr(). > > Implementation > > There is a new (experimental) define: > > #define PY_UNICODE_SIZE 2 > > There is a new configure option: > > --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. > > It is also proposed that one day --enable-unicode will just > default to the width of your platforms wchar_t. > > Windows builds will be narrow for a while based on the fact that > there have been few requests for wide characters, those requests > are mostly from hard-core programmers with the ability to buy > their own Python and Windows itself is strongly biased towards > 16-bit characters. > > Notes > > This PEP does NOT imply that people using Unicode need to use a > 4-byte encoding for their files on disk or sent over the network. > It only allows them to do so. For example, ASCII is still a > legitimate (7-bit) Unicode-encoding. > > It has been proposed that there should be a module that handles > surrogates in narrow Python builds for programmers. If someone > wants to implement that, it will be another PEP. It might also be > combined with features that allow other kinds of character-, > word- and line- based indexing. > > Rejected Suggestions > > More or less the status-quo > > We could officially say that Python characters are 16-bit and > require programmers to implement wide characters in their > application logic by combining surrogate pairs. 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. > > "Space-efficient Unicode" type > > Another 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. Guido is not willing to undertake the > implementation right now. > > Two types > > We could introduce a 32-bit Unicode type alongside the 16-bit > type. There is a lot of code that expects there to be only a > single Unicode type. > > This PEP represents the least-effort solution. Over the next > several years, 32-bit Unicode characters will become more common > and that may either convince us that we need a more sophisticated > solution or (on the other hand) convince us that simply > mandating wide Unicode characters is an appropriate solution. > Right now the two options on the table are do nothing or do > this. > > References > > Unicode Glossary: http://www.unicode.org/glossary/ Plus perhaps the Mark Davis paper at: http://www-106.ibm.com/developerworks/unicode/library/utfencodingforms/ > Copyright > > This document has been placed in the public domain. Good work, Paul ! -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From peter at engcorp.com Fri Jul 13 02:22:02 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 13 Jul 2001 02:22:02 -0400 Subject: Is Python Dead? Long Live Python! References: <mailman.994943120.433.python-list@python.org> <3B4E483C.4379E84E@engcorp.com> <mailman.994988062.18418.python-list@python.org> <3B4E68C5.E47D5F0F@engcorp.com> <mailman.994998742.17624.python-list@python.org> Message-ID: <3B4E938A.96C7E937@engcorp.com> Paul Prescod wrote: > > Peter Hansen wrote: > > > > ... I can't believe Python will > > end up with the volume of five-inch thick books that PHP and > > its ilk have barfed forth. > > I still think that you have too much faith that the actual technical > features of the topic have any real effect on the structure of the books > (or the market). Once you move past the first ten books written by > zealots and early adopters, the rest are written by people like "the > Deitels" who have a structure and are looking for content to pour into > it. Believe me, after reading Philip Greenspun's article, I no longer have faith of any kind in publishing, except that the industry exists largely to serve itself and that we should find ways to support online publishing (by authors!) and make it sustainable. I agree with what you're saying for the most part. I'm just looking for some sign that with Python, it's "different." Up until now, for me it's been the fact that of those first ten Python books, only about two were a total waste of dead trees. (Specifically, the "24 Hours" book, and ... hmmm, maybe that's only one out of ten. :-) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From qrczak at knm.org.pl Wed Jul 25 08:47:30 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 25 Jul 2001 12:47:30 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <eppstein-03540D.13070222072001@news.service.uci.edu> <LNBBLJKPBEHFEDALKOLCOECNLAAA.tim.one@home.com> <mailman.995899647.346.python-list@python.org> <tclolt053o18f8q0ntb7n4aggitdkmeg4h@4ax.com> <Io_67.23543$B7.3779351@ruti.visi.com> <slrn9lp2m5.vp.Gareth.McCaughan@g.local> <p56plt8q4rs3bgcqbepk61q2r3g0tr2vhe@4ax.com> <slrn9ls3ae.2fm.Gareth.McCaughan@g.local> <cpitghbq05.fsf@cj20424-a.reston1.va.home.com> <m2wv4xdxlf.fsf@mycroft.actrix.gen.nz> Message-ID: <slrn.pl.9ltfv2.241.qrczak@qrnik.zagroda> 26 Jul 2001 00:03:56 +1200, Paul Foley <see at below> pisze: >> int < long < rational < float < complex > > Well, it could, I suppose, but that would be a good reason to avoid > Python :-) > > What it *should* look like is this: > > int < long < rational > \ > + < [real] < complex > / > float There are no real reals in programming. And Python's complex is as inexact as float. I don't understand you. What practical difference do these diagrams yield? What is wrong in *consequences* of Guido's and mine model which your model puts differently? What happens if you int to float in your model? Rational to float? -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From peter at engcorp.com Thu Jul 12 23:19:33 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 12 Jul 2001 23:19:33 -0400 Subject: Is Python Dead? Long Live Python! References: <mailman.994943120.433.python-list@python.org> <3B4E483C.4379E84E@engcorp.com> <mailman.994988062.18418.python-list@python.org> Message-ID: <3B4E68C5.E47D5F0F@engcorp.com> Paul Prescod wrote: > > Peter Hansen wrote: > >... > > The users of the first would have most of their needs met by the > > online information available, and the incredible ease of learning > > the language or of applying it in diverse areas. > > > > Publishers can smell this and would not put their efforts into > > tree-killing for the second language. Entire forests, however, > > would be slaughtered in the name of the second language, to buy > > Mercedes automobiles for the publishing executives. > > If this is true, why are there so many Python books all of a sudden? I wouldn't have described the situation as "so many", rather "so few", but a quick Amazon search shows 30-odd Python books published or soon to be, so maybe "all of a sudden" is the key. I thought there were only ten! I think, however, the trick is that with PHP the books were probably being written with or even before the hype, and probably even contributed directly to the sudden popularity. After all, when someone sees four whole shelves shouting ASP or PHP, surely that must be one of the best languages ever invented. Four lone books (one written in 1995) dispersed across three sections of the bookstore clearly indicate a dying language with a lack of focus.... Which means if Python's popularity has grown to the point of attracting significant publisher attention, then as you say "The number of books is a pretty good indication of a languages' growth. The only problem is that it is an indicator that trails badly." I stand corrected. :) > Publishers clearly believe that Python is going to be a big thing. Well, maybe if we could measure, sometime in the future when the user base of Python and PHP is identical (not sure which is actually larger now, mind you), publisher revenues from the books, I might still be sort of right... I can't believe Python will end up with the volume of five-inch thick books that PHP and its ilk have barfed forth. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From quacko at lists.postmastergeneral.com Fri Jul 6 12:53:01 2001 From: quacko at lists.postmastergeneral.com (Quacko Lotto) Date: Fri, 06 Jul 2001 12:53:01 EDT Subject: QUACKO LOTTO - BEAT THE SUMMER HEAT Message-ID: <200107061702.LAA96567@s0203.pm0.net> Beat the Summer Heat! Stay Inside and Play Email-lotto http://lotto.quacko.com ******************************************** Dear Lotto Player - Today you can play the following tickets: (10) Daily Pick 6 Tickets (1) Daily Pick 1 Ticket (11) TOTAL TICKETS Play today and Win up to $1,000,000.00 in Cash tomorrow! http://lotto.quacko.com ********************************************************** GRAND BANK CASINO - JULY PROMOTIONS http://www.grandbankscasino.com/default.asp?from=1072 *********************************************************** 25% Welcome !!! Grand Banks Casino is offering all new users a 25% initial deposit bonus in casino credits. Example: Make an initial deposit of $100 and receive $25 in casino credits for a total of $125.00! Red Carpet Rewards !!! The best way to earn free credits! Grand Banks casino is rolling out the Red Carpet for our patrons! For every $10 in real bets that you place, Grand Banks will credit your account with one comp point. Collect 100 comp points and you will receive one casino credit! It's so simple and calculated automatically for you. For more information regarding comp points, please see our FAQ #16. http://www.grandbankscasino.com/default.asp?from=1072 Refer a Friend !!!-Earn $25 for every new unique player that you refer to Grand Banks! Latest Newsletter Have a look at the latest Grand Banks Casino news and special promotion announcements here! http://www.grandbankscasino.com/default.asp?from=1072 Tournaments - A great way to show the world your table skills - and a great place to make some extra cash! Grand Banks loves to host a good tournament - from Black Jack to Craps to Video Poker - see if there is one going on right now and get playing! Stop By and Play For Free! http://www.grandbankscasino.com/default.asp?from=1072 <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> * 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 steve at hkit.net Mon Jul 9 11:38:47 2001 From: steve at hkit.net (Steve S.L. Wong) Date: Mon, 9 Jul 2001 23:38:47 +0800 Subject: [Tkinter]: Grid as in wxPython? References: <9ic90t$s1l$1@newsreaderm1.core.theplanet.net> Message-ID: <tkjjrtr89f687e@news.supernews.com> #I download this code from internet. Hope that helps you. from Tkinter import * class MultiListbox(Frame): def __init__(self, master, lists): Frame.__init__(self, master) self.lists = [] for l,w in lists: frame = Frame(self); frame.pack(side=LEFT, expand=YES, fill=BOTH) Label(frame, text=l, borderwidth=1, relief=RAISED).pack(fill=X) lb = Listbox(frame, width=w, borderwidth=0, selectborderwidth=0, relief=FLAT, exportselection=FALSE) lb.pack(expand=YES, fill=BOTH) self.lists.append(lb) lb.bind('<B1-Motion>', lambda e, s=self: s._select(e.y)) lb.bind('<Button-1>', lambda e, s=self: s._select(e.y)) lb.bind('<Leave>', lambda e: 'break') lb.bind('<B2-Motion>', lambda e, s=self: s._b2motion(e.x, e.y)) lb.bind('<Button-2>', lambda e, s=self: s._button2(e.x, e.y)) frame = Frame(self); frame.pack(side=LEFT, fill=Y) Label(frame, borderwidth=1, relief=RAISED).pack(fill=X) sb = Scrollbar(frame, orient=VERTICAL, command=self._scroll) sb.pack(expand=YES, fill=Y) self.lists[0]['yscrollcommand']=sb.set def _select(self, y): row = self.lists[0].nearest(y) self.selection_clear(0, END) self.selection_set(row) return 'break' def _button2(self, x, y): for l in self.lists: l.scan_mark(x, y) return 'break' def _b2motion(self, x, y): for l in self.lists: l.scan_dragto(x, y) return 'break' def _scroll(self, *args): for l in self.lists: apply(l.yview, args) def curselection(self): return self.lists[0].curselection() def delete(self, first, last=None): for l in self.lists: l.delete(first, last) def get(self, first, last=None): result = [] for l in self.lists: result.append(l.get(first,last)) if last: return apply(map, [None] + result) return result def index(self, index): self.lists[0].index(index) def insert(self, index, *elements): for e in elements: i = 0 for l in self.lists: l.insert(index, e[i]) i = i + 1 def size(self): return self.lists[0].size() def see(self, index): for l in self.lists: l.see(index) def selection_anchor(self, index): for l in self.lists: l.selection_anchor(index) def selection_clear(self, first, last=None): for l in self.lists: l.selection_clear(first, last) def selection_includes(self, index): return self.lists[0].selection_includes(index) def selection_set(self, first, last=None): for l in self.lists: l.selection_set(first, last) if __name__ == '__main__': tk = Tk() Label(tk, text='MultiListbox').pack() mlb = MultiListbox(tk, (('Subject', 40), ('Sender', 20), ('Date', 10))) for i in range(1000): mlb.insert(END, ('Important Message: %d' % i, 'John Doe', '10/10/%04d' % (1900+i))) mlb.pack(expand=YES,fill=BOTH) tk.mainloop() "Franz GEIGER" <fgeiger at datec.at> ???g???l?? news:9ic90t$s1l$1 at newsreaderm1.core.theplanet.net... > Is anybody aware of anything like wxPython grids, but for Tkinter? For a > Tkinter GUI I need a grid as it is available in wxPython. I already use PMW, > but there isn't such a beast. > > Regards > Franz > > > > From volucris at hotmail.com Wed Jul 4 19:28:41 2001 From: volucris at hotmail.com (Volucris) Date: Wed, 4 Jul 2001 18:28:41 -0500 Subject: Dynamic call of a method : error References: <3pM07.8236$Yq2.6098008@nnrp5.proxad.net> Message-ID: <3b43a648$0$318$6e49188b@news.goldengate.net> -- Volucris (a) hotmail.com "Eu n?o falo uma ?nica palavra do portugu?s." "Dublanc, David" <ddublanc at free.fr> wrote in message news:3pM07.8236$Yq2.6098008 at nnrp5.proxad.net... > Hello, when I execute the module : > *************** > L = [] > > for method in dir(L): > "dynamic call" > print L.method.__doc__ > **************** > > I have the following error : > > 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 "f:\python21\pythonwin\pywin\framework\scriptutils.py", line 301, in > RunScript > exec codeObject in __main__.__dict__ > File "G:\script python\test concat?nation.py", line 5, in ? > print L.method.__doc__ > AttributeError: method > > > How can I call a method dynamically ? > > Thanks. > > Regards, > -- > David > Remember that dir() returns a list of _strings_, so method is the name of the function (or whatever's in the module) not the actual function. Strings don't have a 'method' attribute. That is where the exception comes from. Try this: #the name of the module you're digging in dynamically mod_name = 'gc' #import the module dynamically exec 'import %s' % mod_name #create a copy of the module dynamically mod_copy = eval('%s' % mod_name) for method in dir(mod_copy): try: #retrieve each member's docstring dynamically... print eval('%s.%s' % (mod_name, method)).__doc__ except AttributeError: #unless it can't have one (ints, floats, etc.) print 'No \'__doc__\' for %s.' % method Please excuse the excessize use of the word 'dynamically'. I really like that word. -- Volucris (a) hotmail.com "Eu n?o falo uma ?nica palavra do portugu?s." From guido at python.org Fri Jul 27 10:47:58 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 27 Jul 2001 14:47:58 GMT Subject: PEP 238 (revised) References: <cp4rrz5onj.fsf@cj20424-a.reston1.va.home.com> <y%587.32307$EP6.8411583@news1.rdc2.pa.home.com> Message-ID: <cp1yn24eem.fsf@cj20424-a.reston1.va.home.com> "Terry Reedy" <tjreedy at home.com> writes: > >This makes expressions expecting float or complex > > results error-prone when integers are not expected but possible > as > > inputs. > > and vice versa for integer expressions getting float input That's not the same argument -- expressions expecting ints are generally broken when they receive floats; expression expecting floats are *only* broken when they receive ints IF THEY USE DIVISION. The PEP cannot do anything about floats passed in where ints are expected -- such usage is broken. > > Semantics of True Division > > > > True division for ints and longs will convert the arguments to > > float and then apply a float division. That is, even 2/1 will > > return a float (2.0), not an int. > > Given that one spurious argument for this proposal was the claim that > float division preserves more information than quotient division, I > think it might be appropriate to warn here that the opposite is true > for sufficiently long longs, so that one may need to switch to > long//long to preserve accuracy. I never bought the "preserving information" argument. In general all classic use of long/long should be switched to long//long, of course, as should all classic use of int/int. > > - It has been proposed to call // the quotient operator. I like > > this. I might rewrite the PEP to use this if enough people like > > it. (But isn't the assumption that this truncates towards > > zero?) > > Its true that -8/3 = -(2+2/3), but I think divmod(-i,j)[0] is up for > grabs in most people's mental space. This concern never entered my > mind until I read the above. Good! > --- > The only way I can think of to 'globally' turn on new division on my > own Windows computer is to rebind .py and .pyc to python.bat > containing '...python.exe -Dnew'. Do I need to add that to the PEP? > Great revision! Thanks. --Guido van Rossum (home page: http://www.python.org/~guido/) From scarblac at pino.selwerd.nl Mon Jul 9 06:41:07 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 9 Jul 2001 10:41:07 GMT Subject: license suggestions? References: <mailman.994649774.8137.python-list@python.org> Message-ID: <slrn9kj2cf.el0.scarblac@pino.selwerd.nl> Chris Watson <chris at voodooland.net> wrote in comp.lang.python: > > > That is not really what the license says though. With that license you > > can't integrate it with anything. If you put it in a closed source product > > it would have a more restrictive license and thus couldn't be used that way. > > How do you figure you can't integrate my licensed code into a say binary > only product? How is it restricting binary only products? The typical binary only product would usually be under a license other than your license. And your clause 3 doesn't allow that. Your license is a sort of ultra-GPL. -- Remco Gerlich From grante at visi.com Thu Jul 26 13:47:34 2001 From: grante at visi.com (Grant Edwards) Date: Thu, 26 Jul 2001 17:47:34 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <eppstein-03540D.13070222072001@news.service.uci.edu> <LNBBLJKPBEHFEDALKOLCOECNLAAA.tim.one@home.com> <mailman.995899647.346.python-list@python.org> <tclolt053o18f8q0ntb7n4aggitdkmeg4h@4ax.com> <Io_67.23543$B7.3779351@ruti.visi.com> <slrn9lp2m5.vp.Gareth.McCaughan@g.local> <p56plt8q4rs3bgcqbepk61q2r3g0tr2vhe@4ax.com> <slrn9ls3ae.2fm.Gareth.McCaughan@g.local> <cpitghbq05.fsf@cj20424-a.reston1.va.home.com> <MWD77.27751$EP6.6983549@news1.rdc2.pa.home.com> <9jnt9p$qhe$1@newsy.ifm.liu.se> <SYV77.27286$B7.4239335@ruti.visi.com> <cpitgf7itx.fsf@cj20424-a.reston1.va.home.com> Message-ID: <WIY77.27607$B7.4257794@ruti.visi.com> In article <cpitgf7itx.fsf at cj20424-a.reston1.va.home.com>, Guido van Rossum wrote: >grante at visi.com (Grant Edwards) writes: > >> >The important thing is that i//j will return the same value >> >regardless if i and j ar ints or floats; ditto for the new i/j. >> >> If that's important, why won't the other math operators do it??? > >Huh? They do (apart from unavoidable round-off errors). 1+2 == 1.0+2.0. They compare equal with the "==" operator, but they are not the same value: >>> 1+2 3 >>> 1.0+2.0 3.0 >>> ... unless 3 and 3.0 are "the same value". In which case my definition of that phrase is merely different than yours. -- Grant Edwards grante Yow! I wonder if I ought at to tell them about my visi.com PREVIOUS LIFE as a COMPLETE STRANGER? From pkulkarni at sequoianet.com Thu Jul 12 14:19:13 2001 From: pkulkarni at sequoianet.com (Pradeep Kulkarni) Date: 12 Jul 2001 11:19:13 -0700 Subject: Python NT Service Message-ID: <83241e1a.0107121019.308ebc6f@posting.google.com> I am not able to import a user class (a class which send a mail) in my NT service, which I am trying to develop since three days. Any help in this problem would be appreciated. Thank you - Pradeep From rhystucker at rhystucker.fsnet.co.uk Fri Jul 27 16:14:56 2001 From: rhystucker at rhystucker.fsnet.co.uk (rhys tucker) Date: Fri, 27 Jul 2001 20:14:56 GMT Subject: How to use Unicode regexes? Message-ID: <1103_996264896@pan> Could somebody show me how to do Unicode regexes? I'm trying to write a strings-like utility for windows - so I want to match ascii and unicode characters in a binary file. Do I need one regex pattern since ascii and Unicode are similar for ascii text characters or are 2 regex patterns needed since they are different byte sizes? The documentation suggest that I need to use \w pattern to match Unicode and set UNICODE. I'm not sure what and how to set Unicode. This is what I've done so far - it matches (some ?) ascii characters but misses those unicode strings. #!/usr/bin/env python # strings program import sys from re import compile, findall f = open(sys.argv[1]) fl = f.read() patt = compile("[\032-\176\000]{4,}") matches = findall(patt, fl) for match in matches: print match Thanks to those people who answered my earlier question. rhys From tbryan at python.net Sat Jul 28 12:31:34 2001 From: tbryan at python.net (Tom Bryan) Date: Sat, 28 Jul 2001 21:31:34 +0500 Subject: doctest x idle problem? References: <mailman.996311033.21035.python-list@python.org> <etdg0bhqczl.fsf@lola-granola.mit.edu> Message-ID: <9jvooi$hf8$1@slb1.atl.mindspring.net> Alex wrote: > >> This won't be solved in general by magic until someone contributes >> code to launch "Run Script" in a fresh process; but that's not always >> what you'll want either. > > I got sick of having to keep track of which modules need to be reloaded, > and now have a framework for emacs python-mode that temporarily > overrides __builtin__.__import__ and tracks which modules are importing > which so that by top-sorting the dependancy graph it only needs to > reload the modules that have changed on disk and the modules that depend > on those. It works pretty well for my needs, except that sometimes the > dependancy graph is a little out of sync and you have to do the reload a > time or two extra. If there's enough interest, I could have a look at > fixing that (just a matter of repeating the reloads until the dependancy > graph stabilizes) and folding it into IDLE. Heck. I'd be interested in having it in python-mode! xemacs-should-be-able-to-read-my-mind-ly yours ---Tom From quinn at hork.ugcs.caltech.edu Wed Jul 4 21:54:10 2001 From: quinn at hork.ugcs.caltech.edu (Quinn Dunkan) Date: 5 Jul 2001 01:54:10 GMT Subject: Two problems with backslashes References: <Xns90D4A141E71CDgustaflalgonetse@194.213.69.148> <mailman.994256588.17929.python-list@python.org> <Xns90D4AEEA4B92Agustaflalgonetse@194.213.69.152> <9hvcu5$fu4ja$1@ID-11957.news.dfncis.de> <Xns90D4BD1F823A1gustaflalgonetse@194.213.69.148> Message-ID: <slrn9k7i61.tj1.quinn@hork.ugcs.caltech.edu> On 4 Jul 2001 16:34:43 GMT, Gustaf Liljegren <gustafl at algonet.se> wrote: >"Emile van Sebille" <emile at fenx.com> wrote: > >>So it appears to work here using getopt. Something else must be going >>on. Can you post an example that generates the string with the embedded >>tabs? > >Thank you. I had no idea that Python would add the extra backslash >automatically. Tried to isolate the problem before trying the whole thing >on getopt. This solved the problem on a more appropriate level. Try not to think of things in terms of python "adding" or "removing" backslashes. Python will never alter your strings (and won't even let you change them). However, it will interpret what you put in between ""s, just as it interprets [1,2] as a list, math.pi as a number, and open('foo') as a file object. It needs some way of readably representing nonprintable characters, and backslash is it. When printing a string, exactly what is in the string will be printed (after all, if it mangled strings, that would really screw up writing a JPEG to disk). However, the interactive prompt doesn't print strings exactly, it prints a representation of them that will be easy for python to parse (with doubled backslashes, among other things). You may have noticed that it will also put quotes around your string, even though those aren't part of the string. For example: s = 'foo\\bar' # requires \\ because ''s interpret \s s2 = raw_input('enter path: ') # doesn't require the user to double \s because # raw_input doesn't interpret what it reads (hence the raw part) print s # prints foo\bar print repr(s) # prints a python-readable representation of s, "foo\\bar" And note that if you just type 's' at the interactive prompt, that's like "print repr(s)". From owen at astrono.junkwashington.emu Wed Jul 25 11:24:45 2001 From: owen at astrono.junkwashington.emu (Russell E. Owen) Date: Wed, 25 Jul 2001 08:24:45 -0700 Subject: Advice wanted: asynch I/O on unix References: <owen-66B4BF.09573623072001@nntp4.u.washington.edu> <ku4rs3yueb.fsf@lasipalatsi.fi> <9jk65h$dto$1@nntp6.u.washington.edu> <9jk9ve$m94$1@nntp6.u.washington.edu> Message-ID: <9jmobv$kqi$1@nntp4.u.washington.edu> Thank you very much to all who responded. Since there's no standard mechanism for buffering an unbuffered device, I will try the driver package that comes with the card. It has an implementation of buffering that is a bit complex but should do just fine. The C code I started with has yet another implementation of buffering (it ignores the card vendor's driver package), but it is clumsier. I didn't want to go to extra fuss if a standard buffering mechanism existed, but since it doesn't...time to get to work! I'm just glad the driver package exists. (I'll know just how glad to be once I see IF the driver package works! But it's an EDT company product, so I expect it'll be just fine.) I'm most of the way through a Python interface to the driver library. Once that's done (my first C extension module, wish me luck), I can do everything else in Python. Hooray! -- Russell From malcolm at commsecure.com.au Sun Jul 1 22:50:39 2001 From: malcolm at commsecure.com.au (Malcolm Tredinnick) Date: Mon, 2 Jul 2001 10:50:39 +0800 Subject: New PEP: Quality Guidelines For Standard Modules In-Reply-To: <5.0.2.1.0.20010701213736.0277d700@mail.inet.com.br>; from cribeiro@mail.inet.com.br on Sun, Jul 01, 2001 at 09:45:23PM -0300 References: <5.0.2.1.0.20010701213736.0277d700@mail.inet.com.br> Message-ID: <20010702105039.A23408@Vetinari.home> Some quick initial impressions to get the ball rolling (hopefully this won't degenerate into a repeat of some previous threads). Mostly, these are critical comments, but that's not because I'm a negative bastard (well, I am, but...). Rather, some resolution would be nice to these discussions, so if somebody throws out a PEP like this, let's hammer it out and then it either survives and becomes policy or it becomes clear that we don't really need. I'm glad some people have taken the time to write down come conclusions from the earlier discussions. On Sun, Jul 01, 2001 at 09:45:23PM -0300, Carlos Ribeiro wrote: > Last but not least, this proposal must be understood as a > broad set of recommendations. It is not meant to be read as > a set of rules to be enforced. Non-compliant modules may be > still be accepted as part of the standard library for several > reasons. Common sense and community acceptance are still the > best judges on this. This last bit pretty much guarantees that everytime somebody proposes a slightly border-line case, we will revisit the same tired old arguments again and again. In fact, it's a bit worse than that: since there are a whole bunch of modules in the current distribution which fail to meet you recommendations, there's scope for "discussion" aplenty without further delay. :-) More seriously, this caveat is useful, since it is a response to all of my complaints below: anything that falls between the cracks becomes a source of discussion and then something like a BDFL pronouncement to settle it. > What is the Standard Library? > > The Standard Library is comprised of the modules that are > referenced in the Python Library Reference manual. Standard > Python Distributions MUST support all modules from the > Standard Library, with the exception of OS-dependant ones. This seems loosely phrased. What do you mean by "support all modules"? Do they have to compile? Do they have to return sensible answers when they run? Can they just say "Not supported on this platform"? It may be tempting to change this to "must include all modules from the standard library". However, this is tricky for a couple of reasons: this PEP hasn't really discussed why the concept of a Standard Library is required, and I'm not convinced it's a good idea to keep making the Python "distribution" larger and larger. My modem already starts to complain if I have to do a full download (thank heavens for CVS updates). That last paragraph possibly sows the seed for a whole discussion on the merits of including every standard component under the sun, or just having a system for saying "component ZZ is required" and having a place to download it (a la CPAN in that other world). I'm also not sure this PEP is necessarily the place for also defining things like "what is a distribution" (I don't even think that's a useful concept to formalise). [...] > OS-dependency guidelines > > 1. There are three main categories of modules regarding the > dependency on some particular OS or hardware platform: > > * OS-DEPENDENT modules are, for intrinsec reasons, supported > only on some particular platforms and/or hardware > platforms. They may not be ported to other platforms > without substantial investment or changes to the > underlying environment. > > * OS-LIMITED modules are supported only on some particular > platforms. They are not inherently limited to the > supported platforms, but for some reason the code cannot > be easily ported (or supported) on other platforms. > > * OS-INDEPENDENT modules are supported on many platforms. > Some particular platforms may not support the module, > because of severe limitations on the platform itself. > These limitations are easily recognizable, specially if > the module is already supported on all major platforms. > > 2. OS-LIMITED modules SHOULD NOT be included in the Standard > Library. The module author MUST rewrite the module in such > a way to make possible to port it to other platforms as a > OS-INDEPENDENT module. The OS-LIMITED concept was a bit confusing to me the first couple of times I read this. Basically, you are saying "write portable code", as far as I can tell. If there were other obstacles, wouldn't that make the module OS-DEPENDENT? If I'm missing something here, perhaps you can give an example of something that is portable code, but OS-LIMITED and not OS-DEPENDENT. > 3. OS-DEPENDENT modules SHOULD only be included to support > functionality required to use Python in the target platform. This is again a little loosely phrased. I can "use" Python with only a handful of modules. Of course, it becomes reasonably functionality-free at that point and I'd probably prefer C or Perl or shell scripting instead. :-( It is quite reasonable to have modules in the "standard library" that are only supported on a wide range of platforms (not all platforms). For example, there are already various things that are Unix specific and are awkward at best on Redmond-based operating systems. The set of Unix-like systems is quite large and if module X runs well on those, why should it not be included just because Windows is broken (to pick but one example)? Similarly, the current stuff for supporting the Macintosh finder tools and the like are fairly narrowly targeted, but they touch a large user base. > 4. OS-INDEPENDENT modules that rely on specific code in Python > for every platform supported MUST import a separate module > that implements the platform specific code. This (sub)module > SHOULD preferably be part of the main package. In this case > the module name should reflect the platform it supports. Lest I sound too negative above, I think this categorisation scheme is somewhat useful (it also exists already, since the library reference already identifies the platform availability). Particularly for module writers, who should be thinking about where their target is (does the module really have to be platform dependent, or can they design it so that somebody else can come along and add the bits to make it run on a Palm Pilot and a Cray and a Space Shuttle, etc). Cheers, Malcolm -- A clear conscience is usually the sign of a bad memory. From steve at lurking.demon.co.uk Wed Jul 25 03:27:01 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Wed, 25 Jul 2001 08:27:01 +0100 Subject: PEP0238 lament AND Re: Case (In)sensitivity References: <00867F2E.N22121@rsmi.com> <3B5CAED2.80B9CF3C@ActiveState.com> <mailman.995930982.17575.python-list@python.org> <acppltstdl0oo692su8e9c4fhm6cf14kt9@4ax.com> <3B5E3FE1.1C1ABBA4@engcorp.com> Message-ID: <7coslt0rfthrfhgdc7emr6t9kh8tf7j6r9@4ax.com> On Tue, 24 Jul 2001 23:41:21 -0400, Peter Hansen <peter at engcorp.com> wrote: >Stephen Horne wrote: >> >> On Mon, 23 Jul 2001 18:35:35 -0500, "Chris Gonnerman" >> <chris.gonnerman at newcenturycomputers.net> wrote: >> >> >Both of these changes fall in the same group IMHO... they >> >break a lot of code. >> >> Case insenstitivity is also a serious issue for me - it might even >> bite me for adopting a case-based naming convention as an apparently >> sensible way to avoid future identifier conflicts - [...] >> >> Anyway, it's probably less an issue for me than division - I use >> integer division a lot, whereas defining different identifiers with >> only case-changes to distinguish them is a definite no-no. > >This last item should always be said in conjunction with an >"in my opinion"... We *frequently* use identifiers which differ >only in case from their class name. We also use identifiers >which are identical to other identifiers except for case, primarily >when we have a large series of CONSTANTS defined somewhere. Ah - I should have thought more carefully. Well, anyway, I'm still saying the same thing. It's wrong in principle to change fundamental syntax and semantics, but in this particular case I'm all right jack so sod you ;-) (some have expressed the same view for '/', of course, but *they* are evil whereas I am not ;-) From grante at visi.com Sun Jul 22 18:31:34 2001 From: grante at visi.com (Grant Edwards) Date: Sun, 22 Jul 2001 22:31:34 GMT Subject: PEP0238 lament References: <mailman.995826216.11537.python-list@python.org> Message-ID: <slrn9lml32.qb.grante@tuxtop.visi.com> On Sun, 22 Jul 2001 14:22:21 -0400, Tim Peters <tim.one at home.com> wrote: >It shouldn't be so hard to understand why. The current integer division >loses information silently and without a trace. No, it doesn't. Integer division is integer division. The correct answer for the value of 3/4 is 0. If you wanted the remainder, you should ask for it. If you want to divide floating point numbers, you should _use_ floating point numbers. Perhaps my mind was warped by using nothing but integer arithmatic in my software for many years because floating point was simply too slow and too expensive. -- Grant Edwards grante Yow! Are we THERE yet? My at MIND is a SUBMARINE!! visi.com From nperkins7 at home.com Fri Jul 6 15:55:28 2001 From: nperkins7 at home.com (Nick Perkins) Date: Fri, 06 Jul 2001 19:55:28 GMT Subject: the C++ Standard Library for Python References: <hin17.110546$Mf5.30282205@news3.rdc1.on.home.com> Message-ID: <QIo17.427166$eK2.86457968@news4.rdc1.on.home.com> First impression: Very cool!, especially the fact that it seems to play well with python iterators. (I just need Python 2.2 to take full advantage..) It took me about 30 seconds to install and start using it! I will definitely be checking this out further. ( the website is also excellent ) good work! "Tom" <tom-list at home.com> wrote in message news:hin17.110546$Mf5.30282205 at news3.rdc1.on.home.com... > > The core of the C++ Standard Library is now available for Python. This > includes 4 sequence containers, 8 mapping containers, and approximately 60 > algorithms. The algorithms can be applied to any of these containers, or to > any of the Python built-in sequences. > > This is an actual C++ standard library, exposed to Python, not a Python > implementation of it - so it is all native code. > > It is being release under a standard Python style license. > > Please note that this is a beta release. > > http://www.malcolmson.com/pystl > > I'll watch this thread for comments and feedback (thanks in advance). > > > > From roy at panix.com Mon Jul 16 09:30:13 2001 From: roy at panix.com (Roy Smith) Date: 16 Jul 2001 09:30:13 -0400 Subject: converting from perl: variable sized unpack References: <roy-B2459F.22112513072001@news1.panix.com> <slrn9l4esk.885.quinn@yak.ugcs.caltech.edu> <roy-E01423.21425015072001@news1.panix.com> <9iulp401r93@enews3.newsguy.com> Message-ID: <9iuq95$3e0$1@panix6.panix.com> Alex Martelli <aleaxit at yahoo.com> wrote: > I find I can rarely throw away the match-objects in this cavalier > way, because they carry much, often-needed information -- so, I > don't get to use this idiom anyway. Rather, I have to code: > > mo = re1.match(thestring) > if mo: > dostuff(mo) > else: > mo = re2.match(thestring) > if mo: > dootherstuff(mo) > else: > mo = re3.match(thestring) > if mo: > etcetcetc(mo) > else: > nomatchatall() > >which is hardly elegant and clean. No it's not, but the problem is not that match returns None, the problem is that Python doesn't allow assignment as a side effect. Imagine if you could write it this way: if mo = re1.match(thestring) dostuff(mo) elif mo = re2.match(thestring) dootherstuff(mo) elif mo = re3.match(thestring) etcetcetc(mo) else: nomatchatall() Wouldn't that be elegant and clean and obvious? After 4 years of using Python, I still find the lack of any way to do an atomic "assign and test" unbelievably constraining. From aahz at panix.com Tue Jul 3 00:26:58 2001 From: aahz at panix.com (Aahz Maruch) Date: 2 Jul 2001 21:26:58 -0700 Subject: Python for Commercial Games? References: <9haoiv$jnv$1@mtc1.mtcnet.net> <slrn9k21pe.aqd.kamikaze@kuoi.asui.uidaho.edu> <9hr4k5$peq$1@panix6.panix.com> <slrn9k2gib.aqd.kamikaze@kuoi.asui.uidaho.edu> Message-ID: <9hrhii$n7h$1@panix2.panix.com> In article <slrn9k2gib.aqd.kamikaze at kuoi.asui.uidaho.edu>, Mark 'Kamikaze' Hughes <kamikaze at kuoi.asui.uidaho.edu> wrote: >2 Jul 2001 17:45:57 -0700 in <9hr4k5$peq$1 at panix6.panix.com>, >Aahz Maruch <aahz at panix.com> spake: >> In article <slrn9k21pe.aqd.kamikaze at kuoi.asui.uidaho.edu>, >> Mark 'Kamikaze' Hughes <kamikaze at kuoi.asui.uidaho.edu> wrote: >>> >>> I suspect that Infocom-style interactive fiction, with good production >>>values and nice packaging, could sell again just fine. You'd have to >>>sell it outside of most computer game shops, though, because the games >>>publishing and distribution networks just won't carry it, and the games >>>magazines won't review it (they're all run by and for hyperactive >>>adolescent males (of all ages))... >> >> ...and genders. ;-) > > Hah! When I was writing, I included exactly that clause, but then >removed it because I couldn't think of any female game designers, >publishers, or reviewers who trade in the "hyperactive adolescent male" >genre, except possibly the "booth babes" at game developer's conferences >(and they're almost universally hired models or non-game-design >employees) or the female "mascot" at one of the game review mags (that >specific word was used to describe her by one of the male reviewers...) Okay, fair enough. I tracked down one of my favorite reviewers at Games Domain (http://www.gamesdomain.co.uk/gdreview/), but the closest she comes to reivewing the "hyperactive adolescent male" genre is Diablo II and Shogo. > I love games design, but I really really despise the games industry. >Does it show much? No. Tell us how you really feel. -- --- 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'm not tense, i'm just terribly, terribly alert" --unknown From tim at digicool.com Mon Jul 30 16:37:50 2001 From: tim at digicool.com (Tim Peters) Date: Mon, 30 Jul 2001 16:37:50 -0400 Subject: Python Windows installer: good news! In-Reply-To: <JFa97.68$Nq1.2992@nreader1.kpnqwest.net> Message-ID: <BIEJKCLHCIOIHAGOKOLHOEPNCDAA.tim@digicool.com> [Paolo Invernizzi] > Request... is possible to provide also a MSI package? It's not possible for me, no. Wise's InstallMaster 8.1 is not an MSI authoring tool, and the only behavior I was able to provoke out of Microsoft's Visual Installer MSI authoring tool was program crashes and corrupt installs. As Guido said, ActiveState offers an MSI package, and PythonLabs has no plans in that direction. If you have an MSI authoring tool that works, or can afford the time to write one from scratch, feel free to ship your own Python installer. at-least-it's-a-break-from-"write-a-pep"<wink>-ly y'rs - tim From tjreedy at home.com Fri Jul 27 21:52:52 2001 From: tjreedy at home.com (Terry Reedy) Date: Sat, 28 Jul 2001 01:52:52 GMT Subject: PEP0238 lament References: <mailman.995839419.19134.python-list@python.org> <lZX67.36860$Cy.4285646@news1.rdc1.az.home.com> <11moltg2i6s1ftkpku5dkr0cmifn9f5q1o@4ax.com> <Ew_67.36904$Cy.4360445@news1.rdc1.az.home.com> <eppstein-E3BB02.12500023072001@news.service.uci.edu> <WV177.36940$Cy.4447774@news1.rdc1.az.home.com> <20010727.150850.1605894428.16613@hp.com> Message-ID: <UVo87.35811$EP6.9140747@news1.rdc2.pa.home.com> > I strongly favor the // operator for the new behaviour. The proposal, based on the premise that the old behaviour is broken for Python (though not for C) is to replace the old behaviour with TWO new behaviors. It is somewhat arbitrary which new behavior goes with which symbol, but the assignment chosen is pretty obviously the more sensible than the reverse. Terry J. Reedy From thomas at xs4all.net Mon Jul 2 03:17:35 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 2 Jul 2001 09:17:35 +0200 Subject: Augmented Assignment (was: Re: PEP scepticism) In-Reply-To: <nBQ%6.417370$oc7.58837743@news2.rdc2.tx.home.com> References: <mailman.994035602.29848.python-list@python.org> <nBQ%6.417370$oc7.58837743@news2.rdc2.tx.home.com> Message-ID: <20010702091735.J8098@xs4all.nl> On Mon, Jul 02, 2001 at 02:00:51AM +0000, Rainer Deyke wrote: > "Delaney, Timothy" <tdelaney at avaya.com> wrote in message > news:mailman.994035602.29848.python-list at python.org... > An interesting (and AFAIK legal) optimization would be to make tuples act as > mutable objects with respect to augmented assignment if their reference is > 1. But they are never 1 unless you're in a C extention that just created it. When you call 'x += y', the refcount for both x and y is always 2 when the arguments arrive at the __iadd__ (or C equivalent.) So you mean '2'. But then you could run into trouble on, say, () += y because the empty tuple is shared, just like interned strings and integers. The refcount *could* be 2, and you end up modifying someone else's empty tuple. -- Thomas Wouters <thomas at xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From tjenkins at nospiced.ham.devis.com Thu Jul 26 09:45:01 2001 From: tjenkins at nospiced.ham.devis.com (Tom Jenkins) Date: Thu, 26 Jul 2001 13:45:01 GMT Subject: Informix IDS2000 and Zope/Python/Perl/PHP on Linux References: <3B600F47.2F59C1FC@gdp-group.com> Message-ID: <3B601FC0.4030400@nospiced.ham.devis.com> Thomas Volkmar Worm wrote: > Hi all! > > I am consindering to use Informix Dynamic Server (Informix Internet > Foundation 2000/Linux) together with Zope and the other 3 P's. > > I wonder, whether somebody has any experience with Linux and > > - IDS 2000 and Perl > or > - IDS 2000 and PHP > or > - IDS 2000 and Python > or > - IDS 2000 and Zope > > and can tell me about the experience he made with one or more of these > combinations. I am interested to hear about > > - availibility of the needed drivers > - their (practical) compatibility to (eg. perl DBI, python DB-API 2.0, > etc.) > - stability > - and what else someone has experienced > > I already was an php.net, python.org, perl.org, zope.org - I guess I > know whats available. It looks to me as if the support for IDS is not so > strong, so I am really interested in real experience somebody had rather > that what you can read in the READMEs. If you stopped using IDS together > with P..., please tell me why and what db (other than mySQL, thats > allready running here) are you using instead. > > If some Informix/IBM people are around: Are there any contributions > planned or in progress for the 3 P's by Informix/IBM? Where can I find > online information about it? > > If you respond to this posting, please send a CC to my email-address > too. > > Thanks for your efforts in advance > > Regards > Thomas Volkmar Worm > One thing to keep in mind with Zope... you can call perl also. This was added (by ActiveState I believe) so that the more "esoteric" databases that perl supports can be accessed in Zope. Just a thought. Tom From kirwin14 at home.com Sat Jul 14 13:55:11 2001 From: kirwin14 at home.com (Keith F Irwin) Date: 14 Jul 2001 10:55:11 -0700 Subject: (no subject) In-Reply-To: <200107141318.AA116326580@mtni.net> References: <200107141318.AA116326580@mtni.net> Message-ID: <995133311.4401.9.camel@c234192-a> Could you use threads? I just wrote a program that does something like: 1. start thread to read database between sleep(500) 2. start thread to ping machines listed in database, update global struct,sleep(300) 3. in forever loop, listen on a socket, if there's a connection, start thread to handle it (ie, spit out html table of global struct, close socket) Not sure if this fits in, but using timed threads can get you out of the event driven model. So, have a thread to listen via socket and update list when data comes in, another thread to print out list when list changes. You'll have to lock the list while it's being update, which'll make the list print method wait until it's updated. Add some sleeps to slow things down a bit, etc. Anyway, I'm new to python, and new to socket stuff too, so.... -K On 14 Jul 2001 13:18:31 -0400, Shane Anglin wrote: > Here's the basics of what I want to do with my new app: > Main loop is: > 1 - check socket for any incoming data > 1a - if no data on socket, go to 2, else get the data and place it into a list > 2 - print out list > 3 - go to 1 and do it all over again > > Currently, I can create a TCP socket server app using examples that will sit and wait (idle 99% of the time) and accepts the incoming data just fine, my 'print list' part is not processing at all until I get any new data in... for example, 1-wait on a client connect on socket, when a connection happens, get data, 2- place new data into list, print list, 3 -go to 1 and do it all over again... in this scenario, #1 has the rest of my code 'hostage' until a client connection is made and closed. > > Thanks a bunch! > Shane Anglin > shaneanglin at bigfoot.com > > -- > http://mail.python.org/mailman/listinfo/python-list From mlh at idi.ntnu.no Tue Jul 3 19:04:05 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Wed, 4 Jul 2001 01:04:05 +0200 Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> <bebbba07.0107021206.70a22aa8@posting.google.com> <3b4102f4.887720905@wa.news.verio.net> <0Kd07.7470$e5.974463@newsb.telia.net> Message-ID: <9htj16$fre$1@tyfon.itea.ntnu.no> "Fredrik Lundh" <fredrik at pythonware.com> wrote in message news:0Kd07.7470$e5.974463 at newsb.telia.net... > Bengt wrote: [...] > I've built mission-critical, real-time Python systems. Just out of (honest) curiosity: What kind of systems? > Cheers /F -- 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 clpy at snakefarm.org Sun Jul 8 05:47:48 2001 From: clpy at snakefarm.org (Carsten Gaebler) Date: Sun, 08 Jul 2001 11:47:48 +0200 Subject: readline()/readlines() inconsistent? Message-ID: <3B482C44.6E6EB163@snakefarm.org> Hi there! I've just come across a strange difference between readline() and readlines(): Python 2.1 (#17, Jun 15 2001, 15:24:30) [GCC 2.95.2 19991024 (release)] on linux2 Type "copyright", "credits" or "license" for more information. >>> f = open("foobar", "w") >>> f.readline() '' >>> f.close() >>> >>> f = open("foobar", "w") >>> f.readlines() Traceback (most recent call last): File "<stdin>", line 1, in ? IOError: [Errno 9] Bad file descriptor >>> Why does readlines() raise an exception while readline() does not? I expected it to return an empty list. According to the docs readlines() uses readline(). If I open the file "w+" everything's fine. Opinions? Regards Carsten. From sholden at holdenweb.com Tue Jul 17 10:02:08 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 17 Jul 2001 10:02:08 -0400 Subject: web interface to c program running on different server References: <3B53B116.86535A3@usa.net> <3B53BB43.986D70AE@engcorp.com> <3B53C285.F8405344@usa.net> <3B543A08.5E66740C@engcorp.com> Message-ID: <bxX47.23541$d4.596732@e420r-atl1.usenetserver.com> "Peter Hansen" <peter at engcorp.com> wrote in message news:3B543A08.5E66740C at engcorp.com... > Lee wrote: > > > > I wasn't asking the readers to provide me with a list of pros and cons - > > those would be for me to figure out when I have a few suggestions for > > implementations. > > In other words, "don't think about it, just do it". I get it. <1/2 wink> > You do realise this means Peter is entirely serious. unless-he-really-meant-<1.0/2 wink>-ly y'rs - steve -- http://www.holdenweb.com/ From foobarickknob at yahoo.com Thu Jul 26 21:05:50 2001 From: foobarickknob at yahoo.com (Scott Taylor) Date: 26 Jul 2001 18:05:50 -0700 Subject: Couple of newbie questions... Message-ID: <5a140c6d.0107261705.3a4f7db3@posting.google.com> I'm just getting started w/ Python - and have run into a couple issues w/ the Windows extensions... 1) time.sleep doesn't seem to release time back to the Win32 subsystem. I had a tight loop, and CPU was maxed out at 100% even if I did a PumpWaitingMessages w/ a time.sleep. To actually get the loop to return slices of time back to windows and not max out the CPU I had to do a PumpWaitingMessages followed by a win32api.Sleep(0) call. My question is - shouldn't time.sleep actually make the process sleep w/o hogging CPU? 2) There seems to be a bug in win32gui.SetDlgItemText, or I'm not using it appropriately. win32gui.SendMessage w/ a WM_SETTEXT param works, whereas SetDlgItemText w/ the dialog window and the control don't... anybody else noticed this? Thanx... and python rocks!!! Scott From michael at stroeder.com Wed Jul 4 09:16:46 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Wed, 04 Jul 2001 15:16:46 +0200 Subject: problem with sending email References: <mailman.994139704.17222.python-list@python.org> <ku3d8d31ve.fsf@lasipalatsi.fi> <3B42BD95.D6A0BC30@stroeder.com> <kuwv5o28r9.fsf@lasipalatsi.fi> Message-ID: <3B43173E.9CEB7C0D@stroeder.com> Erno Kuusela wrote: > > In article <3B42BD95.D6A0BC30 at stroeder.com>, Michael Str?der > <michael at stroeder.com> writes: > > | Now think about systems where sendmail isn't installed at all. > > every unix mta provides a "sendmail" command afaik. unixes don't > function very well without the capability to deliver mail since > it's used by cron and whatnot. Well, you are making the assumption that your Python app lives on a fully-installed Unix like a mainstream Linux or BSD distribution. This is e.g. wrong for most web applications. > ok, you may have a box that is configured to only deliver local mail, > but not very common and easy to remedy. How about restricted systems or non-Unix systems? Did you ever think about this? IMHO a simple Python app which always sends to a certain e-mail address through a well-defined mail relay can be reviewed much easier than a full-blown MTA. Unless you can really derive the assumption that sendmail has to be present on the target system I'd always vote for smtplib. Ciao, Michael. From machin_john_888 at hotmail.com Fri Jul 13 19:57:18 2001 From: machin_john_888 at hotmail.com (John Machin) Date: 13 Jul 2001 16:57:18 -0700 Subject: PEP: Defining Unicode Literal Encodings References: <mailman.995025922.12846.python-list@python.org> Message-ID: <92ae279c.0107131557.5e0be899@posting.google.com> "M.-A. Lemburg" <mal at lemburg.com> wrote in message news:<mailman.995025922.12846.python-list at python.org>... > Please comment... > > Syntax > > The syntax for the directives is as follows: > > 'directive' WS+ 'unicodeencoding' WS* '=' WS* PYTHONSTRINGLITERAL > 'directive' WS+ 'rawunicodeencoding' WS* '=' WS* PYTHONSTRINGLITERA > L > > with the PYTHONSTRINGLITERAL representing the encoding name to be > used as standard Python 8-bit string literal and WS being the > whitespace characters [ \t]. > (1) An example of a directive complying with the syntax might aid the understanding. directive unicodeencoding='big5' (2) Could we possibly have e.g. raw_unicode_encoding (my preference) or RawUnicodeEncoding instead of rawunicodeencoding? The latter could be a little boggling for humans of some cultures to parse; it reminds me of the preposterously long words that are used to frighten beginners in lesson 1 of German language classes e.g. Dampfschiffahrtgesellschaftsdirektorsstellvertretersgemahlin. From aleaxit at yahoo.com Sat Jul 14 05:03:34 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 14 Jul 2001 11:03:34 +0200 Subject: not safe at all References: <mm8tkt4te3qnbpv3nh5nhsi591o1osln73@4ax.com> <slrn9ku3c3.mrk.9nick9m@localhost.localdomain> <u26ukt4vot7b1qu02hkp8l1pnmdi0sfp3l@4ax.com> <3B4F743C.66778F9F@tundraware.com> Message-ID: <9ip1qa012en@enews4.newsguy.com> "Tim Daneliuk" <tundra at tundraware.com> wrote in message news:3B4F743C.66778F9F at tundraware.com... ... > Furthermore, bear in mind that code "portability" is no where near as > important in the commercial sector as it is in academics. Commercial That depends on the state of the market. Just a few years ago, it would have KILLED us if our CAD applications didn't run portably between VMS, Apollo Domain, and many versions of Unix -- each OS accounted for an important segment of our customer base. Today, running on a small number of somewhat-different Microsoft operating systems suffices -- but any day now, it would not at all surprise me if an important market segment suddenly demanded, say, Linux -- in which case, lack of portability would again become a commercial killer in this nice. (Before you scoff -- markets as important as the French public administration and China appear to be oriented to demanding Linux pretty soon, while others keep demanding MS systems -- better keep those portability skills not too badly honed, is my opinion). Besides, portability is NOT only an issue between operating systems and hardware platforms (...and on the latter, someday soon the ability to exploit Itanium well may be a key market differentiator...). Anything that qualifies as a "platform" for applications needs to be seen in this light. Portability between IIS and Apache can double the potential market for a commercial web framework. And it serves our PDM product well that it's portable between SQL dialects and RDBMS's -- some customers are totally wed to Oracle and would never buy a product that can only run on SQL Server, and vice versa -- this DOES give us an important marketing differentiator wrt some of our competition. I'm not getting into the C++ flamewar you're trying to unchain -- just noticing that one of our competitors in the PDM field recently released their newest product version, and one of the fundamental differences wrt the previous one is that they rewrote it from Java (as it originally was) to C++ (as it is now) -- they claim speed-ups of about 60% overall, more solidity, etc, as a consequence. If that is an example of C++ "dying a slow death", I think Mark Twain's well-known dictum may apply. I _do_ agree that C++ is too complex for the human brain and thus should only be used sparingly (for system interaction and top-speed components -- but do notice that those components ARE part of large commercial applications... and many people still do not realize that multi-language applications are the way to go, thus, needing maybe 10% of the app to be in C++, they go ahead and make or rewrite it ALL in C++, rather than make it 10% C++ and 90% Python...:-). Alex (Brainbench MVP for C++ -- declaring interest, as it were:-) From rnd at onego.ru Fri Jul 13 14:12:45 2001 From: rnd at onego.ru (Roman Suzi) Date: Fri, 13 Jul 2001 22:12:45 +0400 (MSD) Subject: Scripting vs. whatever, again (was Re: Long Live Python!) In-Reply-To: <9in5bs01mio@enews1.newsguy.com> Message-ID: <Pine.LNX.4.30.0107132148080.8976-100000@rnd.onego.ru> On Fri, 13 Jul 2001, Alex Martelli wrote: >"Grant Edwards" <grante at visi.com> wrote in message >news:H6D37.14720$B7.2683686 at ruti.visi.com... > ... >> >> I interpret "scripting" as automating a series of operations >> >> that would probably be done interactively by a user otherwise. > ... >> Probably not. To add to my "definition", I guess I would call >> it a script if it was done using the same set of "primitives" >> that the user would have done had it been done interactively. >> Primitives like the "ls" "find" "rm" executables found on Unix >> systems. > >So you wouldn't "call a script" a script scripted in VBScript >on the Windows Scripting Host, or a script scripted in JScript or >Javascript, residing typically between <SCRIPT> and </SCRIPT> >tags in an HTML page? Because, while they may well be automating I think, there are several features which make language play a "scripting" role: - fast startup (Java IS NOT scripting language) of scripts - ability to easily glue large software components (sh, for example, use many external programs) - related to the previous, scripts assume rich environment and are better wired into it. For example, CGI-scripts interact with web-server and are incomplete without this interaction It could be even said, that scripts are command language to control inside programm environment. More usually than not, scripts add a function to the environment. And scripts are usually more independent from each other than modules. - scripts are interpreted. One do not need to recompile scripts. - sometimes scripts are results of convertion from other kind of user input (script or macro could be created by a series of mouseclicks and key pressing). Scripting languages differ from system programming languages by having higher-level commands and (as is case with Python) higher-level data-structures. Scripting languages are problem-domain oriented. However, universal scripting languages (Perl, Python, Ruby, ...) are becoming more and more popular in IT industry. Scripts fight complexity better than monolithic applications. For example, authorisation scripts for RADIUS server allow us to have a hook on what to do if such and such user wants to login. This is FAR better approach than having large application which will require selecting dozens of checkboxes from preselected list to do the same. compact, simple and reliable engine with scripting hooks + scripts WINS large all-in-one memory-greedy application without scripts For example, Quark Xpress (if I'm not mistaken) has no scripting capabilities (PageMaker got it only recently), which makes me feel better with TeX/LaTeX which had such from the start (it's itself a programming language). * All said, I conclude that being "scripting language" is a role, described above and not language feature in itself. Python is universal programming language. But when it is used inside Sketch, it is scripting language. When it is used to write Sketch itself it is "normal" programming language. By scripting languages we usually call those which are almost always used for scripting. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Friday, July 13, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Useless Invention: Open Toed Safety Shoes." _/ From guido at python.org Fri Jul 6 09:17:18 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 06 Jul 2001 13:17:18 GMT Subject: Comment on PEP-0238 References: <3B3BE855.A6223E70@3-cities.com> <cp7kxvlake.fsf@cj20424-a.reston1.va.home.com> <Y4J%6.4084$Z6.2010194@news1.rdc2.pa.home.com> <mailman.994016102.30019.python-list@python.org> <7ef50c46.0107020554.31cc948b@posting.google.com> <mailman.994084684.19932.python-list@python.org> <7ef50c46.0107030657.2e0fc92b@posting.google.com> <mailman.994177387.31239.python-list@python.org> <3B42B152.5EC4F056@3-cities.com> Message-ID: <cp1ynukxmv.fsf@cj20424-a.reston1.va.home.com> "Robert J. Harrison" <rjh at 3-cities.com> writes: > Again, my major objection to this proposal is that it gives us > nothing and breaks a lot of existing code. Other educators disagree. Take the case of VPython. The VPython folks have used Python very successfully to teach freshman physics students at Carnegie Mellon to create 3D models. Many students had little or no programming experience. The goal of the course wasn't to teach programming, it was to teach understanding of physics. Throughout the course, students were writing Python programs implementibg various laws of physics. Here's a quote from Bruce Sherwood, one of the teachers (without permission, but I'm sure he doesn't mind): """ The final activity (last week) was very satisfying. Students made a traveling electromagnetic wave in 3D, and then moved a positron relativistically (leaving a trail) under the influence of the wave. Almost every student did a very nice job. This is way beyond what is normally done in these courses. And remember that this was with extremely little instruction, with a sizable minority of the students never having written a program before entering our course. """ Now read his criticism of Python: """ Everything worked extremely well except for integer division, both 1/2 being zero and 10**-15 giving an execution error. For example, on last week's program one student spent two hours trying to figure out why he was getting a strange positron trajectory, and it finally turned out to be (x+y)**(1/2), which looks fine but is equal to 1 for all values of x and y. """ This exactly corroborates the experience of the Alice team (who started this discussion). > The proposal is based upon the supposition that uniting floats with > integers makes programming easier to learn for beginners, but this > is absolutely not consistent with my experience in teaching > programming using Python and other languages (including Maple that > has rationals). No, the proposal intends to make *using* Python easier. Now, clearly there are some areas where the current approach (1/2 == 0) is more useful, and other areas where the proposed new approach (1/2 == 0.5) is more useful. But I think that the latter rule is useful vastly more often than the former. There just are more places in life where 1/2 equals one half then where it equals zero. Note that I'm not saying that 1/2 *returns* 0.5. While in the current proposal that's indeed the plan, I'm not necessarily against returning something else, e.g. maybe a rational. (I have a different reason to dislike rationals and favor decimal arithmetic instead, but that's quite a different discussion.) I'm just saying that the *value* of 1/2 should be equal to the value of 0.5, in other words, 1/2 should act like 0.5 when fed into a floating point expression > All programmers must very soon appreciate the different nature of > integer and floating point (or rational) arithmetic in order to > address discretized quantities such as lists, files, strings, etc. Agreed. And integers should remain required for indexing etc. But when dividing two integers, we shouldn't drop the remainder on the floor by default. --Guido van Rossum (home page: http://www.python.org/~guido/) From philh at comuno.freeserve.co.uk Wed Jul 4 17:09:15 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Wed, 4 Jul 2001 22:09:15 +0100 Subject: batch generation of keypairs by GnuPG Message-ID: <slrn9k71fq.707.philh@comuno.freeserve.co.uk> [x-posted to several newsgroups, because I don't know what the best way to proceed is] I am developing an email encryption system in Python. (The details of what it will do are at <http://www.vision25.demon.co.uk/oss/herbivore/intro.html> ) It uses public-key encryption. As the encryption engine, I am using GnuPG, which I am calling from my program using the system() call. I am having problems programmatically generating a public/private keypair using GnuPG. The relevant code segment is: #--------------------------------------------------------------------- def createSecretKey(realName, email): """ invoke GPG to create a secret key for me """ if debug: print "!! in createSecretKey() !!" # create a tempory file to contain parameters for key creation keyCreationParas = """%%secring %s %%pubring %s Key-Type: %s Key-Length: 1024 Expire-Date: 0 Name-Real: %s Name-Comment: %s Name-Email: %s %%commit """ % (secPn, pubPn, gpgCreateKeyType, realName, gpgKeyComment, email) tmpFilename = os.tempnam(herbDir, "temp_") tmpFilename2 = os.tempnam(herbDir, "temp2_") utility.writeFile(tmpFilename, keyCreationParas) #>>>>> invoke GPG to create the key: gpgCommand = ("gpg --batch " + "--no-default-keyring --secret-keyring %s --keyring %s " + "--gen-key -a %s") % (secPn, pubPn, tmpFilename) if debug: print "!! About to [%s]..." % gpgCommand gpgProcess = popen2.Popen3(gpgCommand) # GPG is now running as a separate process. We may need to give it # a source of entropy. Running tasks in the background is intended # to achieve this if debug: print "!! returned from Popen3()" while 1: #####was: while gpgProcess.poll() != -1: pollValue = gpgProcess.poll() if debug: action = "stopped" if pollValue == PROCESS_STILL_RUNNING: action = "continuing..." print "!! gpgProcess.poll() => %s, %s" % (pollValue, action) if pollValue != PROCESS_STILL_RUNNING: break # gpg process hasn't finished yet, so execute some tasks result = commands.getoutput("ps auxw") result2 = commands.getoutput("date") result3 = commands.getoutput("df") utility.writeFile(tmpFilename2, result+result2+result3) # ...feed these results into GPG?... if debug: print "w", # tidy up: remove the temporary files os.remove(tmpFilename2) os.remove(tmpFilename) #--------------------------------------------------------------------- When I execute this, I get this output from gpg: ------------------ begin -------------------- gpg: Warning: using insecure memory! gpg: /home/philh/.herbivore/secret_keys.gpg: keyring created gpg: /home/philh/.herbivore/public_keys.gpg: keyring created +++++.+++++++++++++++..+++++++++++++++++++++++++++++++w !! gpgProcess.poll() => -1, continuing... ++++++++++++++.+++++.+++++++++++++++++++++++++w !! gpgProcess.poll() => -1, continuing... .++++++++++++++++++++++++++++++.+++++>.+++++w !! gpgProcess.poll() => -1, continuing... .w !! gpgProcess.poll() => -1, continuing... ..w !! gpgProcess.poll() => -1, continuing... (etc) ------------------- cut --------------------- Note that it says it's creating the keyring files before the keypair is computed -- this seems wrong to me. On exit, when I try to view what's in the keyring files, gpg complains thus: ------------------ begin -------------------- philh:~/.herbivore> gpg --list-sig --keyring ~/.herbivore/public_keys.gpg gpg: Warning: using insecure memory! gpg: [don't know]: invalid packet (ctb=2d) near 1 gpg: read_keyblock: read error: invalid packet gpg: enum_keyblocks(read) failed: invalid keyring ------------------- cut --------------------- So, I have two questions: (1) how do I get GnuPG to generate keypairs as a batch process? (2) Should I be using GnuPG at all? I don't need its key management facilities -- I can use a serialised Python data structure for that -- and I find it overcomplex to use programmatically. Is there a better solution? What I need is software that can generate keypairs (using an unencumbered algorithm such as ElGamal), and can encrypt and decrypt using those keys, and make/test signatures using the keys. Is there anything which does this (either a Python program, or something accessible from the command line)? -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From Tom_Good1 at excite.com Thu Jul 26 13:36:32 2001 From: Tom_Good1 at excite.com (Tom Good) Date: 26 Jul 2001 10:36:32 -0700 Subject: a break for comprehensions References: <9jpadd$s5k$1@news.duke.edu> Message-ID: <ac677656.0107260936.2d0eb14d@posting.google.com> "Kevin Lacker" <kdl4 at acpub.duke.edu> wrote in message news:<9jpadd$s5k$1 at news.duke.edu>... > Can you do this: > > answer = [] > for x in my_list: > if not is_good(x): > break > answer.append(process(x)) > > with a list comprehension somehow? I'm starting to dislike explicit for > loops just for the purposes of constructing another list from a current one. > > Would this work in the future python with iterators... > > def done(): raise StopIteration > answer = [process(x) for x in my_list if is_good(x) or done()] > > If I used it a lot it might not be a pain to define done(). I think it would > be cool to be able to reuse the while keyword inside comprehensions like > > answer = [process(x) for x in my_list while is_good(x)] > > Makes sense to me... it's like being able to use a sentinel with iterators > but more flexible. You could simulate a "while...break" within comprehensions using a generator, like this: #---- begin code def itrWhile(obj, func): itr = iter(obj) while 1: x = itr.next() if func(x): yield x else: return #---- end code Then: >>> def isGood(n): ... return n < 4 ... >>> a = [1,2,3,4,5,6,7] >>> [x for x in itrWhile(a, isGood)] [1, 2, 3] >>> Notice the important difference between this and "[x for x in a if isGood(x)]" >>> def isGood(n): ... print "comparing", n ... return n < 4 ... >>> [x for x in a if isGood(x)] comparing 1 comparing 2 comparing 3 comparing 4 comparing 5 comparing 6 comparing 7 [1, 2, 3] >>> [x for x in itrWhile(a, isGood)] comparing 1 comparing 2 comparing 3 comparing 4 [1, 2, 3] >>> The "itrWhile" version breaks out after the first unsuccessful comparison. The version using "if" tests every element. Tom From tim.one at home.com Sun Jul 15 21:36:22 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 15 Jul 2001 21:36:22 -0400 Subject: re Challenge: More Compact? In-Reply-To: <slrn9l4fob.p58.tim@vegeta.ath.cx> Message-ID: <LNBBLJKPBEHFEDALKOLCKEKLKOAA.tim.one@home.com> [Tim Hammerquist] > ... > Easily implemented in Perl: > >: sub valid_ip { >: my ($ip, $failed, @elements) = (shift, 0); >: @elements = ($ip =~ /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/); >: $failed = grep { $_ > 255 } @elements; >: return ($failed) ? undef : 1; >: } > > Slightly more verbose in Python: > >: import re >: def valid_ip(ip): >: expr = r'^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$' >: elements = map(int, re.match(expr, ip).groups()) >: failed = filter(lambda x: x > 255, elements) >: if failed: return None >: else: return 1 Well, it's un-Pythonic to try to emulate Perl undef via Python None; it's idiomatic to return 0 for false and 1 for true, in which case the last three lines can be replaced by, e.g., return max(elements) < 256 Note that the leading "^" in the Python regexp isn't needed (can save another entire character that way <wink>). The Python version should also check for match failure. Like def valid_ip(ip): m = re.match(r'(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$', ip) if m: elements = map(int, m.groups()) return max(elements) < 256 return 0 Yes, you can squash lines out of that -- I wouldn't. BTW, does it bother anyone that all of these solutions accept an IP ending with a newline? regexps-are-surprising-ly y'rs - tim From aleaxit at yahoo.com Wed Jul 18 17:48:01 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 18 Jul 2001 23:48:01 +0200 Subject: converting from perl: variable sized unpack References: <roy-B2459F.22112513072001@news1.panix.com> <mailman.995081424.8581.python-list@python.org> <slrn9l4esk.885.quinn@yak.ugcs.caltech.edu> <slrn9l5lc4.6ko.philh@comuno.freeserve.co.uk> <9j2dnn$ndm$0@216.39.144.220> <slrn9lavp6.v3.philh@comuno.freeserve.co.uk> Message-ID: <9j507g01j75@enews3.newsguy.com> "phil hunt" <philh at comuno.freeserve.co.uk> wrote in message news:slrn9lavp6.v3.philh at comuno.freeserve.co.uk... ... > if not myCollection.hasIndex(x): raise Exception > > (Note that hasIndex() should equally work for dictionaries as well > as sequence-collections (strings, tuples, lists, etc). IMO it is > an unnecessary non-orthogonality of the present python that it doesn't > do this) It's quite orthogonal if you think of exceptions as the MAIN way to communicate the missing index case: def hasindex(myCollection, x): try: myCollection[x] except LookupError: return 0 else: return 1 LookupError is the common base class of IndexError, raised by sequences, and KeyError, raised by mappings. > No, because on the odd occasions that you want an exception you can > always throw one manually. And viceversa, if the odd occasions are those in which you want to SUPPRESS the exception, you can easily try/except it. > Here, I'm assuming that usually you don't want one -- perhaps this > is jsut my idiosyncratic programming style and most people vare different > here. Comments? I think that most languages supporting exceptions are hinged to using them only for exceptional cases, so it's clearly going to be common for people with such backgrounds to find that style the 'usual' one -- but I also think that best Pythonic style is different, and very oriented to "it's easier to ask forgiveness than permission", and to rather free use of exceptions. Alex From tim.one at home.com Wed Jul 25 17:09:09 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 25 Jul 2001 17:09:09 -0400 Subject: Language change and code breaks In-Reply-To: <cpofq9a858.fsf@cj20424-a.reston1.va.home.com> Message-ID: <LNBBLJKPBEHFEDALKOLCKEDJLBAA.tim.one@home.com> [Guido van Rossum] > ... > But never mind, I'm giving up on making *Python* case-insensitive. > The hostility of the user community is frightening. Try to think of it as invigorating instead. You haven't seen hostility until they have to pay for Python. Or weren't we going to announce that yet <wink>? new-division-is-free-old-division-is-$500-per-download-ly y'rs - tim From chris at voodooland.net Sun Jul 8 23:35:37 2001 From: chris at voodooland.net (Chris Watson) Date: Sun, 8 Jul 2001 22:35:37 -0500 (CDT) Subject: license suggestions? In-Reply-To: <9ib6nn$tut$1@apollo.csd.net> Message-ID: <20010708223109.O93454-100000@open-systems.net> > That is not really what the license says though. With that license you > can't integrate it with anything. If you put it in a closed source product > it would have a more restrictive license and thus couldn't be used that way. How do you figure you can't integrate my licensed code into a say binary only product? How is it restricting binary only products? > Also no one can make your code GPL. Your code is always under the license > you released it under. However the GPL would make the entire collection GPL > if GPL code were released with it. That really is no different then > including BSD code in a closed source product since the closed source > license takes precedence. That is where you are wrong. If someone either A) uses my code in a GPL app the entire app is GPL'ed *including* my code. Or B) someone can just flat out put the GPL on top of my code *HAD* my code been licensed with only clause 1 and 2. The BSDL does *not* say you cannot place further restrictions on it. Thats the whole point of BSDL. Do whatever you want with it just dont sue me (the author) if you put it in your pace maker and you die the next morning. > That capitalism/communism thing is FUD and I hope people grow up and stop > using it. Communism \Com"mu*nism\, n. [F. communisme, fr. commun common.] A scheme of equalizing the social conditions of life; specifically, a scheme which contemplates the abolition of inequalities in the possession of property, as by distributing all wealth equally to all, or by holding all wealth in common for the equal use and advantage of all. communism n 1: a form of socialism that abolishes private ownership 2: a political theory favoring collectivism in a classless society That is the GPL to the letter. I dont care what smoke and mirrors you try to BS it with. Chris From bokr at accessone.com Wed Jul 11 16:17:27 2001 From: bokr at accessone.com (Bengt Richter) Date: Wed, 11 Jul 2001 20:17:27 GMT Subject: Language Shootout References: <mailman.994742356.29669.python-list@python.org> <3b4b04fb.1257683@nntp.sprynet.com> <3b4bab70.1586151915@wa.news.verio.net> <3b4c647e.2934740@nntp.sprynet.com> Message-ID: <3b4ca7bc.1650739848@wa.news.verio.net> On Wed, 11 Jul 2001 14:48:13 GMT, ullrich at math.okstate.edu (David C. Ullrich) wrote: [...] >>On my system I get >> >>[18:47] C:\pywk\fib>strL.py str 10L**20899 >>str took 13.601617 seconds >> >>[18:47] C:\pywk\fib>strL.py strL 10L**20899 >>strL took 1.044989 seconds >> >>Recursion rides again ;-) > >Recursive or not, the idea that we can write >a replacement for str that's faster is very >curious. > Well, it's a seldom-used aspect of str to print monster longs. They surely had more urgent things to do ;-) >>BTW, how do you put everything inside the strL def >>to hide names, and how do you recurse inside without >>a warning message? I'm leaving this question in ;-) [...] > >Of course you have to do the recursion in a non-stupid >manner, as here; if you'd made a recurzive routine >that concatenated Python strings instead of building >that list I doubt that recursion would win. But it is >curious how often recursion does seem to win in Python. >(Doesn't usually beat built-in functions, though.) > I hope people realize what you are pointing out, i.e., that it's not recursion per se that made the gains. The algorithm is the thing. Recursion is a powerful way of expressing algorithms, and the more expressive power you have, the better your chances of coming up with a good algorithm. Clean expressive power is Python's main attraction IMO. A better algorithm can often overcome the advantage of optimized brute force, and recursion is a natural when you have foo(x) and can partition x into x1 and x2 such that foo(x) == bar( foo(x1), foo(x2) ) and the times for foo-ing the pieces and bar-ing their results is less than the time for foo-ing the whole. BTW, if we were recursively searching for the optimumly timed partition and sub-partitions, UIAM & IIRC it would amount to optimization by Dynamic programming, I think. You know, the Bellman thing ;-) From ken_chiba at hotmail.com Tue Jul 17 07:17:36 2001 From: ken_chiba at hotmail.com (Ken) Date: Tue, 17 Jul 2001 11:17:36 GMT Subject: MySQLdb - possible without install? References: <3b4d0ea7.11581823@news1.on.sympatico.ca> <slrn9kqr2k.p1.gerhard.nospam@lilith.hqd-internal> <3b4d7a61.39160079@news1.on.sympatico.ca> <slrn9krt7k.nj.gerhard.nospam@lilith.hqd-internal> <3b4e2495.82731972@news1.on.sympatico.ca> <slrn9ksrdc.sa.gerhard.nospam@lilith.hqd-internal> <3b50d5dd.47261648@news1.on.sympatico.ca> <slrn9l704c.8s2.gerhard.nospam@lilith.hqd-internal> Message-ID: <3b541ea5.262501657@news1.on.sympatico.ca> Okay... thanks for your suggestions. I have been on the provider's case for a few months now to install the module - which they promised to do a while ago.. but still no luck! I guess I'll just have to wait it out. Thanks again, On Tue, 17 Jul 2001 02:35:40 +0200, gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) wrote: >On Sat, 14 Jul 2001 23:40:24 GMT, Ken <ken_chiba at hotmail.com> wrote: >>Ok. >> >>Still no luck! In case I'm just missing something... here is a >>listing of various files/directories: > >Sorry, I'm out of ideas, too. The "ImportError: File not found" is the thing I >don't get. If I had to debug, I would check if you can import a file "mysql.py" >in the cgi-bin directory instead. (One, very improbable thing could be that the >provider disabled dynamic loading of extension modules. But they would have had >to do this explicitly on Linux.) > >I'd perhaps contact the provider and ask if they could install the module. > >What I have done one time, is install my own copy of Python in the cgi-bin >directory. But this is normally more difficult than installing MySQLdb and it >really sucks if you don't have access via ssh. > >Gerhard >-- >mail: gerhard <at> bigfoot <dot> 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, [chr(ord(x)^42) for x in list('zS^BED\nX_FOY\x0b')]) From com-nospam at ccraig.org Sat Jul 28 19:14:23 2001 From: com-nospam at ccraig.org (Christopher A. Craig) Date: 28 Jul 2001 19:14:23 -0400 Subject: proposed language change to int/int==float (was: PEP0238 lament) In-Reply-To: <slrn.pl.9m4s03.f3g.qrczak@qrnik.zagroda> References: <mailman.995989601.30748.python-list@python.org> <cp3d7lbo89.fsf@cj20424-a.reston1.va.home.com> <ubsm8epr5.fsf@ctwd0143.fitlinxx.com> <cp7kww92ph.fsf@cj20424-a.reston1.va.home.com> <m266cg73ig.fsf@mycroft.actrix.gen.nz> <3b60d65e.219212588@news.eircom.net> <cpy9pa4hnh.fsf@cj20424-a.reston1.va.home.com> <slrn.pl.9m4s03.f3g.qrczak@qrnik.zagroda> Message-ID: <87itgcabow.fsf@elbereth.ccraig.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl> writes: > This doesn't work in my model. The simplest way to let it work is to > treat ints (with longs) and rationals as representation details of > the same concept (no matter if it's the same Python's type or not). > > This is not nice IMHO and it leads to more cases when the type of the > result depends on the value of the argument (x**y returns at least > a float when y is a rational, but may return an integer when y is > a nonnegative integer) and turns some TypeErrors into ValueErrors > (e.g. s[1/2]). > > I would not make 5/2-3/2 usable as a sequence index. My style is more > "typeful". But you decide. I don't like this. If we accept PEP238 then I would like to see the rational type return an int (preferably a united long/short int) if the denominator is one. Meaning that 5/2-3/2 would actually be an int, and thus could be used as a sequence index. - -- Christopher A. Craig <com-nospam at ccraig.org> Often statistics are used as a drunken man uses lampposts -- for support rather than illumination. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: Processed by Mailcrypt iEYEARECAAYFAjtjR04ACgkQjVztv3T8pzsXYgCcDirmNvyZJXZKlaeorpaVUQCP 3SwAnRF7OHdZPP6qSD7CPnmjx0b33Esg =pFlW -----END PGP SIGNATURE----- From hoki26 at gmx.de Sun Jul 8 12:14:49 2001 From: hoki26 at gmx.de (Holger Kipp) Date: Sun, 8 Jul 2001 18:14:49 +0200 Subject: Q: Duplicating Objects ... HOW ??? Message-ID: <9ia0ru$80k$1@sun.rhrk.uni-kl.de> Hi 2 all, I've got a problem duplicating objects ... please could you help me ? i've created an object named "test" ... now I would duplicate this object for x times und rename the new objects to "test1", "test2", ... "test20" ... and so on ... for the numbers, i will take a adequate loop ... but: how can i paste the serial numbers to the duplicated class name? do you have any sources for my problem (duplicating classes and rename them)? greetings -Holger- From chris.gonnerman at newcenturycomputers.net Mon Jul 23 09:10:21 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Mon, 23 Jul 2001 08:10:21 -0500 Subject: PEP0238 lament References: <mailman.995873261.11975.python-list@python.org> <roy-2E6A21.08305123072001@news1.panix.com> Message-ID: <009a01c11378$d4eeaf20$0101010a@local> ----- Original Message ----- From: "Roy Smith" <roy at panix.com> > Well, heck, in perl, "1"/2 is 0.5 as well. I'm sure there are lots of > people new to programming who gets confused when they discover that numbers > and strings are different too. Perhaps we should add auto-conversion of > strings to numbers to python as well? :-) If that were the rule in the first place (pre-1.5.2 at least) we wouldn't cry about it (much). > The thing that scares me most about this idea is that it breaks existing > code. And, the idea that there will be conversion tools, and auto-warnings > generated, don't impress me. You still need to touch all the old code. YES. This is my headache too. All the pro-PEP0238 people out there assume that we will track version upgrades... but I upgraded several systems directly from 1.5.2 to 2.1. There's nothing to stop me from doing that with 2.4, and then I'll be in a world of hurt. > What about code that you've shipped to customers already? Are we going to > demand that they not upgrade their python installation, or that they > maintain a new version for their own work and an old version to keep our > stuff going? Ouch. > While, I happen to like the way integer division works, I could be > convinced that auto-promotion from int to float might be a good thing, if > that's the way the language had been defined in the first place. Too late > to go back now, however. Much too late. Consistent rules which are not *wrong* but only *different* should NOT be changed this late in the game. I really don't think it takes that long to teach a newbie about integer division; is saving 5 minutes times the number of newbies out there really worth the man-hours of fixing the bugs and the serious loss of face when we screw with a fundamental rule? From msoulier at storm.ca Fri Jul 6 17:27:05 2001 From: msoulier at storm.ca (Michael P. Soulier) Date: Fri, 06 Jul 2001 21:27:05 GMT Subject: lvalues and the lgb rule Message-ID: <J2q17.427820$eK2.86548710@news4.rdc1.on.home.com> Greetings. This has probably been dealt with, but I didn't see it in the python faq, so I'm asking. In Python, previously unused lvalues cause that variable to be dynamically declared. x = 1 # if x did not previously exist, following the LGB rule, it is # declared dynamically here Now, while this is great for scripting, it can cause major headaches with large programs if you're a bad typist. It can declare new variables accidentally, when you wanted to assign to an existing one... myvar = 5 . . myver = othervar ...so here my typo of myver instead of myvar dynamically creates myver instead of assigning othervar to myvar. It can also accidentally obscure globals. So, while the simple answer would be, "don't do that", we all know that accidents happen. So, I was wondering if there is a way to force declarations of variables to catch this kind of thing. Is there, or is there anything in the works, to assign with very large programs? Thanks for your time, Mike -- Michael P. Soulier <msoulier at storm.ca> "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 philh at comuno.freeserve.co.uk Fri Jul 13 18:53:26 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Fri, 13 Jul 2001 23:53:26 +0100 Subject: license suggestions? References: <mailman.994825097.24532.python-list@python.org> <3B4D0045.EBCDA083@cosc.canterbury.ac.nz> <wzzoa8lhu7.fsf@sunshine.cs.uu.nl> Message-ID: <slrn9kuuv6.vde.philh@comuno.freeserve.co.uk> On 13 Jul 2001 22:00:48 +0200, Piet van Oostrum <piet at cs.uu.nl> wrote: > >They also accuse it to be more viral than it is in reality. They seem to >suggest that e.g. code compiled with gcc also has to be GPL'ed. This is what is know in technical terminology as a "lie". -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From chris.gonnerman at newcenturycomputers.net Wed Jul 11 08:20:50 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Wed, 11 Jul 2001 07:20:50 -0500 Subject: Apache, CGI, Python... References: <3B45051300120CE9@mail.san.yahoo.com> (added by postmaster@mail.san.yahoo.com) Message-ID: <006101c10a03$f1006880$0101010a@local> ----- Original Message ----- From: "Vincent A. Primavera" <vincent_a_primavera at netzero.net> > Hello, Hi. > Looking for some guidance as to the set up of Apache's httpd.conf for > some basic CGI scripting practice in Python... Any suggestions? The "out of the box" configuration of Apache on Unix/Linux/BSD works fine for me. Python is no different than any other CGI scripting language with respect to Apache. Check the docs/FAQ at apache.org for CGI guidance. Of course, if you have a more specific question feel free to ask. > Thank you, > Vincent A. Primavera You're welcome. From macias at bp.com.pl Tue Jul 3 08:36:44 2001 From: macias at bp.com.pl (Maciej Pilichowski) Date: Tue, 03 Jul 2001 12:36:44 GMT Subject: PEP scepticism References: <mailman.993747643.21070.python-list@python.org> <9hfqb5$dsllb$3@ID-89274.news.dfncis.de> <3dhex01n1m.fsf@ute.cnri.reston.va.us> <roy-900E5D.10061401072001@news1.panix.com> Message-ID: <3b43b9df.25087634@news.tpi.pl> On Sun, 01 Jul 2001 10:06:14 -0400, Roy Smith <roy at panix.com> wrote: >Having now used python for about 4 years, I still think >indentation-for-grouping was a dumb idea. The problem is that it is just >too easy to add or delete whitespace by accident (and without noticing), >especially when cutting and pasting hunks of code from one place to >another. In languages like Pascal and C I indent all my code to get clear look. And I don't remember if I make mistake putting one less or one more space in all those years. Besides: for i:=1 to 10 do begin mytab.first; while not mytab.eof do begin sum:=sum+mytabfee.ascurrency; ... It sure will compile but is it an advantage? You have to correct this mess anyway -- the only thing which is useless here is pairs of begin-end. And what's more -- pure indentation means full WYSIWYG. In such cases if x==y: if q==w: print x else: print y you don't have to remember rules of if-else joining. You _see_ it and that's enough. Recently I was really seriously mislead by omitting ";" in my Pascal code in last line of "case" but just before "else". This type of mistakes are not possible in Python /thank you Guido van Rossum :-))/. have a nice day bye -- Maciej "MACiAS" Pilichowski http://www.torun.pdi.net/~macias/ z a k u p i e : pisma Komputer: 3/86,4/87 From skip at pobox.com Tue Jul 31 10:21:40 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 31 Jul 2001 09:21:40 -0500 Subject: 2.2 features In-Reply-To: <cpae1lzio7.fsf@cj20424-a.reston1.va.home.com> References: <mailman.996258542.15795.python-list@python.org> <cpwv4u16rx.fsf@cj20424-a.reston1.va.home.com> <mailman.996270412.11895.python-list@python.org> <cpofq524lr.fsf@cj20424-a.reston1.va.home.com> <slrn9m61bs.atb.quinn@retch.ugcs.caltech.edu> <slrn.pl.9m6a5m.kmu.qrczak@qrnik.zagroda> <cpae1lzio7.fsf@cj20424-a.reston1.va.home.com> Message-ID: <15206.48884.18637.676324@beluga.mojam.com> Guido> I love it. 'x in type' as a shorthand for isinstance(x, type). Guido> Checked into CVS! How about 'x in type' as a shorthand for 'issubclass(x, type)' if x is a type or class instead of an instance? Skip From emile at fenx.com Tue Jul 3 12:51:51 2001 From: emile at fenx.com (Emile van Sebille) Date: Tue, 3 Jul 2001 09:51:51 -0700 Subject: MS "bans" GPL References: <7iq1ktcmslo24kbr8qvob2g3hpgleuf025@4ax.com> <9hshbp$oqv$2@216.39.170.247> <slrn9k3ji4.49l.gerhard.nospam@lilith.hqd-internal> <9hst9p$oqv$5@216.39.170.247> Message-ID: <9hstef$g1hef$1@ID-11957.news.dfncis.de> "David LeBlanc" <whisper at oz.nospamnet> wrote in message news:9hst9p$oqv$5 at 216.39.170.247... > In article <slrn9k3ji4.49l.gerhard.nospam at lilith.hqd-internal>, > gerhard.nospam at bigfoot.de says... <snip> > the part about XP being evil where and are my supposition and opinion did you mean to say "...evilware..." ;-) -- Emile van Sebille emile at fenx.com --------- From zen-nos at pam-heavengames.com Thu Jul 26 15:26:32 2001 From: zen-nos at pam-heavengames.com (Zen) Date: Thu, 26 Jul 2001 19:26:32 GMT Subject: Python 2.1 _sockets error Message-ID: <u9r0mtkbja3hbichui2ki1vqniqd0051b0@4ax.com> I'm trying to upgrade to Zope 2.4.0 on my server, and upgrading Python from 1.5.2 was required for that to work. When I start Zope, I get this error: Traceback (most recent call last): File "/usr/www/heavenga/Zope-2.4.0-src/z2.py", line 540, in ? import ZServer File "/usr/www/heavenga/Zope-2.4.0-src/ZServer/__init__.py", line 87, in ? from medusa.test import max_sockets File "/usr/www/heavenga/Zope-2.4.0-src/ZServer/medusa/test/max_sockets.py", line 2, in ? import socket File "/usr/local/lib/python2.1/socket.py", line 41, in ? from _socket import * ImportError: /usr/local/lib/libcrypto.so.1: Undefined symbol "ERR_load_RSAREF_strings" Then I went into python's interactive mode, and typed in "import socket", and got the same thing: Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/local/lib/python2.1/socket.py", line 41, in ? from _socket import * ImportError: /usr/local/lib/libcrypto.so.1: Undefined symbol "ERR_load_RSAREF_strings" The system is running FreeBSD 3.4, and the installed version is Python 2.1. This happened with the install from the ports collection, as well as installing from the source package with the basic configure. Anyhelp is appreciated... thanks in advance! -Zen (remove -no at spam- from email) From bokr at accessone.com Fri Jul 27 05:11:52 2001 From: bokr at accessone.com (Bengt Richter) Date: Fri, 27 Jul 2001 09:11:52 GMT Subject: Toppling the numeric tower References: <DLW77.49367$Cy.6275542@news1.rdc1.az.home.com> <cpzo9r5qty.fsf@cj20424-a.reston1.va.home.com> Message-ID: <3b612f52.538503356@wa.news.verio.net> On Thu, 26 Jul 2001 21:21:55 GMT, Guido van Rossum <guido at python.org> wrote: >"Tim Hochberg" <tim.hochberg at ieee.org> writes: > >> For discussion purposes, I'm going to assume that some forms of PEP 237, 238 >> and 239 are eventually adopted. In that case, integers and longs will be >> unified. The integers can then be completely emebedded into rationals. This >> leaves us with just one level of precision/range for exact numbers (infinite >> more or less) and one level of precision/range for inexact numbers (C >> double). This allows the numeric tower to be knocked down and stirred around >> to form a box: >> >> Real Complex >> | | >> rRational cRational -- Rational (Exact) >> rFloat cFloat -- Float (Inexact) > >I just don't see much use for complex rational... So then we're back >to my original tower (with rational). > For a different slant on diagramming all this, please see my post "Number Tree (was: Re proposed language change ...(was: ...))" From ehagemann at home.com Sat Jul 7 08:24:40 2001 From: ehagemann at home.com (Eric Hagemann) Date: Sat, 07 Jul 2001 12:24:40 GMT Subject: lvalues and the lgb rule References: <mailman.994457412.4660.python-list@python.org> <8Gt17.7112$PF2.1324057@news1.rdc1.md.home.com> <mailman.994498754.15402.python-list@python.org> Message-ID: <ccD17.7613$PF2.1683637@news1.rdc1.md.home.com> Ok I think I might have this -- let me state it another way When the compiler compiles a codeblock it makes a list of all variables in the code block. At the top of the code block these variables have NULL (or similar) reference because they have yet to to be pointed to an object. If I try to access these I get an "UnboundLocalError". As the assignment occurs then the compiler fills in the references (points the variables to the objects) and all is well At the highest level (outside of a function) the name does not exist since it is only entered into the global name space, a dictionary, when it is found -- Is this since the compiler does not look at the entire "global" or "outer" code block before execution -- it just handles the code line by line ? Cheers "Thomas Wouters" <thomas at xs4all.net> wrote in message news:mailman.994498754.15402.python-list at python.org... > On Sat, Jul 07, 2001 at 01:33:56AM +0000, Eric Hagemann wrote: > > > > Not dynamic. Just look at the code in an editor: if a name is bound > > > anywhere within a code block, and isn't declared in a "global" stmt, then > > > that name is local throughout the entire code block. > > > Is this true ? > > Yes. > > > Given a file with the following > > > print x > > x=1 > > print x > > > The first print will fail with a 'NameError'. It was my (perhaps) wrong > > impression > > that x "came into being" at the assignment (x=1) > > Yes and no. If you execute the above snippet at the top level (not inside a > function) you'll get a NameError because the name doesn't exist yet. This is > because you are evaluating in the 'global' namespace, and it is handled > slightly differently from the local namespace inside a function. If you > write the above as part of a function, say, > > def spam(): > print x > x = 1 > print x > > spam() > > You'll also get a NameError under 1.5.2, but a more appropriate > UnboundLocalError in newer versions of Python. The reason of the error is > the same in both cases, but the exact exception raised was changed to make > the difference between the first example and the second more obvious. > (UnboundLocalError is a subclass of NameError, so catching NameError will > still work for both cases.) > > > I would think the variable is local to the code block once the assignement > > has been executed > > No, it's local once the compiler sees an assignment statement for the > variable inside the code block. But because the global (module) namespace is > a global one as well as a local one, it behaves slightly differently there. > What happens is that the global namespace is a straight dictionary, where > assignment is a 'setitem', lookup is a 'getitem', and 'del' is a 'delitem'. > > The local namespace inside a function is actually stored (in absence of > 'exec' or 'import *') as a vector (list) and the names of all local > variables are translated into indexes. At runtime the interpreter will try > to retrieve the X'th element of the vector and notice it's empty (a NULL > value), raising the UnboundLocalError. A 'del' statement also empties the > element. > > Just look at the LOAD_FAST opcode in Python/ceval.c in the source > distribution :) > > -- > Thomas Wouters <thomas at xs4all.net> > > Hi! I'm a .signature virus! copy me into your .signature file to help me spread! > From skip at pobox.com Mon Jul 23 15:20:14 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 23 Jul 2001 14:20:14 -0500 Subject: Future division patch available (PEP 238) In-Reply-To: <ij7oltslop050daaj5amiqvepigolbn0kf@4ax.com> References: <GNZwEiAJepW7Ew0F@jessikat.fsnet.co.uk> <mailman.995776716.24336.python-list@python.org> <mailman.995825018.9832.python-list@python.org> <9jfjd6$ad4$2@newshost.accu.uu.nl> <7u6nltoqdnqjjdiquu6ngtaruflhvbvdl5@4ax.com> <j4g0bof3jv.fsf@informatik.hu-berlin.de> <p8unltsi5qda8rpdavja4iemj6r1s2ak4a@4ax.com> <j48zhfgbny.fsf@informatik.hu-berlin.de> <ij7oltslop050daaj5amiqvepigolbn0kf@4ax.com> Message-ID: <15196.30958.558869.492693@beluga.mojam.com> Steve> This isn't going to be a little problem. It's going to happen in Steve> a lot of scripts - many of which are used in environments where Steve> no-one is going the warning - and I don't know how many scripts I Steve> wrote, or who has copies of them, or who has personally modified Steve> versions or anything much that would allow me to sort the problem Steve> out in advance. I think many of the warnings generated for integer division will just wind up in Apache log files where nobody will see them. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From jm7potter at hotmail.com Wed Jul 11 09:59:08 2001 From: jm7potter at hotmail.com (Joe Potter) Date: Wed, 11 Jul 2001 09:59:08 -0400 Subject: Newbie asks(2): How to do this line of C in Py? References: <tkmfvla7npuqfd@news.supernews.com> <uzoaci9zw.fsf@ctwd0143.fitlinxx.com> <7s9oktcv5vll2hberldlt51mcdg5qnitke@4ax.com> <3B4C5274.2220577C@engcorp.com> Message-ID: <n2moktssh2n9vpvr6bmrmvga1p2dr87mon@4ax.com> On Wed, 11 Jul 2001 09:19:48 -0400, Peter Hansen <peter at engcorp.com> wrote: >Joe Potter wrote: >> >> On 10 Jul 2001 20:29:23 -0400, David Bolen <db3l at fitlinxx.com> wrote: >> <snip> >> As a newbie to Python, I find that the one liners in c are easy to follow and the >> translation into Python show me where I am missing Python techniques. >> >> My purpose in writing this is simply to say you are not just helping Mr. Wong when >> you respond. > >Good point, Joe. My slightly boorish response failed to consider that fact. > I sorta figured you might have forgot that a lot of newbies lurk here. (I wonder how many) > >On the other hand, posting obscure one-liners from C is not necessarily >the best way to learn much, if anything about Python. Context is always >useful, and the response might be different if more of the original >C code were made available. I think this is similar to an attempt >to translate from one spoken language into another, one word at a time, >which looks like it works for a while but doesn't withstand serious >scrutiny. > I have bought 5 books on Python in the last three weeks, and 2 on MySQL. I have a working program now which uses Tkinter/Python/Gadfly. I had to pick up gui programming and learn SQL to do the program the way I wanted. The folks here have been wonderful --- make that damn wonderful --- in providing help. So, it is not as if I am trying to learn Python with just his one-liners. However, it has been great fun to see if I could do the little one-liners in Python before I read what the crowd suggests. Sorta like problems in a math text with answers in the back. >(As it stands, Steve kindly wrote to me off-line and mentioned he was >attempting to port GnuGo from C to Python as a learning exercise. If >we want "context" we can always go look at the source ourselves. :-) > >Joe (and other self-professed newbies), why don't you find some other >interesting one-liners (or two, or three-liners) and post them here? > I will try to do so as soon as I get the MySQL module working so I can port my little program out of Gadfly and into MySQL. > >Maybe the code base for GnuGo is not one of the best sources of example >code for conversion to Python... Based on a sample size of three, >it consists of 33% strtok() calls and 67% sscanf() calls, making it >one of the all-time poorest C programs! ;-) One of the worst perhaps, but I am positive that I wrote the very worst one in 1986 while modeling population growth for a math grad class. Also, I think I recall that extrapolation from a small data set can lead to erroneous conclusions. :-) Warmest Regards, Joe From thomas at xs4all.net Tue Jul 10 08:21:47 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 10 Jul 2001 14:21:47 +0200 Subject: os.nice (or docs) BUG? In-Reply-To: <87g0c5oybk.fsf@litterbox.meowing.net> References: <mailman.994755195.13246.python-list@python.org> <87g0c5oybk.fsf@litterbox.meowing.net> Message-ID: <20010710142147.Y8098@xs4all.nl> On Tue, Jul 10, 2001 at 06:47:27AM -0400, Inconsistent Meowbot wrote: > So, it looks like the One and Only Real True Way to call nice() is to > set errno to 0, raise an exception only if errno is set after the call > completes, and not to trust the return value to actually mean anything > unless you know what platform you're on and what its nice returns. This is why we have Python. We'll emulate the standard behaviour even on Linux, using getpriority() when necessary, and converting -1-error-values to exceptions, solving that problem nicely, too. See SF patch #439995: http://sourceforge.net/tracker/?func=detail&aid=439995&group_id=5470&atid=305470 -- Thomas Wouters <thomas at xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From quinn at yak.ugcs.caltech.edu Sun Jul 8 18:47:23 2001 From: quinn at yak.ugcs.caltech.edu (Quinn Dunkan) Date: 8 Jul 2001 22:47:23 GMT Subject: "has" Operator References: <Pine.LNX.4.30.0107080115240.17775-100000@rnd.onego.ru> <mailman.994543873.6493.python-list@python.org> <tkfa751vldoo66@news.supernews.com> <cpelrriogf.fsf@cj20424-a.reston1.va.home.com> Message-ID: <slrn9khonr.gg0.quinn@yak.ugcs.caltech.edu> On Sun, 08 Jul 2001 12:43:13 GMT, Guido van Rossum <guido at python.org> wrote: >Actually, Paul's proposal to write > > x has y > >instead of > > hasattr(x, 'y') > >has a nice Pythonic ring to it, and the fact that you have to use >quotes with hasattr() has always bothered me. Too bad I didn't think >of this 10 years ago; right now, I'd say it's too little value for too >much disturbance (a new keyword). Actually, I think there's a nice symmetry to hasattr taking strings. It is to objects what has_key is to dicts, though it's more important because dicts are naturally keyed with strings while objects are naturally keyed with identifiers. Now, the spelling I don't quite like. We should have either haskey and hasattr, or has_key and has_attr. I prefer the latter, but it's too late now in any case. 'x has y' would also have a nice resemblance to 'x in y', where one checks if y is in the object itself, and the other checks if y is in the container the object represents. I don't want the former functionality often enough to think a keyword is worth it, though. From Matthew.Alton at anheuser-busch.com Fri Jul 13 13:24:33 2001 From: Matthew.Alton at anheuser-busch.com (Alton, Matthew) Date: Fri, 13 Jul 2001 12:24:33 -0500 Subject: Newbie list question Message-ID: <DDF5392E0FB3D41196C10008C7D9AE5D013C438B@STLABCEXG022> Thank you Mikael! This explanation is concise and enlightening. I drew up one of my pointer diagrams (inspired by Feynman Diagrams) based on your explanation and the little light bulb came on. Intriguing language, Python. Just fascinating. I'm having fun! -----Original Message----- From: Mikael Olofsson [mailto:mikael at isy.liu.se] Sent: Friday, July 13, 2001 12:14 PM To: Matthew.Alton at Anheuser-Busch.COM Cc: python-list at python.org Subject: RE: Newbie list question Hi Matthew! Welcome to the world of Python. On 13-Jul-2001 Matthew Alton wrote: > I am a UNIX/C programmer w/15y experience. Forgive me if my neural > pathways are all about following pointers. The adjustment to > Python-think is bumpy but I'll get by with a little help from my > friends, eh? Before we start; everything is a pointer in Python. > Here's the crux of the biscuit: > > >>> foo = ['a', 'b', 'c'] # We have a list named 'foo.' Excellent. Actually, we have a pointer foo pointing to a list of pointers to the strings 'a', 'b', and 'c'. > >>> bar = foo # bar points to foo. Or does it? We copy the pointer foo. So bar now points to the same list as foo. > >>> baz = foo[:] # baz is a copy of foo. baz points to a copy of the list. However, that list still points to the same strings... The pointer stuff explains the following. > >>> foo > ['a', 'b', 'c'] > >>> bar > ['a', 'b', 'c'] > >>> baz > ['a', 'b', 'c'] # So far, so good. > >>> del foo[2] # Get rid of 'c' in foo and, therefore in > bar (?) > >>> foo > ['a', 'b'] # 'c' is gone from foo... > >>> bar > ['a', 'b'] # ... and also from bar, as expected. > >>> baz > ['a', 'b', 'c'] # baz, the copy, is unaffected. Also as > expected. But now things happen: > >>> foo = foo + ['c'] # Add 'c' back to foo. The RHS creates a new list containing pointers to strings 'a', 'b', and 'c'. The LHS binds foo to this new list, i.e. foo now points to the new list. You have not done anything to bar. > >>> foo > ['a', 'b', 'c'] # 'c' is back. Good. > >>> bar > ['a', 'b'] # ??? What the... ??? Where is 'c'? > >>> baz > ['a', 'b', 'c'] # baz still unaffected, of course. > >>> I suggest that you go through your code again and try id(foo), id(bar), and id(baz) here and there. The function id(pointer) returns an integer, basically the address of pointer. All this is documented behaviour. However, I do not have the time to find it for you right now. I'm sorry. Good luck /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson <mikael at isy.liu.se> WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 13-Jul-2001 Time: 18:59:45 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From dsavitsk at e-coli.net Fri Jul 13 22:40:31 2001 From: dsavitsk at e-coli.net (douglas savitsky) Date: Sat, 14 Jul 2001 02:40:31 GMT Subject: VB client, Python server: NULL result ... References: <q5J37.19922$uJ3.727435@e420r-atl2.usenetserver.com> Message-ID: <ziO37.35492$C81.2894779@bgtnsc04-news.ops.worldnet.att.net> have you tried registering with the --debug argument? i had similar troubles, and i found that sometimes i have to restart both pythonwin and vb to clear the memory. doug "Steve Holden" <sholden at holdenweb.com> wrote in message news:q5J37.19922$uJ3.727435 at e420r-atl2.usenetserver.com... > On three separate systems I am experiencing the same problem trying to > create an Python COM object from VB. The VB satetement > > Set obj = CreateObject("Python.Dictionary") > > (or any other Python COM object) gives the dreaded error 80004005, with the > message: > > Unexpected Python Error: exceptions.SystemError: NULL result without > error in call_object > > No problem creating "Python.Interpreter", (not, of course, written in > Python) for example. So it doesn't appear to be a VB client problem. > > A Python client can do what I'm trying to do in VB, using Dispatch, so the > COM object registration is at least half right (I'm using UseCommandLIne() > to register and de-register). > > Seems I must have overlooked something dead obvious, so I'm hoping the > collective wisdom of c.l.py will quickly tell me what. Couldn't find > anything on ActiveState's site. > > regards > Steve > -- > http://www.holdenweb.com/ > > > > > > From rnd at onego.ru Sun Jul 1 05:49:38 2001 From: rnd at onego.ru (Roman Suzi) Date: Sun, 1 Jul 2001 13:49:38 +0400 (MSD) Subject: Discussions and developing In-Reply-To: <DCB%6.382672$eK2.78065159@news4.rdc1.on.home.com> Message-ID: <Pine.LNX.4.30.0107011339370.22883-100000@rnd.onego.ru> On Sun, 1 Jul 2001, Nick Perkins wrote: >The newsgroup is a bit like an evolving ecosystem. A certain balance is >achieved by the fact that really dumb questions generate fewer and shorter >responses, while really interesting ones generate more and longer responses. >In turn, the level of response may influence whether (and how often) similar >questions are asked in the future. Certainly. I do not complain about newbies questions. I just see like lot of energy is spent in discussions which go round and round, like discussion about a += 1. It's like a positional war and is very boring... I think maillist is not right technology for this kind of discussions. Maybe Wiki is more appropriate and productive: no need to quote, counter-arguments could be put right after arguments without need to look thru quotings or lots of earlier posts. Also less typing ;-) Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Sunday, July 01, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "DEVICE=EXXON.SYS may mess up your environment" _/ From alavoor at yahoo.com Tue Jul 17 22:45:10 2001 From: alavoor at yahoo.com (alavoor) Date: Wed, 18 Jul 2001 02:45:10 GMT Subject: All computers in the world MUST sync with ATOMIC clock before 12:00 AM 21 July 2001!!! Message-ID: <3B54F839.AC6C11C3@yahoo.com> All computers in the world MUST sync with ATOMIC clock before 12:00 AM 21 July 2001!!! hello: You must sync your PC's date and time with Cesium Atomic clock. Use this very small and tiny program written in PHP. Do you know that Cesium Atomic clock located in Boulder, Colarado, USA is the world's most accurate clock!! It does not lose or gain one second even after running for 25 MILLION YEARS!!! This clock is the official time USA and for the world. There are also similar Atomic clocks in France, UK, Germany and Japan. This program runs on MS Windows 95/98/NT/2000/XP/ME and MS Windows 3.11. This program also runs on all flavors of Unix and Linux and Apple Mac. Please download the program from: http://phpclasses.upperdesign.com/browse.html/package/285 From ngps at madcap.dyndns.org Fri Jul 27 11:27:18 2001 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 27 Jul 2001 15:27:18 GMT Subject: Distributed computing using SOAP. What about speed ? References: <LBA77.58$bXi.175168000@news.telia.no> <48F88F43C9842AD9.1E631B0D03856868.6FDBB21E772A6CB3@lp.airnews.net> Message-ID: <9js18m$n54$1@clematis.singnet.com.sg> According to Cameron Laird <claird at starbase.neosoft.com>: > On the other hand, lots of people are using SOAP, > it'll get better, and, if performance annoys enough > capable people, someone will invent a reworked > transport layer that solves these problems. There's BEEP, formerly known as BXXP. RFC 3080 and 3081, I think. A new Internet-draft talks about running SOAP over BEEP. See www.beepcore.org. (Python implementation seems to have fallen behind.) -- Ng Pheng Siong <ngps at post1.com> * http://www.post1.com/home/ngps Quidquid latine dictum sit, altum viditur. From stupot999 at hotmail.com Sun Jul 29 22:53:22 2001 From: stupot999 at hotmail.com (Soup-a-Stu) Date: Mon, 30 Jul 2001 03:53:22 +0100 Subject: I want to do something: References: <jYy87.177$vM1.2880@e3500-atl1.usenetserver.com> <Xns90ECAC6078D75cliechtimailsch@62.2.32.50> Message-ID: <u0497.7910$ip4.2331123@news2-win.server.ntlworld.com> i get given a new IP every single connection, vecause i have free internet i get disconnected every single 2 hours so in my case some hours would be bad, every 10-15 minutes would be alright... possibly every 5. "chris liechti" <cliechti at mails.ch> wrote in message news:Xns90ECAC6078D75cliechtimailsch at 62.2.32.50... > [posted and mailed] > > "Jeremy Moles" <xione at bellsouth.net> wrote in > news:jYy87.177$vM1.2880 at e3500-atl1.usenetserver.com: > > Basically, what this code does is get my IP address and upload it to my > > webserver - since my IP is dynamic, and I never quite know what it is > > when I leave this house. > > > > But anyways - how can I do this - say - every minute or so? Could I: > > > > import time > > > > while(time.time()%60==0): > > do_my_function() > > > this will not do what you want.. surround the modulo expression with > int(...) otherwise it chances are small that it will be zero (the > probability for the milliseconds beeing exacly zero are 1/1000 and % with > floats returns a float reminder). also this while loop would exit when it > sould do the function call but call it in a loop when you want to wait (and > does this with 100% CPU load)... > > i would do it with sleep: > ------- > import time > > while 1: > do_my_function() #upload file > time.sleep(600) #wait ten minits > ------- > i also think that ten minits or some hours are enough. usually the IP is > valid for some longer time. i now get the same IP assigned (DHCP) for over > one month and i switch off the pc every night. > > chris <cliechti at mails.ch> > From saabdaniel at yahoo.se Mon Jul 9 05:35:21 2001 From: saabdaniel at yahoo.se (Daniel Larsson) Date: 9 Jul 2001 02:35:21 -0700 Subject: How to include e.g. module variables in Happydoc generated files? Message-ID: <d6b13572.0107090135.41f66c2b@posting.google.com> Hi! I'm using Happydoc to document a package. It's a very nice tool, but my problem is that it only includes doc strings and comments in the documentation. Is there a way to make it include e.g. variable names in the documentation for a file? I'm using a file that only contains "constant" declarations on the form CONSTANT_NAME = 999.9 and since these constants are used in the calls to functions in the other package files, it would be nice for future users to be able to see the available constant names in the module documentation for the constant file. I don't want to use e.g. Pydoc or PythonDoc since I can't import all modules refered to in my package. I also don't want to add a text comment for each "constant". Thank you in advance, Daniel Larsson From peter at engcorp.com Fri Jul 13 23:44:45 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 13 Jul 2001 23:44:45 -0400 Subject: Javascript + Python... References: <mailman.995037983.15466.python-list@python.org> Message-ID: <3B4FC02D.C2373022@engcorp.com> "Vincent A. Primavera" wrote: > > Hello, > Does anyone know if there are ways to have JavaScript(client side...) > "communicate" with Python(server side...) via variables(environmental?) > etc...? Things that are unclear in your posting: 1. Your environment (are you limiting this to Windows machines? particular versions of Javascript?) 2. What "communicate" means. Even you seem unsure... 3. Why you want to use "variables" instead of, say, sockets or something else. 4. What environmental (sic) variables have to do with this. *Environment* variables are unrelated to network communications. 5. What you are actually trying to accomplish. Providing some context with questions like this is the most helpful way to get useful responses, instead of borderline rude ones like this. :-) By the way, one possibly I've seen used was MSXML3's special "load" function to retrieve from a Python server data formatted as XML. This only works with IE 5.0 or later with the MSXML3 parser installed and in any case I'm fairly sure from the way you asked the question that this solution is not readily available to you... -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From eppstein at ics.uci.edu Wed Jul 25 12:01:36 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Wed, 25 Jul 2001 09:01:36 -0700 Subject: PEP0238 lament References: <5sdnlt072hm6hp17nluu6f0fqq4bvr6mj8@4ax.com> <mailman.995873261.11975.python-list@python.org> <916olt0p3kciv0evmotdg6jev9bl29l57i@4ax.com> <Xns90E77C7A1776Cjimpublishingresourc@207.126.101.100> <3B5C52EA.9430255E@alcyone.com> <cpofqaova7.fsf@cj20424-a.reston1.va.home.com> <Xns90E99AC16C87Bduncanrcpcouk@127.0.0.1> <cpzo9t80l7.fsf@cj20424-a.reston1.va.home.com> Message-ID: <eppstein-FD4197.09013625072001@news.service.uci.edu> In article <cpzo9t80l7.fsf at cj20424-a.reston1.va.home.com>, Guido van Rossum <guido at python.org> wrote: > In a farther future, when PEP 228 is fully implemented, Python may > only have *one* (built-in) numeric type, "number". Uh oh, if this is a later change than 238, does this mean we have to wait until Python 4.0 for the grand unification? -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From guido at python.org Tue Jul 31 03:01:43 2001 From: guido at python.org (Guido van Rossum) Date: Tue, 31 Jul 2001 07:01:43 GMT Subject: 2.2 features References: <mailman.996258542.15795.python-list@python.org> <cpwv4u16rx.fsf@cj20424-a.reston1.va.home.com> <mailman.996270412.11895.python-list@python.org> <cpofq524lr.fsf@cj20424-a.reston1.va.home.com> <slrn9m61bs.atb.quinn@retch.ugcs.caltech.edu> <slrn.pl.9m6a5m.kmu.qrczak@qrnik.zagroda> Message-ID: <cpae1lzio7.fsf@cj20424-a.reston1.va.home.com> Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl> writes: > If you forget about 'isinstance' then everything is ok, right? > 'in' performs some membership test whose details depend on the second > argument. It should not be more confusing that '+' being either addition > of numbers and concatenation of sequences. We don't expect "a"-(-"b") > to be equivalent to "a"+"b" just because 3-(-4) is equivalent to 3+4. > > Now thow in 'isinstance' as an old way to spell a specific membership > test (for types and classes) which doesn't have to be learned about > at all. I love it. 'x in type' as a shorthand for isinstance(x, type). Checked into CVS! > > Or you could just say that type objects implement a __contains__ > > method that does an isinstance. But if classes and types are unified, > > that would get in the way of classes that define __contains__. > > It indeed shows a flaw in unifying "attributes of instances which > are defined by their classes" with "attributes of class objects > themselves". > > For example many objects are hashed by what o.__hash__() returns, > but not type objects, because their __hash__ is something completely > different (it expects an argument and hashes it instead of the > receiver). Similarly for most magic methods. > > It more or less works because intersection of proper attributes of > type objects and attributes which are always polymorphically extracted > using names (and not slots in the representation of type objects) > happens to be empty. > > This is so hardwired into Python and pushed by type/class unification > that I don't believe it can be avoided without redesigning the language > from scratch. > > This particular case of __contains__ is not different than e.g. > __hash__ or __str__. You can't redefine in Python how your class object > (or type object in Python-2.2) will be hashed or printed, you won't > be able to override the membership test either (and you can't now > AFAIK) - unless something solves the generic problem of putting class > attributes and static instance attributes in one namespace. Good analysis of this particular problem, and indeed I've given up on fixing it. --Guido van Rossum (home page: http://www.python.org/~guido/) From michael.g.abbott at ntlworld.com Tue Jul 24 12:37:49 2001 From: michael.g.abbott at ntlworld.com (Michael Abbott) Date: Tue, 24 Jul 2001 16:37:49 GMT Subject: PEP0238 lament References: <3B5B3676.40F39389@alcyone.com> <eppstein-03540D.13070222072001@news.service.uci.edu> <mailman.995836120.7223.python-list@python.org> <vyIKbWAP62W7EwC+@jessikat.fsnet.co.uk> <9jg6ei$ges7$1@sky.inp.nsk.su> <23891c90.0107230118.752e3f00@posting.google.com> <u3tnlt0480u7o655p988bsr9p3vc1g14ee@4ax.com> <slrn9lp1ui.vp.Gareth.McCaughan@g.local> <bl7pltkl8bv0eecsfcr90v45hh0aek72u7@4ax.com> <m2puaqh6t2.fsf@mycroft.actrix.gen.nz> Message-ID: <Xns90E8B2C2EF3FBmichaelrcpcouk@194.168.222.8> Paul Foley <see at below> wrote in news:m2puaqh6t2.fsf at mycroft.actrix.gen.nz: > On Mon, 23 Jul 2001 23:23:34 +0100, Stephen Horne wrote: >> As the saying goes, Lotsof-Infuriatingly-Stupid-Parentheses. > > Lisp doesn't have any parentheses. You must be thinking of Scheme. Huh? (defun list-reverse (list) (do ((x list (cdr x)) (y '() (cons (car x) y))) ((endp x) y))) (Steele, "Common Lisp, The Language") Looks like lots of parentheses to me. From guido at python.org Sun Jul 22 12:22:54 2001 From: guido at python.org (Guido van Rossum) Date: Sun, 22 Jul 2001 16:22:54 GMT Subject: PEP0238 lament References: <mailman.995814276.15005.python-list@python.org> Message-ID: <cp66clexxt.fsf@cj20424-a.reston1.va.home.com> Arthur Siegel and I seem to be pushing each other's buttons constantly. I don't know why it is, but ever post of his feels like a flame or flamebait to me. I always feel that he attacks me as a person rather than attacking my arguments (usually because he claims that I haven't given any arguments). Try as I may, this makes it very hard, almost impossible for me to respond in a meaningful manner to Arthur's posts. I wonder what I've done to tick him off. I also wonder how come he is so good at ticking me off. The reason for wanting / to return a float (or at least a type that can represent close approximations of numbers like 0.75) has been discussed many times before. The summary of the argument in the PEP may not be complete, but I disagree with Arthur's assessment that integer division is not a problem -- the VPython folks have ample experience that it is. Because all Arthur does is tick me off, I'll leave it at this -- maybe someone else can explain it all to him. --Guido van Rossum (home page: http://www.python.org/~guido/) From rnd at onego.ru Tue Jul 3 01:00:25 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 3 Jul 2001 09:00:25 +0400 (MSD) Subject: Python and DB support (was: Re: Is Python Dead?) In-Reply-To: <9hqoe8019j5@enews4.newsguy.com> Message-ID: <Pine.LNX.4.30.0107030854220.15928-100000@rnd.onego.ru> On Mon, 2 Jul 2001, Alex Martelli wrote: >"Roman Suzi" <rnd at onego.ru> wrote in message >news:mailman.994100826.19440.python-list at python.org... >> It seems I start to understand database concerns of Mr. Wilson the second. >> >> Once we tried 3 databases (MySQL, PostgreSQL, Interbase) to suit our task. >> And for every database (we stopped at Interbase) there was Python support. >> >> However, my collegues were not satisfied with it. One somplain was that in >> ASP/IIS it is "very easy" to receive a "recordset" from database and then > >Internet Information Server (IIS) serves webpages, including Active >Server Pages (ASP), but neither has anything to do with database access. > >What you're using to access databases in such a setting is most likely >MSDAC (MicroSoft Data Access Controls, I believe) and specifically the >ADO (Active Data Objects, I believe) part thereof. So if that's what you >like, why not access it from Python? I happen to like it quite a bit too, >and as it happens Python + win32all makes it a snap to use it (on a >Win32 platform, only, of course -- but then, that's where IIS runs, too, >or has MS released it for OpenBSD lately?-). Yes, ADO is what I meant. With the recent object-orientation hype, Windows looks more attractive to developers than UNIX. Probably ADO adds to it. >> apply it in different situations in the ASP-page, because recordset is an >> object and even subqueries could be made without quering DB again. > >Yep, the recordset part of ADO is undoubtedly the most popular single >feature of it among us lazy programmers. You can even disconnect from >the DB and keep the recordset around, persist it to a file (maybe in XML), >depersist it later... it's fun!-) I have not tried Zope (it's overkill for our tasks) but I think Zope must have something similar. >> From this and also from my own experience with PostgeSQL queries from >> Python, I could say that DB support in Python exists, but need enhancement >> and standartization. Probably, higher level more or less common >> object-oriented interfaces could help this. > >It seems to me the (DB API 2) standard is fine (maybe a bit too >ambitious, so actual implementations may not have reached up >to it yet?-). > >> I must also say, that I myself am completely satisfied with Python DB >> support, but I do not use DB extentensively and routinely to judge. >> However, I think that including some more DB support, at least for open >> source databases like Postgresql and MySQL + ODBC/JDBC, could be a good >> idea and will give a standard. (Yes, I know about Python DB API). > >And? What's wrong with it? According to some individuals here it makes Python dead snake :-)))) >What support would you get from ODBC, >portably between Postgres & MySQL, that the relevant DB API modules >don't supply? Maybe we could supply an ADO-recordset-workalike on >top of any DB API compliant implementation, that might be handy at >times I guess. But hardly a make-or-break thing, no? >> Are there licensing problems or what stops from letting RDB support >> modules into standard library? > >Why would I want to have to download support for many databases >I don't use each and every time I download Python? It's bad enough >getting the Irix or Mac stuff as a part of my (e.g.) Windows d'load -- >why would I want Postgres and/or MySQL and/or Oracle and/or SQL >Server and/or (&c) if what I end up using is Interbase (as you did)? This is clever. Though ADO-like higher-level abstraction could be useful. >If I had a vote, I'd rather seen _Gadfly_ tuned up (out with regex >and regsub, in favour of re; minimal-tolerance support of stuff it >does not implement, such as NULLs) and made a part of Python. Yes, this could be cool. > It >might give a taste of SQL to SQL-unaware programmers and it would >provide a DB API implementation (usable like dumbdbm is as the >last-choice fallback for anydbm, if you see what I mean). But it sure >wouldn't be THE db of choice for demanding professional use -- go >see Oracle or SQL Server for that, or maybe Interbase, MySQL &c if >that's what rocks your boat. The DB scene seems just too fragmented >at this point in time to warrant including support for 10% of it in >the standard Python library, I think... >Alex Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Tuesday, July 03, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Paranoia is nothing to be afraid of!!" _/ From aahz at panix.com Sat Jul 7 18:24:06 2001 From: aahz at panix.com (Aahz Maruch) Date: 7 Jul 2001 15:24:06 -0700 Subject: Comment on PEP-0238 References: <mailman.994427714.26169.python-list@python.org> <3dd77drkea.fsf@ute.cnri.reston.va.us> <9i5guj$7kg$1@panix6.panix.com> <cphewokhez.fsf@cj20424-a.reston1.va.home.com> Message-ID: <9i8266$3s6$1@panix2.panix.com> In article <cphewokhez.fsf at cj20424-a.reston1.va.home.com>, Guido van Rossum <guido at python.org> wrote: >aahz at panix.com (Aahz Maruch) writes: >> >> I'm in agreement with Guido that at least two releases are necessary >> (I also agree that it could be two warning releases). But I think >> Guido's step 3 (if used) should be changed to the semantically equivalent >> >> In Python 2.4, integer division with the '/' operator raises an >> exception. This exception can be caught as usual, but the >> programmer should prepare for the next release of Python by either >> using the div() function or by using the future directive to get >> floating point division. > >Oh, Aazh! I wasn't writing a formal specification, I was sketching a >plan. In that context, using "make it an error" is the right level of >detail. Everybody can fill in for themselves that that means it's an >exception, since that's how we typically signal errors in Python. Given that the person who followed up to you didn't seem to quite get this, I figured it was a worthwhile clarification. <shrug> -- --- 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 So much Astroglide. So little time. From sh at ttsoftware.co.uk Mon Jul 23 07:21:58 2001 From: sh at ttsoftware.co.uk (Steve Horne) Date: Mon, 23 Jul 2001 12:21:58 +0100 Subject: PEP0238 lament References: <3B5B639C.FF5961E7@Lugoj.Com> <mailman.995848837.9325.python-list@python.org> Message-ID: <k61olt001jfs878bo50snpb9f2uu80utee@4ax.com> On Sun, 22 Jul 2001 20:39:43 -0400, "Tim Peters" <tim.one at home.com> wrote: >Your choice, but my guess is that Guido has done an excellent job of >maintaining backward compatibility so far (he burned me by changing >str(long) to stop producing a trailing "L", and I must have spent nearly 20 >minutes recovering from that -- BFD). Of course - so far. In 2.2, the biggest issue is the new 'yield' keyword, for instance - easy to fix, and not a problem for me because I have a naming convention where identifiers always contain at least one uppercase letter. Changing the behaviour of a fundamental arithmetic operator is going to ruin this record quite effectively, I think. Integers are much more used in scripting code than floats - subscripts and loop indices being the main culprits. Integer division happens quite a bit. All that code is just going to suddenly stop working. How nice. -- Steve Horne Home : steve at lurking.demon.co.uk Work : sh at ttsoftware.co.uk From guido at python.org Tue Jul 24 16:39:38 2001 From: guido at python.org (Guido van Rossum) Date: Tue, 24 Jul 2001 20:39:38 GMT Subject: 2.2 features References: <gER67.534750$eK2.111982758@news4.rdc1.on.home.com> <slrn.pl.9lo6uq.ss0.qrczak@qrnik.zagroda> <cpg0bmqfzs.fsf@cj20424-a.reston1.va.home.com> <slrn.pl.9lrln1.aq.qrczak@qrnik.zagroda> Message-ID: <cpwv4yoyd8.fsf@cj20424-a.reston1.va.home.com> [PEP 253] > >> Isn't this backwards incompatible? Won't it break existing code? It > >> would, if we changed the method resolution order for all classes. > >> However, in Python 2.2, the new lookup rule will only be applied to > >> types derived from built-in types, which is a new feature. Class > >> statements without a base class create "classic classes", and so do > >> class statements whose base classes are themselves classic classes. > >> For classic classes the classic lookup rule will be used. (To > >> experiment with the new lookup rule for classic classes, you will be > >> able to specify a different metaclass explicitly.) We'll also provide > >> a tool that analyzes a class hierarchy looking for methods that would > >> be affected by a change in method resolution order. > Tue, 24 Jul 2001 19:33:34 GMT, Guido van Rossum <guido at python.org> pisze: > > > There are many things that could be improved here. What exactly is > > bothering you about it? Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl> writes: > That a subtle difference in the program (deriving from a class which > inherits from a builtin type instead of using delegation) causes a > non-obvious subtle change in the behavior which doesn't seem related > to the source (method lookup order). This is a compromise between breaking backwards compatibility and doing the right thing. > If some consistent rule of method lookup order is going to eventually > win, no matter which, then I didn't say anything. But if such fuzzy > behaviors are going to stay, they feel almost as bad as would > "'/' rounds down if you used '%' in the program or towards 0 otherwise" > feel to me. Eventually the new MRO rule will be the default, but a metaclass that implements the old rule will be made available for code that requires backwards compatibility (until demand disappears). You can write "__metaclass__ = <some_class>" at the top of your module to choose the default metaclass. Fortunately this problem is much easier to detect at compile time than int division, so a tool that detects potential issues is not hard to write. I will definitely give this plenty of time (like I will with all incompatibilities I introduce). --Guido van Rossum (home page: http://www.python.org/~guido/) From thomas at xs4all.net Tue Jul 24 18:26:53 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Wed, 25 Jul 2001 00:26:53 +0200 Subject: 2.2 features In-Reply-To: <3B5DEFA2.FCE4B85B@hotmail.com> References: <gER67.534750$eK2.111982758@news4.rdc1.on.home.com> <slrn.pl.9lo6uq.ss0.qrczak@qrnik.zagroda> <cpg0bmqfzs.fsf@cj20424-a.reston1.va.home.com> <slrn.pl.9lrln1.aq.qrczak@qrnik.zagroda> <cpwv4yoyd8.fsf@cj20424-a.reston1.va.home.com> <3B5DEFA2.FCE4B85B@hotmail.com> Message-ID: <20010725002653.D21770@xs4all.nl> On Tue, Jul 24, 2001 at 09:58:56PM +0000, scott wrote: > P.S I hope they don't use Python in my Pension scripts... Why not ? If all goes well, by that time Python will have done int/int->float correctly for years, and you won't even end up with monthly payments of $0 :-) -- Thomas Wouters <thomas at xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From paulsid at home.com Sat Jul 7 16:57:49 2001 From: paulsid at home.com (Paul Sidorsky) Date: Sat, 07 Jul 2001 14:57:49 -0600 Subject: "has" Operator Message-ID: <3B4777CD.A6EBEA7F@home.com> I was thinking that Python might benefit from a "has" operator that would allow you to type something like this: if myobject has someattribute: foo() else: bar() This would be roughly equivalent to: try: uselessvar = myobject.someattribute execpt AttributeError: bar() # myobject does not have someattribute else: foo() # myobject has someattribute ...but (IMO) the operator version would be much nicer and more readable. (This idea came about when I actually tried to type in the former! Python's syntax is so clean that it seemed to be a natural extension.) The Inform interactive-fiction language provides "has" and "hasnt" operators that do something similar so this is not without precendent. But for Python, it admittedly may be nothing more than syntactic sugar. What does everyone else think? (Please forgive me if this has already been proposed/discussed before.) -- ====================================================================== Paul Sidorsky Calgary, Canada paulsid at home.com http://members.home.net/paulsid/ From kirill at xyz.donetsk.ua Fri Jul 27 17:47:41 2001 From: kirill at xyz.donetsk.ua (Kirill Simonov) Date: Sat, 28 Jul 2001 00:47:41 +0300 Subject: 2.2 features In-Reply-To: <cpwv4u16rx.fsf@cj20424-a.reston1.va.home.com>; from guido@python.org on Fri, Jul 27, 2001 at 08:01:04PM +0000 References: <mailman.996258542.15795.python-list@python.org> <cpwv4u16rx.fsf@cj20424-a.reston1.va.home.com> Message-ID: <20010728004741.A1138@xyz.donetsk.ua> On Fri, Jul 27, 2001 at 08:01:04PM +0000, Guido van Rossum wrote: > John Schmitt <jschmitt at vmlabs.com> writes: > > > Why do we have to wait for 2.2? You can do this already. > > > >>> import types > > >>> types.IntType > > <type 'int'> > > >>> assert isinstance(0,types.IntType) > > [me, earlier] > > > assert isinstance(num, int) > > > assert isinstance(msg, str) > > In 2.2 you don't have to import types. It would be nice to have 'in' operator for types: assert (num in int) assert (msg in str) Kirill. From BrianQ at ActiveState.com Tue Jul 3 20:33:11 2001 From: BrianQ at ActiveState.com (Brian Quinlan) Date: Tue, 3 Jul 2001 17:33:11 -0700 Subject: PyArg_Parse In-Reply-To: <slrn9k4ncv.f00.quinn@yak.ugcs.caltech.edu> Message-ID: <004f01c10420$e81f1420$b503a8c0@activestate.ca> > This is a bit of a silly question, but where is PyArg_Parse > documented? Does that function even exist? PyArg_ParseTuple is documented at http://www.python.org/doc/ext/parseTuple.html -- 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 bokr at accessone.com Sat Jul 7 17:15:25 2001 From: bokr at accessone.com (Bengt Richter) Date: Sat, 07 Jul 2001 21:15:25 GMT Subject: Comment on PEP-0238 References: <mailman.994427714.26169.python-list@python.org> <cpsngaja4g.fsf@cj20424-a.reston1.va.home.com> <FFv17.1178$Y6.656565@news1.rdc2.pa.home.com> <cpelrskgrr.fsf@cj20424-a.reston1.va.home.com> Message-ID: <3b476990.1307204851@wa.news.verio.net> On Sat, 07 Jul 2001 13:33:55 GMT, Guido van Rossum <guido at python.org> wrote: [...] >The "div" keyword would be ideal except for the added complexity of >adding a new keyword to the language -- do we need a separate warning >phase here, too? > >(Hm. For various reasons I'm very tempted to introduce 'yield' as a >new keyword without warnings or future statements in Python 2.2, so >maybe I should bite the bullet and add 'div' as well...) What about a 'special' keyword for special semantic scoping, to control meanings within a block, e.g., special use_integer_defaults: x = 1/2 # makes zero because of special scope special use_rationals, use_auto_bignums: x = 1/2 # makes rational in pref to float x <<= 65 # auto promotion to long of numerator # back to (proposed) normal x = 1/2 # makes float 0.5 as normal default This is not exactly PEP-ready, but I thought I'd offer the idea. Maybe 'special' might also have natural tie-ins to migration issues? BTW, should I have posted this under a new heading? From chrishbarker at home.net Fri Jul 6 20:26:18 2001 From: chrishbarker at home.net (Chris Barker) Date: Fri, 06 Jul 2001 17:26:18 -0700 Subject: Stopping a script in PythonWin? References: <3B460F65.CBA46D2D@home.net> <ONp17.39923$he.2569508@e420r-atl1.usenetserver.com> Message-ID: <3B46572A.E1B77690@home.net> Steve Holden wrote: > > When using PythonWin, Is it possible to stop a running script without > > killing the whole IDE? I find that I want to do that on a fairly regular > > basis, and have not found a way to do it. > > > If you look in the system tray you'll see a Python icon (oicon?). Right-menu > on that has a "break into running script" item. Note that this won't work if > your program is hanging in systems calls (e.g. waiting for socket input), > but it's better than nothing. Thanks, that does the trick -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From opengeometry at yahoo.ca Mon Jul 2 21:42:40 2001 From: opengeometry at yahoo.ca (William Park) Date: Mon, 2 Jul 2001 21:42:40 -0400 Subject: Python for air traffic control? In-Reply-To: <bebbba07.0107021638.3dc5429f@posting.google.com>; from 18k11tm001@sneakemail.com on Mon, Jul 02, 2001 at 05:38:04PM -0700 References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> <bebbba07.0107021206.70a22aa8@posting.google.com> <mailman.994111084.403.python-list@python.org> <bebbba07.0107021638.3dc5429f@posting.google.com> Message-ID: <20010702214240.D4372@node0.opengeometry.ca> On Mon, Jul 02, 2001 at 05:38:04PM -0700, Russ wrote: > Yes, you are missing something: my question. I asked about the > feasibility of using Python for a safety-critical application. I > didn't ask for a fifth-grade-level analysis of the problem. Trust me: > you don't have a clue. BTW, I scored in the top 1% in the math section > of the Graduate Records Exam. How did you do? I trust you. Which city did you say you were working at? -- William Park, Open Geometry Consulting, <opengeometry at yahoo.ca> 8 CPUs cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc. From dale at riverhall.NOSPAMco.uk Tue Jul 31 13:01:57 2001 From: dale at riverhall.NOSPAMco.uk (Dale Strickland-Clark) Date: Tue, 31 Jul 2001 18:01:57 +0100 Subject: Arg decoding with a template? References: <ljidmtouqj6som2t9ecagbkj95c53kjaeh@4ax.com> <4oA97.5883$9i1.519137@e420r-atl1.usenetserver.com> Message-ID: <duodmt0itqq9t1kq6bs5dhpnk9io64p2sj@4ax.com> "Steve Holden" <sholden at holdenweb.com> wrote: OK, I've had a good look at this now. It's hideous! It's no wonder that people get fed up with computers if they get given a user interface that expects pointless dashes all over the place. You simply can't use this routine to code a nice arg string. My search continues but thanks again for the quick response, Steve. -- Dale Strickland-Clark Riverhall Systems Ltd From aleaxit at yahoo.com Tue Jul 31 06:08:32 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 31 Jul 2001 12:08:32 +0200 Subject: Unicode File References: <3B66179D.1D55B27C@yahoo.com> Message-ID: <9k604101pp8@enews4.newsguy.com> "Tksee Lhsoh" <tksee at yahoo.com> wrote in message news:3B66179D.1D55B27C at yahoo.com... > > I would like to open and save a file in unicode. > > > For example, > s=open("unicode_filename").read(); > seems to return oridinary string, not unicode. > > What should I do ? There are several approaches, but I think the simplest one is to use the unicode() built-in function, giving it the codec name you want. For example, suppose string s (e.g. as obtained from the above operation) is: >>> s '\xff\xfec\x00i\x00a\x00o\x00' e.g. as would be given by encoding UTF-16. In this case, >>> unicode(s,'utf-16') u'ciao' As I said there are several other approaches, but this one may be simplest for simple needs. Alex From m at moshez.org Mon Jul 30 14:27:53 2001 From: m at moshez.org (Moshe Zadka) Date: Mon, 30 Jul 2001 21:27:53 +0300 Subject: Large-scale Python (was: Language Niches (long)) In-Reply-To: <C2D62BF6D2E4F577.D8696582805EEB21.2093367A0D5F09C4@lp.airnews.net> References: <C2D62BF6D2E4F577.D8696582805EEB21.2093367A0D5F09C4@lp.airnews.net>, <8beb91f5.0107280407.5a30341d@posting.google.com> <mailman.996429234.13926.python-list@python.org> <Ej5QPKA1WHZ7EwvP@jessikat.fsnet.co.uk> <mailman.996442753.17197.python-list@python.org> Message-ID: <E15RHlh-0005rL-00@darjeeling> On 30 Jul 2001, claird at starbase.neosoft.com (Cameron Laird) wrote: > What role has "language change" played in this, though? > I don't think Python's syntax or semantics support > modularization and packaging significantly better than > in '96 Packages (as opposed to just modules) are post '96, IIRC. -- gpg --keyserver keyserver.pgp.com --recv-keys 46D01BD6 54C4E1FE Secure (inaccessible): 4BD1 7705 EEC0 260A 7F21 4817 C7FC A636 46D0 1BD6 Insecure (accessible): C5A5 A8FA CA39 AB03 10B8 F116 1713 1BCF 54C4 E1FE Learn Python! http://www.ibiblio.org/obp/thinkCSpy From quinn at yak.ugcs.caltech.edu Fri Jul 13 20:51:49 2001 From: quinn at yak.ugcs.caltech.edu (Quinn Dunkan) Date: 14 Jul 2001 00:51:49 GMT Subject: FW: Newbie list question References: <3D7C088D6CCFD31190A5009027D30E9103391050@torex004.attcanada.ca> <mailman.995046806.4294.python-list@python.org> Message-ID: <slrn9kv5t5.u3o.quinn@yak.ugcs.caltech.edu> On Fri, 13 Jul 2001 12:53:34 -0500, Skip Montanaro <skip at pobox.com> wrote: > Mark> Does: > > Mark> foo += 'c' > > Mark> act like an append then? I always assumed it was the same as: > > Mark> foo = foo + 'c' > > Mark> which obviously should raise a TypeError. Here however it works, > Mark> in that it appends 'c' to the object to which foo refers and thus > Mark> to the object to which bar refers... I just noticed that too. Of course, I knew that (+=) on a list maps to [].extend, but didn't realize that extend would accept a string while (+) wouldn't. It's a manifestation of the fact that both lists and strings are both sequences and hence "sorta similar". In this case, one version of the operation thinks of strings as lists of characters, and the other thinks of them as strings ('TypeError: can only concatenate list (not "string") to list'). This seems inconsistent to me. Either [].extend('string') should raise a TypeError or "[1, 2] + 'ab'" should evaluate to [1, 2, 'a', 'b']. From ullrich at math.okstate.edu Tue Jul 24 10:38:03 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Tue, 24 Jul 2001 14:38:03 GMT Subject: re bad leadership References: <XFMail.20010724142502.mikael@isy.liu.se> <mailman.995979252.31899.python-list@python.org> <yTedznATrXX7Ew7W@jessikat.fsnet.co.uk> Message-ID: <3b5d8598.1522578@nntp.sprynet.com> On Tue, 24 Jul 2001 14:40:35 +0100, Robin Becker <robin at jessikat.fsnet.co.uk> wrote: >In article <mailman.995979252.31899.python-list at python.org>, Chris >Gonnerman <chris.gonnerman at newcenturycomputers.net> writes >.... >>I'm guessing here, but I'd bet from the tone of his postings that Robin >>means >> >> Malevolent Dictator For Life >> >>While I'm not happy with Guido over this change (because it makes cross- >>version code very ugly, and introduces errors in meaning that may be hard >>to detect) I would not call him such a rude name. >... >when the Gods smile upon us they are benevolent, when lighting strikes >they are malevolent. They are still Gods. Luckily we only have >dictators. Sometimes the dictatorship is good, sometimes bad it's still >a dictatorship. Supposing for the sake of argument that the DFL's views on this are just totally wrong that's still far from "malevolent", could be he's just stupid. Not that that seems likely to me, of course (cracks about orthogonal delphic oracles notwithstanding). And not that the issue matters to me, and not that my opinion has any bearing, but I saw a post by Tim today explaining an aspect of this that seems totally missing from most of the arguments we see on the topic. (Look for a post containing the string "500". If there _are_ 500 posts on a topic it's a good thing if some of them get replies from people with contrary views, for the benefit of people like me who only read a few - I'm certain that what Tim said has been said many times before, but I hadn't noticed...) >-- >Robin Becker David C. Ullrich From tim at vegeta.ath.cx Sun Jul 15 21:03:29 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Mon, 16 Jul 2001 01:03:29 GMT Subject: converting from perl: variable sized unpack References: <roy-B2459F.22112513072001@news1.panix.com> <mailman.995081424.8581.python-list@python.org> <slrn9l4esk.885.quinn@yak.ugcs.caltech.edu> Message-ID: <slrn9l4g1c.p58.tim@vegeta.ath.cx> Me parece que Quinn Dunkan <quinn at yak.ugcs.caltech.edu> dijo: > Ruby allows * notation: > > a, b, *c = sequence # `c' gets the rest of the sequence > > which is cute, but I don't like it. Just another random "convenient" little > trick to remember. It's not half as useful as the 1.6 * apply trick. Let's > go easy on the syntax gimmicks. I'm relatively new to Python. What's the '1.6 * apply' trick? -- Little one, I would like to see anyone -- prophet, king or god -- persuade a thousand cats to do anything at the same time. -- Orange Cat, The Sandman From arildh at stud.cs.uit.no Mon Jul 2 11:02:24 2001 From: arildh at stud.cs.uit.no (Arild Hansen) Date: Mon, 2 Jul 2001 17:02:24 +0200 Subject: Sound recording (wav) Message-ID: <Pine.LNX.4.33.0107021659540.19599-100000@arildh.pasta.cs.uit.no> Hello, I want to record a sound sample from the microphone. Can anyone give me a small example of how to do this as I don't seem to figure it out. My system is as follows: Linux: 2.4.0 Python: 2.0c1 I just want to record to a wav file either using the Esd frontend for python (which I have installed and which playbacks sound without problem) or any other possible method (there are some wav methods in python but I don't know if I can use them to record sound). Thx for all help, AH From clspence at one.net Wed Jul 11 15:53:06 2001 From: clspence at one.net (Chris Spencer) Date: 11 Jul 2001 14:53:06 -0500 Subject: Freeing memory from Python lists! References: <cdd0bc89.0107111041.c3f8209@posting.google.com> Message-ID: <qebpktoe7n33altfhpar744nhak7hf4b6u@4ax.com> I can confirm these results. Why would a deleted list retain 90% of its memory usage after being deleted? Sounds like a pointer is getting lost somewhere. Chris. On 11 Jul 2001 11:41:25 -0700, msimpson at ioindustries.com (Mike Simpson) wrote: >I can't figure out how to free the memory used in the creation of a >large list in Python. >I am running the Python 2.1 interpreter on Windows 2000 Professional >to run the following piece of code: > >result = [] >for count in xrange(510*478): > result.append(count) >del result > >By using Windows Task Manager I was able to determine that 4332K of >memory was used up until the end of the for loop, but only 960K of >memory was returned to the system after the call to "del". Is there >any way to return the other 3372K of memory to the system without >quitting the Python interpreter? > >Any help would be greatly appreciated. > > > >Mike From juergen.erhard at gmx.net Thu Jul 26 12:56:37 2001 From: juergen.erhard at gmx.net (=?ISO-8859-1?Q?=22J=FCrgen_A=2E_Erhard=22?=) Date: Thu, 26 Jul 2001 18:56:37 +0200 Subject: re bad leadership In-Reply-To: <0+yM4IAgmKX7EwIQ@jessikat.fsnet.co.uk> (message from Robin Becker on Mon, 23 Jul 2001 23:48:00 +0100) References: <0+yM4IAgmKX7EwIQ@jessikat.fsnet.co.uk> Message-ID: <26072001.2@wanderer.local.jae.dyndns.org> >>>>> "Robin" == Robin Becker <robin at jessikat.fsnet.co.uk> writes: Robin> it doesn't matter what the leadership says is right. The Robin> popular vote is against the stupid float '/' operator. Robin, has it ever occured to you that the majority might be *for* that change? But because we feel Guido *will* implement that change, we don't see a need to speak up. The most vocal group is not necessarily the majority (and much less right). There *is* such a thing as a silent majority... I personally like that change. And yes, I'll have to fix up some code too, probably. But it will be worth it. Bye, J PS: What Fran?ois said. -- J?rgen A. Erhard (juergen.erhard at gmx.net, jae at users.sourceforge.net) My WebHome: http://members.tripod.com/Juergen_Erhard GNOME Desktop Project (http://www.gnome.org) I have a firm grip on reality, now I can strangle it. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 248 bytes Desc: not available URL: <http://mail.python.org/pipermail/python-list/attachments/20010726/df608355/attachment.sig> From nas at python.ca Mon Jul 9 17:38:13 2001 From: nas at python.ca (Neil Schemenauer) Date: Mon, 9 Jul 2001 14:38:13 -0700 Subject: Is Python Dead? Long Live Python! In-Reply-To: <5174eed0.0107091109.d3a53f6@posting.google.com>; from web2ed@yahoo.com on Mon, Jul 09, 2001 at 12:09:23PM -0700 References: <MNS%6.355$Xs4.225014@news.pacbell.net> <458b194a.0107050711.72007607@posting.google.com> <TH%07.3499$i8.339613@e420r-atl3.usenetserver.com> <458b194a.0107060959.6bd34b3f@posting.google.com> <7sn17.7740$i8.679052@e420r-atl3.usenetserver.com> <458b194a.0107071317.508ef7e4@posting.google.com> <mailman.994599260.9137.python-list@python.org> <5174eed0.0107091109.d3a53f6@posting.google.com> Message-ID: <20010709143813.B10434@glacier.fnational.com> Edward Wilson wrote: > [...] Python won't bennefit from the best developers, the > developers who code for a living. How exactly are these developers going to benefit Python? It appears to me that the loss would be minor. If you think there is something wrong with the DB support in Python then do something about it. Posting lots of whiny messages to c.l.p doesn't help. Python-helps-those-who-help-themselves-ly'rs Neil From piotrlg at sci.pam.szczecin.pl Thu Jul 26 08:17:40 2001 From: piotrlg at sci.pam.szczecin.pl (Piotr Legiecki) Date: Thu, 26 Jul 2001 14:17:40 +0200 Subject: Class with subclass and dynamic lists Message-ID: <3B600A64.EC187E9@sci.pam.szczecin.pl> Hi I can't resolve my problem. Here is the test code class A: x=[] #it will be list of B objects z=None #something, doesn't matter class B: y=None #this function adds to A object (arg) B objects with value val def f(arg, val): for i in range(1,3): #to put some values into the list arg.x.append(B()) l=len(arg.x)-1 #well, it is just added the last object in a list, arg.x[l].y=val+i #assign him somethig print 'in f', arg.x[l].y # test print l #test, here I can see, that my list in class A (x[]) is THE SAME for all the #A instances! Why? def main(): p=[] #list of class A objects p.append(A()) #make 2 objects of class A f(p[0], 10) #send object A, from list of A's objects (I hope) to add a list of B objects to A object p[0].z='aaa' p.append(A()) #second A object p[1].z='bbb' f(p[1],20) #testing, not good print p[0].x[0].y print p[0].x[1].y print p[0].z print p[1].x[0].y #here I have the same values as in p[0].x[0].y, why? print p[1].x[1].y #why p[1].x is the same list for both (p[0], p[1]) A objects? print p[1].z print p[0].z main() -- Regards Piotr Legiecki From simonb at webone.com.au Wed Jul 11 23:58:50 2001 From: simonb at webone.com.au (simonb at webone.com.au) Date: Thu, 12 Jul 2001 13:58:50 +1000 Subject: python and applications References: <V%337.677940$166.13952126@news1.rdc1.bc.home.com> <TX837.333827$p33.6744731@news1.sttls1.wa.home.com> Message-ID: <3B4D207A.90100@webone.com.au> Why is Eiffel better anyway? It's faster, OK, and it has nifty assertions as part of the language, but, well i tried them both and i vote for python. Greg Jorgensen wrote: >I read that Python is too slow for MUDs, and Eiffel is better anyway. Try >Eiffel or Haskell if you are blind. > > >"tyler spivey" <tspivey8 at home.com> wrote in message >news:V%337.677940$166.13952126 at news1.rdc1.bc.home.com... > >>could you write a fast mud in python? >>having a lot of monsters like dikumuds do? >>how many blind programmers use python? and is python just a toy language? >>can it do more or as much as c? could you create a roguelike in it? >>I am blind myself. >> > > From tundra at tundraware.com Mon Jul 16 13:50:02 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 16 Jul 2001 17:50:02 GMT Subject: re Challenge: More Compact? References: <3B51E6B1.47E25214@tundraware.com> <92ae279c.0107151429.398e6e9e@posting.google.com> Message-ID: <3B5328D7.34DDA5C1@tundraware.com> John Machin wrote: > <SNIP> (Sound of TV Audience Clapping And Yelling, "Good Answer, John") In the situation I am using this, I don't need to known whether the digits are in range. I am looking at a log file and just want to know whether a given field is in host name or IP quad format (so I can do an reverse on the quad)... Thanx to all who chimed in... and here I thought I understood re construction ... boy, am I a loser ;) > Now for the third big two-byte saving: throw away the rightmost set of > capturing parentheses. > ipquad = r"^(\d{1,3}\.){3}\d{1,3}$" > Either (a) you have no intention of retrieving parts of the matched > string later, so the "capturing" functionality is of no use to you, or > (b) you haven't considered this: if your input string is > "010.020.030.040", then with your original re, groups 0 and 1 will be > "010.020.030.040", group 2 will be "030." and group 3 will "040" -- > about as useful as a hip pocket on an athletic supporter. > > OK, so now we've trimmed the text description of the re down a little, > let's revisit the "legitimate IP address" notion. Is 999.999.999.999 > now a legitimate IP address? Last I heard, the max for each little > doodad was 255. If so, you may not want to cr[au]ft a complicated re > to try to enforce that. The one-liner freaks would no doubt relish a > challenge to come up with something better than > > max(map(int, your_input_string.split("."))) > 255 > > to use as a test *after* the uncomplicated_re.match() is successful. -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From bokr at accessone.com Sat Jul 28 00:51:08 2001 From: bokr at accessone.com (Bengt Richter) Date: Sat, 28 Jul 2001 04:51:08 GMT Subject: PEP 238 (revised) References: <cp4rrz5onj.fsf@cj20424-a.reston1.va.home.com> <slrn9m3bt8.114.sill@sill.silmarill.org> <3B61B7E4.5C6DFF01@Lugoj.Com> <cpzo9q16ux.fsf@cj20424-a.reston1.va.home.com> Message-ID: <3b622f18.603981038@wa.news.verio.net> On Fri, 27 Jul 2001 19:59:16 GMT, Guido van Rossum <guido at python.org> wrote: [...] > >IEEE 754, the floating point standard in use in virtually all current >hardware, mandates that -0.0 be distinguishable from 0.0, in order to >be able to represent the sign of degenerated underflow results. (Or >so I understand, having been educated in IEEE 754 through numerous >discussions with Tim Peters, but not by reading the standard. If I'm >wrong, Tim will surely correct me. :-) > >I don't know of a portable way to generate -0.0 in Python; on my Linux >box, simply writing -0.0 does it, but not on my Windows box. > My gut feeling is that the symmetry of sign,magnitude numbers in IEEE754 is not good when you are dealing with a mapping of the real axis to the unit circle. It doesn't feel right to me, though probably it's not of much practical consequence. But, speaking of the unit circle, UIAM Scheme has what appears to me to be a wart. Functions that return angles apparently do so as values in (-pi,pi] rather than [-pi,pi). To me that is a wart. Apparently Scheme got it from APL, and I still haven't got to the local U library to see the referenced paper with the rationale. Mathematically, you can't translate the interval by exactly pi and get a 2pi interval that includes zero! It strikes me as weird to exclude zero and include 2pi. [1] And look what that interval does if you want to turn it into a Python index range for k steps of 2*pi/k. Adding pi to an angle puts it in (0,2pi] -- and unless you turn 2pi into zero before doing angle*k//twopi, you will have an out of range index when an arctangent returns pi instead of -pi. My intel book says the pentium FPATAN instruction returns radians with a magnitude *less than* pi, so whatever constant is defined as pi for purposes of returning it from software, the choice must have been made there between +pi and -pi, or they just return whatever the hardware provides, which would make the scheme documentation wrong about the interval. It could either be called (-pi,pi) or [-pi,pi], but not half open. Is this something that might be given a clean resolution in Python? I.e., [-pi,pi) , IMHO ;-) [1] Afterthought ... unless angles are being represented inversely somewhere, i.e., as x when you want 2*pi/x. From new_name at mit.edu Sat Jul 21 14:14:15 2001 From: new_name at mit.edu (Alex) Date: 21 Jul 2001 14:14:15 -0400 Subject: Hello, References: <mailman.995736253.29035.python-list@python.org> Message-ID: <etd3d7qxi88.fsf@w20-575-7.mit.edu> Not really. There are some ways you could speed up the python code: def LogError(msg): old = open("./error.log", "r").read() err = open("./error.log", "w") err.write(msg) err.write(old) ...but you're still going to be reading a lot from the disk only to write it straight back out again. There's the additional problem that opening "err" will truncate the log file, and if an error occurs while you're writing the new version back, you could lose messages. HTH. Alex. From quinn at yak.ugcs.caltech.edu Wed Jul 18 18:38:54 2001 From: quinn at yak.ugcs.caltech.edu (Quinn Dunkan) Date: 18 Jul 2001 22:38:54 GMT Subject: basic python-unix question References: <xxn57.48174$J91.2654135@bgtnsc06-news.ops.worldnet.att.net> Message-ID: <slrn9lc3vt.85k.quinn@yak.ugcs.caltech.edu> On Wed, 18 Jul 2001 21:51:25 GMT, Ed T <spi at micro.soft> wrote: >Hi Folks, >New to Python and have been unable to us the "ps ef |grep" command >correctly. From what I can tell I need to use the os.system() command. But >have had no luck. Here an example of a basic script: > >import os, sys >process = ("test1", "test2") > >for eachProcess in process: > os.system('ps ef | grep eachProcess') > > >The idea is to place processes that should be running into a for loop and >see if it is running. When I do the above it appears only to check for the >word "eachProcess" not for the process (i.e., test1 or test2). Is this a >case of how to enter this command where substitution takes place in Python? Yes. Automatic substitution does not take place at all. Strings will never change their contents. There are many functions that operate on strings, though. You can concatenate strincgs with (+): 'ps ef | grep ' + eachProcess You can interpolate strings with (%): 'ps ef | grep %s' % eachProcess Read the docs for more. As an aside, the above os.system is not a very good way to check for running processes (you want a >/dev/null in there at least, not to mention that it will break if you move it to a bsd). I recommend finding out the relevant pids and using os.kill(0, pid). From db3l at fitlinxx.com Wed Jul 11 16:38:13 2001 From: db3l at fitlinxx.com (David Bolen) Date: 11 Jul 2001 16:38:13 -0400 Subject: Language change and code breaks References: <wuN27.13377$Y6.4240331@news1.rdc2.pa.home.com> <cplmlvh6dx.fsf@cj20424-a.reston1.va.home.com> <6A%27.454703$eK2.93741234@news4.rdc1.on.home.com> <m3k81fb7jc.fsf@chinon.cnrs-orleans.fr> Message-ID: <un16bcibu.fsf@ctwd0143.fitlinxx.com> Konrad Hinsen <hinsen at cnrs-orleans.fr> writes: > Sounds like a good idea. Just the existence of two division operators > would help newbies to recognize that there is a nontrivial problem. > And a//b definitely beats (a+0.)/b, which does the trick, but is not > at all evident. Well, I'd probably suggest using "float(a)/b" instead which at least makes it a little easier to see what's going on :-) -- -- 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 peter at engcorp.com Tue Jul 17 10:11:04 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 17 Jul 2001 10:11:04 -0400 Subject: python vs kung fu References: <50220745.0107170521.24f1c18b@posting.google.com> Message-ID: <3B544778.CFC9293B@engcorp.com> neil bromehead wrote: > > It seems that, just like in chinese kung fu circles, lots of people > are trying to justify their style (python in this case) to themselves, > myself included. why ?, all styles can be equally effective , it > depends on how you use them ! Without debating whether all styles are equally effective (see Ultimate Fighting for example :-), I think there's another point you aren't considering. (And clearly Shorinji-ryu Karate is superior to chinese kung fu! ;-) > so rather than get into endless arguments with java guys or perl guys > about the virtues of python , lets just try to beat them at their own > game ! Many of us are idealists who feel saddened that so many are effectively wasting their time with languages which are holding them back. We feel the urge (obviously an irresistable one :) to try to convince those miscreants^H^H^H^H^H poor misguided souls that they could better spend their time with Python. That they would be more productive, enjoy their work more, produce higher quality results, and spend more time programming and less time debugging. That pragmatism and simplicity are far more important than optimization and the ability to write entire applications in one line. We are not so much arguing as trying to show them that we _understand_ their points, and in fact used to think the same way, but that we have found a better way and want to see them try it out for themselves. Definitely sounds like religion: probably indistinguishable, but that doesn't mean we should all stop and silently use Python for our own applications and never breathe a word of it to another soul... Some of us just don't want to be the "quiet revolutionary" who has played such an important role in history, sitting at home peacefully practicing his new world-view and waiting for the rest of the world to realize how effective it is... -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From grayson-wilson at home.com Mon Jul 9 00:41:36 2001 From: grayson-wilson at home.com (EricIDLE) Date: Mon, 09 Jul 2001 04:41:36 GMT Subject: Help With map() *He says while pulling his hair out* References: <pM927.657463$166.13605776@news1.rdc1.bc.home.com> <bqa27.442234$eK2.89986862@news4.rdc1.on.home.com> Message-ID: <4Ca27.657799$166.13617032@news1.rdc1.bc.home.com> Sorry. I still dont understand. Its just more confusing now. From tim at vegeta.ath.cx Mon Jul 16 16:01:42 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Mon, 16 Jul 2001 20:01:42 GMT Subject: re Challenge: More Compact? References: <mailman.995247446.16415.python-list@python.org> <slrn9l4llv.p58.tim@vegeta.ath.cx> <o8a6lt0sdmgbm6vn939no9chocul4fpq10@4ax.com> Message-ID: <slrn9l6inc.qqs.tim@vegeta.ath.cx> Me parece que Ben Wolfson <rumjuggler at cryptarchy.org> dijo: > In that case you can eliminate a whole line this way: > > def valid_ip(ip): > m = re.match( r'(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$', ip) > return (m and max(map(int, m.groups())) < 256)) or 0 You meant: return (m and max(map(int, m.groups())) < 256) or 0 of course? You have a knack for one-liners. That's not necessarily a bad thing. <wink> -- I am following my fish. -- Delirium, The Sandman From tim.one at home.com Mon Jul 23 21:13:05 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 23 Jul 2001 21:13:05 -0400 Subject: PEP0238 lament In-Reply-To: <9jhmoc$9nm$1@panix6.panix.com> Message-ID: <LNBBLJKPBEHFEDALKOLCAEICLAAA.tim.one@home.com> [Tim] > Why is that? It's because unlike any other builtin arithmetic > operation, "/" today can cause *catastrophic* loss of > information silently, and in ordinary cases. [Roy Smith] > Surely assignment causes catastrophic loss of information, no? If I > say "x = 4", havn't I lost the old value of x? Possibly (you may have aliases for the same value -- I can't guess), but if so that was either your intent or a logic error in your code. > Multiplication by zero causes catastrophic loss of information too. No. x*0 is exactly 0: the true result is the result you get. 3/4 is-- forgetting the conceits of computer numerics for a moment --exactly 0.75, and sqrt(pi)**2 is exactly pi, and exp(log(1 + 1e-200))-1 is exactly 1e-200. In the first case a result of 0 is 100% loss of the full truth (and so "catastrophic" in this sense); in the second case 754 double arithmetic may lose about 1 part in 2**53 of the full truth (and so is an insignificant loss of information for most applications); while in the last case 754 double arithmetic will return 0, again a 100% loss of information (not academic: that kind of expression with small |x| is important in financial models). > Should we redefine how those operations work too? Sounds even sillier to me than it did to you, you know. From tim.one at home.com Sun Jul 22 18:08:09 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 22 Jul 2001 18:08:09 -0400 Subject: subclassing Exceptions In-Reply-To: <88gmltsdpn4brhtr7ng71b7c22qqlhlfac@4ax.com> Message-ID: <LNBBLJKPBEHFEDALKOLCKEDBLAAA.tim.one@home.com> [Sheila King] > ... > That's because the "big picture" is the general overview of how the > parent class works. It is a general question, which is why I wanted to > see the source for the class (which is all I originally asked for...a > pointer to the source files...and that question has since been > answered.) Actually, I just downloaded the source for 1.5.2 and am > looking at exceptions.py and am finding it quite enlightening. > > This is silly. I'm defending asking to see the source code. ???? You don't have to defend yourself -- Guido will do it for you <wink>. He opened a bug report on SourceForge today: #443559 creating exceptions is underdocumented and attached one of your first msgs as evidence. This area is indeed "underdocumented". From quinn at yak.ugcs.caltech.edu Wed Jul 11 16:04:21 2001 From: quinn at yak.ugcs.caltech.edu (Quinn Dunkan) Date: 11 Jul 2001 20:04:21 GMT Subject: Tuple Semantics - Rationale'? References: <3B4CA0A8.20B53230@tundraware.com> Message-ID: <slrn9kpca4.t6.quinn@yak.ugcs.caltech.edu> On 11 Jul 2001 19:00:01 GMT, Tim Daneliuk <tundra at tundraware.com> wrote: >And that works fine. But *why* is the trailing comma designed into the >language semantics this way. I've been scratching my head and cannot come >up with a rationale'. It seems to me that the explicit use of the parens >should be telling python that I want the second entry in each data >structure to be a *tuple* of 0 or more tuples. Because parens are overloaded. Consider: print (10 + 5) * 3 Do you expect 45 or (15, 15, 15) ? >Supposed I did want 0 argument pairs in that tuple, but I wanted to prepare >the way for adding some later. Would I use: > > (()), (), ((,)) ??? Did you try it? According to the documentation you use ((), (), ()) The documentation also recognizes that () vs. (one_elt,) vs. (two, elts) is ugly, but there's no getting around it unless we get keyboards with more bracket keys. Large complicated data structures of nested tuples might be a mistake. Tuples and python's simple pattern matching can be handy for small ad hoc types, but don't forget about classes. From m.faassen at vet.uu.nl Wed Jul 4 15:24:43 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 4 Jul 2001 19:24:43 GMT Subject: PEP: Procedure for Adding New Modules (please comment) Message-ID: <9hvqhr$gj2$1@newshost.accu.uu.nl> Hi folks, I've been working on a text for PEP 2. Currently, PEP 2 is a 3 line text written by Eric Raymond: http://python.sourceforge.net/peps/pep-0002.html Tim Peters suggested we fleshed it out, so I've made the attempt. I've conferred with Eric to make sure I wasn't stepping on any toes there. The PEP that follows officially has no number yet; it hasn't been assigned one yet. My hope is of course i'tll be accepted as PEP 2. Carlos Ribeiro has also been working on a text, which may become a separate PEP or may be merged into this one. The two texts are fairly complementary; Carlos talks more about guidelines for what the modules should look like, while my text talks more about the acceptance procedure. I'm in communication with Carlos about further development of that text. Comments are very welcome. I'll attempt to integrate any feedback and will try to move this forward if the feedback is positive. This text assumes the community will play a large role in developing and maintaining any standard library modules. So, community, please give some feedback. Title: Producedure for Adding New Modules Introduction The Python Standard Library contributes significantly to Python's success. The language comes with "batteries included", so it is easy for people to become productive with just the standard library alone. It is therefore important that this library grows with the language, and that such growth is supported and encouraged. Many contributions to the library are not created by core developers but by people from the Python community who are experts in their particular field. Furthermore, community members are also the users of the standard library, applying it in a great diversity of settings. This makes the community well equipped to detect and report gaps in the library; things that are missing but should be added. New functionality is commonly added to the library in the form of new modules. This PEP will describe the procedure for the _addition_ of new modules. PEP 4 deals with procedures for deprecation of modules; the _removal_ of old and unused modules from the standard library. Finally there is also the issue of _changing_ existing modules to make the picture of library evolution complete. PEP 3 and 5 give some guidelines on this. The continued maintenance of existing modules is an integral part of the decision on This PEP also introduces concepts (integrators, maintainers) relevant to this issue. Integrators The integrators are a group of people with the following responsibilities: - They determine if a proposed contribution should become part of the standard library. - They integrate accepted contributions into the standard library. - They produce standard library releases. This group of people shall be PythonLabs, led by Guido. Maintainer(s) All contributions to the standard library need one or more maintainers. This can be an individual, but frequently is a group of people such as for instance the XML-SIG. Groups may subdivide maintenance tasks among themselves. One ore more maintainers shall be the _head maintainer_ (usually this is also the main developer). Head maintainers are convenient people the integrators can address if they want to resolve specific issues, such as the ones detailed later in this document. Developers(s) Contributions to the standard library have been developed by one or more developers. The initial maintainers are the original developers unless there are special circumstances (which should be detailed in the PEP proposing the contribution). Acceptance Procedure When developers wish to have a contribution accepted into the standard library, they will first form a group of maintainers (normally initially consisting of themselves). Then, this group shall produce a PEP called a library PEP. A library PEP is a special form of standards track PEP. The library PEP gives an overview of the proposed contribution, along with the proposed contribution as the reference implementation. This PEP should also contain a motivation on why this contribution should be part of the standard library. One or more maintainers shall step forward as PEP champion (the people listed in the Author field are the champions). The PEP champion(s) shall be the initial head maintainer(s). As described in PEP 1, a standards track PEP should consist of a design document and a reference implementation. The library PEP differs from a normal standard track PEP in that the reference implementation should in this case always already have been written before the PEP is to be reviewed; the reference implementation _is_ the proposed contribution. This different requirement exists for the following reasons: - The integrators can only properly evaluate a contribution to the standard library when there is source code and documentation to look at; i.e. the reference implementation is always necessary to aid people in studying the PEP. - Even rejected contributions will be useful outside the standard library, so there will a lower risk of waste of effort by the developers. - It will impress the integrators of the seriousness of contribution and will help guard them against having to evaluate too many frivolous proposals. Once the library PEP has been submitted for review, the integrators will then evaluate it. The PEP will follow the normal PEP work flow as described in PEP 1. If the PEP is accepted, they will work through the head maintainers to make the contribution ready for integration. Maintenance Procedure After a contribution has been accepted, the job is not over for both integrators and maintainers. The integrators will forward any bug reports in the standard library to the appropriate head maintainers. Before the feature freeze preparing for a release of the standard library, the integrators will check with the head maintainers for all contributions, to see if there are any updates to be included in the next release. The integrators will evaluate any such updates for issues like backwards compability and may require PEPs if the changes are deemed to be large. The head maintainers should take an active role in keeping up to date with the Python development process. If a head maintainer is unable to function in this way, he or she should announce the intention to step down to the integrators and the rest of the maintainers, so that a replacement can step forward. In the case where no head maintainer can be found (possibly because there are no maintainers left), the integrators will issue a call to the community at large asking for new maintainers to step forward. If no one does, the integrators can decide to declare the contribution deprecated as described in PEP 4. Open issues Should there be a list of what criteria integrators use for evaluating contributions? (source code but also things like documentation and a test suite, as well as such vague things like 'dependability of the maintainers'). A related question is integration with the Python documentation process. Contributions should come with good documentation that can be integrated with the Standard Library documentation. Should we detail this more in this PEP? Should the current standard library be subdivided among such maintainers? Many parts already have (informal) maintainers; it may be good to make this more explicit. Perhaps there is a better word for 'contribution'; the word 'contribution' may not imply enough that the process (of development and maintenance) does not stop after the contribution is accepted and integrated into the library. Relationship to the mytical Catalog? Copyright This document has been placed in the public domain. -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From machin_john_888 at hotmail.com Sat Jul 21 01:54:14 2001 From: machin_john_888 at hotmail.com (John Machin) Date: 20 Jul 2001 22:54:14 -0700 Subject: interpreter command line recall/editing/completion under Windows (was Re: interpreter improvements) References: <5e8bd451.0107190224.7171e61@posting.google.com> <mailman.995680066.20051.python-list@python.org> Message-ID: <92ae279c.0107202154.45eb36f@posting.google.com> Skip Montanaro <skip at pobox.com> wrote in message news:<mailman.995680066.20051.python-list at python.org>... > > As for command history and command completion, sounds like you must be stuck > on Windows. Readline and rlcompleter do a decent job of command recall and > with the atexit module you can save the history file across sessions. Indeed there are a lot of us rabbits stuck in those briar patches, whether we asked to be thrown there or not :-) However there seem to be different sub-species of briar: Win NT4 seems to support "DOSKEY" style command editing inside any application, including Python -- one just hits the up-arrow key and there's the previous input, waiting to be edited. This is without my having done anything special to make this happen (that I'm aware of!). This facility is just so handy for fiddling around, checking what works and what doesn't, trying out one-liners, experimenting with the 2.2 alpha goodies, etc etc that everyone IMO should just have it straight away when they get Python out of the box. Win 95B seems to do command editing only at the DOS prompt level, not within applications -- certainly not within the Python interpreter. I recall from a thread a few weeks ago that there were 2 or 3 competing but not widely-known and not (AFAIR) novice-installable solutions to this problem. How can we progress this? Would it be possible to build something into the standard Win32 distribution? From grante at visi.com Tue Jul 24 13:02:52 2001 From: grante at visi.com (Grant Edwards) Date: Tue, 24 Jul 2001 17:02:52 GMT Subject: PEP0238 lament References: <mailman.995839419.19134.python-list@python.org> <lZX67.36860$Cy.4285646@news1.rdc1.az.home.com> <11moltg2i6s1ftkpku5dkr0cmifn9f5q1o@4ax.com> <Ew_67.36904$Cy.4360445@news1.rdc1.az.home.com> <eppstein-E3BB02.12500023072001@news.service.uci.edu> <WV177.36940$Cy.4447774@news1.rdc1.az.home.com> <eppstein-1C3F40.16121323072001@news.service.uci.edu> <Lk377.36960$Cy.4485776@news1.rdc1.az.home.com> Message-ID: <0Th77.23755$B7.3909918@ruti.visi.com> In article <Lk377.36960$Cy.4485776 at news1.rdc1.az.home.com>, Tim Hochberg wrote: >> Another possible step instead of breaking integer division >> would be to add a warning for any int/float or float/int >> division, to make it more explicit that the two kinds of >> division are different and that you need to make up your mind >> which one you want to do. Take out all the automagic and make >> people use explicit casts. > >I don't think that's viable. Just issuing warning can break >plenty of code. WTF? We've argued that changing the definition of "/" will break plenty of code. Response: "tough shit, bucko, deal with it. We need this operator to change so that code that hasn't been written yet will look the way we want it to." -- Grant Edwards grante Yow! Well, I'm INVISIBLE at AGAIN... I might as well visi.com pay a visit to the LADIES ROOM... From new_name at mit.edu Sun Jul 15 15:51:53 2001 From: new_name at mit.edu (Alex) Date: 15 Jul 2001 15:51:53 -0400 Subject: re Challenge: More Compact? References: <3B51E6B1.47E25214@tundraware.com> Message-ID: <etdhewe0y3q.fsf@quiche-lorraine.mit.edu> def ip_p(ip_string): try: bytes = map(int, ip_string.split('.')) except ValueError: return None return 0 <= min(bytes) <= max(bytes) < 256 HTH. Alex. From steve at lurking.demon.co.uk Fri Jul 27 18:18:42 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Fri, 27 Jul 2001 23:18:42 +0100 Subject: int(a), b = divmod(x, y) References: <Pine.LNX.4.33.0107251514570.6992-100000@bms> <mailman.996109404.25018.python-list@python.org> Message-ID: <lvf3mto2i116sl1nrjn6q6p1ckt0c3ddbe@4ax.com> On Wed, 25 Jul 2001 18:00:50 -0700, "Ken Seehof" <kens at sightreader.com> wrote: >This is not the same as a = int(5.2) and it would seem really wierd to >me if it were. Then again, from a C++ point of view, any syntax that >is currently illegal is a natural candidate for a new syntax feature :-). >But python is not C++, so I'm afraid you'll have to settle for something >less terse and more clear. > >a,b = divmod(x,y) >a = int(a) I don't know why the first output in the tuple isn't an int anyway. After all, it *is* a member of the set of integers even if it is currently represented using a float. A quick example... >>> divmod(5.1,2.0) (2.0, 1.0999999999999996) So why doesn't this return... >>> divmod(5.1,2.0) (2, 1.0999999999999996) If the 2 is used anywhere a float is needed it will be cast to float implicitly anyway once PEP238 goes through. From max at alcyone.com Mon Jul 23 11:54:08 2001 From: max at alcyone.com (Erik Max Francis) Date: Mon, 23 Jul 2001 08:54:08 -0700 Subject: A use for integer quotients References: <mailman.995866298.23496.python-list@python.org> <eppstein-E19F08.00451323072001@news.service.uci.edu> <3B5BDCB4.A2010560@letterror.com> Message-ID: <3B5C48A0.56D88724@alcyone.com> Just van Rossum wrote: > Do you really want 2047 bytes to be shown as 1 kbyte? Integer division > is a lousy tool in this particular example... Just add 512 to it first. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laughter is the only genuine form of applause. \__/ Camden Benares Kepler's laws / http://www.alcyone.com/max/physics/kepler/ A proof of Kepler's laws. From steve at hkit.net Tue Jul 10 00:31:52 2001 From: steve at hkit.net (Steve S.L. Wong) Date: Tue, 10 Jul 2001 12:31:52 +0800 Subject: Newbie asks: How to translate this line of C to Py Message-ID: <tkl15g5on0mla8@news.supernews.com> while (command = strtok(line_ptr,";"),line_ptr=0,command) { } From hnowak at cuci.nl Sun Jul 29 16:46:07 2001 From: hnowak at cuci.nl (Hans Nowak) Date: Sun, 29 Jul 2001 22:46:07 +0200 Subject: importing modules In-Reply-To: <3b5f38c5.112013116@news.libero.it> Message-ID: <200107292048.f6TKmG914531@hera.cuci.nl> On 25 Jul 01, at 21:29, Duilio Foschi wrote: > >Where did you get this from? > > http://www.hvision.nl/~ivnowa/newsite/Python/Python-DX/python-dx.html > > "Hans Nowak's Python-DX is a version of Python for 32-bit DOS. > Python-DX is equivalent to Python 1.5.2, but Hans no longer maintains it, > so it's doubtful that Python 1.6 will be supported. " > > what shoud I do ? > > Or - put it in a different way - which is fully working version for > Dos I should download ? Sorry, I didn't see this earlier... there are simply too many messages in the newsgroup for me to keep up with everything. :( I didn't realize my site, or what's left of it, was still online... people at Home Vision moved things around, forgot to copy some files in the process, and the result looks horrible. Anyway, it's true that I don't maintain Python-DX anymore, but I do have an executable of 2.0. I built it just for kicks, so there's no guarantees really, and you'll need to download the official 2.0 source which contains the standard library. I can send this executable to you if you want to. If more people are interested, I might consider putting a new page online with downloads and some info. Regards, --Hans Nowak (zephyrfalcon at hvision.nl) You call me a masterless man. You are wrong. I am my own master. May some hornox duel your Beatles records! From barry at zope.com Wed Jul 25 12:45:35 2001 From: barry at zope.com (Barry A. Warsaw) Date: Wed, 25 Jul 2001 12:45:35 -0400 Subject: PEP238 and zope References: <15198.56371.751100.459533@anthem.wooz.org> <m15PQoi-000wcBC@swing.co.at> Message-ID: <15198.63407.158009.6372@anthem.wooz.org> >>>>> "CT" == Christian Tanzer <tanzer at swing.co.at> writes: >> really-portable-code-is-always-ugly-anyway-ly y'rs, CT> So-lets-make-it-even-uglier-?-ly y'rs, I don't consider int(math.floor(a / b)) to be ugly. In fact, it's arguably much more Pythonic: Explicit is better than implicit. There's no ambiguity in intention with that idiom, like there is with bare a / b. -Barry From volucris at hotmail.com Sun Jul 22 04:11:33 2001 From: volucris at hotmail.com (Volucris) Date: Sun, 22 Jul 2001 03:11:33 -0500 Subject: Any Suggestions for an Editor with MS-Windows ? References: <92757716C8BFF476.D432477A795DB759.E2FB05E062137965@lp.airnews.net> Message-ID: <3b5a8a87$0$320$6e49188b@news.goldengate.net> You can find ActivePython here: http://aspn.activestate.com/ASPN/Downloads/ActivePython/ It has PythonWin, a very good editor. If that's what you're looking for. -- Volucris (a) hotmail.com "Eu n?o falo uma ?nica palavra do portugu?s." "zeke" <Zeke at xyz.net> wrote in message news:92757716C8BFF476.D432477A795DB759.E2FB05E062137965 at lp.airnews.net... > Am almost half way through the manual and getting ready for the easy > job of bringing over some basic files (yea, right). Currently using > Ultra Edit but having doubts about it. > zeke > From machin_john_888 at hotmail.com Sat Jul 14 18:36:52 2001 From: machin_john_888 at hotmail.com (John Machin) Date: 14 Jul 2001 15:36:52 -0700 Subject: converting from perl: variable sized unpack References: <roy-B2459F.22112513072001@news1.panix.com> <3B4FD35A.26B4568E@Lugoj.Com> <roy-B49CE8.09521914072001@news1.panix.com> Message-ID: <92ae279c.0107141436.31407065@posting.google.com> Roy Smith <roy at panix.com> wrote in message news:<roy-B49CE8.09521914072001 at news1.panix.com>... > James Logajan <JamesL at Lugoj.Com> wrote: > > This may not be the most elegant or efficient, but how about this: > > > > [f1, f2, f3, f4, f5, f6] = (string.split (line) + 6*[None])[:6] > > Yeah, that's what I had come up with, but I was hoping somebody would have > an idea that was more elegant and efficient :-) Strive for correctness first, then worry about elegance and efficiency -- this "solution" does not fulfill your original request that the extra fields be populated with null strings; it drops None objects in instead. From aleaxit at yahoo.com Wed Jul 4 12:38:56 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 4 Jul 2001 18:38:56 +0200 Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <9htgsb$ck3@news1.gtech.com> <9huo4n01jfl@enews1.newsguy.com> <slrn9k605n.esf.jajvirta@sirppi.helsinki.fi> <9hv9pl$5c7$1@panix6.panix.com> <56f6kt4goieognhbpi8i8kh4v79egmtaa2@4ax.com> Message-ID: <9hvgr202d1v@enews1.newsguy.com> "Courageous" <jkraska1 at san.rr.com> wrote in message news:56f6kt4goieognhbpi8i8kh4v79egmtaa2 at 4ax.com... > > >>b) Very good professional programmers are ten times as productive as > >> poor ones, at same training and two-year experience level. > >> (Sackman, Grant and Erickson) > > I agree with this wholeheartedly, with the exception that I would change > it to "Highly motivated and very good professional...". Motivation and Can we make it "Highly motivated and very good professionals in an optimal enviroment"...? At which point the 10-times estimate is VERY restrictive, as Prechelt's study shows. > a willingness to really throw oneself into programming is an essential > element of a real programming maverick. But the best & highest-motivated guru can only do so much if hampered by too-heavy process, inadequate tools, &c. And one can't always choose (client needs given process and tools, but motivation is high anyway e.g. because of VERY good $$ bonus... that still doesn't give the same productivity as when process and tools are optimally chosen). Alex From ssthapa at classes.cs.uchicago.edu Fri Jul 13 09:28:00 2001 From: ssthapa at classes.cs.uchicago.edu (Suchandra Thapa) Date: Fri, 13 Jul 2001 13:28:00 GMT Subject: LAMBDA IS IT USELESS? References: <tO837.679712$166.14009323@news1.rdc1.bc.home.com> Message-ID: <slrn9ktu24.8c3.ssthapa@hepcat.telocity.com> EricIDLE <grayson-wilson at home.com> wrote: >Ok well I dont quite grasp the Lambda concept heres an example. [...] > >Isnt that easier?? > >Or do I not get lambda? > >*NOTE ... I think its just a way to complicate things OR just a way to avoid >typing the function name beacuse.... I dont know they are scared of the >names they give them. The lambda can be a way to avoid the need to define and name trivial functions that get used in only one place. However, the lambda function is a also a way to dynamically create functions as well as a way of composing two functions together. For example, suppose you need to apply a scaling factor to a list but the scaling factor depends on user input. In this case, with lambda you can do a with lambda x: x * s where the value of s depends on the user input. Also, suppose you have two image filters and you want to create a new filter that applies the first filter then the second one. Then using lambda, you can just use lambda x: filter2(filter1(x)). Incidentally, you can use lambda to do a bunch of different things including reducing the number of parameters a function takes (currying). E.g. suppose foo takes x, y, and z then lambda x, y:foo(x, y, 4) returns a function that takes only two paramters. Basically, think of lambda as a way of applying mathematical operations like +, /, * as well as a few others to functions. -- ---------------------------------------------------------------------------- | 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 tjreedy at home.com Thu Jul 12 01:06:36 2001 From: tjreedy at home.com (Terry Reedy) Date: Thu, 12 Jul 2001 05:06:36 GMT Subject: Language change and code breaks References: <wuN27.13377$Y6.4240331@news1.rdc2.pa.home.com> <cplmlvh6dx.fsf@cj20424-a.reston1.va.home.com> Message-ID: <wfa37.18$Z6.28801@news1.rdc2.pa.home.com> "Guido van Rossum" <guido at python.org> wrote in message news:cplmlvh6dx.fsf at cj20424-a.reston1.va.home.com... > Very good sumary, Terry. I'm beginning to get second thoughts about > integer division -- maybe it's better to leave well enough alone, and > try to fix areas of the language that could really stand some fixing > (such as subclassing built-in types). > > --Guido van Rossum (home page: http://www.python.org/~guido/) --- Thanks for the response. My specific comments (for today) on int division are in the PEP 0238 thread. My general view on arithmetic change is this: while your design for Python's arithmetic has served well for a decade, without any change that I can think of, there are several dissatifactions and proposals for modification. Many involve semantic replacement, with its accompanying problems. If you are not going to reject them all indefinitely, then we should discuss, debate, plan, and experiment for several months to a year to come up with a coherant new design for Python arithmetic that we can install all at once and then live with for several more years without further change. Piecemeal change release after release could become very messy. Terry J. Reedy From sheila at spamcop.net Sun Jul 22 21:59:59 2001 From: sheila at spamcop.net (Sheila King) Date: Mon, 23 Jul 2001 01:59:59 GMT Subject: subclassing Exceptions References: <88gmltsdpn4brhtr7ng71b7c22qqlhlfac@4ax.com> <mailman.995839778.19397.python-list@python.org> Message-ID: <271nltoop99epq3hi76prqm5gq38qn21te@4ax.com> On Sun, 22 Jul 2001 18:08:09 -0400, "Tim Peters" <tim.one at home.com> wrote in comp.lang.python in article <mailman.995839778.19397.python-list at python.org>: :You don't have to defend yourself -- Guido will do it for you <wink>. He :opened a bug report on SourceForge today: : : #443559 creating exceptions is underdocumented : :and attached one of your first msgs as evidence. This area is indeed :"underdocumented". Thanks. I needed that. <big grin> Look, maybe after I've figured out exceptions, I can write up my own understanding of them, and see how that flies? -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From mail at fredriks.org Tue Jul 10 12:41:40 2001 From: mail at fredriks.org (Fredrik Stenberg) Date: Tue, 10 Jul 2001 18:41:40 +0200 Subject: getting argument names from a function In-Reply-To: <6%F27.4784$yh2.453987@weber.videotron.net> References: <6%F27.4784$yh2.453987@weber.videotron.net> Message-ID: <Pine.SOL.4.30.0107101835460.10785-100000@my.nada.kth.se> On Tue, 10 Jul 2001, dan wrote: > def aFunction(arg1, arg2): > print arg1, arg2 > > is there a way I can get to the arguments of aFunction (i.e. 'arg1' and > 'arg2')? > > I've tried dir(..) on the function object and subsequent object and can't > find what I'm looking for. Is it possible to do what I want? > > thanks, > Dan If the function has a func_code object you can try this approach, I have never use it myself and there probably is better ways. Use Ctrl-D (i.e. EOF) to exit. >>> def foo(bar,bar2): ... print "foobar" ... >>> foo.func_code.co_varnames ('bar', 'bar2') I think this will only work for functions written in python, and not extensions written in C (atleast thats what my brain thinks). /fredriks From bsb at winnegan.de Fri Jul 6 09:23:06 2001 From: bsb at winnegan.de (Siggy Brentrup) Date: 06 Jul 2001 15:23:06 +0200 Subject: any books for python for downloading? In-Reply-To: <994422510.510089@athnrd02.forthnet.gr> References: <993939668.727430@athnrd02.forthnet.gr> <0yX%6.1611$h45.10769@news.uk.colt.net> <994422510.510089@athnrd02.forthnet.gr> Message-ID: <87r8vu2nut.fsf@winnegan.de> Hi, first of all, why do you post this message 3 times? "whats_really_hot" <whats_really_hot at hotmail.com> writes: > yea.great sites but they don't have any books for downloading, only for web > reading and this requires time -internet time, which is unfortunately > expensive. If you have access to a *nix box, use wget(1), if you're on Windoze, do a Google search for "offline web browser": http://www.google.com/search?hl=en&safe=off&q=offline+web+browser Using such a beast might reduce your online bill. Regards Siggy -- Siggy Brentrup - bsb at winnegan.de - http://www.winnegan.de/ ****** ceterum censeo javascriptum esse restrictam ******* From tjreedy at home.com Sat Jul 21 01:47:16 2001 From: tjreedy at home.com (Terry Reedy) Date: Sat, 21 Jul 2001 05:47:16 GMT Subject: Most efficient solution? References: <mailman.995289809.28477.python-list@python.org><slrn9l5urp.nto.alf@leo.logilab.fr><OeF47.11959$p7.3571067@news1.rdc2.pa.home.com><wkk813nz6e.fsf@mail.connact.com><mailman.995662297.13101.python-list@python.org><E6367.7541$EP6.2460187@news1.rdc2.pa.home.com> <mailman.995674715.6446.python-list@python.org> Message-ID: <EH867.9011$EP6.2837134@news1.rdc2.pa.home.com> "Christopher A. Craig" <com-nospam at ccraig.org> wrote in message news:mailman.995674715.6446.python-list at python.org... > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > "Terry Reedy" <tjreedy at home.com> writes: > > > To compare program running times, they should compute the same thing. > > > > How long does dict2 take if you remove the not, so it makes the list > > of 1500 elements that revised dict does, instead of the 'not' list of > > 6000? > > > > How long does dict take if you feed filter with 'lambda x, > > f=c.has_key: f(x)', so it make the 'not' list of 6000 elements? > > > > dict2 without the not takes (predictably) about twice as long as dict > (.038 seconds vs. .019) (because the explicit loops in the list > comprehensions are slower) > > dict with a not takes (also predictably) slightly longer than dict2 > (.06 vs .055) (because the overhead of a lambda is higher than the loops) > > My point was not to compare dict to dict2, but to show that the > original author's comp() was greatly outperformed by a proper > dictionary solution. I know this was not your main point, so thank you for running these. I'm going to replace 1.5.2 with 2.1.1 soon, so could not do this myself yet. Your result is about what I expected based on previous comparisons. TJ Reedy From alank at algintech.NOSPAM.com Mon Jul 9 14:18:34 2001 From: alank at algintech.NOSPAM.com (Alan Klietz) Date: Mon, 9 Jul 2001 13:18:34 -0500 Subject: typo.py - Warn of typographical errors in Python scripts References: <XGk27.111$S23.104714@news.uswest.net> <15177.59858.853310.961010@beluga.mojam.com> Message-ID: <jzm27.359$q7.211304@news.uswest.net> Thanks for the pointer. I did some quick comparisons and found that PyChecker does overlap somewhat. It doesn't check typos quite as aggressively, however. For example: class Square: def __init__(self, width, height): self.width = width self.height = height def calculate_area(self): return self.width * self.height def Run(): s = Square(10, 20) c = s.calculate_areaa() # oops print s.hieght # oops import os print os.path.sep # oops PyChecker does do extra checking in areas not related to typography: omitted doc strings, unused vars, return types, etc. I agree it is a useful tool. Probably for the most rigorous checking would be to use a combination of both typo.py and PyChecker. Regards, -Alan alank at algintech.NOSPAM.com "Skip Montanaro" <skip at pobox.com> wrote in message news:15177.59858.853310.961010 at beluga.mojam.com... > > Alan> You can download typo.py from http://utools.com/typo.htm > > Doesn't PyChecker already do this sort of thing? > > -- > Skip Montanaro (skip at pobox.com) > (847)971-7098 From DOUGS at oceanic.com Sun Jul 15 12:52:02 2001 From: DOUGS at oceanic.com (Doug Stanfield) Date: Sun, 15 Jul 2001 06:52:02 -1000 Subject: greenbeen seeks advice Message-ID: <8457258D741DD411BD3D0050DA62365907A975@HUINA> [wyatt stafford wrote:] > I bought "Learn > to Program using Python" (Gauld) and "Quick Python" > (Harms/McDonald). Also > checking out the tutorial, and other good info at > www.python.org. Don't miss the references there to the Python Tutor mailing list. Go here, http://mail.python.org/mailman/listinfo/tutor to subscribe. HTH, -Doug- From paul at boddie.net Tue Jul 10 12:20:40 2001 From: paul at boddie.net (Paul Boddie) Date: 10 Jul 2001 09:20:40 -0700 Subject: Augmented Assignment (was: Re: PEP scepticism) References: <Pine.LNX.4.33.0106281419260.11263-100000@bms> <mailman.993764502.10834.python-list@python.org> <cpae2rlarx.fsf@cj20424-a.reston1.va.home.com> <mailman.993841846.2132.python-list@python.org> <cpsngijfcg.fsf@cj20424-a.reston1.va.home.com> <hpjsjt04gj33rbcbpurvv2mbiknuqf6fob@4ax.com> <mailman.993964021.7787.python-list@python.org> <8pkujt04pv49fvklj6n8jv61fl177kv6c4@4ax.com> Message-ID: <23891c90.0107100820.1068b146@posting.google.com> Courageous <jkraska1 at san.rr.com> wrote in message news:<8pkujt04pv49fvklj6n8jv61fl177kv6c4 at 4ax.com>... > >I don't always have the opportunity to talk to people and explain > >confusing things to them. In one class I gave, a guy let out a gasp when > >he came to understand the reference rules. He said that that was what > >had prevented him from coming to understand Python the first two times > >he tried. Now I think we've made life harder for guys like that to save > >Numeric Python users from typing a method call for their mutations. > >That's a poor trade-off. > > Sure; I can buy this argument. I'm not a big fan of the ongoing lexical/ > grammatical expansion of Python. What scares me is that, whilst I don't use Python at work but do have some interest in experimenting a fair amount with it on my own machine at home, it's very likely that Python 2.1 will completely pass me by (for real use) and, at some point in the not-too-distant future, the code that I have for Python 2.0 will break mysteriously under 2.2 (or an even later release which could appear within the year) which I'll probably have been forced to use because some modules will require it. At that point, I'm sure that everyone will say how fluidly the transition from release to release has been, but that won't be a consolation for people who neither need nor want to indulge in "version surfing". If it hadn't been for Unicode support and Pygame, I'd probably have stuck with 1.5.2 until now. It's bad enough when APIs are changing frequently, like in the earlier days of Java, but it's downright scary when a language starts to (or has the potential to) change so quickly. Programmers are raised on the idea that languages are stable and glacially-slow moving targets, but people do seem to fear that there's now a substantial melting process taking place with Python. Paul From max at alcyone.com Thu Jul 12 22:01:04 2001 From: max at alcyone.com (Erik Max Francis) Date: Thu, 12 Jul 2001 19:01:04 -0700 Subject: pythonista.com References: <mailman.994955667.9160.python-list@python.org> <lbl37.161430$Mf5.43742860@news3.rdc1.on.home.com> <oYl37.1089$%6.234079@news1.rdc2.pa.home.com> Message-ID: <3B4E5660.82848022@alcyone.com> Terry Reedy wrote: > Probably easiest and cheapest to let it expire and reregister the next > day. There are lots of "services" that will immediately reregister a domain as soon as it expires, so even if you're watching it is very easy to miss it -- and once you do you're going to have to buy it off a third party. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Gods are born and die, but the atom endures. \__/ Alexander Chase blackgirl international / http://www.blackgirl.org/ The Internet resource for black women. From new_name at mit.edu Mon Jul 2 22:47:11 2001 From: new_name at mit.edu (Alex) Date: 02 Jul 2001 22:47:11 -0400 Subject: Is Python Dead? References: <MNS%6.355$Xs4.225014@news.pacbell.net> <3B411339.6DADAFF0@yahoo.com> Message-ID: <etdvglag24w.fsf@w20-575-3.mit.edu> > I don't understand why people are replying to this troll. I didn't recognize it as such, at first. :) Alex. From 18k11tm001 at sneakemail.com Thu Jul 5 03:56:40 2001 From: 18k11tm001 at sneakemail.com (Russ) Date: 5 Jul 2001 00:56:40 -0700 Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> <9hrj3q$cj1@news1.gtech.com> <mailman.994199197.7049.python-list@python.org> Message-ID: <bebbba07.0107042356.20b76c21@posting.google.com> Carlos Ribeiro <cribeiro at mail.inet.com.br> wrote in message news:<mailman.994199197.7049.python-list at python.org>... > Many of the concerns raised on the group are related to memory-related > problems: allocation/deallocation and garbage collection, which can be an > plentiful source of bugs. I have some specific suggestions to deal with > them, which may or not be applicable in your case. > > - You can avoid allocation/deallocation in some languages by using static > structures, or by preallocating as much memory as possible. For example, > you could preallocate a vector to contain all the data from the aircrafts. > In this case you would have a maximum limit hardcoded in the software, but > this is not as bad as it may seem, because the limit is *deterministic*. > One of the problems of relying on dynamic allocation is that you never know > when it is going to fail, because it depends on the amount of memory > allocated for other purposes. This technique is can't be easily applied in > Python due to the nature of the language. It is still possible to do it in > some particular cases, but not as extensively as in C/C++. As I wrote in a recent post, I used this technique extensively in a real-time C++ application I worked on a few years ago (an integrated GPS/INS autoland system). We had an update rate of a few milliseconds, so we couldn't spare much memory management after startup. It works great as long as you have enough memory, and you usually do these days. Our update rate for this ATC application is on the order of a few seconds, but I will still be disappointed if I can't use this same technique in Python. I just don't like the idea of having the OS interupt at what could be an inopportune time. > - Don't rely on a long-running process for everything. Use multiple > short-running processes for batch-style tasks, and a lightweight dispatcher > to coordinate them. The batch-style tasks must be run on separate > interpreters. While the performance penalty may be not as acceptable for > many real-time tasks, you have one specific advantage: every new instance > of the interpreter always start with a fresh memory heap. This will allow > you to avoid fragmentation-related problems, which may happen on any > platform after a long time (not to mention Win98, where it *always* happen > in few time). Interesting idea. In actual operation, I'll bet we'll restart at least once per day, if not more. Thanks for your insights. Russ From mcherm at destiny.com Mon Jul 23 10:34:36 2001 From: mcherm at destiny.com (mcherm at destiny.com) Date: Mon, 23 Jul 2001 09:34:36 -0500 Subject: PEP0238 lament Message-ID: <ce05109ca.109cace05@destiny.com> Guido writes: > [...] > Because all Arthur does is tick me off, I'll leave it at this -- > maybe someone else can explain it all to him. Well, I'll see what I can do. In the language there are (at least) two distinct things we might want to do when "dividing" A and B: (1) split A up into B parts (2) find how many B's fit in an A A good example of (1) is float division, and the cannonical example of (2) is "int division", aka "div". These are DIFFERENT THINGS. For instance, if you are implementing a sort algorithm, you may well want (2) in a place where (1) will never do! On the other hand, if your program is performing CAD drawings, then (1) is probably the meaning you need. Note that (2) often makes most sense with integers (especially since it always gives out an integer), while (1) may make sense with floats, rationals, fixed-position decimals, as well as various other numerical types. So I'm hoping that everyone reading this can agree, BOTH (1) and (2) are USEFUL things, and a good language should allow BOTH. If not, then please stop reading: there's no way I can convince you. Given that you want both (1) and (2), there is just one problem: the syntax "A / B" is the ideal syntax for BOTH of these purposes. It's ideal for (1) because the mathematical operation of division is traditionally represented with a "/", and it's ideal for (2) because C and other languages have historically used "/" between integers for (2). In my opinion (and those of quite a few others), this is pretty lopsided: (1) is probably used more often, so it should get priority, PLUS just imitating C isn't very convincing since other languages (eg: Pascal) use other syntax, PLUS the use of division in mathematics is far more widespread and well-known than the use of "/" in C, PLUS the people who intend to use (2) will probably be able to remember to use a different symbol. So if you believe these arguments, then the next time you go out and invent a new language, you'll use "/" to mean (1), not (2). But Python is not a new language, and in existing versions of Python, "/" has meant (2) if both arguments were integers. To change this now is VERY bad, because it will break lots of existing code. It probably won't be hard for existing programmers to adapt, but having to repair all those old scripts is a VERY BAD THING. So Guido is trying to balance two things: the desire to use "/" to mean (1) in all cases, regardless of the type of its arguments, and the desire to keep Python stable, without breaking lots of existing code. The issue is important because we often see newbie bugs based on this issue, and because if the change is EVER going to happen, it HAS to be soon... the longer he waits, the more old scripts there are which will have to be broken. In the end, after hearing all of the arguments (and if you haven't spoken up yet I STILL suspect someone else has made your argument for you before in a previous usenet thread), Guido has apparently decided that the design improvement is worth breaking old scripts. Obviously, that means that tools and techniques (warnings, type inferring source checkers, etc) need to be provided which will help in that transition... but it'll still be painful. Guido is well aware of that, and I'm sure he approaches this with reluctance. But remember, there's a GOOD side too! After the trasnsition is over, the language will be (in one small way) even better than before. -- Michael Chermside From mikael at isy.liu.se Tue Jul 24 10:16:02 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Tue, 24 Jul 2001 16:16:02 +0200 (MET DST) Subject: re bad leadership In-Reply-To: <00af01c11440$87a53c20$0101010a@local> Message-ID: <XFMail.20010724161602.mikael@isy.liu.se> On 24-Jul-2001 Chris Gonnerman wrote: > ----- Original Message ----- > From: "Mikael Olofsson" <mikael at isy.liu.se> > > > > On 23-Jul-2001 Robin Becker wrote: > > > MDFL you are wrong! Give up gracefully now! > > > > I've seen BDFL referring to GvR, and I know the interpretation of that. > > Here, obviously, MDFL suddenly referres to the very same GvR. What's > > with that M? > > I'm guessing here, but I'd bet from the tone of his postings that Robin > means > > Malevolent Dictator For Life Of course! My English is obviously not good enough. > While I'm not happy with Guido over this change (because it makes cross- > version code very ugly, and introduces errors in meaning that may be hard > to detect) I would not call him such a rude name. Neither would I. I always thought of "GvR is the BDFL" as an axiom, which means that whatever he does regarding Python is benevolent. /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson <mikael at isy.liu.se> WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 24-Jul-2001 Time: 16:09:37 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From aleaxit at yahoo.com Fri Jul 13 08:28:42 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 13 Jul 2001 14:28:42 +0200 Subject: How to run codeobjects in Python? References: <mailman.995024902.7812.python-list@python.org> Message-ID: <9imphr015u5@enews1.newsguy.com> "Vesselin Peev" <vesselinpeev at hotmail.com> wrote in message news:mailman.995024902.7812.python-list at python.org... > Can anyone tell me how to use the so called "code objects" in Python, for ... You asked this 6+ hours ago under subject "How can I run precompiled code objects?" and I answered 26 minutes before you reposted. Have a little patience, already: netnews propagation delays and varying timezones mean it WILL take a little time for you to get answers! Alex From aleaxit at yahoo.com Tue Jul 3 12:05:07 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 3 Jul 2001 18:05:07 +0200 Subject: Python and DB support (was: Re: Is Python Dead?) References: <mailman.994168085.8709.python-list@python.org> Message-ID: <9hsqfl02gbd@enews1.newsguy.com> "Roman Suzi" <rnd at onego.ru> wrote in message news:mailman.994168085.8709.python-list at python.org... ... > >http://phplib.netuse.de/documentation/documentation-3.html#ss3.1 > >After studying that page a bit, unless I'm missing something, > >it appears to me that this interface is *VASTLY* inferior to > >the Python DB API. > > I do not believe it. PHP is so widely used with databases > that I cant believe it's database connectivity is that bad! As I said, I'm no PHP expert -- I hit on phplib because I saw it mentioned as the only way to program PHP in such a way that you won't have to redo everything if you move from one RDBMS to another, which to me feels like a very fundamental requirement. Maybe the typical PHP user cares not a whit about that and is deliriously happy to program against Oracle-only, or MySQL-only, or whatever -- I have not examined the widely different (I'm told) interfaces you get to use for that, only saw what seemed to me highly justified SQUEALS of pain by Perl programmers used to the RDBMS-portability of Perl's DBI at the idea of having to program against a _specific_ RDBMS and redo everything when (not if -- life doesn't work that way) the RDBMS that has to be used changes under them... Alex From qrczak at knm.org.pl Sat Jul 28 03:31:00 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 28 Jul 2001 07:31:00 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <eppstein-03540D.13070222072001@news.service.uci.edu> <LNBBLJKPBEHFEDALKOLCOECNLAAA.tim.one@home.com> <mailman.995899647.346.python-list@python.org> <tclolt053o18f8q0ntb7n4aggitdkmeg4h@4ax.com> <Io_67.23543$B7.3779351@ruti.visi.com> <slrn9lp2m5.vp.Gareth.McCaughan@g.local> <p56plt8q4rs3bgcqbepk61q2r3g0tr2vhe@4ax.com> <slrn9ls3ae.2fm.Gareth.McCaughan@g.local> <cpitghbq05.fsf@cj20424-a.reston1.va.home.com> <m2wv4xdxlf.fsf@mycroft.actrix.gen.nz> <slrn.pl.9ltfv2.241.qrczak@qrnik.zagroda> <m2wv4w5lj3.fsf@mycroft.actrix.gen.nz> <mailman.996130247.13985.python-list@python.org> <m2hevy4fsa.fsf@mycroft.actrix.gen.nz> <slrn.pl.9m33bh.a1o.qrczak@qrnik.zagroda> <m2r8v13gyn.fsf@mycroft.actrix.gen.nz> Message-ID: <slrn.pl.9m4qhk.eqf.qrczak@qrnik.zagroda> 28 Jul 2001 14:50:08 +1200, Paul Foley <see at below> pisze: > No, I know what you're intending, and you're right, it doesn't give > wrong answers. The problem is, it doesn't correspond to the type > graph you draw, either! Arrows don't mean subtypes but: 1. the direction of implicit conversions needed to perform some operations, 2. the fact that any function accepting a (say) rational should accept an integer with the same meaning wrt. the mathematical value, similarly for other types. It's not the question of a particular hierarchy but of the meaning of such diagram at all. It works the same way for all its type relations. Int is not a "subtype" of rational wrt. your meaning of subtypes. > *IF* rational is a subtype of float, it *should* be able to turn > floats into rationals, if they fit. There are no implicit conversions in this direction in other contexts either. Rationals never turn into ints in my model for example. > *IF* rational is a subtype of float, every rational should be > representable as a float. My model doesn't claim that these implicit conversions lose no information. Adding a large int to a float converts the int to a float which may truncate. It doesn't change the fact that it makes more sense to perform this lossy conversion than for example convert both to rationals, because the input float is inexact so the result will be inexact anyway (that is: its value is not quite true), so it should be treated as inexact (that is: represented in a type which is perceived as inexact). Your diagram doesn't tell how to add a float to a rational at all. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From gmcm at hypernet.com Thu Jul 19 19:44:56 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 19 Jul 2001 23:44:56 GMT Subject: Distributing a Python app References: <mailman.995572771.19528.python-list@python.org> Message-ID: <Xns90E3C8FCADDE6gmcmhypernetcom@199.171.54.194> Jay Parlar wrote: > I'm just wondering if anyone has any suggestions as to the best way to > distribute an application written in Python, intended for people who > don't have Python installed on their machines? Even possibly a > commercial distrubtion program, if it's the best. I've been playing > around with py2exe, with not much success (although that's a topic for > a different day). Assuming I do get py2exe working properly, how would > everyone suggest we distribute our application? (By the way, this > application is for Windows machines). I'm afraid that only Thomas (py2exe), Jack (macPython) and I (Installer) even think about that stuff. Everyone else distributes Python modules to people with existing Python installations. As far as a free Windows installer (for py2exe or Installer), Inno gets good reviews. I don't know anyone who can stand InstallShield. Wise is the commercial one most people use. - Gordon From piercew at hushmail.com Wed Jul 25 17:49:25 2001 From: piercew at hushmail.com (Wayne) Date: 25 Jul 2001 14:49:25 -0700 Subject: Going from webscripting to server-client software. References: <6572890e.0107251014.47e07810@posting.google.com> Message-ID: <9d848d5d.0107251349.68519652@posting.google.com> Shriek at gmx.co.uk (Stephen) wrote in message news:<6572890e.0107251014.47e07810 at posting.google.com>... ... > intranet and it was really easy. But it was possible for one of the > staff to be looking at a resource (eg. a squash court) and not > be aware of a booking made by another member of staff in real time, > which could lead to double-bookings if telephone bookings are made. > They do not like to hit refresh in order to see the most up to date > status of a particular resource. They want software more like > Windows-applications. Have you considered a small applet that displays the status of the currently viewed resource? This might be created in Jython and automatically update from the server at a specific interval. > How should I keep all of the client applications in synchronization > with each other? When each client app is opened, it gets all the > bookings for the day from the server. Are they able to edit the bookings once the data has been downloaded? i.e., do they get the data in "read only" mode then click on a button or link to edit the data? If so you might create a lock file, or similar item, on the server when someone clicks on the edit button or link. If anyone after that clicks on the edit button it could check for the existance of the lock file. If the file is present they might see the current information and who has it locked but not be able to edit the information. Wayne From bill-bell at bill-bell.hamilton.on.ca Sat Jul 21 08:53:40 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Sat, 21 Jul 2001 08:53:40 -0400 Subject: whats this mean? In-Reply-To: <995680671.491.75448.l9@yahoogroups.com> Message-ID: <3B594314.6161.27E3255@localhost> thedustbustr at aol.com (TheDustbustr) wrote, in part: > # BEGIN CODE BLOCK > try: > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > s.bind((HOST, PORT)) > s.listen(1) > conn, addr = s.accept() > except socket.error, why: ## reference 1 > print "Server Error: " + errno.errorcode[why[0]] + ", " + why[1] > ## > reference 2 > sys.exit(1) > # END CODE BLOCK > > what does reference 2 mean? what do those brackets do? And for > reference 1, what will 'why' hold if an error occurs? Dustin, Consider the following code that is similar to what you included in your message. from errno import * import socket try: raise socket.error ( 1, "an error message" ) except socket.error, why: print why print why [ 0 ] print why [ 1 ] print "Error: " + errno.errorcode[why[0]] + ", " + why[1] I have replaced the sockets code with a 'raise' statement that does what the sockets code would do in case of an exception. When I executed this code I got the following output: (1, 'an error') 1 an error Error: EPERM, an error ie, one line for each 'print' statement in the exception suite. 1. 'why' will contain a tuple whose elements are the arguments passed to the procedure socket.error 2. 'why[0]' is the first element in the tuple and thus is the first argument to socket.error; likewise 'why[1]' will contain the second argument. 3. 'errno.errorcode' supplies the os-specific code (ie the code that is meaningful for the os) corresponding to the value of the first argument to 'socket.error' A pair of brackets indexes into the expression to the left of the pair. For example, '[0]' in 'why[0]' returns the 0th item in 'why'. How well does this clarify the code? Bill From philipprw at gmx.at Fri Jul 13 08:42:44 2001 From: philipprw at gmx.at (Philipp Weinfurter) Date: 13 Jul 2001 12:42:44 GMT Subject: Comparison of different types does not throw exception References: <mailman.994953783.6278.python-list@python.org> <O4A37.23$Fv3.59@news1.oke.nextra.no> Message-ID: <slrn9ktr6c.1n8.philipprw@chello213047126184.14.univie.teleweb.at> On Fri, 13 Jul 2001, Nils O. Sel?sdal <noselasd at frisurf.no> wrote: > "Gordon Williams" <g_will at cyberus.ca> wrote in message >> I would like to know why python does not produce an exception when a >> comparison of objects of different types is made. For example: >> >> >>> 1 < "aaa" >> 1 [...] > In any OO language its desired to take advantage og polymorphisme, > and let comparison between diffrent objects be allowed.The programmer > is responsible, > for providing comparison functions. > I wanna know if my User also equals my SecureUser.... hmm, i'm still new to python, so please correct me if i'm wrong here. but since you can not subclass `integer' and `string' (and override the comparison operators for those types), there is not much polymorphism here. and as the language reference states: "Otherwise, objects of different types always compare unequal, and are ordered consistently but arbitrarily." i, too, think that this doesn't make much sense. philipp From qrczak at knm.org.pl Tue Jul 24 14:15:53 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 24 Jul 2001 18:15:53 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <mailman.995989601.30748.python-list@python.org> <slrn.pl.9lrdbk.ae3.qrczak@qrnik.zagroda> <Xns90E8BFE339C47michaelrcpcouk@194.168.222.9> Message-ID: <slrn.pl.9lreqp.186.qrczak@qrnik.zagroda> Tue, 24 Jul 2001 17:55:14 GMT, Michael Abbott <michael.g.abbott at ntlworld.com> pisze: > sqrt(2)**2 == 2 > > By pretty much the same arguments as have been used elsewhere in this > discussion, I'm sure that you would expect this to evaluate to true. Why? -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From me at charliedaniels.com-1.net Sun Jul 15 00:28:21 2001 From: me at charliedaniels.com-1.net (chajadan) Date: Sun, 15 Jul 2001 04:28:21 GMT Subject: accessing the clipboard in windows and/or linux Message-ID: <3b511bae.1235716@news.mailops.com> I want to be able to access the clipboard for Windows, and also linux. Using python of course. If you know how, please pass this knowledge on to me. Thanks =) --chajadan From aahz at panix.com Fri Jul 6 22:21:57 2001 From: aahz at panix.com (Aahz Maruch) Date: 6 Jul 2001 19:21:57 -0700 Subject: PEP: Procedure for Adding New Modules (please comment) References: <9hvqhr$gj2$1@newshost.accu.uu.nl> <B7695827.13DAA%dgoodger@bigfoot.com> <9i1pd8$8ei$1@newshost.accu.uu.nl> Message-ID: <9i5ro5$arv$1@panix3.panix.com> In article <9i1pd8$8ei$1 at newshost.accu.uu.nl>, Martijn Faassen <m.faassen at vet.uu.nl> wrote: >David Goodger <dgoodger at bigfoot.com> wrote: >> Martijn: >>> >>> The library PEP differs from a normal standard track PEP in that >>> the reference implementation should in this case always already >>> have been written before the PEP is to be reviewed; the reference >>> implementation _is_ the proposed contribution. >> >> By "to be reviewed" do you mean "to be decided upon by the >> Integrators"? Or "to be released to the Python community for >> comment"? I hope the former. Please clarify. > >The former, I shall clarify, thank you. Actually, I think it should be both, just as with all standard PEPs. That is, the PEP is reviewed and commented upon by the community, but the Integrators (as proxies for Guido, BDFL) make the final decision about whether to include it. -- --- 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 So much Astroglide. So little time. From aleaxit at yahoo.com Mon Jul 2 12:04:19 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 2 Jul 2001 18:04:19 +0200 Subject: Is Python Dead? References: <MNS%6.355$Xs4.225014@news.pacbell.net> <mailman.994049882.30354.python-list@python.org> <9hp1f002dp6@enews4.newsguy.com> <mailman.994078809.12040.python-list@python.org> Message-ID: <9hq62g0kiq@enews4.newsguy.com> "Chris Gonnerman" <chris.gonnerman at newcenturycomputers.net> wrote in message news:mailman.994078809.12040.python-list at python.org... ... > > "Chris Gonnerman" <chris.gonnerman at newcenturycomputers.net> wrote in > message > > news:mailman.994049882.30354.python-list at python.org... > > ... > > > When am I forced? Sadly it seems that integrating any other language > > > directly into MS Access is out of the question. (Am I wrong? Someone > > > please tell me if I am!) > > > > Depends what you mean by "directly". With COM and ActiveScripting, > > it's generally not a problem to use Python or other AS-compliant languages > > with any Office or other Automation-enabled app, albeit with a simple > > passage through VBA or VBScript. > > Define "simple"... what I want is to drop in Python in place of VBA. I'm > still not sure it's possible. I agree it's not possible to "drop in Python _in place of_ VBA" -- tricking MS Access (or other office app) into using other DLL's in lieu of the ones it's linked-to would be anything BUT simple (or solid:-). What I do mean by "simple" is, the (e.g.) code that responds to the (whatever) event is still in VBA, but all it does is delegate the call right to a Python object. > > > The only other time is when I must work with dBase tables... but I would > > > hardly typify that as not being "good database support". > > > > http://www.stud.ifi.uio.no/~larsga/download/python/ > > I can't get this URL to work... I am getting Forbidden errors. Darn, it's giving forbidden errors to me too, right now, it worked the other day. I haven't tried it, but maybe http://www.fiby.at/dbfpy.tgz may help you -- or perhaps the idea of using ODBC (or ADO/OleDB, etc) to access the dBase files remains better. Alex From bokr at accessone.com Sun Jul 8 23:02:27 2001 From: bokr at accessone.com (Bengt Richter) Date: Sun, 08 Jul 2001 20:02:27 -0700 Subject: Comment on PEP-0238 In-Reply-To: <20010709015224.Q8098@xs4all.nl> References: <3b48de4e.1402626870@wa.news.verio.net> <mailman.994427714.26169.python-list@python.org> <cpsngaja4g.fsf@cj20424-a.reston1.va.home.com> <FFv17.1178$Y6.656565@news1.rdc2.pa.home.com> <cpelrskgrr.fsf@cj20424-a.reston1.va.home.com> <9i7a7k$h9ks6$1@ID-11957.news.dfncis.de> <cp4rsok3i7.fsf@cj20424-a.reston1.va.home.com> <mailman.994531918.7040.python-list@python.org> <9i8512$haelg$1@ID-11957.news.dfncis.de> <cpk81jip74.fsf@cj20424-a.reston1.va.home.com> <3b48de4e.1402626870@wa.news.verio.net> Message-ID: <5.0.2.1.1.20010708185646.023c9640@mail.accessone.com> At 01:52 2001-07-09 +0200, Thomas Wouters wrote: >On Sun, Jul 08, 2001 at 10:45:12PM +0000, Bengt Richter wrote: > > > Why not parameterize the concept with a single block-scope-introducing > > keyword, e.g., 'semantics' or 'special' e.g., rewriting from above: > > > semantics PRECISION, 0: # everything behaves as it does now > > print 2 / 7 # -> 0, ie to precision 0 decimal places > > print 2/7.0 # -> 0.285714285714 > > > semantics PRECISION 1: # all calculations yield 1 decimal point > > print 2 / 7 # -> 0.2, ie to precision 1 decimal places > >Doesn't fix the problems. What about this: > >semantics PRECISION, 0: > x = 2/7 > >semantics PRECISION, 100: > print x I'm thinking that's trying to peek from one nested scope into another, and would be either illegal, trigger a special exception, or get you a NameError. I haven't thought this through, but that was part of the reason for a block rather than just setting global control parameters. I think only new bindings would be affected. Rebinding global names to stuff created within a semantic scope might have to carry environment along. I haven't thought that through either ;-) Regards, Bengt Richter P.S. I'm not a list subscriber, just reading the newsgroup, so I'm not sure what is going where, but this is an email reply with cc to list. Hope that's ok ;-) From njm at rectec.net Mon Jul 16 10:09:31 2001 From: njm at rectec.net (NJM) Date: Mon, 16 Jul 2001 09:09:31 -0500 Subject: timed event?? Message-ID: <tl5t1fprkuobd@corp.supernews.com> I want to write a program that does things on a timed basis. Can someone tell me where is the best place to start? I can't seem to find any modules that will help me. From tjreedy at home.com Fri Jul 13 15:50:04 2001 From: tjreedy at home.com (Terry Reedy) Date: Fri, 13 Jul 2001 19:50:04 GMT Subject: not safe at all References: <mm8tkt4te3qnbpv3nh5nhsi591o1osln73@4ax.com> <slrn9ku3c3.mrk.9nick9m@localhost.localdomain> Message-ID: <MhI37.2619$p7.719925@news1.rdc2.pa.home.com> > I believe it, but it doesn't demonstrate a thing about type safety. > You've just discovered dynamic typing. This might be better called dynamic naming or dynamic binding. 'Dynaming typing' is confusing, as evidenced here, because of its two possible interpretations. 1. Types are assigned at runtime (because they are created at runtime). True. 2. Types are changeable at runtime. Untrue, unless you count changing an instance's base class (a recent addition to the language. In this sense, Python object types are fixed or static. They are not like C unions. > You see, your implied view of > typing seems to come from a statically typed language, where every > *variable* has a type of its own. > > In Python, types are associated with *objects*, not with *variables*. > IOW, all variables are of the same type: reference-to-object. One of the keys to understanding Python. Terry J. Reedy From greg at cosc.canterbury.ac.nz Thu Jul 19 23:32:47 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 20 Jul 2001 15:32:47 +1200 Subject: Language change and code breaks References: <mailman.995378792.16515.python-list@python.org> <cpvgkq1f2b.fsf@cj20424-a.reston1.va.home.com> <_bh57.32695$d4.1090608@e420r-atl1.usenetserver.com> <9j4a6e0cpu@enews4.newsguy.com> <3B566ED8.E14732F8@cosc.canterbury.ac.nz> <9j5u2302v3e@enews3.newsguy.com> Message-ID: <3B57A65F.BDB6BAE5@cosc.canterbury.ac.nz> Alex Martelli wrote: > > I think it was a 19th century fancy, to start with. Extremely > recent when compared to the amount of time mathematics > has been written about. It's still a lot longer than computers have been around. And the fact that they *did* adopt it suggests they found it useful in some way. Perhaps because it let them express things more succinctly? They seem to be satisified with the decision, too. I've never heard a group of mathematicians debating whether mathematics should go back to being case-insensitive (if it ever really was to begin 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 sill at optonline.net Wed Jul 11 16:34:17 2001 From: sill at optonline.net (Rainy) Date: Wed, 11 Jul 2001 20:34:17 GMT Subject: Long Live Python! References: <mailman.994874959.29064.python-list@python.org> Message-ID: <slrn9kpe08.496.sill@sill.silmarill.org> On Wed, 11 Jul 2001 12:10:43 -0600 (MDT), Bruce Sass <bsass at freenet.edmonton.ab.ca> wrote: > On Wed, 11 Jul 2001, phil hunt wrote: >> On Tue, 10 Jul 2001 15:31:11 -0700, Paul Prescod <paulp at ActiveState.com> wrote: > <...> >> >Python does not have a niche and is not obviously a niche-friendly >> >language. >> >> Sure it does: python's niche is as a scripting language that's also good >> for longer programs. > > Hehe, you must have missed the recent thread about removing the first > line from a text file... I thought it showed that Python is a horrible > scripting language, way too verbose, it turned what should be a few > lines of script into a program. Wasn't one solution only 2 lines? If I remember right it was Alex Martelli's. -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: http://silmarill.org/cymbaline From kirschh at lionbioscience.com Thu Jul 12 02:46:39 2001 From: kirschh at lionbioscience.com (Harald Kirsch) Date: 12 Jul 2001 08:46:39 +0200 Subject: shortest match regexp operator anyone? References: <yv266cz4aom.fsf@lionsp093.lion-ag.de> <3b4c9b7f.8143238@news.hrz.uni-kassel.de> <9ii8a2$hg6$1@macareux.ens-lyon.fr> Message-ID: <yv2wv5e3ar4.fsf@lionsp093.lion-ag.de> ejeandel at ens-lyon.fr (Emmanuel Jeandel) writes: > > 1) It doesn't solve the intellectual challenge. > > What about : ([^<]|(<+(A<+)*([^A<]|(A[^<>]))))*<+(A<+)*A>B ? Woow, seems to work. Did you fiddle around long enough by hand or is it the result of a formal construction? In the latter case it should be easy to write a script which, given a string s, results in a regexp matching t s where t does not include s. >From the construction I expect the resulting regexp to have a length of O(2^len(s)). Harald. -- ----------------+------------------------------------------------------ Harald Kirsch | kirschh at lionbioscience.com | "How old is the epsilon?" LION bioscience | +49 6221 4038 172 | -- Paul Erd?s *** Please do not send me copies of your posts. *** From danb at champonline.com Fri Jul 20 14:26:21 2001 From: danb at champonline.com (Dan Bergan) Date: Fri, 20 Jul 2001 13:26:21 -0500 Subject: Case insensitivity References: <mailman.995647175.15752.python-list@python.org> <3B5867E8.6B8751F8@Lugoj.Com> Message-ID: <096101c11149$7a512e70$1164a8c0@champ17> > Dan Bergan wrote: > > (Declare the variable in mixed-case) > > Dim myVariable as Integer > > > > (then I purposely type in the wrong case when I use 'myVariable') > > myvaraible = 1 '<==TYPO! > > Well, if you "correct" that to myVaraible you would still be in error, > because you accidentally exchanged "ia" with "ai" in addition to changing > "V" to "v". Python will not inform you about about some typos, whether > case-related, dropped characters, exchanged characters, or added characters. I think you missed my point a bit. VB would NOT correct the typo (because it does not match a variable name that is already declared). So, I use the fact that it was NOT corrected as a flag that I screwed something up. Dan From tim.one at home.com Tue Jul 10 01:18:16 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 10 Jul 2001 01:18:16 -0400 Subject: Language Shootout In-Reply-To: <3b4a468d.1494788532@wa.news.verio.net> Message-ID: <LNBBLJKPBEHFEDALKOLCGEFIKNAA.tim.one@home.com> [Bengt Richter] > ... > I just did a python recursive fib(100000) in > just over 15 seconds, including startup and > printing to screen, by my watch. (Not a typo, > that was 100k). Of course, it might not be the > usual recursive solution (see below) ;-) > ... > It's a close translation of a scheme version I came > up with about five years ago. Dave Ulrich may remember. > He pointed out that the next to last version wasn't > doing what I thought. So he helped nudge it into being. > Never did establish what wheel I was reinventing, but > apparently there is something related. Cute! For "something related", see Knuth section 4.6.3 exercise 26. Apart from tricks specific to Fibonacci numbers, a general "good thing to know" is that an order-N linear recurrence can be viewed as mapping N-vectors to N-vectors via multiplication by a fixed NxN matrix M. N==2 in this case, and if a,b,c are consecutive Fibonacci numbers then [b c] = [a b] * M where "*" is matmult and M is 0 1 1 1 That's why your program wound up with expressions that look a lot like 2-term dot products: they are <wink>! Moving ahead k steps is essentially equivalent to computing M**k, and that can be done in "the usual" way via O(log(k)) 2x2 matmults. This has practical application in, e.g., many kinds of recurrence-based random-number generators, for "skipping ahead" a huge number of terms very quickly. From sholden at holdenweb.com Fri Jul 6 13:30:46 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 6 Jul 2001 13:30:46 -0400 Subject: Marking a Python COM server safe for Internet Explorer References: <mailman.994434612.10076.python-list@python.org> Message-ID: <Kxm17.11707$F%5.789485@e420r-atl2.usenetserver.com> "Bill Bell" <bill-bell at bill-bell.hamilton.on.ca> wrote in ... > > As a kind of default, Internet Explorer will ask the user's permission > before instantiating an ActiveX control. However, one can > implement IObjectSafety to inform IE that one's control is safe, > thus sparing the user the need to respond to the dialog box. > I must have misunderstood. Are you telling me that IE has a security system to detect potentially unsafe downloaded content, but that it won't use this system if the downloaded content tells it there's no need? How very Microsoft. I must have missed something. regards STeve -- http://www.holdenweb.com/ From Arthur_Siegel at rsmi.com Fri Jul 27 16:22:29 2001 From: Arthur_Siegel at rsmi.com (Arthur_Siegel at rsmi.com) Date: Fri, 27 Jul 2001 15:22:29 -0500 Subject: Language change and code breaks Message-ID: <0088D6B5.N22121@rsmi.com> Guido writes - >Actually, it's been very tough. Years of therapy didn't prepare me >for the accusations of dictatorship. I also didn't see enough support >*for* my position to want to continue. I also would like to send apologies to the extent you have felt - as you have made clear you have - that I have gotten too personal when pressing my positions. My interest in these topics is a passionate avocation. I understand that to you it is so much more - and that my position is the easy one. I have indeed pressed hard on viewpoints that oppose yours. Not only do I believe what I say, but I believe some of it is important to at least get said. Important because Python is important - God knows, no thanks to me. Perhaps we push each others buttons because our differences are somehow deep - more worldview differences than syntactical differences. Nevertheless, never questioned the structure itself. As you say - the fact that Python is open source and you have worked to make it so, is, as far as I am concerned, all that needs to be said on the issue of dictatorships. But if you feel that I have taken unfair advantage of this very open forum in which you have chosen to participate (subject yourself), I do indeed have regrets. ART From cgp at nospam.le.ac.uk Thu Jul 12 05:48:55 2001 From: cgp at nospam.le.ac.uk (Clive Page) Date: 12 Jul 2001 10:48:55 +0100 Subject: Language change and code breaks References: <XFMail.20010712083841.mikael@isy.liu.se> Message-ID: <9ijrq7$2qui@owl.le.ac.uk> In article <XFMail.20010712083841.mikael at isy.liu.se>, Mikael Olofsson <mikael at isy.liu.se> wrote: >Being in EE, I would immediately interprete a//b as two resistors, a and >b, in parallel. Thus, I would expect 1//2 to return 0.666666... While a Fortran programmer would expect to see character concatenation. -- Clive Page cgp at le.ac.uk From thomas at xs4all.net Thu Jul 12 04:13:43 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Thu, 12 Jul 2001 10:13:43 +0200 Subject: SocketServer returns bad file descriptor In-Reply-To: <74cc9702.0107110622.6d95a609@posting.google.com> References: <74cc9702.0107110622.6d95a609@posting.google.com> Message-ID: <20010712101343.G5396@xs4all.nl> On Wed, Jul 11, 2001 at 07:22:04AM -0700, phillip wrote: > I use the following from an example > > class TestHandler(SocketServer.StreamRequestHandler): [..] > But every time I connect I get the following error : > self.rfile + self.connection.makefile('rb', self.rbufsize) error: (9, > 'Bad file descriptor') This looks suspiciously like a bad bug Guido fixed in the SocketServer module just a few days ago. If so, it'll be fixed in Python 2.2 and Python 2.1.1 (of which the release candidate should be released tomorrow, if all goes well.) You can grab the CVS tree for either and find out -- the SocketServer.py module can just be dropped into your current Python library directory. You can get it through SourceForge, using ViewCVS: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/~checkout~/python/python/dist/src/Lib/SocketServer.py?rev=1.24.2.1&content-type=text/plain -- Thomas Wouters <thomas at xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From Dominikus.Herzberg at eed.ericsson.se Tue Jul 24 02:41:32 2001 From: Dominikus.Herzberg at eed.ericsson.se (Dominikus Herzberg) Date: Tue, 24 Jul 2001 08:41:32 +0200 Subject: UML Packages And Python Modelling References: <oecpltcn42hqfpf8ge308jpk6pe28n5bqm@4ax.com> Message-ID: <3B5D189C.C3BBD958@eed.ericsson.se> Lothar Scholz wrote: > I'm writing an UML Diagram Editor for python and would like to ask the > community what entity is an UML package. My first idea was that a file > is the logical equivalent, not the directory (likejava.and eiffel > programmers would expect). But then what is a directory ? > Should this be represented by a nested package ? Hi Lothar, maybe the following project "TransWarp" is of interest for you as well, in case you plan to integrate code generation etc. to your editor. http://www.zope.org//Members/pje/Wikis/TransWarp/HomePage http://www.zope.org/Members/tsarna/AnnounceEbySarnaStuff Dominikus From peter.milliken at gtech.com Tue Jul 3 22:47:03 2001 From: peter.milliken at gtech.com (Peter Milliken) Date: Wed, 4 Jul 2001 12:47:03 +1000 Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> <9hrj3q$cj1@news1.gtech.com> <bebbba07.0107031040.593143f8@posting.google.com> <9htgsb$ck3@news1.gtech.com> <slrn9k4out.ms.grante@tuxtop.visi.com> Message-ID: <9hu07g$ck6@news1.gtech.com> True, but all you are arguing here is that Python and accompanying toolset, in it's current state, is not up to the task but could be made more appropriate to the problem/situation. So, "how long is a piece of string"? The original question related to using Python for a particular job. Where are you going to end your Holy Grail of making Python up to the task i.e. answering the "objections" as to why Python wouldn't necessarily be a good choice. Sure the source code is there for anyone to "tweak", so lets just keep "tweaking" it until it comes up to the required standard - in which case it won't be Python anymore :-). There are other languages that offer the same code constructs that Python offers plus more, without the "drawback" of being an interpreted, dynamic language. Different languages have different uses, just because you "love" a particular language doesn't mean that it would suit all possible situations. I could create the same arguments for using assembler. Why don't we all code in assembler - because of good and obvious reasons such as ease of coding, more readable code, higher productivity etc. Yet, I could show that assembler is a perfectly good choice for certain situations/applications. I could also talk about "support staff" extending the assembler to offer the advantages perceived in language X :-) But of course, after the project is ended you would find that you had a compiler for language X, not an assember anymore. Another "rub" here is, sure the project might have some support staff (generally not though, because staffing such a large project would leave only the "dreggs" available to act as support staff - assuming you had any programmers left over at all, usually such projects are short staffed throughout their entire development cycle :-)). Whoops, sentence got too long there :-). But the point is you can't afford to have "support" staff working on improving the tools in parallel with the development effort - unless it is a small change then the main project can't afford to wait for whatever feature is being crafted so they program around not having it :-). Peter "Grant Edwards" <grante at visi.com> wrote in message news:slrn9k4out.ms.grante at tuxtop.visi.com... > On Wed, 4 Jul 2001 08:25:50 +1000, Peter Milliken <peter.milliken at gtech.com> wrote: > > >This assumes that your coding standing inforces passing > >arguments by name - just try staffing an ATC project and > >enforcing a coding standard. There will be many programmers who > >"don't like the standard" and will do anything to get around > >it. You generally catch these people through code review only > >and often too late! :-). Python doesn't enforce this, > > [without looking at the source code] I think it would probably > be farily trivial to hack Python to require all arguements be > passed by keyword. > > >personally I believe it is a good feature and I use it > >frequently - but not all of the time :-) > > > >> In C++, the function calls all get checked automatically at > >> compile time, but Python doesn't check them until run time. > >> That is a valid concern, but hardly a show-stopper. I > >> understand that PyChecker can be used for static checking. I > >> actually think the core Python language should have an option > >> to do static checking, but as long as some product is > >> available to do it, the issue is not major. > > > >PyChecker is still very imature and some things it will never > >(poor word to use, since if someone wants to put in the effort, > >nothing is impossible :-)) be checked by it. It will only ever > >be an aid. The ability of Python to dynamically "change its > >behaviour on the fly" is one of its strengths but also a > >weakness from the point of view of ensuring correctness and > >reliability in such an application domain. > > On a project as large as an ATC program there will probably be > (or at least _should_ be) some support staff whose job is > nothing other than specify/acquire/develop/tweak/test > development tools. > > -- > Grant Edwards grante Yow! I wish I was a > at sex-starved manicurist > visi.com found dead in the Bronx!! From friends at openxxx.net Sat Jul 14 23:41:08 2001 From: friends at openxxx.net (friends at openxxx.net) Date: Sun, 15 Jul 2001 05:41:08 +0200 (MEST) Subject: Hello, your friend recommended openxxx to you Message-ID: <UTC200107150341.FAA08258@hera.cwi.nl> You have been invited to check out this adult site by one of your friends who visited us. our URL is http://www.openxxx.net/ enjoy, OpenXXX TEAM 2001 From newgene at bigfoot.com Wed Jul 18 10:49:09 2001 From: newgene at bigfoot.com (newgene) Date: 18 Jul 2001 07:49:09 -0700 Subject: Two Simple Qs: References: <a50631f6.0107171019.74fb42a5@posting.google.com> Message-ID: <a50631f6.0107180649.b711dd1@posting.google.com> Thank you all! Now I got the solutions for both Qs. Newgene From adam.seyfarth at home.com Sun Jul 22 14:17:35 2001 From: adam.seyfarth at home.com (Vonlia) Date: Sun, 22 Jul 2001 13:17:35 -0500 (CDT) Subject: HOWTO: exit Message-ID: <Pine.LNX.4.33.0107221315300.4146-100000@cc489744-a> Hi, Sorry, I know this will be easy and I'm making alot of noise, but how do I exit from a script? I was hoping for something like sh's `exit' command...Once again, sorry, I just got into the python thing (long time Monty Python liker, though C-:) -- singing person: ``There's nothing quite as wonderful as money, There's nothing quite as beautiful as cash...'' choire: ``money money money money money money money...'' -- Monty Python::music(unknown) /|| Name: `Adam Seyfarth' Nicks: `Vonlia', `Fortuno' ||\ /?|| <mailto:cloud at users.sf.net> <http://plib.sf.net> ||?\ \?|| <http://tuxaqfh.sf.net> <http://tuxkart.sf.net> ||?/ \|| <http://vim.sf.net> <http://www.majik3d.org> ||/ From yeah at right.net Fri Jul 6 16:50:43 2001 From: yeah at right.net (baronsamedi) Date: Fri, 06 Jul 2001 20:50:43 GMT Subject: webbrowser module reveals a Netscape bug. References: <mailman.994426691.24524.python-list@python.org> Message-ID: <3B46249E.8050608@right.net> I'm a firm believer in the idea that something only proves its usefulness by its possibilities for misuse, or unintended use. True, that is a rather low stunt to pull, but alas, it is rather funny. In a school/college environment these kind of jokes are the general fodder that get you through the monotony of just another day at school/college. I seriously doubt i'll be able to get a root password for my college... oh, wait.. they're using NT, and our projects throughout the year are done in pascal/vb.. oh well, guess i'll suggest python, and see if i can use it on my own coursework :) ========================== baronsamedi/icarus take this job and shove it ========================== Oleg Broytmann wrote: > On 6 Jul 2001, Charles Harrison wrote: > >>If you are working in a school lab environment where you have >>the root password on the machines >> > > If you have root passwords you must be more responsible than that. > > Oleg. > ---- > Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru > Programmers don't die, they just GOSUB without RETURN. > > > From sill at optonline.net Sun Jul 22 13:40:10 2001 From: sill at optonline.net (Rainy) Date: Sun, 22 Jul 2001 17:40:10 GMT Subject: PEP0238 lament References: <mailman.995814276.15005.python-list@python.org> Message-ID: <slrn9lm3u8.as.sill@sill.silmarill.org> On Sun, 22 Jul 2001 11:01:08 -0500, Arthur_Siegel at rsmi.com <Arthur_Siegel at rsmi.com> wrote: > > If I was told that experinced programmers might > appreciate this change for any possible reason - > I'd be quiet as a mouse. I don't think they will.. > > Since I remain convinced that the single most important > factor for Python's acceptance as an educational language is > the growth of its acceptance as a professional language. First of all, it's really ugly. It's the ugliest thing in python for a newbie, imho. Yes, 1/2 is 0. You have to type 1.0/2 to get 0.5. No, there is no good reason for that, just memorize it. Ugh. If it was just a matter of that, it wouldn't be enough for a change (non- backwards-compatible one). But, the problem is that people will have strange bugs because of this and spend hours upon hours trying to figure out what's wrong. Python may be around during next 10-20 years and userbase may grow a thousandfold, and having this ugliness on board for all this time is a big problem. It's arguable whether the problem is serious enough to break old code, but it's obvious (to me, anyway) that there *is* a rather big problem here. -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: http://silmarill.org/cymbaline From James_Althoff at i2.com Mon Jul 16 13:45:04 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Mon, 16 Jul 2001 10:45:04 -0700 Subject: Long Live Python! Message-ID: <OFB4F80B00.12505A31-ON88256A8B.0061408B@i2.com> Philip Hunt wrote: >On Fri, 13 Jul 2001 12:29:32 -0700, James_Althoff at i2.com <James_Althoff at i2.com> wrote: >> >>Granted, I used "only". On the other hand, if someone says "good for short >>programs <100 lines" -- mentioning a specific number ("100" in this case) >>-- wouldn't common sense dictate that the intention was also to indicate >>something like "Python is something *different than good* for programs >> >=100 lines (or let's say *significantly* greater than 100 lines -- to be >>reasonable and fair)? > >No it would not. If I say "my car is convenient for journeys <10 miles", >it doesn't mean it is inconvenient for journeys >10 miles, does it? How about if we just forward this over to the Department of Arguments? (I think it's right next to the Office of Silliness). Jim From ajs at ix.netcom.com Mon Jul 23 21:08:19 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Mon, 23 Jul 2001 21:08:19 -0400 Subject: PEP0238 lament Message-ID: <000001c113e2$8cf52fe0$a9e1fea9@carol> >Well, I'll see what I can do. In the language there are (at least) >two distinct things we might want to do when "dividing" A and B: > (1) split A up into B parts > (2) find how many B's fit in an A etc... The well intentioned response I think only points out the problem more. You don't seem to understand that my point is that, within reason, I do in fact understand all this fairly well. Anyone else of normal intelligence should be able to also. My further point is that there is a lot about programming that I do find difficult. The difficult parts. Which is why I keep feeling the techies among you have lost touch with common sense. Almost comically. The easy stuff is easy, the hard stuff is hard. It's not that difficult to separate which is which. Which is why I am always amazed at what gets reported - and taken seriously - as significant. Will I have any problem with // and / - using them appropriately Doubt it. Can I handle case sensitivity any way you give it to me. Cake. Why is two years of discussion going on as if someone like myself is not fully representative. I simply have no reason to believe I am not. And will scrutinize carefully any evidence which contends otherwise. Should major design decisions for a professional language be made on anecdotal reports from ???????? sources without a hard look at their context and meaning. Not in my opinion. Do I believe the change is a significant enhancement on behalf of the newbie. Not in the least. Will Python be a better language after it is done. I don't have a good basis to disagree with that assertion. And none of these statements seem a bit contradictory to me. >A good example of (1) is float division, and the cannonical example >of (2) is "int division", aka "div". These are DIFFERENT THINGS. >For instance, if you are implementing a sort algorithm, you may >well want (2) in a place where (1) will never do! On the other >hand, if your program is performing CAD drawings, then (1) is >probably the meaning you need. Note that (2) often makes most sense >with integers (especially since it always gives out an integer), >while (1) may make sense with floats, rationals, fixed-position >decimals, as well as various other numerical types. From quinn at yak.ugcs.caltech.edu Wed Jul 11 14:10:30 2001 From: quinn at yak.ugcs.caltech.edu (Quinn Dunkan) Date: 11 Jul 2001 18:10:30 GMT Subject: An unspeakable act References: <ib0lktkade28a9ci198b1jpn9jejqjbtlj@4ax.com> <994786203.24889.0.nnrp-10.d4e48e5c@news.demon.co.uk> <9ihql4$ah7$1@panix2.panix.com> <3B4C76A3.A624D05F@Lugoj.Com> Message-ID: <slrn9kp5kl.v9a.quinn@yak.ugcs.caltech.edu> On Wed, 11 Jul 2001 08:54:11 -0700, James Logajan <JamesL at Lugoj.Com> wrote: >Hmmm. Any language design that aspires to allow programmers the ability to >express algorithms independent of the type of object to which it may be >applied, such as containers, must at some level provide typeless handles. In >C/C++ those handles are typically (void *). In Java they are typically >Object references. In Python they are most all variables. Not quite. C and Java are pretty poor examples of "static typing". Eiffel and sather container classes use type parameters: ARRAY[INTEGER] In haskell, most all functions are naturally polymorphic, with no declarations required, and data constructors can take type arguments: data Tree t = Leaf t | Node (Tree t) (Tree t) I gather that even C++ supports something similar to eiffel generics through "templates". When a weak type system fails, you have to cast it away, at which point you lose all the advantages of having a type system in the first place. I'm surprised to hear that Java makes such common use of down casts; it seems to make the highly deprecated C practice of throwing around void pointers into a basic language idiom. Eiffel has the equivalent of down casts through the assignment attempt, but it's surrounded by blinky warning lights saying "only to implement persistence mechanisms and other nasty tricky bits where types are lost". I used to think of java as a sort of ugly slow version of eiffel without contracts, but now I suppose I should add "static types" to that prejudicial dustbin as well :) From Bill.Scherer at VerizonWireless.com Tue Jul 3 15:25:50 2001 From: Bill.Scherer at VerizonWireless.com (Scherer, Bill) Date: Tue, 3 Jul 2001 15:25:50 -0400 (EDT) Subject: using python to append a file In-Reply-To: <13e6b4a6.0107031113.441998c@posting.google.com> Message-ID: <Pine.LNX.4.33.0107031525130.31581-100000@ampeg.corp.bam.com> open(fileName, 'a') will do the trick. On 3 Jul 2001, Thanh Le wrote: > I am new to Python and was wondering if anyone could show me a way to > append a file (similar to the way Unix does by using >> ). I've tried > using open('file','r+') method and it overwrote whatever i had in that > file. I am sure there is a way to append a file, but havent had much > luck. > Thanks in advance, > Thanh > William K. Scherer Sr. Member of Applications Staff - Verizon Wireless Bill.Scherer_at_VerizonWireless.com From llothar at mailandnews.de Thu Jul 5 12:10:31 2001 From: llothar at mailandnews.de (Lothar Scholz) Date: Thu, 05 Jul 2001 18:10:31 +0200 Subject: Building an embedded Python application with Borland C++ Message-ID: <q449kt49kjuse1ft0fobvr85kqp3pa26vm@4ax.com> I have the problem that i can build an import library from the python20.dll but not link my program against it. Python is compiled without the preceding underline character, so i must compile my application with the -u- option. But when i do so the runtime library can't find a "_main" function because it is now compiled as "main". Has anybody solved this problem or has a makefile to build the complete python DLL with the Borland 5.5 version. From gerhard.nospam at bigfoot.de Thu Jul 5 16:36:48 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Thu, 5 Jul 2001 22:36:48 +0200 Subject: ICFP 2001 contest - Python team, anyone? Message-ID: <slrn9k9hbd.8uh.gerhard.nospam@lilith.hqd-internal> The International Functional Programming Contest was announced. I'd like to join this year. If you are a Python hacker and want to have all the fun and glory, please contact me :-) http://cristal.inria.fr/ICFP2001/prog-contest/ """ On Thursday, July 26, 2001 at 15:00 UTC (see this page to convert to your time zone), a challenge task will be posted on the Internet. It will also be sent by mail to the contest mailing list. Teams will have 72 hours to implement a program to perform this task and submit this program to the contest judges. """ (Im not an ubercoder, I just want to have fun) Gerhard -- mail: gerhard <at> bigfoot <dot> 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 rajarshi at seed.chem.psu.edu Tue Jul 31 12:32:54 2001 From: rajarshi at seed.chem.psu.edu (Rajarshi Guha) Date: Tue, 31 Jul 2001 12:32:54 -0400 Subject: sleep command/function & searching the python docs References: <9k6ilm$2sed8$1@ID-91520.news.dfncis.de> <m3bsm1hyje.fsf@kepler.ibp.de> Message-ID: <9k6mev$2vg4b$1@ID-91520.news.dfncis.de> markus at kepler.ibp.de wrote: > >> throught the modules but could'nt seem to find one. BTW, is there any way >> to search the Python docs for a specific function/module etc? Or is there >> any resource on the web that provides a searchable interface? > > Would be nice, but I don't know. Another post in this thread mentioned http://web.pydoc.org - looks pretty useful -- -- Rajarshi Guha From guido at python.org Fri Jul 27 10:09:43 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 27 Jul 2001 14:09:43 GMT Subject: PEP 238 (revised) References: <cp4rrz5onj.fsf@cj20424-a.reston1.va.home.com> <3B60B3D5.664A3D7F@engcorp.com> Message-ID: <cpg0bi4g6d.fsf@cj20424-a.reston1.va.home.com> Peter Hansen <peter at engcorp.com> writes: > Guido van Rossum wrote: > > > > Here's a completely revised version of PEP 238. > [...] > > Command Line Option > > > > The -D command line option takes a string argument that can take > > three values: "old", "warn", or "new". The default is "old" in > > Python 2.2 but will change to "warn" in later 2.x versions. The > > "old" value means the classic division operator acts as described. > > The "warn" value means the classic division operator issues a > > warning (a DeprecatinWarning using the standard warning framework) > > when applied to ints or longs. The "new" value changes the > > default globally so that the / operator is always interpreted as > > true division. > > The choice of command line options is inconsistent with the terminology > used elsewhere in the updated PEP. > > To further reduce the potential for confusion, I suggest changing > "old" and "new" to "classic" and "true". I considered this, but I disagree. I don't think there will be much confusion since the words "classic" and "true" don't occur in the source (except when overloading __truediv__). The old/new distinction makes the arrow of time more obvious. > If that suggestion is accepted, "warn" might be better spelled > more like "classic-warn". > -- > > The updated PEP also makes no mention of a utility for scanning > existing code to check for potential problems. Is this considered > an intractable problem? Is there any commitment to doing this, > eventually, as part of the implementation of this PEP? Or is the > presence of the "warn" option considered sufficient (to allow for > testing, rather than scanning)? The PEP can't address everything. I have no idea how to write such a scanner, and I think it would require type inference of unrivaled sophistication, so I'm not keen on promising it in the PEP. I assume there will be some kind of conversion tool, but it's outside the scope of the PEP. --Guido van Rossum (home page: http://www.python.org/~guido/) From skip at pobox.com Fri Jul 6 08:44:56 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 6 Jul 2001 07:44:56 -0500 Subject: There's got to be an easy way to do this In-Reply-To: <92ae279c.0107060410.7beef3fa@posting.google.com> References: <ABEE81BE08ADD311B6A1009027DE908D0BD87D90@conmsx03.conway.acxiom.com> <mailman.994351690.22119.python-list@python.org> <9i27i8$gd9bq$1@ID-11957.news.dfncis.de> <3B44B031.819C93E@stroeder.com> <9i2c77$gmc74$1@ID-11957.news.dfncis.de> <mailman.994359729.14667.python-list@python.org> <92ae279c.0107060410.7beef3fa@posting.google.com> Message-ID: <15173.45768.417053.440826@beluga.mojam.com> >> def str_join2(iters): >> ... elided ... John> The arguments to has() will be strings of unit length. The keys in John> the dictionary are integers. Yeah, thanks for pointing out the error. It does ruin the performance advantage... ;-) -- Skip Montanaro (skip at pobox.com) (847)971-7098 From m.faassen at vet.uu.nl Mon Jul 23 15:53:30 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 23 Jul 2001 19:53:30 GMT Subject: Language change and code breaks References: <6957F6A694B49A4096F7CFD0D900042F27D55F@admin56.narex.com> <mailman.995575532.23146.python-list@python.org> Message-ID: <9jhvbq$ap4$3@newshost.accu.uu.nl> Guido van Rossum <guido at digicool.com> wrote: [snip] > You misunderstood the intention. The programming > environment should be case-preserving, and automatically correct > identifiers to use the same case as used when they were defined. Which programming environment do you want us to all use, though? I can only see this if you add this functionality to the Python interpreter itself, as you can't enforce everybody to use a particular editing environment, right? In fact my programming environment *currently* is case-preserving! If I mispell 'Foo' as 'FoO' then the python interpreter will tend to issue some complaints about this. How do you intend to improve this functionality? Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From eppstein at ics.uci.edu Tue Jul 24 19:11:45 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Tue, 24 Jul 2001 16:11:45 -0700 Subject: PEP238 and zope References: <3B5DE0F7.9070001@nospiced.ham.devis.com> <mailman.996013122.28143.python-list@python.org> Message-ID: <eppstein-C5F75F.16114524072001@news.service.uci.edu> In article <mailman.996013122.28143.python-list at python.org>, barry at zope.com (Barry A. Warsaw) wrote: > >>> must_be_int = 1 / 2 > >>> must_be_int > 0 > >>> must_be_int = int(1.0 / 2.0) > >>> must_be_int > 0 And this addresses the problem of long->float inaccuracies how? Seems like must_be_int = divmod(1,2)[0] is safer (if way uglier). -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From phawkins at connact.com Fri Jul 27 13:45:37 2001 From: phawkins at connact.com (phawkins at connact.com) Date: 27 Jul 2001 13:45:37 -0400 Subject: a break for comprehensions References: <9jpadd$s5k$1@news.duke.edu> <3B60A053.75938301@engcorp.com> <9jqnlr$flb$1@news.duke.edu> <3B60E96C.2A99AD87@engcorp.com> Message-ID: <wkhevyfepq.fsf@mail.connact.com> >>>>> "PH" == Peter Hansen <peter at engcorp.com> writes: PH> In my post I was attempting to point out that I find list PH> comprehensions less readable than the equivalent, longer but PH> more explicit while loop version, not that one list comprehension PH> is more or less cryptic than another. Personally, as soon as I saw list comprehensions, I found them splendidly, instantly readable -- so long as they aren't nested, I can read them at a glance, where it takes me just a little longer to comprehend all of a loop. This is certainly true for the examples we've been looking at. So I think this just has to do with how one's mind works. and-no-I-don't-find-perl-at-all-readable-ly yr's Patricia -- Patricia J. Hawkins Hawkins Internet Applications, LLC From skip at pobox.com Thu Jul 26 12:26:28 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 26 Jul 2001 11:26:28 -0500 Subject: perl2py - In progress! :-) In-Reply-To: <oqae1rg432.fsf@lin2.sram.qc.ca> References: <oqae1rg432.fsf@lin2.sram.qc.ca> Message-ID: <15200.17588.34980.217940@beluga.mojam.com> If one seeks difficulties against this project, I easily found one: I do not have the slightest idea about how to proceed about Perl "goto"s! Raise and catch exceptions at the appropriate places? raise == goto except == target of goto -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From claird at starbase.neosoft.com Wed Jul 25 16:15:24 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 25 Jul 2001 15:15:24 -0500 Subject: Driver finds 4' Python in hire car. References: <mailman.996064604.22983.python-list@python.org> <cpitgg94bk.fsf@cj20424-a.reston1.va.home.com> Message-ID: <04CE12C79327711A.081CEE4D6057F4D8.CD12FA66AFCF5BC4@lp.airnews.net> In article <cpitgg94bk.fsf at cj20424-a.reston1.va.home.com>, Guido van Rossum <guido at python.org> wrote: >Simon Brunning <SBrunning at trisystems.co.uk> writes: > >> <http://www.foxnews.com/story/0,2933,30352,00.html> > >And in Fairfax County, home of PythonLabs no less! :-) > >--Guido van Rossum (home page: http://www.python.org/~guido/) And they say there's no $eg#^7A+G?q+ .............. -- Cameron Laird <claird at NeoSoft.com> Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From spboulet at speakeasy.net Tue Jul 3 23:01:35 2001 From: spboulet at speakeasy.net (Stephen Boulet) Date: Tue, 3 Jul 2001 23:01:35 -0400 Subject: Changing default font in idle/linux Message-ID: <tk55clhbjjrfd@corp.supernews.com> Anyone know how to change the default font in idle in linux? I've looked at the file "EditorWindow.py" but found no "text['font'] = ("lucida console", 8)" line. Here are my versions: # rpm -q python tkinter python-2.1-1mdk tkinter-2.1-1mdk Thanks. -- Stephen From aleaxit at yahoo.com Tue Jul 3 04:15:54 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 3 Jul 2001 10:15:54 +0200 Subject: Python -- Use with both COM & Java? References: <Jpc07.289$GI4.22690@typhoon.mn.mediaone.net> Message-ID: <9hruvr116bo@enews1.newsguy.com> "Howard Dunlavy" <howard at dunlavy.net> wrote in message news:Jpc07.289$GI4.22690 at typhoon.mn.mediaone.net... > This question may be way off base, but here goes anyway... > > Would it be possible to maintain one set of Python code that would run in > both a Microsoft COM environment and a Java environment -- both natively? Yes, if you constrain that set to simple-enough operations. For example, a script made up of print "hello world" would satisfy such constraints:-). > Our situation is that we are currently using Delphi and WebHub in our web > applications. However, as we talk to more of our larger customers, they are > falling into either the native Microsoft camp (IIS, COM, MTS) or the native > Java world. We had been trying to bridge this problem by using SOAP as our > RPC. However, since we actually have to install our software (we are an > ISV) at our client site, they would prefer software that would live in their > respective "worlds". > > Hence my question. Is Python something that could be used to create both > COM object and EJB's, for instance (using JPython). > > Any comments would be appreciated. Seriously: you can (and should) isolate the system dependencies in separate modules. "import foo" will import different foo.py modules (or packages etc) depending on the environment. The 'business logic' part can be unchanged, but there's no way to avoid the two separate implementations for the 'technology-infrastructure access' part. > I realize that this approach might be the "worst of both worlds", and it > would probably make sense for us to pick one world or the other, but I am > concerned that we are going to shut ourselves out of a major part of market > by choosing just one of MS or Java. A perfectly understandable concern! Alex From Randy.L.Kemp at motorola.com Thu Jul 5 11:33:21 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Thu, 5 Jul 2001 11:33:21 -0400 Subject: FTP program works -- now how do I send the directory over? Message-ID: <E566B020833BD311B6610008C791A39705CA520A@il93exm04.css.mot.com> I made the change and everything is working fine now. Thanks to everyone for the wonderful support. And Python has another edge over Perl. With Python, the FTP client is build in, while with Perl, you need to obtain and install the CPAN (crummy programming archive network) libnet module. -----Original Message----- From: Oleg Broytmann [mailto:phd at phd.fep.ru] Sent: Thursday, July 05, 2001 9:08 AM To: Kemp Randy-W18971 Cc: 'python-list at python.org' Subject: Re: FTP program works -- now how do I send the directory over? On Thu, 5 Jul 2001, Kemp Randy-W18971 wrote: > I seem to be getting the listing of what's on my d drive in windows, rather then the binary contents. Here is what I do (the server id changed to protect the innocent: > > for filename in glob.glob('d:\programsPython\*'): > ftp.storbinary("STOR " + filename, open(filename, 'rb')) > List the directory contents in Unix > > ee110:/usr2/ecadtesting/tarbackups> ls > d:\programsPython\CE H2-102000 Usage Mentor1.txt > Why do I get the text d:\programsPython\filename? Because glob() returns full path, so you end up running commands like ftp.storbinary("STOR " + 'd:\\programsPython\\CE H2-102000 Usage Mentor1.txt'... (please note double backslashes) If you want just filenames without path you can do one of two things: 1) cd d:\programsPython (os.chdir("d:\\programsPython")) and then use glob('*') - this will list just the curent directory 2) or cut off the file/path yourself: for filename in glob.glob('d:\programsPython\*'): name = string.split(filename, '\\')[-1] ftp.storbinary("STOR " + name, open(filename, 'rb')) > How should I change the program to get the actual files sent over? Why do you think those funny files are not real files? It is just UNIX didn't interpreted backslashes! :) I am sure they are your real files! Test it. 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 Sat Jul 14 10:11:36 2001 From: rnd at onego.ru (Roman Suzi) Date: Sat, 14 Jul 2001 18:11:36 +0400 (MSD) Subject: PEP: Defining Unicode Literal Encodings (revision 1.1) In-Reply-To: <3B502DBA.761D4F69@lemburg.com> Message-ID: <Pine.LNX.4.30.0107141805550.5125-100000@rnd.onego.ru> On Sat, 14 Jul 2001, M.-A. Lemburg wrote: >directive unicodeencoding = 'latin-1' >#!/usr/local/python >""" Module Docs... >""" >directive unicodeencoding = 'latin-1' >... >u = "H?ll? W?rld !" >... Is there any need for new directive like that? Maybe it is possible to use Emacs-style "coding" directive in the second line instead: #!/usr/bin/python # -*- coding=utf-8 -*- ... Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Saturday, July 14, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "A mainframe: The biggest PC peripheral available." _/ From tim.one at home.com Tue Jul 31 18:28:14 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 31 Jul 2001 18:28:14 -0400 Subject: Python Threads on Linux In-Reply-To: <3B671B63.23CC4490@raqia.com> Message-ID: <LNBBLJKPBEHFEDALKOLCEEJOLCAA.tim.one@home.com> [David Lees] > Question - Does this affect the global lock at all? You better hope not! > Is it some way to get around it? I wrote some simple threaded code > while back that ran on a dual processor board. The global lock kept 2 > threads from running in parallel on separate processors. That's its purpose: the CPython implementation relies on the GIL to keep your Python objects sane. Consider what would happen if, e.g., two threads mucked with the internal refcount of an object at the same time. Python releases the GIL only around potentially-blocking and thread-safe C library calls (like I/O and time.sleep()), and every sys.setcheckinterval() bytecodes to give another Python thread a chance to run. If you want it released at any other time, the only way is to write a C extension module. However, even then a thread can *never* call a Python C/API function (with a very few exceptions) unless it holds the GIL at the time. From kelly.gerber at mindspring.com Wed Jul 18 15:26:50 2001 From: kelly.gerber at mindspring.com (me) Date: Wed, 18 Jul 2001 12:26:50 -0700 Subject: Readline on RedHat 7.1 with Python 2.1 References: <mailman.995434769.10172.python-list@python.org> Message-ID: <3B55E2FA.4BCFF3A@mindspring.com> Roman Suzi wrote: > Isn't Python already compiled with readline in RH7.1??? > > If so, add > > .startpy > import readline > import rlcompleter > readline.parse_and_bind("tab: complete") > print "Realine loaded" > > to your homedir and put > > export PYTHONSTARTUP=.startpy > > into your .bash_profile > (if you are using bash) > > Then re-login and try: > > $ python > > Readline loaded > >>> import os. > >>> os. > Display all 155 possibilities? (y or n) > > as usual. > > > Thanks, > > Kelly > > Sincerely yours, Roman A.Suzi > -- > - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - > I did not make myself clear. I am trying to compile the latest version Python from source code. It will not compile the module, so I am not able to do what you suggest becaue the module does not exist yet. See the answer from Nils. I installed the readline-devel package, but now there is still a problem with -ltermcap. One step closer.......... Thanks, Kelly From inigoserna at terra.es Tue Jul 10 19:06:29 2001 From: inigoserna at terra.es (=?ISO-8859-1?Q?I=F1igo?= Serna) Date: 11 Jul 2001 01:06:29 +0200 Subject: curses woes In-Reply-To: <Pine.LNX.4.33.0107101209540.4375-100000@phd.fep.ru> References: <Pine.LNX.4.33.0107101209540.4375-100000@phd.fep.ru> Message-ID: <994806389.845.2.camel@lethe.infernus.org> El d?a 10 Jul 2001 12:11:39 +0400, Oleg Broytmann escribi? > On Tue, 10 Jul 2001, Rainy wrote: > > while 1: > > c = win.getch() > > if c == curses.KEY_BACKSPACE: > > do_something() > > > > The problem is that backspace key shows up as ^? and doesn't match the above > > test. I also tried doing c == 14 but also without luck. I'm using > > curses.wrapper() here. > > Your terminal is incorrectly configured. > > man 5 terminfo > man tic > man stty you can use print 'key: \'%s\' <=> %c <=> 0x%X <=> %d' % (curses.keyname(c), c & 255, c, c) to learn the key code which is generated and then use it in your code, but, of course, this is the wrong way (tm). In my system (a much-modified RedHat Linux 7.1 with ncurses-5.2-8), backspace generates code 8 (Ctrl-H) in xterm and gnome-terminal, but curses.KEY_BACKSPACE in rxvt. Greetings, I?igo Serna From vvainio at karhu.tp.spt.fi Tue Jul 10 01:57:21 2001 From: vvainio at karhu.tp.spt.fi (Ville Vainio) Date: 10 Jul 2001 08:57:21 +0300 Subject: Python: Database to Web Part II (and "teaching language") References: <5174eed0.0107060820.ff90805@posting.google.com> <yox66d25zkd.fsf@karhu.tp.spt.fi> <23891c90.0107090815.3685a9@posting.google.com> Message-ID: <yoxvgl12uny.fsf@karhu.tp.spt.fi> paul at boddie.net (Paul Boddie) writes: > I haven't seen any particularly notable bias towards "newbies" in this > group. Anyway, if people want to go and develop their applications True, this group seems to be perhaps the most enjoyable among the language newsgroups I have browsed. Not too much "how should I learn C++". I'm talking about the tutorial here. There is a line that says "... or perhaps you're not sufficiently familiar with C.". It just might scare away some potential Python programmers. Familiarity with C is rarely a problem for people - slow, tedious and error-prone development is. When I mentioned Python to one of my colleagues, ha said he had has the impression that Python was for people who can't learn some other language (which, according to anecdotal evindce, seems to be the very opposite of the truth - python people seem to know lots of languages). > entirely in C (as seems to be fashionable in certain open source > circles), because they believe that Python isn't for real programmers > or is too slow or "wasteful", then they can feel free to do so and > waste their own time in the process. C is also kinda fun, if you have lots of time, are doing nothing complicated or playing with something that doesn't need to be run in a production environment. > Edward's right in one respect: stop concentrating on language issues > and start concentrating on library issues. It's shocking but I think the Python library is excellent, and the only thing I miss is the database thing. I actually read the library reference docs every now and then just for fun, enjoying all the beautiful and useful stuff there (that I probably won't even use - knowing that they are there and how they work is justy comforting). People doing the documentation for python reserve special commendation. > illustrative that many people claim to choose Perl for work purely on > the basis of library availability for that language. Perl DBI seems to be one one of the Perl's killer apps... -- 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 hcsgss at texlife.com Tue Jul 24 16:11:49 2001 From: hcsgss at texlife.com (Galen Swint) Date: Tue, 24 Jul 2001 15:11:49 -0500 Subject: cost of change Message-ID: <1010724151149.ZM39634@anson.hcs.tl> Has anyone tried to figure out how much changes to Python cost? The way I figure it, it goes something like this: 500,000 Python programmers $20/hr 3 hrs to port *all* needed code Thats $30 *million*, and all those numbers are surely low -- especially the time to port. I can't imagine if you're using third party packages and have to wrangle with all their code yourself. I've been programming with Python only two months, and I've already gone through part of the 1.5 to 2.1 upgrade, and it cost several hundred dollars in salary simply because pickling doesn't port up versions. (I know that's documented, but it's still crazy not to have a pickly that works across versions). There are other hidden costs to breaking a language with every upgrade. Two come to mind - first, people like me, who thought they liked it, now don't want to do anything long term in it, and second, no one can afford to spend time on optimizations because the structure and code they are trying to optimize keeps shape shifting. If you're going to change it, fine. *BUT*, do the world a favor and be sure that *any* change which breaks existing code carries a new major version number (PEP0238 clearly warrants a Python 3.0 designation) . Galen From peter at engcorp.com Fri Jul 13 23:38:08 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 13 Jul 2001 23:38:08 -0400 Subject: Partition Problem References: <tku1tt92ac2g8e@corp.supernews.co.uk> Message-ID: <3B4FBEA0.D5A6DC8A@engcorp.com> Donovan Hide wrote: > Basically how can I find all the sets of six numbers which sum to 17 and > also to 20. There are zero sets of six numbers which sum both to 17 and to 20? ;-) > I have come across algorithms written twenty years ago, but they are > written in Pascal and Fortran. I am learning to program with Python, so it > is difficult to translate them. I would be very grateful if someone could > supply some c, python or even pseudocode to generate the solution to this > problem. If you have algorithms, why not post them? Are you hoping somebody will write this from scratch just for you? (Someone might, but he's in a different timezone and wasting his time creating it.comp.lang.python, and _still_ hasn't replied since you posted this 13 hours ago, so you might be out of luck. :) > Also is generation the correct phrase or is enumeration better? Enumeration means counting or listing one by one. That presupposes the items being counted or listed exist. Generation means to bring into being. So do the sets you are looking for already exist or not? I'm fairly sure a mathematician would say you want enumeration... (http://www.dictionary.com was instrumental in forming my response. I'd also like to thank my mother and my father, and my first grade teacher Mrs. Hurry.) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From philh at comuno.freeserve.co.uk Fri Jul 13 09:07:36 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Fri, 13 Jul 2001 14:07:36 +0100 Subject: Long Live Python! References: <mailman.994969462.27792.python-list@python.org> <3B4E52B1.FBAE6F34@engcorp.com> Message-ID: <slrn9ktsko.tn7.philh@comuno.freeserve.co.uk> On Thu, 12 Jul 2001 21:45:21 -0400, Peter Hansen <peter at engcorp.com> wrote: >James_Althoff at i2.com wrote: >> >> Phil Hunt wrote: >> >On Wed, 11 Jul 2001 17:47:50 -0400, Peter Hansen <peter at engcorp.com> >> wrote: >> >>I tend to think of Python more as an extremely effective and maintainable >> >>general-purpose programming language, which happens also to work >> >>very well when applied as a "scripting language" (whatever that means). >> > >> >To me it means "good for short programs <100 lines". Bear in mind >> >that 100 lines of Python is equivalent to 300 lines of Java or 400 >> >lines of C++. >> >> We are shipping a successful product that comprises more than 100,000 lines >> of Jython. >> >> What is it about Python that would, in your experience, make it only "good >> for short programs <100 lines". > >In Phil's defense (not that I think he can't speak for himself), >he didn't say "only". That's your word. He was just responding to >my parenthetical (whatever that means) in reference to the label >being applied to Python. Indeed so. Python is suited to longer programs, as has been demonstrated many times. -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From jwbaxter at spamcop.com Sat Jul 14 00:01:09 2001 From: jwbaxter at spamcop.com (John W. Baxter) Date: Fri, 13 Jul 2001 21:01:09 -0700 Subject: [Python-Dev] RE: Defining Unicode Literal Encodings References: <LNBBLJKPBEHFEDALKOLCAEEMKOAA.tim.one@home.com> <mailman.995061384.26877.python-list@python.org> Message-ID: <130720012101095839%jwbaxter@spamcop.com> In article <mailman.995061384.26877.python-list at python.org>, M.-A. Lemburg <mal at lemburg.com> wrote: > I think that allowing one directive per file is the way to go, > but I'm not sure about the exact position. Basically, I think it > should go "near" the top, but not necessarily before any doc-string > in the file. > > > [Guido] > > > Hm, then the directive would syntactically have to *precede* the > > > docstring. That currently doesn't work -- the docstring may only be > > > preceded by blank lines and comments. Lots of tools for processing > > > docstrings already have this built into them. Is it worth breaking > > > them so that editors can remain stupid? > > > > No. > > Agreed. > > Note that the PEP doesn't require the directive to be placed before the > doc-string. That point is still open. Technically, the compiler > will only need to know about the encoding before the first > Unicode literal in the source file. Is there a strong possibility that *other* directives will come along which also "want" to be before the docstring? [I find it unlikely, at the moment.] If so, and if directives happen, it would seem necessary to adjust the docstring rules (and implementation <drat!> and tools <drat!>) to allow directive-before-docstring. But... Can Unicode be used for docstrings? A simpleminded test suggests "yes": [localhost:/tmp] john% python Python 2.1 (#1, 04/22/01, 11:06:25) [GCC Apple DevKit-based CPP 6.0alpha] on darwin1 Type "copyright", "credits" or "license" for more information. >>> import t >>> t.__doc__ u'I am a unicode docstring' So it might be annoying for the file-level docstring's Unicode flavor to differ from that of all the other Unicode strings in the file. Horrible thought: can the compiler revisit the unicode docstring if it turns out that there is a directive after it which sets the unicode flavor? always defer compiling the unicode docstring until after it's no longer possible to write a unicode-flavor directive (first other unicode string, end of file...just end of file?). Is there a need for something ugly like u-big5"I am a big 5 Unicode string" (ugh!)? (Unrestricted location in file.) Of those two, the latter is the more powerful, but is the power needed? --John (full of questions; lacking answers; unhappy with own ideas) From skip at pobox.com Tue Jul 3 15:29:02 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 3 Jul 2001 14:29:02 -0500 Subject: Alternate Syntax for dictionary elements In-Reply-To: <3b421046.1836046@news.t-online.de> References: <3b421046.1836046@news.t-online.de> Message-ID: <15170.7422.465821.631192@beluga.mojam.com> Gerson> dict = { 'type' : 'button', 'id': 32, 'name' : 'some name' } ... Gerson> if o.type == 'button': Gerson> # do something for objects of type button Gerson> Worthwile pursuit or total crap ? How about: import UserDict class Dict(UserDict.UserDict): def __getattr__(self, name): if name == "data": return self.__dict__['data'] try: val = self.data[name] except KeyError: raise AttributeError, "object has no attribute %s" % name return val def __setattr__(self, name, val): if name == "data": self.__dict__['data'] = val else: self.__dict__['data'][name] = val def test(): d = Dict() d['a'] = 1 print d.a d.b = 1 print d['b'] try: print d.c except AttributeError: print "d.c does not exist, as expected" test() -- Skip Montanaro (skip at pobox.com) (847)971-7098 From root at rainerdeyke.com Thu Jul 26 20:08:36 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Fri, 27 Jul 2001 00:08:36 GMT Subject: Operator symbol for "nb_intdivide" References: <C0Z77.8508$uM6.1020602@news1.telusplanet.net> Message-ID: <8i287.3114$oh1.1140514@news2.rdc2.tx.home.com> "Peter Dobcsanyi" <petrus at pobox.com> wrote in message news:C0Z77.8508$uM6.1020602 at news1.telusplanet.net... > "nb_intdivide" and "nb_divide" are very different let's show this > difference. Among the still free symbols ("?", "@", "$" I guess) I > would suggest to use "$" for the integer division. My vote (if I had one): keep '/' for integer division and introduce a new symbol for floating point division. Justification: - Everybody uses integers, but not everybody uses floats. Therefore, if '/' is used for integers, then fewer people will have to change their code. - The short and pretty modulus operator should be matched with a short and pretty integer division operator. - It makes floats more difficult for newbies. This is a good thing, since floats are dangerous. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From quinn at retch.ugcs.caltech.edu Fri Jul 13 23:36:37 2001 From: quinn at retch.ugcs.caltech.edu (Quinn Dunkan) Date: 14 Jul 2001 03:36:37 GMT Subject: readline()/readlines() inconsistent? References: <3B482C44.6E6EB163@snakefarm.org> <slrn9ki07c.vu.tim@vegeta.ath.cx> <slrn9ki6cn.8ud.quinn@retch.ugcs.caltech.edu> Message-ID: <slrn9kvfi5.fk9.quinn@retch.ugcs.caltech.edu> On 9 Jul 2001 02:40:23 GMT, Quinn Dunkan <quinn at retch.ugcs.caltech.edu> wrote: >Despite what the documentation may say, readlines does not use readline. >readlines uses fread() (since it doesn't have to worry about reading too much) >and then checks with ferror(). readline uses getc() (or perhaps fgets()) and, >when it gets EOF for error, proceeds to *not* check for error (clears it, in >fact). So I'd say linux, SunOS, and Irix are correct here and OSX is wrong >(must not be reporting via ferror() correctly). > >I'd say python is wrong here too, by not being consistent. If readline >checks, readlines should too. I've submitted a patch that makes readline() check for errors. From guido at python.org Thu Jul 26 10:09:36 2001 From: guido at python.org (Guido van Rossum) Date: Thu, 26 Jul 2001 14:09:36 GMT Subject: 2.2 features References: <mailman.996098094.16930.python-list@python.org> <l_P77.559300$eK2.117135519@news4.rdc1.on.home.com> Message-ID: <cplmlb7pev.fsf@cj20424-a.reston1.va.home.com> "Nick Perkins" <nperkins7 at home.com> writes: > Here's a nice little use of type/class unification: > > instead of using: > if type(x) is type(0): > > we can use: > if type(x) is int: > > or, for type checking.. > > assert type(num) is int > assert type(msg) is str > > ( I assume the use of 'is', rather than '==', is acceptable here ) Yes, 'is' is right. But you should never use this; instead, you should use assert isinstance(num, int) assert isinstance(msg, str) --Guido van Rossum (home page: http://www.python.org/~guido/) From meowbot at meowing.net Fri Jul 27 01:39:04 2001 From: meowbot at meowing.net (Miasmic Meowbot) Date: 27 Jul 2001 01:39:04 -0400 Subject: Language change and code breaks References: <mailman.996208009.24941.python-list@python.org> <Xns90EB99AB31ADBatodddexterpinioncom@203.2.194.51> Message-ID: <874rrzhqx3.fsf@litterbox.meowing.net> andy_todd at spam.free.yahoo.com (Andy Todd) wrote: > I just did a search for 'python' on their web site (http://www.qks.com/) > and got "Service is not running". I'm presuming this means not yet. <URL:http://www.smallscript.net/Python_for_AOS.htm> would seem to concur. From duncan at NOSPAMrcp.co.uk Mon Jul 2 09:06:54 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Mon, 2 Jul 2001 13:06:54 +0000 (UTC) Subject: Singleton classes (with no such thing as static variables) References: <MdY%6.168$iF.4908@news.lhr.globix.net> Message-ID: <Xns90D28EBA8E49Aduncanrcpcouk@127.0.0.1> Giles Constant <gilesc at hyperlink-interactive.co.uk> wrote in news:MdY%6.168$iF.4908 at news.lhr.globix.net: > I'm trying to make a class called "Environment" which will store some > global data such that all instances of the class have access to it. > The alternative is to create a single instance and pass it around every > single object in the entire project, but it gets used so frequently > that it would be rediculous. > > Is there a way of doing this, or do I need a new paradigm? :-) > The easiest thing here is to put your environment class in its own module, and simply make the shared data global to that module. -- 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 uberfustigator at yahoo.com Tue Jul 3 11:30:26 2001 From: uberfustigator at yahoo.com (Brian Kelley) Date: 3 Jul 2001 08:30:26 -0700 Subject: GUI Builder for Python ? References: <aknrjt8j3cm3qcnpu6qsgvu313rlmi8emg@4ax.com> <3B3DE732.660AF0E1@earthlink.net> <3l1vjtg9cu1jcr78hdgnchmp8bt53cuhbi@4ax.com> <slrn9jvbc6.pdh.carlf@panix2.panix.com> Message-ID: <22fbef71.0107030730.ae258df@posting.google.com> carlf at panix.com (Carl Fink) wrote in message news:<slrn9jvbc6.pdh.carlf at panix2.panix.com>... > In article <3l1vjtg9cu1jcr78hdgnchmp8bt53cuhbi at 4ax.com>, Lothar Scholz wrote: > > > > Perhaps you have missed that i was asking for an verion > alpha. > > I think Pythoncard will not be useable for some years. > > The current _Linux Journal_ has an article on Glade as a Python GUI > builder. It surely looks impressive to me, but I haven't tried it. > You'd end up with a GTK program (no native Windows/Mac look and feel) > if that matters to you. > > (I suppose you could use a GTK widget set that looks like WinX or > Mac?) My tutorial at the Python 9 Conference was based on the source that Mitch wrote for the Linux Journal article. You can get the tutorial at http://www.bioreason.com/~brian/GladeBase.html Glade, libglade and pygtk currently complile and work under windows and I believe someone has ported _libglade.pyd as well which was the missing piece of the puzzle. Hopefully I can bundle this stuff up into an installer along with the tutorial and GladeBase within the next decade :) From iumrgk at nowasia.net Fri Jul 20 18:45:33 2001 From: iumrgk at nowasia.net (iumrgk at nowasia.net) Date: Fri, 20 Jul 2001 22:45:33 +0000 (UTC) Subject: The PC and Software Museum Message-ID: <9jacad$5cc$383@usenet.otenet.gr> - Do you like OLD computers and software ? - Would you like to download some OLD Windows Versions ? ** THE NUMBER 1 MUSEUM FOR PERSONAL COMPUTERS AND SOFTWARE ** /////////////////////////////////////// / www.pcmuseum.8m.net / /////////////////////////////////////// Featuring: * Personal Computers * Terminals * Dumb Terminal Support Center * Software Section * Trade & Buy Market * and MORE ! http://www.pcmuseum.8m.net mgodttfuwchrerlmbnxlhlfwqvdxenjnowvuegnkjpsmniemsmtozfidweskcscriunmsmxzdpybvnnvnkdmoowjjdrxc From paulsid at home.com Tue Jul 31 14:07:15 2001 From: paulsid at home.com (Paul Sidorsky) Date: Tue, 31 Jul 2001 12:07:15 -0600 Subject: Control of flow References: <Pine.LNX.4.31.0107311355450.2321-100000@cb921.local> Message-ID: <3B66F3D3.B8B41AEC@home.com> Campbell wrote: > I use python to write telephony apps, and I find that a 'goto' is often > a nice tool (stop going 'aargh', its properly "useful" sometimes =). I disagree, it's evil and should be avoided at all costs! :-) > Here is a little snippet that gets a month/day from a caller. If the > day entered is not in the range of days valid for the month entered, we > repeat from the top. Does anyone have a few minutes to waste helping > me?? How better can I code things that look like this: > > >>> snip <<< > while 1: > cont = 1 ## ugh! > month = getdtmf("enter2digs.vox", 2) > if month < 1 or month > 12: > play("invalidmonth.vox") > continue > while 1: > day = getdtmf("enterday", 2) > if day < 1 or day > Month[month]: > play("invalidday.vox") > cont = 1 > cont = 0 > if cont == 1: > continue > break > >>> snip <<< Your second loop will run indefinitely, and cont will always be 0. Unfortunately this bug (or pasting error?) makes it kind of hard to see exactly what you want to do, but I'll take a shot at it. (Two shots actually.) If you always want to start back entering the month if the day was misentered, this should work: while 1: month = getdtmf("enter2digs.vox", 2) if month >= 1 and month <= 12: day = getdtmf("enterday", 2) if day >= 1 and day <= Month[month]: break # Or another if statement should you need to do more. else: play("invalidday.vox") else: play("invalidmonth.vox") This is very straightforward and easy to read even when nested heavily. If, however, there are also times when just the day can be reentered (which is the only reason I can see for needing the second loop in your example) then you'll still control variables, but maybe this will be nicer: dayvalid = 0 monthvalid = 0 while not monthvalid: month = getdtmf("enter2digs.vox", 2) if month >= 1 and month <= 12: monthvalid = 1 while not dayvalid: day = getdtmf("enterday", 2) if day >= 1 and day <= Month[month]: dayvalid = 1 break # Or another if statement with a similar while loop. else: dayvalid = 0 if needtostartoverwiththemonth: ## play("invalidday.vox") monthvalid = 0 break else: play("otherinvalidday.vox") ## else: monthvalid = 0 play("invalidmonth.vox") (Lines with ## are pseudocodeish.) With this approach you can quite easily back out of the loops to wherever you need to start over. For example, if you nested this further so you could get an hour then a minute then some data, and if (for some reason) inputting invalid data warranted restarting input at the day, you just set datavalid=0 and dayvalid=0 then break from the data loop and the other loops will do the rest without any changes. That is, minutevalid and hourvalid will be 1 so they will terminate the minute and hour loops, leaving you back in the day loop which will then start over because the day is no longer valid. This approach does make for more long-winded code and more indents, but that's a plus with hellish loop constructs. When you need to look at it months later, it's a lot easier to find a printer or screen that can display extra columns than it is to find the team of programmers needed to figure out WTF you were originally trying to do. :-) Does that help? If not I hope you'll post more details and corrected code. -- ====================================================================== Paul Sidorsky Calgary, Canada paulsid at home.com http://members.home.net/paulsid/ From aahz at panix.com Sat Jul 28 23:44:57 2001 From: aahz at panix.com (Aahz Maruch) Date: 28 Jul 2001 20:44:57 -0700 Subject: Decimal arithmetic again (was Re: PEP 238 (revised)) References: <mailman.996352193.17199.python-list@python.org> <rzJ87.20458$oh1.6779045@news2.rdc2.tx.home.com> Message-ID: <9k00rp$qmc$1@panix2.panix.com> In article <rzJ87.20458$oh1.6779045 at news2.rdc2.tx.home.com>, Rainer Deyke <root at rainerdeyke.com> wrote: > >'1.0' is a fixed point number with one digit to the right of the decimal >place. '1.00' is a fixed point number with two digits to the right of the >decimal place. '1e-1' is a fixed point number with one digit to the right >of the decimal point. '1e1' is a fixed point number with negative one >digits to the right of the decimal point. Conceptually, integers are fixed >point numbers with zero digits to the right of the decimal place. > >Internally, each number could be represented as two integers (longs): one >'base' and 'exp', such that the value of the number is 'base + 10 ** exp'. >'-exp' is the number of digits to the right of the decimal point. > >For addition (and subtraction), the number with fewer digits to the right of >the decimal point is padded with zeros. Addition is therefore an exact >operation: > >1.00 + 1.0 => 1.00 + 1.00 => 2.00 This is precisely what I'm currently implementing as Decimal.py. You can find my current code at 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 Fortune cookie: Watch your relations with other people carefully, be reserved. From tanzer at swing.co.at Fri Jul 27 09:38:21 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Fri, 27 Jul 2001 15:38:21 +0200 Subject: PEP 238 (revised) In-Reply-To: Your message of "Fri, 27 Jul 2001 09:06:00 EDT." <200107271306.JAA23956@cj20424-a.reston1.va.home.com> Message-ID: <m15Q7or-000wcBC@swing.co.at> > > Keeping old interpreters around doesn't work for my biggest worry: > > use of old scripts with new versions of TTTech's applications. In this > > context, TTTech ships an application containing a new interpreter to a > > customer who might still have old scripts around. These scripts might > > come from a third party and be totally opaque to the customer itself > > (e.g., a script to import from a tool of company XYZ into TTTech's > > TTPplan). > > Well, I hope that making the change Python 3.0 does the right thing > for you. It shouldn't be hard to alert your customers that Python 2 > is required for your company's applications. Like Perl 4 and Perl 5, > Python 2 and Python 3 will probably live alongside for many years. Well, I'd prefer not to get stuck with Python 2.0 forever. Unlike many I usually enjoy the new features you add to the language :-) > > I agree that exact emulation of old versions doesn't make sense. What > > I would propose is to enable Python somehow to identify old code > > (e.g., by absence of a version specifier) and let it raise an > > exception when `/` is applied to two integer arguments by old code. > > This would avoid both permanent warts and silent breakage of old code. > > Requiring a version specifier in all new code is very annoying. The > future statement is annyoing too, but at least it's a transitional > measure. I agree and that's the reason I didn't want to propose any concrete way of tagging new stuff. But I was hoping that maybe someone comes up with a cleaver idea how mark new code in a non-intrusive and thus non-annoying way. Someone proposed a change in file extension. Too bad, that this doesn't cover all cases (like my user scripts which are fed to execfile). > I agree that if we really need to have a way to explicitly request > past behavior, "from __past__ import ..." is a decent syntax. I just > noticed that PEP 236 (the __future__ PEP) mentions this as an > possibility (although the author claims it is unlikely). Explicitly marking the past won't work for my case. If a file is touched anyway, it should be fixed properly. I'm worried about the files out of reach. > I just looked it up at dictionary.com, and the meaning of quotient is > just the result of a division. One source even mentions that the > quotient is rational if the operands are. My Langenscheidt English/Geman dictionary just gives quotient <--> Quotient. But my Webster's New Encyclopedic Dictionary tells me: quotient: the number resulting from the division of one number by another [Latin quotiens `how many times`, from quot `how many`] If they had only written integer in place of number! OTOH, one learns in school that (integer) division gives a quotient and a remainder. So I think quotient is still better than `floor division`. How many newbies are going to know the meaning of floor? -- 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 vvainio at karhu.tp.spt.fi Wed Jul 11 03:53:54 2001 From: vvainio at karhu.tp.spt.fi (Ville Vainio) Date: 11 Jul 2001 10:53:54 +0300 Subject: Threading.Event w/ timeout veeeeeery slow on win32? Message-ID: <yoxr8vnaokt.fsf@karhu.tp.spt.fi> I'm using a Threading.Event object. When I specify a timeout for wait(), it takes almost 1 second for the thread that is wait()'ing to wake up when I kick the Event obj with a set(). I know I could get around this by creating a thread to perform set()'s periodically, but since this slowness is not mentioned in the documentation I was wondering whether I have misunderstood something. I'm using Python 2.1. -- 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 missive at frontiernet.net Wed Jul 25 21:15:33 2001 From: missive at frontiernet.net (Lee Harr) Date: Thu, 26 Jul 2001 01:15:33 +0000 (UTC) Subject: how to import curses References: <9jni8c$3hl8$1@node21.cwnet.roc.gblx.net> <20010725195635.22015.00001518@ng-fx1.aol.com> Message-ID: <9jnqvk$3a7e$1@node21.cwnet.roc.gblx.net> On 25 Jul 2001 23:56:35 GMT, TheDustbustr <thedustbustr at aol.com> wrote: > I have a winmodem so I use Win95 for internet programming. Is there any > substitute modlue I can use? I need a non-blocking alternative for > raw_input(). Two possibilities: 1.) Get a new modem. Can't cost more than about $20. (my last two were free... up to 33.6 kbps now. woo hoo!) 2.) I did a search on google for "python win32 curses" and came up with a few links. One lists something called pdcurses try: http://www.mikroplan.com.pl/~mak/python/ From tim at vegeta.ath.cx Sat Jul 28 04:28:39 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Sat, 28 Jul 2001 08:28:39 GMT Subject: Typing system vs. Java References: <871yn2zdch.fsf@complete.org> <3B61D9A3.FDFF109F@home.net> Message-ID: <slrn9m4um1.28g.tim@vegeta.ath.cx> Me parece que Chris Barker <chrishbarker at home.net> dijo: [snippage] > > From what I hear about Python, it is weakly-typed like Perl. > > Python is dynamically typed, and NOT like Perl! Could someone elaborate on this a bit more? What is the difference here? What makes Perl's typing _not_ dynamic? I've heard this statement often in clpy, but do not understand the semantics of the argument. However, Perl's typing system is much more flexible (read: context-sensitive) than Python's. [snippage] -- "supported" is an MS term that means the function exists. The fact that it always fails means, that it is an exercise for the programmer. -- Sarathy, p5p From erno-news at erno.iki.fi Mon Jul 23 21:42:52 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 24 Jul 2001 04:42:52 +0300 Subject: Advice wanted: asynch I/O on unix References: <owen-66B4BF.09573623072001@nntp4.u.washington.edu> Message-ID: <ku4rs3yueb.fsf@lasipalatsi.fi> In article <owen-66B4BF.09573623072001 at nntp4.u.washington.edu>, "Russell E. Owen" <owen at astro.washington.edu> writes: | The present C program works as follows: | - open the parallel port as a file-like device (and config with ioctl) | - allocate some buffers | - call aioread to start reading into one buffer | - call aioread to queue a read into a 2nd buffer | - repeatedly poll the aioreads; when one finishes, | processes the data, deallocate the buffer, | and allocate a new buffer and queue an aioread on it | writing works similarly | It would be nicest to end up with as little C code as possible (i.e. | move most of this functionality into Python). unix character devices often support select(), if that works it would probably be easiest (look in the select module). if not, you can still use python threads. if you want to keep the c library, the lowest overhead method might be to start a separate process for the parallel port reading process and have a bit of c send things to your python program (for example with pipes.) | Ideally, I'd like to start a read into a | big FIFO, then check every once in awhile and process the data that has | arrived. that's approximately what select lets you do (from many files at once). -- erno From aahz at panix.com Fri Jul 27 21:02:39 2001 From: aahz at panix.com (Aahz Maruch) Date: 27 Jul 2001 18:02:39 -0700 Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <eppstein-03540D.13070222072001@news.service.uci.edu> <9jnt9p$qhe$1@newsy.ifm.liu.se> <SYV77.27286$B7.423933 <slrn9m3q54.1c5.Gareth.McCaughan@g.local> Message-ID: <9jt2vf$gj8$1@panix2.panix.com> In article <slrn9m3q54.1c5.Gareth.McCaughan at g.local>, Gareth McCaughan <Gareth.McCaughan at pobox.com> wrote: >Guido van Rossum wrote: >>[Tim Hochberg:] >>> >>> Actually, I do dislike this. Much as I find floats generally useless, I >>> think that 0.666667 should return a float, and that if I want to write a >>> rational literal I should be able to write it as 2/3. >> >> I think you're right. An early version of ABC worked like this, and >> at the time I though "hmm, but why shouldn't 0.98 be an exact number; >> it could be intended as a price or something like that", and I >> convinced the team to change it. But in practice it was more often >> annoying. Now maybe that was because we (the biggest users) were CS >> and math folks, and we tended to tackle typical math and CS problems >> -- but my gut is to vote against this aspect of the PEP. > >I am a fan of rationals, but I strongly agree. Turning 0.98 >into 49/50 is likely to cause much more confusion than it >saves. If I ever get finished with Decimal.py, we'll likely make such numbers into arbitrary-precision decimal numbers instead of binary floating point. [I keep talking about it in public to provide myself with one more motivation to finish. ;-)] -- --- 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 Fortune cookie: Watch your relations with other people carefully, be reserved. From fredrik at pythonware.com Fri Jul 13 16:51:49 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 13 Jul 2001 20:51:49 GMT Subject: Version incomptabilities, code changes, __future__, etc References: <mailman.994953982.6684.python-list@python.org> <Ofl37.2371$uJ3.65780@e420r-atl2.usenetserver.com> Message-ID: <FbJ37.5151$z21.530169@newsc.telia.net> Steve wrote: > That's OK. I'm working on a Python-to-Perl translator. isn't Perl 6 supposed to support different front-ends, including Python? or maybe it's the Python front-end you're working on? Cheers /F From skip at pobox.com Tue Jul 17 13:12:35 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 17 Jul 2001 12:12:35 -0500 Subject: list and implicit continuation may cause bugs in Python programs In-Reply-To: <slrn.pl.9l8iie.pm.qrczak@qrnik.zagroda> References: <mailman.995375611.9710.python-list@python.org> <slrn.pl.9l8iie.pm.qrczak@qrnik.zagroda> Message-ID: <15188.29187.925172.4862@beluga.mojam.com> Marcin> But how to rewrite it? I'm not sure if I like this: Marcin> for i in list: Marcin> if cond: Marcin> do_something Marcin> else: Marcin> pass Marcin> else: Marcin> somethingelse As they say, "explicit is better than implicit". -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From bsass at freenet.edmonton.ab.ca Tue Jul 17 15:52:01 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Tue, 17 Jul 2001 13:52:01 -0600 (MDT) Subject: PEP: Defining Python Source Code Encodings In-Reply-To: <Pine.LNX.4.21.BCL.0107171620190.704-100000@suzi.com.onego.ru> Message-ID: <Pine.LNX.4.33.0107171240290.11975-100000@bms> On Tue, 17 Jul 2001, Roman Suzi wrote: > On Tue, 17 Jul 2001, M.-A. Lemburg wrote: <...> > > Yes, that could be an issue (I don't think it matters much though, > > since parsing usually only done during byte-code compilation and > > the results are buffered in .pyc files). > > No! Scripts are compiled each time they run. > If this will be implemented, developers will need to do the trick > of making each script a module and so on. This is not good idea. > > There clearly must be the way to prevent encode-decode. And it would be > better if only EXPLICITLY given encoding will trigger encode-decode > mechanism. Python currently manages .pyc and .pyo files by placing them in the same location as the .py they are generated from, only if the location is not writeable or the program has changed will it get recompiled... Why not extend this to allow Python to manage .py-s, and allow for set locations for source and byte-code; a command option can be used to get the old behaviour where .pyc|o live where the source does. <...> > And this is right. I even think encoding information could be EXTERNAL. > For example, directory will need to have "__encodings__.py" file where > encodings are listed. > > Then, Python if started with some key could check for such file and > compile modules accordingly. ...or reformat them... > If there is not __encodings__.py, then Python proceed as it does now, > WITHOUT any conversions to and from. ...why restrict this paradigm to character encodings. > This will make script-writer happy (no conversion overhead) and those who > want to write encoding-enabled programs (they could specify > __encodings__.py) Do you mean: use "import __encodings__" in a program, have an __encodings__.py in a modules subdir (as is with __init__.py), or just on sys.path? Allowing for some kind of system and per-user customization seems prudent; a __magic__ file both feels natural (Pythonic) and could allow for system, program, and per-user settings or tweaks... > I think, this solves most problems. ...but it would be in addition to a `trigger' (like magic comments), right? No trigger, no overhead. <...> > I have a feeling that PEP is solving non-problem. Or have I lost > the thread? Who ever said a PEP must solve a problem. > For example, I usually write scripts where I assume "koi8-r" or > "windows-1251" encodings. And the only problems I have is when I use > "koi8-r" strings from modules when I need "1251" ones. (In this case I > explicitely recode). > > Aren't encodings better confined in documents (in XML for examples), > than programs? I agree, this is document meta-stuff and should be handled as far away from the language as possible. However, Python does need to look at documents at some point, so some way of transparently handling different encodings (and why not formats) is needed. > If programs need to be written in unicode, then isn't the next step > o allow embedding sound, graphics and video? > (I imagine video docstring ;-) cool... # ## format videodocstring > I can admit that using utf-8 in writing programs could be justified, > but Unicode... It will bring nightmare... ...if handled badly. - Bruce p.s. Q: How do you handle literate, unicoded source with video docstrings? A: .py-s are assumed to be usable without pre-processing, and only the bit of Python that handles the pre-processing determines when a source is actually a source.py. e.g., doing "python source", when `source' contains: # ## format noweb # ## format videodocstring # ## encoding utf-8 would result in Python running `source' through the noweb filter to separate the code from the docs, then through the videodocstring filter to split off the fancy docstrings, and finally doing whatever it needs to do to handle the non-standard encoding. The result would be called `source.py' and be stored <somewhere>; the next time Python gets handed `source' it can check for <somewhere>/source.py, and eschew the conversion steps if they have already been done. From morten at thingamy.net Wed Jul 25 08:45:00 2001 From: morten at thingamy.net (Morten W. Petersen) Date: Wed, 25 Jul 2001 14:45:00 +0200 (CEST) Subject: Making a Sircam virus-remover in Python In-Reply-To: <3B701D4B@twigger.nl> Message-ID: <Pine.LNX.4.21.0107251440340.25190-100000@bcryachts.atsat.com> On Wed, 25 Jul 2001, Hans Nowak wrote: > Sure, use the _winreg module that is available since 2.0: > > http://www.python.org/doc/current/lib/module--winreg.html Thanks, does anyone want to join in on this one? I'll collect some virus descriptions and start fleshing out a quick-n-dirty script. There's some programs out there that should supposedly remove the virus completely, but they don't even detect it.. -Morten From hdwinter at janbe.jnj.com Mon Jul 23 08:12:29 2001 From: hdwinter at janbe.jnj.com (Hans De Winter) Date: 23 Jul 2001 05:12:29 -0700 Subject: Newbie question on extending Python with C Message-ID: <13ea8ea6.0107230412.3a6e2dd@posting.google.com> Dear, I would like to extend the standard Python classes with a number of new ones implemented as C-structures. However, as a newbie to writing C-extensions for Python, I'm not entirely sure how to C-implement a Python class that can access the data from another C-implemented Python class. Could someone point me to the proper documentation where it is described how to achieve this? Many thanks, Hans From rupe at metro.yak.net Thu Jul 5 16:14:26 2001 From: rupe at metro.yak.net (Rupert Scammell) Date: 5 Jul 2001 13:14:26 -0700 Subject: Best method for updating pickled data objects? Message-ID: <79179cf5.0107051214.19990222@posting.google.com> I was recently working on a project that required that a single dictionary object be periodically written to a file via the pickle module. I quickly realized that the pickle.Pickler(file).dump(object) function would write updated copies of the same data object sequentially to the data file, rather than over-writing the older copy of the object with new data. To work around the problem, I wrote the following function, which takes two arguments; dictionary_file, a string containing the name of the file to pickle the data object in, and object, the name of the data object to pickle. def hash_update(dictionary_file, object): os.remove(dictionary_file) dfile = open(dictionary_file,"w") pickle_file = pickle.Pickler(dfile) pickle_file.dump(object) dfile.close() Deleting and recreating the pickle file, then writing out the data object from memory each time seems horribly inefficient to me (especially for large data objects). There's got to be a better way to do this. Any suggestions would be appreciated. From sh at ttsoftware.co.uk Mon Jul 2 09:48:19 2001 From: sh at ttsoftware.co.uk (Steve Horne) Date: Mon, 02 Jul 2001 14:48:19 +0100 Subject: PEP scepticism References: <mailman.993747643.21070.python-list@python.org> <9hfqb5$dsllb$3@ID-89274.news.dfncis.de> <3dhex01n1m.fsf@ute.cnri.reston.va.us> <roy-900E5D.10061401072001@news1.panix.com> Message-ID: <q5u0kt8grkoedsutk8tr61dnb3rcphmvg7@4ax.com> On Sun, 01 Jul 2001 10:06:14 -0400, Roy Smith <roy at panix.com> wrote: >indentation-for-grouping was a dumb idea. The problem is that it is just >too easy to add or delete whitespace by accident (and without noticing), >especially when cutting and pasting hunks of code from one place to >another. When such whitespace munging makes the code look ugly, it's >simply a minor annoyance. When it changes the meaning of the code, it's a >language design mistake. I've never had this problem. I'd say careful cutting and pasting - generally meaning that when I cut large blocks they are made of complete lines - was force of habit long before I used Python, simply because the odds are I'll have to read the code later - and bad indenting wastes a lot more time than taking care before you cut. But yes - it is a valid, considered opinion. Perhaps there would be some justification to wanting block structures to be marked, and bad indentation could then perhaps cause an error message to force you to tidy it up. But I don't know. I like Pythons lack of clutter. And so we return to the same old personal preferences. -- Steve Horne Home : steve at lurking.demon.co.uk Work : sh at ttsoftware.co.uk From dag at orion.no Mon Jul 2 04:14:49 2001 From: dag at orion.no (Dag Sunde) Date: Mon, 02 Jul 2001 08:14:49 GMT Subject: Help parsing XML References: <mailman.994060443.31499.python-list@python.org> Message-ID: <Z3W%6.736$em.12119@juliett.dax.net> Try changing the order of: <!DOCTYPE events SYSTEM "xml-concerts.dtd"> <?xml version="1.0" encoding-"ISO-8859-1"?> to: <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE events SYSTEM "xml-concerts.dtd"> ...and note the corrected "encoding=" instead of "encoding-"... It is not legal to have anything before "<?xml...", if present. Dag. "Skip Montanaro" <skip at pobox.com> wrote in message news:mailman.994060443.31499.python-list at python.org... > > Warning: I am a complete XML novice trying to parse some XML I dreamed up > with xml.sax.parse. > > I wrote a simple subclass of xml.sax.ContentHandler to parse some XML. It > defines startElement, endElement and characters methods. If I feed it > something simple like so: > > <events> > <event> > <performers> > <performer>James Taylor</performer> > <performer>Carly Simon</performer> > </performers> > <keywords> > <keyword>pop</keyword> > <keyword>rock</keyword> > <keyword>vocals</keyword> > </keywords> > <start-date>20010701T20:00</start-date> > <end-date>20010701T23:00</end-date> > <admission-price>$30</admission-price> > <venue-name>Pepsi Arena</venue-name> > <city>Albany</city> > <state>CA</state> > <country>US</country> > <submitter-name>Skip Montanaro</submitter-name> > <submitter-email>skip at mojam.com</submitter-email> > </event> > </events> > > it works fine. However, note the absence of <!DOCTYPE ...> and <?xml ...> > tags at the start. If I add them at the start of the XML file like so: > > <!DOCTYPE events SYSTEM "xml-concerts.dtd"> > <?xml version="1.0" encoding-"ISO-8859-1"?> > <events> > <event> > ... > > Python squawks: > > Traceback (most recent call last): > File "parsexml.py", line 72, in ? > xml.sax.parse("concert.xml", h) > File "/usr/local/lib/python2.1/xml/sax/__init__.py", line 33, in parse > parser.parse(source) > File "/usr/local/lib/python2.1/xml/sax/expatreader.py", line 43, in parse > xmlreader.IncrementalParser.parse(self, source) > File "/usr/local/lib/python2.1/xml/sax/xmlreader.py", line 123, in parse > self.feed(buffer) > File "/usr/local/lib/python2.1/xml/sax/expatreader.py", line 92, in feed > self._err_handler.fatalError(exc) > File "/usr/local/lib/python2.1/xml/sax/handler.py", line 38, in fatalError > raise exception > xml.sax._exceptions.SAXParseException: concert.xml:2:0: xml processing instruction not at start of external entity > > If I zap the <!DOCTYPE ...> tag I get this: > > Traceback (most recent call last): > File "parsexml.py", line 72, in ? > xml.sax.parse("concert.xml", h) > File "/usr/local/lib/python2.1/xml/sax/__init__.py", line 33, in parse > parser.parse(source) > File "/usr/local/lib/python2.1/xml/sax/expatreader.py", line 43, in parse > xmlreader.IncrementalParser.parse(self, source) > File "/usr/local/lib/python2.1/xml/sax/xmlreader.py", line 123, in parse > self.feed(buffer) > File "/usr/local/lib/python2.1/xml/sax/expatreader.py", line 92, in feed > self._err_handler.fatalError(exc) > File "/usr/local/lib/python2.1/xml/sax/handler.py", line 38, in fatalError > raise exception > xml.sax._exceptions.SAXParseException: concert.xml:1:41: syntax error > > If you're wondering what sort of XML I'm trying to parse, my first cut at a > DTD (I'm a complete novice at DTD writing as well) is at > > http://musi-cal.mojam.com/~skip/concerts.dtd > > I suspect this is more a problem with my lack of XML expertise than with > anything specific I'm doing wrong with my content handler. Suggestions or > pointers to appropriate XML tutorial material would be appreciated. > > Thanks, > > -- > Skip Montanaro (skip at pobox.com) > (847)971-7098 > From barry at digicool.com Mon Jul 9 10:07:50 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Mon, 9 Jul 2001 10:07:50 -0400 Subject: Bug in rfc822 References: <slrn9khcjv.c7q.philh@comuno.freeserve.co.uk> <QFc27.8798$e5.1167735@newsb.telia.net> Message-ID: <15177.47798.190647.733698@anthem.wooz.org> >>>>> "FL" == Fredrik Lundh <fredrik at pythonware.com> writes: >> I have just found out that rfc822.py doesn't conform to >> RFC2822. FL> sounds like it's time to rename that module ;-) mimelib <wink> -Barry From ullrich at math.okstate.edu Fri Jul 27 09:51:02 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Fri, 27 Jul 2001 13:51:02 GMT Subject: [OT] Number theory [Was: A use for integer quotients] References: <yCK67.17615$EP6.4467503@news1.rdc2.pa.home.com> <mailman.995860718.9550.python-list@python.org> <mailman.995862939.15013.python-list@python.org> <mailman.995883879.12071.python-list@python.org> <3B5C5665.8D41D1F1@tundraware.com> <slrn.pl.9los0f.jh4.qrczak@qrnik.zagroda> <3B5C749A.59F97320@tundraware.com> <JDa77.97061$Rr4.549007@ozemail.com.au> <Xns90E97C9849AD5robindotgarneratinam@172.18.25.3> <IjA77.97824$Rr4.589251@ozemail.com.au> <3b602afa.930850@nntp.sprynet.com> <slrn9m121m.e6f.Gareth.McCaughan@g.local> Message-ID: <3b617133.1013412@nntp.sprynet.com> On Thu, 26 Jul 2001 22:14:30 +0100, Gareth.McCaughan at pobox.com (Gareth McCaughan) wrote: >David Ullrich wrote: > >[someone else:] >>> So strictly speaking, Z (the set of integers) is not a subset of R (the set >>> of reals)? >> >> Strictly speaking yes, but nobody _ever_ speaks this strictly >> (except in contexts like the present). >> >> We math guys have reduced more or less everything to sets these >> days - fewer things at the bottom to keep track of. So when we >> want to define a "type" with certain "properties" we figure out >> how to "code" such a thing as a certain sort of set. But almost >> always what set something actually is makes no difference, all >> that matters is how it works. >> >> Strictly speaking the natural number 2 is the set {{},{{}}} > >Tut. You're failing to distinguish interface from implementation. Tut what? If you read more than one paragraph you see that my point was exactly that when we say that Z is not strictly a subset of R that's an irrelevant implemenation detail. >That's one way to define the number 2, which happens to be the >usual one at the moment. It's not the only way. Frege wanted >2 to be the set of *all* unordered pairs {x,y}, and there are >versions of set theory in which that definition works. In NF, >sometimes 2 is defined as {{{}}}. Or there's the Conway approach, >according to which the primitive notion is that of "ordered >pair of sets" and 2 is an equivalence class whose "typical" >member is ({0,1}, {}). > >I'm pretty sure you already know all this, but it's worth >saying explicitly. :-) Probably the fact that I _did_ say explicitly that there are several different "standard" ways to implement integers and reals is what makes you suspect I know this, eh? Very astute of you. >> So yes, strictly speaking the integers are not a subset >> of the reals. But nonetheless if someone asks "Are the >> integers a subset of the reals?" the _right_ answer >> is "yes"; the answer becomes "no" only if we're focussing >> on the irrelevant aspects of things. > >Right. And, actually, I'd say that the isomorphic image >of (say) Z inside R *is* the integers. For exactly the >reasons you mention, what you really mean when you say >"the integers" is "anything that behaves like the integers". >That copy of Z is such a thing. The fact that for some >foundational purposes you start by constructing another >copy of Z doesn't invalidate that. So, I say: for *all* >purposes "the integers are a subset of the reals", unless >for some technical reason you *have* to pick an implementation >of the integers *and* can't make it be the one that lives >inside R. > >-- >Gareth McCaughan Gareth.McCaughan at pobox.com >.sig under construc David C. Ullrich From eduard.hiti at t-online.de Thu Jul 12 15:08:20 2001 From: eduard.hiti at t-online.de (Eduard Hiti) Date: Thu, 12 Jul 2001 21:08:20 +0200 Subject: Python NT Service References: <83241e1a.0107121019.308ebc6f@posting.google.com> Message-ID: <9ikskm$2cg$04$1@news.t-online.com> You didn't include much code to look at ;-) >From where are you importing this class? Is that module on a network share? Services can run under different users, so the share may not be available. Try importing your module from a local drive. "Pradeep Kulkarni" <pkulkarni at sequoianet.com> wrote in message news:83241e1a.0107121019.308ebc6f at posting.google.com... | I am not able to import a user class (a class which send a mail) in my | NT service, which I am trying to develop since three days. Any help in | this problem would be appreciated. | | Thank you - Pradeep From max at alcyone.com Sun Jul 22 14:05:50 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 22 Jul 2001 11:05:50 -0700 Subject: BURNING EARTHSHAKING Tuple Question References: <5e8bd451.0107191249.3c0d9f21@posting.google.com> <3B58EBF4.F24E5129@alcyone.com> <pmglltoiomis08cg8s18ogql1psmb4knkj@4ax.com> Message-ID: <3B5B15FE.A6B51D9F@alcyone.com> Stephen Horne wrote: > Funny - the guy who last taught me maths insisted on the > rhymes-with-couple version. tOOple sounds too high brow to me - > British snobs tend to say things the longest, most stretched out and > emphasised way they can - presumably they need to make up for the lack > of content by at least making their words sound as impressive as > possible. American high brows, I presume, are too busy making money to > waste time saying 'oo' when they can just say 'u' ;-) Yeah, I stick with the _couple_-rhyming version as well. It's the pronunciation I've heard most often. Strangely enough, when he was attempting to correct me, he said that he'd never heard anyone pronounce it to rhyme with _couple_. He started off in academia, so perhaps when mathematicians are isolated with other mathematicians they tend to pronounce it that way. I really don't 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 / \ Never use two words when one will do best. \__/ Harry S. Truman Alcyone Systems' CatCam / http://www.catcam.com/ What do your pets do all day while you're at work? Find out. From aleaxit at yahoo.com Tue Jul 3 10:41:37 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 3 Jul 2001 16:41:37 +0200 Subject: Python and DB support (was: Re: Is Python Dead?) References: <mailman.994100826.19440.python-list@python.org> <9hqoe8019j5@enews4.newsguy.com> <3b4116e1$1@mercury.its.rmit.edu.au> Message-ID: <9hslj4029ga@enews1.newsguy.com> "Zen" <zen at shangri-la.dropbear.id.au> wrote in message news:3b4116e1$1 at mercury.its.rmit.edu.au... > "Alex Martelli" <aleaxit at yahoo.com> writes: > > >Yep, the recordset part of ADO is undoubtedly the most popular single > >feature of it among us lazy programmers. You can even disconnect from > >the DB and keep the recordset around, persist it to a file (maybe in XML), > >depersist it later... it's fun!-) > > I'm preparing a PEP to address a few issues with the Python DB API > and an initial draft has been presented to the DB-SIG. > > I'm unfamiliar with ADO. When you retrieve a recordset, are all > relevant tuples retrieved from the database (like the Cursor.fetchall() > method in the DB API)? Or is it a lazy object that only downloads > the rows when they are accessed by the application (like the Cursor.fetch() > or Cursor.fetchmany() methods in the DB API)? Yes. That is, you can program it either way, ot a bit of each (see later). > Can you provide examples of things you can do using the ADO interface > (don't care what programming language) that are difficult to do using > the Python DB API? Even if it is outside the scope of *this* PEP, I need > to understand peoples wishlists to ensure they can be integrated > in the future. An ADO Recordset holds results from a datasource and implements or delegates cursor behavior to the datasource. Once the Recordset has some data, you can keep working with the Recordset (even in an independent way from the datasource) -- navigate in it, modify it, persist and depersist it... at some later time you may decide to connect to the datasource again, and have the Recordset send an 'update' to the datasource regarding the modifications you did to the Recordset while the datasource was away. It's *NOT* what I would call a shining example of clean, minimalist, elegant OO design. It *IS* deucedly handy and seductive as soon as you start getting used to it, though:-). One example of systematical, handy though inelegant, redundance. Basically all parameters to methods are optional. If you do not supply them, the object uses some of its properties as the parameters. You can query and change the properties at some time, and later call the methods without parameters and they'll do the right thing, or pass some parameters and have only some others default. Think of it as cheap and inelegant, but handy and versatile, 'overridable currying'. So take for example the Open method of a Recordset. It has an argument Source (or that may default from the Source property of the Recordset) which can be a Command object (which can encapsulate several different ways to fetch data) or a text string which, together with option flags, can be implicitly used to build the suitable Command object (an URL, an SQL statement, a Stream object containing a persisted Recordset, etc, etc). An Options argument lets you specify several things (again, you can use properties if you prefer) such as the execution-and-fetching model: adAsyncExecute fully asynchronous adAsyncFetch synchronous for the first CacheSize rows, then async for the rest (CS is a property) adAsyncFetchNonBlocking like adAsyncFetch, but the attempt to read a row not yet fetched won't block adExecuteNoRecords no records are expected in response to the command, the framework will throw away any that might return (but shouldn't:-) adExecuteStream the results are packaged up as a Stream object adExecuteRecord special-case: ONE, but only one, record is returned as the result Default is synchronous access, but the options, as you see, are many. Indeed perhaps TOO many -- not all apply in all situations, always a bad sign (e.g., adExecuteStream with a Source that is NOT a Command object executing is an error). But back to the Open verb. An argument ActiveConnection lets you specify on what connection to open the recordset (a Connection object, a string from which it can be constructed, can default from the connection properties of the recordset itself OR of the command object if you have passed one as Source argument, etc). And then you get to specify (still at Open time) what kind of cursor-type and lock-type you desire. Which is a big topic in itself. adOpenForwardOnly only lets you move forward in the recordset, but is lightweight and may afford optimization. At the other extreme, one can adOpenDynamic and see committed (or even uncommitted, if that's the isolation level for your transaction) changes made by other users while the cursor is open. The transparent get recordset/disconnect/persist the recordset/depersist it later/worh with the recordset (client-side cursor of course!)/persist it again/&c and later reconnect and send the update (as just a delta). All of the clientside software that displays and edits the recordset doesn't even *know* whether it's working on a live DB connection or in such a disconnected edit-at-leisure scenario -- it's all easily encapsulated. If I had to choose one big convenience feature, I think that would be it. Maybe we can get such a level of convenience WITHOUT adopting the "richly redundant architecture" that is so characteristic of ADO... laziness apart, having to do things in one specific sequence rather than any which way isn't half bad (easier to document and explain, not to mention code and test, for example). But apart from such issues there IS real power in such a concept as "a temporarily disconnected and possibly persisted recordset" and the ability to operate polymorphically on either THAT, or a live DB connection. > >> From this and also from my own experience with PostgeSQL queries from > >> Python, I could say that DB support in Python exists, but need enhancement > >> and standartization. Probably, higher level more or less common > >> object-oriented interfaces could help this. > > >It seems to me the (DB API 2) standard is fine (maybe a bit too > >ambitious, so actual implementations may not have reached up > >to it yet?-). > > The 2.0 driver implementations of the major databases seem fine to me. > One problem I notice with database tools is extremly rare for someone > to deal with more than three vendors RDBMS implementations, and generally > people only develop with one or two. True. The specific DB-using product I currently consult for (Think3's ThinkTeam PDM package) currently fully supports only Oracle, SQL Server, and (ecch) Jet (aka "the Access DB") -- we've more or less dropped Informix, Ingres &c as years went by. But my dad's office still works on Watcom SQL (on DOS 3.1...), and of course one has to keep evaluating new releases of such things as MySQL, Interbase, etc, so I try to keep current on more RDBMS's than are strictly necessary for my job. And emerging standards... > >If I had a vote, I'd rather seen _Gadfly_ tuned up (out with regex > >and regsub, in favour of re; minimal-tolerance support of stuff it > >does not implement, such as NULLs) and made a part of Python. It > > I agree that it would be a benefit and worth a PEP if the > Gadfly author agrees and someone volunteers to do the > required tweaking. But would then Gadfly be included in the standard Python distribution if so tuned-up and tweaked? If it's to remain an isolated module the motivation to go and clean it up is an order of magnitude lessened, I think. Having Gadfly in the distribution would really enhance the "batteries included" part of Python's appeal...!!! Of course, it would have to be made clear in the docs that Gadfly is great for small problems but that you can scale up your programs to other (compatible) DB interfaces and put a DB engine behind them, etc, etc. > I don't see a point in including drivers in the core for databases that > follow a different development cycle. Last thing we want is obsolete > PostgreSQL drivers out there when a new version of PostgreSQL is > released. Although PHP manages to do this.... can any PHP users comment? I would hope major DB vendors keep compatibility in their next releases with programs developed to their previous API's...! My objection would be another -- if there are a dozen major RDBMS's and I, as a typical user, care about 1 or 2, why would I want to download the other 10 or so at each Python upgrade? Alex From tjreedy at home.com Tue Jul 31 13:31:35 2001 From: tjreedy at home.com (Terry Reedy) Date: Tue, 31 Jul 2001 17:31:35 GMT Subject: FEEDBACK WANTED: Type/class unification References: <mailman.996527936.11861.python-list@python.org> <cpd76hzjey.fsf@cj20424-a.reston1.va.home.com> Message-ID: <XXB97.56072$EP6.12803318@news1.rdc2.pa.home.com> Guido > I think 'self' would be confusing. I'd like to propose 'cls'. [long slew of suggestions deleted] > Sigh. I sympathize with the desire for a non-acronym, none of the > proposals work for me -- they are all neologisms in this context. > Ditto for "us" etc. I'll drag in my suggestion from a slightly different context: 'cat' for class and type. Or if you insist on abbreviating 'class', then 'cas' is pronouncable. To me, 'cls' is a toss-up with 'class' (whoops, keyword) or 'clas'. In the absence of a aesthetically and logically compelling standard, I suspect people will try lots of things for class methods. -- Suppose one make all methods class methods and raises an exception in __init__(). Would the result do what people want for a singleton? Terry J. Reedy From rnd at onego.ru Sun Jul 15 15:43:32 2001 From: rnd at onego.ru (Roman Suzi) Date: Sun, 15 Jul 2001 23:43:32 +0400 (MSD) Subject: Python, C++, Java, Smalltalk, Eiffel,... In-Reply-To: <20010715171817.D5396@xs4all.nl> Message-ID: <Pine.LNX.4.30.0107152336180.23284-100000@rnd.onego.ru> On Sun, 15 Jul 2001, Thomas Wouters wrote: >On Sun, Jul 15, 2001 at 10:20:38AM -0400, kj0 wrote: > >> Where can I find a reasonably non-partisan but also reasonably >> detailed comparison of the more popular OO languages (C++, Java, >> Python, etc.). (All the comparisons I've found are clearly slanted to >> demonstrate the superiority of the authors' favorite OO language--I'm >> sure it would be easy to find one written by unapologetic Python >> advocates :-) ) Before doing aby comparisons, you must specify your criteria. Or you will engage in positional flame-war. >> I'm not looking to find out which of these languages is "better"; I >> don't care for ranking here. > >The problem is that there isn't one "better", just "better in the eyes of >the author", and that is oddly enough also the reason why you, as you state >in the first paragraph, are unable to find one that isn't biased :) > >> What I want to know is how the various >> popular OO languages compare in terms of OO and general programming >> features (e.g. multiple inheritance; classes-as-objects; garbage >> collection; closures; scoping; contracts; debugging; etc.). > >I seriously think your best bet is to start learning each language. You >can't compare apples and oranges unless you ate them both, and you need to >learn that, for instance, you *peel* the orange first, and you avoid the >middle part of the apple, and you avoid the seeds of both these fruits (but >they are considered the best parts of other fruits.) It'll take the most >time, but it'll be the most satisfying answer, as programming language >preferences are pretty personal. 8-) never heard such a vivid explanation of personal computer language preferences! >I think Python should be the strawberry. It's nice and small, easy to >digest, no need to bite chunks out of it, almost all of it is edible, and >whatever warts it has are plainly visible from the outside :) But unlike strawberries, you can eat, eat and eat it ;-) >I-had-strawberries-for-breakfast-ly y'rs, "-".join("""Thanks for reminding that I have fresh strawberries in my freezer ly y'rs""".split()) Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Sunday, July 15, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "This is Borg. <ESC> is futile <CTRL> is inevitable" _/ From new_name at mit.edu Fri Jul 6 16:31:19 2001 From: new_name at mit.edu (Alex) Date: 06 Jul 2001 16:31:19 -0400 Subject: the C++ Standard Library for Python References: <hin17.110546$Mf5.30282205@news3.rdc1.on.home.com> <QIo17.427166$eK2.86457968@news4.rdc1.on.home.com> Message-ID: <etdhewpkdew.fsf@lola-granola.mit.edu> Sigh, I wish I had a windows machine. This C++/Python integration has really hurt to miss out on. :) Alex. From peter at engcorp.com Wed Jul 18 19:52:21 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 18 Jul 2001 19:52:21 -0400 Subject: software documentation system? References: <mailman.995486071.13046.python-list@python.org> Message-ID: <3B562135.94CD2A7@engcorp.com> Graham Guttocks wrote: > A Python application of mine is now large enough that I need to get > more serious about writing a real manual for it. I'm looking for a > documentation system that uses a single source file to produce both > online information and printed output. (PS, HTML, etc.) > > Any recommendations? I work in a UNIX environment and would prefer > an opensource alternative. So far I've found GNU texinfo and also > SGMLtools which is written in Python, but am open to other > suggestions. It's not a completely "canned" solution, but if you were to use XML for the content (perhaps using the DocBook vocabulary http://www.oasis-open.org/docbook/ ), and XSLT stylesheets to generate the output (direct to HTML in one case, to XSLFO in another and then use, say, FOP to convert to PDF format) you could build such a beast "relatively" easily (compared to the less easy alternatives :-), using pure open source and even some more Python (http://4suite.org/index.html for the XSLT). This has the "advantage" of being about as bleeding edge as you can get without passing out... ;-) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From grante at visi.com Mon Jul 30 23:45:28 2001 From: grante at visi.com (Grant Edwards) Date: Tue, 31 Jul 2001 03:45:28 GMT Subject: "Systems programming" (was: Language Niches (long)) References: <8beb91f5.0107280407.5a30341d@posting.google.com> <mailman.996429234.13926.python-list@python.org> <Ej5QPKA1WHZ7EwvP@jessikat.fsnet.co.uk> <slrn9m96vj.f4i.grante@tuxtop.visi.com> <4E215400D01D7374.0068C51FD6502BE8.99D4E013ECF0FDFB@lp.airnews.net> <bhahn-ya02408000R3007012032180001@news.corp.hp.com> Message-ID: <slrn9mcafp.qj.grante@tuxtop.visi.com> On Mon, 30 Jul 2001 20:32:18 -0700, Brendan Hahn <bhahn at spam-spam.g0-away.com> wrote: As long we're completely off-topic (Python-wise)... >You can do kernel stuff in C++ on a lot of systems, but it's >often more trouble than it's worth...kernel versions of the C++ >runtime can be very quirky. NT is actually pretty nice for >doing C++ drivers. Now that you mention it, I knew that. Not long ago I was helping a guy try to decypher some C++ code in an NT driver. [What a mess: there were local variables that shadowed instance variables that shadowed global variables, and all of the instance variables were accessed via cpp macros. It was like somebody was _trying_ to be obtuse.] The question of how to write a Linux driver in C++ comes up fairly regularly. In theory it's possible as long as you don't use features X,Y, and Z, and you include a set of kenel-mode runtime support routines. Nobody ever wants to try it badly enough. >You could use Objective-C on the old NeXT systems -- Apple has >switched to a C++ IO system, for better performance, but using >a restricted subset of the language. Haven't tried it yet but >I think it'll be nice. Is that in OS X? I thought it was BSD under the hood? >Forth is actually in very wide use, but at the sub-OS level -- >any Open Firmware system starts up running Forth, and if you >want a boot driver for a new storage adapter, say, you write it >in Forth and put it in ROM on the card. That always sounded like a very elegant system -- though I've never worked with it. -- Grant Edwards grante Yow! I'm meditating on at the FORMALDEHYDE and the visi.com ASBESTOS leaking into my PERSONAL SPACE!! From dgrisby at uk.research.att.com Wed Jul 25 05:32:42 2001 From: dgrisby at uk.research.att.com (Duncan Grisby) Date: 25 Jul 2001 09:32:42 GMT Subject: Version compatibility in division References: <mailman.995916220.13066.python-list@python.org> <loj77.544242$eK2.114179510@news4.rdc1.on.home.com> Message-ID: <9jm3nq$ulf$1@pea.uk.research.att.com> In article <loj77.544242$eK2.114179510 at news4.rdc1.on.home.com>, Nick Perkins <nperkins7 at home.com> wrote: >I suppose the only cross-version solution would be: > > # Script MUST run under various Python versions without change > ... > print int(container/widget) ,'widgets will fit in the container' > >It's a tiny bit verbose, but at least it's very explicit. And also wrong in the face of negative divisors (although you probably wouldn't have a negative number of widgets :-) ). >>> 5/-2 -3 >>> int(5.0/-2.0) -2 The "simple" solution is divmod(container, widget)[0]. Lovely. Cheers, Duncan. -- -- Duncan Grisby \ Research Engineer -- -- AT&T Laboratories Cambridge -- -- http://www.uk.research.att.com/~dpg1 -- From maxx at easynews.com Thu Jul 12 20:33:49 2001 From: maxx at easynews.com (maxx at easynews.com) Date: Fri, 13 Jul 2001 00:33:49 GMT Subject: Win32 ADO Connection not closing? Message-ID: <b3gskt8crat32ha1nqjd1m3vajcubmqc81@4ax.com> In the code example below, an ADO connection to a MS SQL Server database is not closing. Even after the 'adoConn.Close()' statement, the SQL Server still has an open connection to the database. The connection does release after the script terminates. As part of the function of the script, I need it to release connections to the database, before continuing. Is there a way to explicitly destroy the adoConn object in the following example ? adoConn = win32com.client.Dispatch('ADODB.Connection') connect = "Provider=SQLOLEDB.1;Data Source=%s;Initial Catalog=%s;User ID=sa;Password=;" % (server, dbname) adoConn.Open(connect) sql = "SELECT * FROM table1" rs = adoConn.Execute(sql) rs[0].Close() adoConn.Close() From Randy.L.Kemp at motorola.com Thu Jul 5 10:24:53 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Thu, 5 Jul 2001 09:24:53 -0500 Subject: FTP program works -- now how do I send the directory over? Message-ID: <E566B020833BD311B6610008C791A39705CA5209@il93exm04.css.mot.com> Thanks. I will try that out today. -----Original Message----- From: Oleg Broytmann [mailto:phd at phd.fep.ru] Sent: Thursday, July 05, 2001 9:08 AM To: Kemp Randy-W18971 Cc: 'python-list at python.org' Subject: Re: FTP program works -- now how do I send the directory over? On Thu, 5 Jul 2001, Kemp Randy-W18971 wrote: > I seem to be getting the listing of what's on my d drive in windows, rather then the binary contents. Here is what I do (the server id changed to protect the innocent: > > for filename in glob.glob('d:\programsPython\*'): > ftp.storbinary("STOR " + filename, open(filename, 'rb')) > List the directory contents in Unix > > ee110:/usr2/ecadtesting/tarbackups> ls > d:\programsPython\CE H2-102000 Usage Mentor1.txt > Why do I get the text d:\programsPython\filename? Because glob() returns full path, so you end up running commands like ftp.storbinary("STOR " + 'd:\\programsPython\\CE H2-102000 Usage Mentor1.txt'... (please note double backslashes) If you want just filenames without path you can do one of two things: 1) cd d:\programsPython (os.chdir("d:\\programsPython")) and then use glob('*') - this will list just the curent directory 2) or cut off the file/path yourself: for filename in glob.glob('d:\programsPython\*'): name = string.split(filename, '\\')[-1] ftp.storbinary("STOR " + name, open(filename, 'rb')) > How should I change the program to get the actual files sent over? Why do you think those funny files are not real files? It is just UNIX didn't interpreted backslashes! :) I am sure they are your real files! Test it. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From jonas.b at home.se Thu Jul 12 17:17:40 2001 From: jonas.b at home.se (Jonas Bengtsson) Date: 12 Jul 2001 14:17:40 -0700 Subject: Problems getting mod_python up n' running Message-ID: <4e2ddb70.0107121317.4c883f6c@posting.google.com> Hi, I can't get mod_python to work. I get this error message when I'm restarting Apache: make_obcallback(): could not import mod_python.apache. make_obcallback(): could not call init. And when I try to look at a .py page I get following error: [Thu Jul 12 03:33:12 2001] [error] [client 127.0.0.1] python_handler: make_obcallback returned no obCallBack! What is wrong? I've got: Apache/1.3.19 (Win32) mod_python/2.7.4 Python/2.1 Running under Windows 2000 I have put mod_python.dll.in E:\program\apache\modules and following rows to httpd.conf: #DSO section LoadModule python_module e:/program/apache/modules/mod_python.dll #under my main directory AddHandler python-program .py PythonHandler mptest PythonDebug on Furthermore I have put following files under e:\program\python21\libs\mod_python: __init__.py apache.py cgihandler.py httpdapi.py publisher.py util.py zhandler.py And my environment path contains: E:\Program\Python21;e:\Program\Python21\libs What can be the problem? TIA Jonas Bengtsson From brian at supremecasino.com Tue Jul 24 11:25:03 2001 From: brian at supremecasino.com (brian at supremecasino.com) Date: 24 Jul 2001 15:25:03 -0000 Subject: We Have Big News and Free Money For You!! Message-ID: <20010724152503.55886.qmail@multiwebhosting.com> An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-list/attachments/20010724/8bdd4ea2/attachment.html> From thomas at xs4all.net Fri Jul 20 07:52:31 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Fri, 20 Jul 2001 13:52:31 +0200 Subject: Case insensitivity In-Reply-To: <cpvgkofyru.fsf@cj20424-a.reston1.va.home.com> References: <mailman.995506711.21636.python-list@python.org> <cpvgkofyru.fsf@cj20424-a.reston1.va.home.com> Message-ID: <20010720135231.L2054@xs4all.nl> On Thu, Jul 19, 2001 at 08:30:15PM +0000, Guido van Rossum wrote: > TeachScheme is an interesting case -- Scheme is a case-sensitive > language, but in "beginner mode", TeachScheme is case-insensitive. I > can't find it on the web, but I bet the TeachScheme folks have a > rationale for this decision. I have another good example for you: LambdaMOO, which is (as I've said in other posts) very Pythonic, is not only case-insensitive in its identifiers, it's even case-insensitive in string comparison: eval ;{A, a} = {"upper", "lower"} ; player:tell("a is " + a + " and A is " + A) a is lower and A is lower (the first statement is a 'sequence unpacking', the second is MOO's version of a method call (<object>:<method>), and the 'eval' and semicolons are necessary to evaluate the expression "on the prompt" :) eval "SOMETHING" == "something" => 1 It's true that this makes it a lot easier for real programming-newbies to learn the language, and to learn programming (I know it certainly helped in my case!) but whether it's a net win in the end is something else. It helps because it takes the burden off of the programmer to remember that kind of detail, allows them to focus on what's important (this is another common trait in MOO and Python :-) and thus lower the learning curve. It did take me a while to get used to case-sensitive string comparison in the real world, but I never really used the case-insensitive identifiers (on the other hand, it never bit me either, as far as I recall.) On the other hand, some people would argue that I'm a decent programmer, intuitively, and that I'm not a good example. I know of MOO-programmers that do use and enjoy and sometimes even need the case insensitivity, but none of those has even thought about programming outside of MOO. I kinda doubt they'll be persuaded by a case-insensitive Python; they like programming in an interactive environment, where you show off you programs to your ('net) friends and to total strangers alike, and where you can @list other people's programs to see how they do it. Now if Python had something like that, that'd sure get 'kids' of all ages addicted :) > To me, the only real important question is, how can we introduce > case-sensitivity for novices without breaking the millions of lines of > existing Python code. One option could be: forget it, it's too late. > Another: put the case-insensitivity in the tools. I'd opt for the tools. -- Thomas Wouters <thomas at xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From tim at vegeta.ath.cx Sun Jul 15 19:15:17 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Sun, 15 Jul 2001 23:15:17 GMT Subject: OO misconceptions (was: Re: Long Live Python!) References: <mailman.994969462.27792.python-list@python.org> <hevsktcrnpckttnkgi1arcue5kjjsbrrb5@4ax.com> <mailman.995046506.2514.python-list@python.org> <9ir1l7$3ja$1@panix2.panix.com> <9irfbc11jaq@enews1.newsguy.com> Message-ID: <slrn9l49me.p58.tim@vegeta.ath.cx> <*someone*@ActiveState.com> wrote: > Python allows you to build larger systems because it allows a looser > binding between granular components, it allows more to be done in less > code and it makes testing so much easier that the loss of compiler > warnings is trivial. I'm all for rapid development and such, and I use Python whenever I think it has an advantage over another choice (which is quite often). But what does 'larger' mean in this case? Larger than the MySQL engine? Larger than a linux kernel? Larger than the Red Hat install scripts? I wouldn't implement a RDBMS in Python. Nor would I implement a word processor in assembler. *nix OSes (like BSD) have attained an incredible scalability. Many attribute this to the fact that everything in this OS is a "file", whether data on a hard drive, a hardware device, or a running process. This is a type of abstraction. Obviously /dev/scd0 isn't a file, at least not in the sense that /etc/services is. But each "file", regardless of what it's linked to, has the same basic interface: open, close, read, write, etc. Is this not a form of OO? And what language is the majority of the core of BSD written in? It's written in C, which does not even claim to be an OO language. An application's scalability has much more to do with the programmer's use of algorithms and abstraction than with the language in which it's implemented...no matter how much money ActiveState has invested in it. -- It's astonishing how much trouble one can get oneself into, if one works at it. -- Destruction, The Sandman From peter at engcorp.com Mon Jul 16 21:00:06 2001 From: peter at engcorp.com (Peter Hansen) Date: Mon, 16 Jul 2001 21:00:06 -0400 Subject: OO misconceptions References: <mailman.994969462.27792.python-list@python.org> <hevsktcrnpckttnkgi1arcue5kjjsbrrb5@4ax.com> <mailman.995046506.2514.python-list@python.org> <9ir1l7$3ja$1@panix2.panix.com> <9irfbc11jaq@enews1.newsguy.com> <slrn9l49me.p58.tim@vegeta.ath.cx> <mailman.995268208.1394.python-list@python.org> <slrn9l6kci.qqs.tim@vegeta.ath.cx> Message-ID: <3B538E16.65394C9D@engcorp.com> Tim Hammerquist wrote: > My only regret is that so many people in this NG are so violently > anti-Perl. I always thought that if someone as cynical, stubborn, and > arrogant as I am can love both languages, anybody could. I wouldn't have said "violently". That is to say, I haven't actually *killed* anyone for using Perl... yet. And I consider my cynicism, stubbornness, and arrogance to be right up there with the best of them. (In fact, my absolutely _unparalleled_ arrogance is _certain_ to be my own downfall, and _nothing_ you could say would convince me otherwise. ;-) Nevertheless, I feel compelled to say that I believe there may be applications for which Perl is the better language, but I'm fairly sure (a) I'd have an argument against _almost_ any example proposed, and (b) the few I might not argue against would likely be "better in Perl" only because of some ugly situation such as maintaining compatibility with a legacy system, supported by programmers who know only Perl and don't want to change, and an application already working and therefore not in need of maintenance of any kind. Any other application, and I would probably say Python was a better choice... > There's always a matter of choosing the right tool for the job, > but this is reality and no one language can be the "right" tool > for _all_ jobs, regardless of how much I love Python. Ah, but I would readily admit Python is not the right tool for *all* jobs, just a better one than Perl in essentially any case I've seen to date, IMHO. I remain open-minded enough to admit that someday I might have a Perl program shoved in front of me for which I'd be forced to admit I'm wrong... I'm still waiting. > My apologies to the group at large. > Tim Hammerquist This group is scary in its degree of both tolerance and forgiveness. (Hey, they even let me stay here.. so far. :) Cheers, ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From chrishbarker at home.net Fri Jul 20 15:48:06 2001 From: chrishbarker at home.net (Chris Barker) Date: Fri, 20 Jul 2001 12:48:06 -0700 Subject: Variable Substitution in commands or funtion names? References: <mailman.995577213.28399.python-list@python.org> Message-ID: <3B588AF6.3D6ED3A5@home.net> fleet at teachout.org wrote: > It looks like all I need to do to convert to your suggestion is add: > > "Customers={" before "Antonia," replace the "=" after Antonia with an > opening brace (and ditto for each of the other customers) and add a > closing brace at the end of the customers. Yep, that's all. > >Customers = {smith: {"busname":"Smitties", "street":"123 West Ave"}, > > jones: {"busname":"Joneses", "street":"123 East Ave"}, > > ....} > > And how are these NOT hardcoded into a module? How would I access them > otherwise? Yes, they are also hardcode into the module if you type it in there. IN fact, I have been know to do it myself, it's easier than putting it in a text file, and then having to parse out the text file to build your dict. The differences are: A) It's easier to access your data B) You can now manipulate the data as well. It might start hardcoded, but you can now manipulate the data far more easily after reading it in: add to it, change it etc. C) you can also write it out more easily, in fact, if you use repr(), you will get a string that can be eval() back to the same dict. D) you can also change how the data is stored in the future, and still access it in the same way, byt writing a class that emulates a mapping. The data could be in text files, in a database, whatever. > Thanks for the input. I'll try this. > > - fleet - have fun! -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 Jul 4 09:06:10 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 4 Jul 2001 15:06:10 +0200 Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> <9hrj3q$cj1@news1.gtech.com> <bebbba07.0107031040.593143f8@posting.google.com> <20010704013238.2DC8A00.NOFFLE@niccolo.ke4.de> Message-ID: <9hv4c301ts3@enews1.newsguy.com> "Mirko Liss" <mirko.liss at web.de> wrote in message news:20010704013238.2DC8A00.NOFFLE at niccolo.ke4.de... ... """ If the arguments of a function are out of order, the compiler should bark and die, shouldn?t it? """ I was taught "shud" is a four-letter word, to be avoided in mixed company. """ Most programmers use type definitions deliberately, just to provoke that kind of compile-time errors. """ In that case, most programmers' hopes are going to be frustrated, if most programmers are working in C. """ An example in C: typedef plane_t int ; /* plane no */ typedef lane_t int ; /* lane no */ typedef go_down_in_pieces_t bool ; go_down_in_pieces_t dispatch( plane_t flightno, \ lane_t neigboring_highway ) ; If the arguments get swapped, the compiler gets angry. Is this what you wanted to have in C ? """ If the compiler gets angry, then the compiler keeps its emotions too bottled-up, and the compiler might be well advised to see an analyst about it, because the compiler is definitely giving no indication at all of its internal emotional turmoil here. In other words, quite apart from the fact that you're apparently reversing the 2nd and 3rd arguments to the various typedef's, AND labouring under the misconception that there is a 'bool' keyword in C (there's one in C++, and I don't know enough about C99 -- maybe they've borrowed it?), there appears to be a fundamental error or deep-misconception here... you *DO* know the most elementary fundamentals of C, right? Such as the fact that type-equivalence is *BY STRUCTURE*, *NOT* by name, and therefore no typedef is ever going to cause a failed compilation because of two "int" arguments getting swapped...?! I.e., once we've fixed the obvious issues: typedef int plane_t; typedef int lane_t; typedef int bool; typedef bool go_down_in_pieces_t; go_down_in_pieces_t dispatch( plane_t flightno, lane_t neighboring_highway); this will compile just fine...: plane_t krek = 23; lane_t pruk = 42; dispatch(pruk, krek); /* oops... */ Oh, and -- that backslash you use is redundant. Not the major issue with your post, sure, but... Alex From machin_john_888 at hotmail.com Tue Jul 31 18:47:56 2001 From: machin_john_888 at hotmail.com (John Machin) Date: 31 Jul 2001 15:47:56 -0700 Subject: The error of building Python on HP UX References: <mailman.996204469.11450.python-list@python.org> Message-ID: <92ae279c.0107311447.799933b6@posting.google.com> "Tim Peters" <tim.one at home.com> wrote in message news:<mailman.996204469.11450.python-list at python.org>... > [Guido] > > (Couldn't resist. :-) > > > > It is indeed an error to attempt to build Python on HP UX. (See the > > endless laments in the SF bug database.) > > [SteveN] > > And yet HP makes it available: > > http://hpux.connect.org.uk/hppd/hpux/Languages/python-2.1/ > > They've made binaries available for some time, yet HP-UX users seem > incapable of successfully compiling it themselves ("see the endless laments > in the SF bug database" indeed). So what's up with that platform?! Would > sure be nice if one of the folks at the HP Porting Centre filled us in -- > and if they need to patch the source to get it to compile, we'd be delighted > to fold that into the core. > > telepathy-challenged-ly y'rs - tim Possible solution: grab the source off the HPPC web-site. Then use that wonderful utility called ndiff.py written by I've-forgotten-who. Sorry, I couldn't resist, either :-) From tjreedy at home.com Mon Jul 2 17:06:33 2001 From: tjreedy at home.com (Terry Reedy) Date: Mon, 02 Jul 2001 21:06:33 GMT Subject: Comment on PEP-0238 References: <3B3BE855.A6223E70@3-cities.com> <cp7kxvlake.fsf@cj20424-a.reston1.va.home.com> <Y4J%6.4084$Z6.2010194@news1.rdc2.pa.home.com> <mailman.994016102.30019.python-list@python.org> <7ef50c46.0107020554.31cc948b@posting.google.com> <mailman.994084684.19932.python-list@python.org> Message-ID: <tn507.6448$Z6.3115703@news1.rdc2.pa.home.com> "Paul Prescod" <paulp at ActiveState.com> wrote in message news:mailman.994084684.19932.python-list at python.org... ... > That is simply not true. Most people do not expect these four > expressions to yield different results: > > 1.0/3.0 > 1/3 > 1.0/3 > 1/3.0 'People' could mean anything from 'CLP-reading Pythoneers' to 'all humans'. The result of a survey of expections would depend on the the precise population surveyed, the precise wording of the question, the manner in which the question is given, whether and what clarification is given to those who say they do not understand the question, and the treatment of "I don't know", "I'm not sure", and "I was never very good at math" type answers, which I believe (without direct data)would predominate in some 'general' populations. > If you were taught this in school, it must be "new math". Presuming that 'this' is the possibility that 1/3 might have a different correct result than 1.0/3 and that calling that idea "new math" is meant as a put down, this snide comment is doubly incorrect. 1) I learned long division (by hand, no calculators) of whole numbers (counts) in about 1955, before there was a 'new math'. We learned to give answers as quotient 'r' remainder. I presume that this was standard practice in the US then, if not now. 2) Indivisible units are not divisible. Example: a school has 4 first grade classrooms and 82 new first graders. If we split the students evenly among the classrooms, how many in each? The correct answer is 20 with 2 left over, not 20.5. A student sliced in two is not a student or even two halves of a student, but two chunks of dying flesh, an ancient wisdom credited to Solomon. Framing the integer division question in the context of the very special case of reciprocals is an unfair tactic. One indivisible unit divided into multiple parts is so very obviously 0 r 1 that we would normally not write 1/n to ask such a question. (Example: 1 BDFL divided among 3 simultaneous computer conferences on different continents is how many BDFLs at each? .33333333? I'm sure BDFL hopes not.) So it is usually reasonable (in this special case only), upon seeing an explicitly written 1/n, to assume that the 1 is a divisible 1.0, especially since '1/n', unlike 1+n, 1-n, or 1*n, is ambiguous to human readers in that it can be read as representing the result of performing the operation. However, in a general case such as 82/4, the expression is more obviously a problem to be solved (which is how the interpreter sees it) rather than an answer in itself and the assumption of divisibility may well be disasterously wrong. So I propose the following question to be asked of 'people': "Do you expect the following two questions to have the same numerical answer? A. If a string 82 centimeters long is cut into 4 equal pieces, how long is each? B. If 82 students are divided evenly among 4 classrooms, how many will be in each?" Or, if proponents of change insist on using potential division of a unit: "On one of Solomon's open court days, citizens of his realm bring him two similar disputes. Should he settle each with the same mathematical procedure? A. Two hungry boys each claim, with equal evidence, a delicious peach pie. B. Two day-old mothers each clain, with equal evidence, a newborn baby as their own. (The other baby died at birth, and neither DNA testing or definitive evidence is available)." With these wordings of the question, I doubt even a majority would definitely give the wrong answer "Yes, the same". Underlying these formulations of the survey question is the observation that most arithmetic is done to answer questions about the 'real' world by using numbers to represent or model quantities of things in the world. When so, each number has an at least implicit unit attached. In this context, the fundamental question is whether the unit is divisible (or is allowed to be) or not. If not, one uses (in Python) an integer (or long). If the units are divisible, one should tell readers and the interpreter by using divisible numbers (floats, complex) to model them, either from the start (by adding '.0') or at least at the point of division (by converting with float()). The suffix '.0' says "Yes, this number is currently a whole number (whether by design or accident) but it represents something that is splittable and which we may well want to split into fractions." Requiring that people think about divisibility in choosing a number representation is no more burdensome (and I think less so) than requiring them to think about mutability in choosing a tuple versus list sequence representation. Terry J. Reedy From volucris at hotmail.com Wed Jul 25 16:07:41 2001 From: volucris at hotmail.com (Volucris) Date: Wed, 25 Jul 2001 15:07:41 -0500 Subject: newbie 'Find File' question. References: <9jn5kb$k16$1@neptunium.btinternet.com> Message-ID: <3b5f3d46$0$327$6e49188b@news.goldengate.net> Yeah that was one of the first scripts I ever wrote. It's under 20 lines, so it's not documented. Just remember os.path.walk() if you friend. It will only scan the C: drive, but that would be easy to change. I think you need some platform API stuff (at least on Windows you do) to get the available drives. I can't remember what it is, though. Does anyone else? Hope this helps. ---Begin mpsscan.py--- #mp3scan.py print 'MP3 Scan 0.1 (volucris at hotmail.com)\n\n' print 'This program will scan the C: drive for files ending in \'mp3\'.' print 'The results will be stored in \'C:\\mp3scan_results.txt\'.\n' res = raw_input('Press ENTER to begin.') if res != 'q': import os def test(of, dir, files): for file in files: if file[-3:] == 'mp3': of.write(os.path.join(dir, file) + '\n') f = open('c:\\mp3scan_results.txt', 'w') os.path.walk('c:\\', test, f) f.close() print '\nScan complete. Check \'C:\\mp3scan_results.txt\' for results.\n' res = raw_input('Press ENTER to quit.') ---End mp3scan.py--- -- Volucris (a) hotmail.com "Eu n?o falo uma ?nica palavra do portugu?s." "G. Willoughby" <thecalm at NOSPAM.btinternet.com> wrote in message news:9jn5kb$k16$1 at neptunium.btinternet.com... > Has anybody coded a script to simulate the windows/mac find file utilitity? > i'm using this to help me learn Tkinter and Python. I have created the GUI i > just need a few design tips for the search code. basically i need to search > all drives (not A:) for a file. any ideas? :) . > > G. WIlloughby. > > From tundra at tundraware.com Thu Jul 5 18:20:02 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 05 Jul 2001 22:20:02 GMT Subject: Question about scope References: <3B44D696.61A8B915@tundraware.com> <3B44DECA.7D64AE2C@home.net> Message-ID: <3B44E5E6.7F0DC56F@tundraware.com> Chris Barker wrote: > Essentially you have only read-only access to immutable global > variables. Mutable variables you can change, because you are not > reassigning them, so you could do: > >>> FLAG = [TRUE] > >>> def FlagFalse(): > ... FLAG[0] = FALSE > ... > >>> FLAG > [1] > >>> FlagFalse() > >>> FLAG > [0] > Got it and it makes sense too.... Thanks to all who answered here and privately... -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From qrczak at knm.org.pl Sun Jul 22 03:14:25 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 22 Jul 2001 07:14:25 GMT Subject: Future division patch available (PEP 238) References: <mailman.995776716.24336.python-list@python.org> Message-ID: <slrn.pl.9lkvah.sin.qrczak@qrnik.zagroda> Sun, 22 Jul 2001 00:36:38 -0400, Guido van Rossum <guido at digicool.com> pisze: > I thought again about the merits of the '//' operator vs. 'div' > (either as a function or as a keyword binary operator), and figured > that '//' is the best choice: it doesn't introduce a new keyword > (which would cause more pain), and it works as an augmented assignment > (//=) as well. Why div= wouldn't work? (Lexed as two tokens.) -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From peter at engcorp.com Tue Jul 17 09:19:41 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 17 Jul 2001 09:19:41 -0400 Subject: OO misconceptions References: <mailman.994969462.27792.python-list@python.org> <hevsktcrnpckttnkgi1arcue5kjjsbrrb5@4ax.com> <mailman.995046506.2514.python-list@python.org> <9ir1l7$3ja$1@panix2.panix.com> <9irfbc11jaq@enews1.newsguy.com> <slrn9l49me.p58.tim@vegeta.ath.cx> <mailman.995268208.1394.python-list@python.org> <slrn9l6kci.qqs.tim@vegeta.ath.cx> <3B538E16.65394C9D@engcorp.com> <slrn9l7a8r.rpe.tim@vegeta.ath.cx> <3B53B339.B6698858@engcorp.com> <slrn9l7lfm.t2g.tim@vegeta.ath.cx> Message-ID: <3B543B6D.A97F2843@engcorp.com> Tim Hammerquist wrote: > > > Perl, in this case (factory automation) would > > definitely *not* have been a better choice, even in your estimation. > > Fair enough. =) Python does sound like a good choice in this case, > despite Perl's strength in sockets. In this case, more than anything else, the driving factor was the easy ability to wrap third-party DLLs (e.g. for a GPIB interface card) with calldll and make a beautiful object-oriented wrapper to talk to instruments on the bus. I knew I would be able to make a maintainable and flexible system which newcomers (new developers that is) could learn to use easily and continue growing. At the time, putting a Tkinter interface on it quickly was an attractive option, although I've since halted work on that development path until we have time to retool around the web paradigm instead... -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From gregj at pdxperts.com Wed Jul 11 23:37:23 2001 From: gregj at pdxperts.com (Greg Jorgensen) Date: Thu, 12 Jul 2001 03:37:23 GMT Subject: python and applications References: <V%337.677940$166.13952126@news1.rdc1.bc.home.com> Message-ID: <TX837.333827$p33.6744731@news1.sttls1.wa.home.com> I read that Python is too slow for MUDs, and Eiffel is better anyway. Try Eiffel or Haskell if you are blind. "tyler spivey" <tspivey8 at home.com> wrote in message news:V%337.677940$166.13952126 at news1.rdc1.bc.home.com... > > could you write a fast mud in python? > having a lot of monsters like dikumuds do? > how many blind programmers use python? and is python just a toy language? > can it do more or as much as c? could you create a roguelike in it? > I am blind myself. From phd at phd.fep.ru Tue Jul 10 12:20:22 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Tue, 10 Jul 2001 20:20:22 +0400 (MSD) Subject: Adding timeouts to Internet sockets In-Reply-To: <RBF27.212379$WB1.31341412@typhoon.tampabay.rr.com> Message-ID: <Pine.LNX.4.33.0107102019040.7138-100000@phd.fep.ru> On Tue, 10 Jul 2001, John Copella wrote: > How have developers added timeout behavior to Internet sockets in Python? I > am developing an application that uses ftplib, and I need to timeout if the > server is unavailable, etc. I note that Tim O'Malley has a package out > (http://www.vex.net/parnassus/apyllo.py?i=87800233) that very cleverly and > transparently does this (or seems to). Has anyone used it? My application > will be mission-critical, and I would prefer to use whatever is considered > the current best practice. I use from time to time. It does the job, though I had some minor problems - it seems sometimes it timeouts a connection that is in progress. Well, I am almost satisfied with it. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From BPettersen at NAREX.com Tue Jul 3 19:38:15 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Tue, 3 Jul 2001 17:38:15 -0600 Subject: ADODB.RecordSet bummer ( was Re: Python and DB support (was: Re: Is Python Dead?)) Message-ID: <6957F6A694B49A4096F7CFD0D900042F27D4DF@admin56.narex.com> > From: Bill Bell [mailto:bill-bell at bill-bell.hamilton.on.ca] > > [Martelli's address not included since many list members may > already know it.] > > Alex Martelli wrote, in part: > > > you CAN write rs.Fields("FieldName").Value ... [and] ... I believe > > ADO (and much more so, COM:-) deserves a far better language than > > Visual Basic... Python, for example!-). > > Yup, me too FWIW. So, as one of this list's most longstanding > newbies, I decided to give the combination a spin. > > In VBA it's common to coin the cliche: > > with myRecordSet > .edit > .fields('myField') = 42 > .update > end with > > Unfortunately, > > >>> import win32com.client > >>> rs = win32com.client.Dispatch("ADODB.RecordSet") > >>> rs.ActiveConnection = "DSN=WebPASS" > >>> rs.Open("[URLs]") > >>> rs.Fields("myField") = 42 > Traceback (SyntaxError: can't assign to function call > > Or, is this because I forgot my medication this morning? Try rs.Fields("myField").Value = 42 -- bjorn From pkalliok at cc.helsinki.fi Sun Jul 8 18:46:04 2001 From: pkalliok at cc.helsinki.fi (Panu A Kalliokoski) Date: 8 Jul 2001 22:46:04 GMT Subject: [OT] Eternal programming References: <mailman.994519931.6264.python-list@python.org> Message-ID: <9ianrc$lh7$1@oravannahka.helsinki.fi> Roman Suzi <rnd at onego.ru> wrote: > This way, the portability is utmost: you write simple core interpreter (~ > RISC-processor) and you can run software! This is sometimes called "portability by ease". I'd say many languages there are fulfill this criterion. Also, I have to suggest you take a peek at http://www.purists.org/esoteric/, which has many good candidates. I think the easiest path to go is character-based Forth with string-based lambda functions for control structures. As for computation, lambda expressions are _the_ swiss army knife for everything. Panu From daniel at dittmar.net Fri Jul 13 15:15:00 2001 From: daniel at dittmar.net (Daniel Dittmar) Date: Fri, 13 Jul 2001 21:15:00 +0200 Subject: More on "with" statement References: <3b4f3600$0$15367@wodc7nh6.news.uu.net> Message-ID: <3B4F48B4.6E6F7316@dittmar.net> > I can only think of two reasons to use it. > > 1) You're a lazy typist. (Or haven't learned to cut and paste) > > 2) You are generally concerned that multiple references to the > same object with complex, multilevel access might be confusing > to the reader or not optimized by the compiler. There's a third one: control blocks give visual structure to a method, making the parts more easily recognizable with sys.stdout: .write (...) .write (...) doSomethingElse () with sys.stdout: .write (...) .write (...) is at least to me more easily scannable than write = sys.stdout.write write (...) write (...) doSomethingElse () write (...) write (...) Of course, the second version is faster, because the lookup of the write method is cached, not of stdout. Admittedly, this is highly a matter of taste. To some, a few blank lines already do the trick. Others will insist that readability is only achieved by sys.stdout.write (...) sys.stdout.write (...) doSomethingElse () sys.stdout.write (...) sys.stdout.write (...) # explicit is better than implicit Daniel From tjreedy at home.com Fri Jul 27 12:08:50 2001 From: tjreedy at home.com (Terry Reedy) Date: Fri, 27 Jul 2001 16:08:50 GMT Subject: PEP 238 (revised) References: <cp4rrz5onj.fsf@cj20424-a.reston1.va.home.com> Message-ID: <mmg87.34184$EP6.8750025@news1.rdc2.pa.home.com> To Guido: Version 1.10, which you indicated would not be the last, has gotten many cogent comments. I recommend that at some point you pre-announce a time limit for discussion, at which time you will gather up existing comments, declare 1.10 and further comments thereon obsolete, retire to your desk or study, write version 1.11, and thereafter restart discussion with a new thread entitled 'PEP 238 v1.11' . To everyone else: such a declaration would in no way stop anyone from discussing anything they want. It would help people not waste their own time by making obsolete comments of no effect. An author of a work in progress has a right and usually a need to stop listening to return to writing a new draft. One he releases the new draft, he has a right to only listen to comments that reference that new draft, so the discussion can move forward, (as it already has with 1.10). This standard procedure is probably most valuable when the work is contentious. Terry J. Reedy From paul.moore at uk.origin-it.com Tue Jul 24 09:24:01 2001 From: paul.moore at uk.origin-it.com (Paul Moore) Date: Tue, 24 Jul 2001 15:24:01 +0200 Subject: win32com: Setting ByRef parameters in an event Message-ID: <urrqlt4g5dgbjjo23msnm1c022deabt5mp@4ax.com> I'm trying to do some event handling code using win32com. I'm using a component called WScriptEx as my test case, which has a Sleep method which fires a regular OnTick event. The IDL for the OnTick event is HRESULT OnTick( [in] VARIANT RemainingTime, [in, out] VARIANT* WakeUp); The WakeUp parameter should be set if the event code wants to stop the sleep at this point. I've tried this, and it works fine in VBScript: Set WScriptEx = WScript.CreateObject("WshToolbox.WScriptEx", "WScriptEx_") ' Sleep for 10 seconds, raising an OnTick event every 1 second WScriptEx.Sleep 10000, 1000 Sub WScriptEx_OnTick (ByVal Remaining, ByRef Wakeup) WScript.Echo "Tick.... " & Remaining Wakeup = True ' Wake the sleep up End Sub Now, based on a post from Mark Hammond ("Re: Handling Com Events in Python (was Python and Windows Scripting Host)" from Fri, 11 Aug 2000) I can do this by just returning the necessary value: import win32com.client class wexEvents: def OnTick(self, Remaining, WakeUp): print "Tick...", Remaining return -1 wex = win32com.client.DispatchWithEvents("WshToolbox.WScriptEx", wexEvents) wex.Sleep(10000,1000) But this doesn't seem to work! The thing just keeps ticking remorselessly until the 10 seconds are up. (And, BTW, if I hit Ctrl-C, I get an error "Unhandled exception detected before entering Python." - shouldn't I get a KeybordInterrupt error?) Am I doing something wrong? Is there a subtle bug here? Any help would be appreciated - this sort of construct is important to me, and I'd hate to be reduced to VBScript or (shudder...) Perl. Thanks, Paul From donn at drizzle.com Tue Jul 31 00:33:35 2001 From: donn at drizzle.com (Donn Cave) Date: Tue, 31 Jul 2001 04:33:35 -0000 Subject: Typing system vs. Java References: None <mailman.996540777.8399.python-list@python.org> Message-ID: <996554015.454155@yabetcha.sttl.drizzle.com> Quoth <brueckd at tbye.com>: [ ... re demonstration that a type checking language can check types ...] | But what benefit have I gained? The only reason it's an error to begin | with is because the language is forcing me to name the type. The fact that | the compiler can detect my breakage of the language-specific rules doesn't | really advance the notion that strict compile-time checking is beneficial. | What is a real world problem that would not have existed if Python had | strict compile-time checking, and how common is such a problem? (I'm not | saying those problems don't exist - I'm just desperate for some examples | so I can understand the other side of the issue). Well, one currently poignant example. In Python, as you can hardly fail to notice these days, division with integer inputs produces an integer output, silently losing any fractional part. That's held to be a common problem. It can happen because Python will let an integer (or anything else!) walk into that division, and try to make the best of what happens. If you a type checking compiler, the object would have to agree at compile time with the programmer's notion of what would be an appropriate input. I don't know if that means Python should have type checking. Its open typed design works awfully well with OOP, and it would be a shame to strangle that freedom for the sake of a half-baked concept of discipline. But some kind of type inference validation could be applied from a lint utility - that already exists and is reportedly useful, but I don't know if it actually covers types. Anyway, maybe it's an area where a big investment could yield something real interesting for industrial strength programming. Donn Cave, donn at drizzle.com From nperkins7 at home.com Sat Jul 14 19:34:03 2001 From: nperkins7 at home.com (Nick Perkins) Date: Sat, 14 Jul 2001 23:34:03 GMT Subject: list[] = var => list.append(var) (phpstyle) References: <4e2ddb70.0107141310.3c7ca355@posting.google.com> <9iqfge0gba@enews1.newsguy.com> Message-ID: <LF447.476898$eK2.98947068@news4.rdc1.on.home.com> "Alex Martelli" <aleaxit at yahoo.com> wrote in message ... > list_var += var_to_append ... you mean: list_var += [var_to_append] or, list_var += list_to_extend From max at alcyone.com Wed Jul 25 11:05:43 2001 From: max at alcyone.com (Erik Max Francis) Date: Wed, 25 Jul 2001 08:05:43 -0700 Subject: [OT] Number theory [Was: A use for integer quotients] References: <yCK67.17615$EP6.4467503@news1.rdc2.pa.home.com> <mailman.995860718.9550.python-list@python.org> <mailman.995862939.15013.python-list@python.org> <mailman.995883879.12071.python-list@python.org> <3B5C5665.8D41D1F1@tundraware.com> <slrn.pl.9los0f.jh4.qrczak@qrnik.zagroda> <3B5C749A.59F97320@tundraware.com> <JDa77.97061$Rr4.549007@ozemail.com.au> <Xns90E97C9849AD5robindotgarneratinam@172.18.25.3> <IjA77.97824$Rr4.589251@ozemail.com.au> Message-ID: <3B5EE047.3342B560@alcyone.com> michael wrote: > > But strictly > > speaking the Integer 2 and the Real Number 2 are different entities. > > So strictly speaking, Z (the set of integers) is not a subset of R > (the set > of reals)? It is, but since the integers have different properties than the reals, whether you mean the integer 2 or the real 2 can have an effect on what you can do with those numbers. For instance, the reals are a field, but the integers are not, so whether 1/2 has any meaning depends on whether you're talking about reals or integers. I think that's what the original poster was getting at. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Be thine own place, or the world's thy jail. \__/ John Donne blackgirl international / http://www.blackgirl.org/ The Internet resource for black women. From plakal at nospam-cs.wisc.edu Tue Jul 10 19:39:46 2001 From: plakal at nospam-cs.wisc.edu (plakal at nospam-cs.wisc.edu) Date: 10 Jul 2001 23:39:46 GMT Subject: PIL palette problem on PIL-1.1.2/Python-2.1/Solaris 2.8 References: <9ig02f$c4@spool.cs.wisc.edu> Message-ID: <9ig3o2$2oh@spool.cs.wisc.edu> plakal at nospam-cs.wisc.edu wrote: > I'm trying to use PIL to draw a line > graph on a pre-existing GIF template file. > However, for some reason, no matter > what palette index I specify as > the ink, the lines I draw are all white > (which happens to be the first color > in the palette). > Can anyone spot what I'm doing wrong? > Code is at the end of the message. > This is with PIL-1.1.2, Python 2.1, > Solaris 2.8. Weirdly enough, the same > code works fine on Linux (with Python 2.0 > and PIL-1.1.2). I finally figured out the problem. There seems to be a bug in the support code in PIL where _draw_lines() (in _imaging.c) passes a pointer to an int as the ink parameter to the ImagingDrawLine() function in libImaging which then treats it as a pointer to unsigned char. This returns zero on big-endian SPARC but returns the correct ink value on little-endian x86. I modified it myself to make it work for me but I assumed that this kind of stuff would be handled by the configure scripts since this kind of casting makes assumptions about endian-ness. Manoj > PS: Remove nospam- from my email address to respond by mail. > ------------------------------------------ > import Image, ImageDraw > image = Image.open( "graph_template.gif" ) # -- 500x600 GIF, 67-color palette > draw = ImageDraw.Draw( image ) > draw.setink(1) # -- Orange-ish > draw.line( [(52,550),(220,40)] ) > draw.setink(2) # -- another shade of orange > draw.line( [(220,40),(300,550)] ) > draw.ellipse( (52,40,300,550) ) > image.save( "graph.gif" ) > ------------------------------------------ From db3l at fitlinxx.com Fri Jul 27 02:35:00 2001 From: db3l at fitlinxx.com (David Bolen) Date: 27 Jul 2001 02:35:00 -0400 Subject: Version compatibility in division References: <mailman.996097129.15274.python-list@python.org> <usnfkcy48.fsf@ctwd0143.fitlinxx.com> <9jqh92$6jl71$1@fido.engr.sgi.com> Message-ID: <u66cevq0b.fsf@ctwd0143.fitlinxx.com> pj at sgi.com (Paul Jackson) writes: > David wrote: > |> Of course, this isn't the best example, since threaded apps by their > |> nature must be written to be safe in such variations ... > > as opposed, of course, to unthreaded apps, which can have > all manner of timing sensitive bugs, right? </joking> > > In other words, speaking more directly, maybe threaded > apps are supposed to be timing safe, but that doesn't > mean that they are. Of course not, but I sure wouldn't worry about bending over backwards in restricting a change to avoid tickling a race condition bug in a multi-threaded application just due to timing variations. If the developer ventured into multi-threaded space, and didn't take that into account, then them's the breaks :-) -- -- 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 paul at boddie.net Thu Jul 12 04:37:53 2001 From: paul at boddie.net (Paul Boddie) Date: 12 Jul 2001 01:37:53 -0700 Subject: Postgres support References: <gul1kts5l6aolk55o7vguk97uorjd08j9f@4ax.com> <5174eed0.0107061058.5446dac9@posting.google.com> <9i6vm3073b@enews3.newsguy.com> <3B4719E1.C5540B19@wwc.com> <9i7t0k01add@enews3.newsguy.com> <3B47C125.A65E5EAC@wwc.com> <23891c90.0107100801.14066af0@posting.google.com> <3B4B458C.A0F96E5D@wwc.com> Message-ID: <23891c90.0107120037.705cbe74@posting.google.com> Steve Williams <stevewilliams at wwc.com> wrote in message news:<3B4B458C.A0F96E5D at wwc.com>... > Paul Boddie wrote: > > > How do you manage to do different types of joins? Do any of the systems > > you mention use the explicit join syntax, for example? > > My work lately has been in DB2 and I use explicit joins exclusively--they > provide the level of documentation and control I want and need. It's been a > long time since I've used anything else. I also use Interbase for a > BiTemporal database I'm developing and, again, I use explicit joins. When I > worked in SQL-Server, I used a sad mixture of implicit and explicit joins--I > hadn't seen the light yet. I can't remember specifically about my work with > the others. I suspect that if you used Sybase ASE (and not ASA), you would have needed to use implicit joins. I suppose it would be possible to provide some kind of statement syntax independence within a database framework, but the amount of work required probably isn't worth it. It's far better off providing approaches which manage the differences between systems in an understandable and easy-to-use way. > > What about the statement parameter (bind variable) syntax? I've corrected your quoting here... > As far as binding, Python does a nice job for me: > > cursorODS = connectionODS.cursor() > intInvoiceNumber = int(str(parmInvoiceNumber)) > parmList = (intInvoiceNumber,) > cursorODS.execute("select " \ > + "InvoiceNumber,LineNumber,PartNumber,Description,Quantity,UnitOfMeasure," > + "Price,ExtendedSale,Cost,ExtendedCost,GP,GPPercent " \ > + "from ODS.OrderLineDetail " \ > + "where InvoiceNumber = ?",parmList) > resultSet = cursorODS.fetchall() > cursorODS.close() > return resultSet > > This works for DB2 and Interbase via ODBC and mxODBC. OK, so you're using paramstyle as 'qmark', as I think DB-API 2 would say. I think the only reasonable abstraction which could be provided over the differing parameter syntaxes is that of a dictionary, with keywords in use within the statement itself. Something like paramstyle as 'pyformat' or, in order to distinguish it from straightforward string substitution (a bad thing), paramstyle as 'named'. [Something about standards] > > Which standard are we talking about now? ADO and COM aren't exactly > > there on most flavours of UNIX, if at all. Of course, there's always > > ODBC. ;-) > > I know very little about ADO or COM. Although mxODBC is a marvellous > package, I'm always suspicious of the actual ODBC drivers. I would rather > directly interface with my target database. But I don't have compile > capability on some of my platforms (AIX or anything not WinTel, actually), > so my contribution to this thread was a fantasy about pre-compiled drivers > for all the databases on all the platforms. I was surprised to see Sybase ASA directly supporting ODBC - going against what Mr Wilson was asserting about its death - but, in general, I suppose that the greater the number of layers between one's application and the database system, the greater the risk for something to fail in obscure ways. In the case of Sybase ASA, I found things to be more reliable if I linked mxODBC directly to the library provided, rather than through the iODBC driver manager. > In general, I don't see much emphasis on relational databases in the Python > jungle. I think that it only appears that way because of the low traffic on the DB-SIG list and because there isn't any other focal point for database-related activity. Paul From guido at python.org Sat Jul 7 14:30:07 2001 From: guido at python.org (Guido van Rossum) Date: Sat, 07 Jul 2001 18:30:07 GMT Subject: PEP scepticism References: <mailman.993747643.21070.python-list@python.org> <9hfqb5$dsllb$3@ID-89274.news.dfncis.de> <3dhex01n1m.fsf@ute.cnri.reston.va.us> <cphewzlbis.fsf@cj20424-a.reston1.va.home.com> <9hlcp4$eiphi$2@ID-89274.news.dfncis.de> <cppubkkbhf.fsf@cj20424-a.reston1.va.home.com> <9hqc3i$f1dia$2@ID-89274.news.dfncis.de> <cpith6l3ip.fsf@cj20424-a.reston1.va.home.com> <iZR5BIA3wdR7EwJx@jessikat.fsnet.co.uk> <mailman.994456001.2112.python-list@python.org> <6Jd$FLAFotR7EwLP@jessikat.fsnet.co.uk> <3B471314.8B179A92@engcorp.com> <5lh$OIA2rxR7Ewou@jessikat.fsnet.co.uk> <3B47256F.72FE6CD0@engcorp.com> <g3+Z6LALyzR7Ewqz@jessikat.fsnet.co.uk> Message-ID: <cp1ynsk324.fsf@cj20424-a.reston1.va.home.com> Robin Becker <robin at jessikat.fsnet.co.uk> writes: > I think you express my position rather well. I don't believe that the > users' needs are changing so fast, rather I think that the user base > itself is changing and with the new users come new needs and perhaps > more and very different needs. Bingo! > On the other hand I think the target user base should be a reasonable > one. I don't think python should be aimed at pre-schoolers. If there is > a target set who and what are they? We're aiming at people with a high school education, actually. Folks whose main intuition about numbers and arithmetic is based on digital calculators. > I think that the development process itself is a bit awry as there are > now more than 250 documents on requirements/changes etc and as you say > getting to grips with the totality of the changes is hard. > > For 250 documents to exist there have to be too many cooks for smooth > development as many organisational studies suggest that best team sizes > are between 3 and 7. Don't jump to conclusions too fast! PEPs aren't numbered consecutively. There are only about 75 PEPs. Roughly half of those are historical documents (already implemented or rejected), some are meta-documents (numbers below 100). The number under consideration is theoretically about 25; in practice, half of those will never make it. --Guido van Rossum (home page: http://www.python.org/~guido/) From chapman at bioreason.com Wed Jul 18 14:05:49 2001 From: chapman at bioreason.com (Mitch Chapman) Date: Wed, 18 Jul 2001 12:05:49 -0600 Subject: One Worry for 2.2 References: <ENi57.22469$M9.7022637@typhoon.we.rr.com> Message-ID: <3B55CFFD.C805B34A@bioreason.com> Pete Shinners wrote: > > i'm excited for the new features coming in 2.2. reading some > release notes, i found a new difference that bothers me. > > """ > There's one very specific (and fortunately uncommon) bug that > used to go undetected, but which is now reported as an error: > class A: > def foo(self): pass > > class B(A): pass > > class C(A): > def foo(self): > B.foo(self) > > Here, C.foo wants to call A.foo, but by mistake calls B.foo. > In the old system, because B doesn't define foo, B.foo is > identical to A.foo, so the call would succeed. In the new > system, B.foo is marked as a method requiring a B instance, > and a C is not a B, so the call fails. > """ > > now in my mind's understanding of OO, if class B inherits > from class A, then class B has a foo() function. what this > is implying is that only _instances_ of class B have a foo() > function. B does have a foo method. The problem is that C is derived from A, not from B. So an instance of C shouldn't be allowed to pass itself to B.foo. -- Mitch Who is sometimes able to pass himself off as a programmer, even though he isn't descended from one. From michael at stroeder.com Thu Jul 5 15:10:21 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Thu, 05 Jul 2001 21:10:21 +0200 Subject: There's got to be an easy way to do this References: <ABEE81BE08ADD311B6A1009027DE908D0BD87D90@conmsx03.conway.acxiom.com> <mailman.994351690.22119.python-list@python.org> <9i27i8$gd9bq$1@ID-11957.news.dfncis.de> <3B44B031.819C93E@stroeder.com> <9i2c77$gmc74$1@ID-11957.news.dfncis.de> Message-ID: <3B44BB9D.BBBFFBCB@stroeder.com> Emile van Sebille wrote: > > I'm not sure how you mean slower, but I tested just now to see, > and this is the fastest of the four. Ooops. I thought the if x in s statement would consume *much* time. Well, now I learned again that optimization can be very subtle... Thanks for doing the benchmark. Ciao, Michael. From fredrik at pythonware.com Mon Jul 9 03:02:08 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 09 Jul 2001 07:02:08 GMT Subject: Bug in rfc822 References: <slrn9khcjv.c7q.philh@comuno.freeserve.co.uk> Message-ID: <QFc27.8798$e5.1167735@newsb.telia.net> phil hunt wrote: > I have just found out that rfc822.py doesn't conform to > RFC2822. sounds like it's time to rename that module ;-) </F> From krag_rao_pyt at rediffmail.com Fri Jul 13 03:53:40 2001 From: krag_rao_pyt at rediffmail.com (raghu k rao) Date: 13 Jul 2001 07:53:40 -0000 Subject: send http request Message-ID: <20010713075340.22954.qmail@mailweb25.rediffmail.com> hi how can i send a http request using POST method. Not just send request Like i want to login with username and passwd using the above method. can anyone tell me a program for this thankyou raghu ____________________________________________________ Buy Feng Shui Package for Rs. 151/- only, at http://shopping.rediff.com/shopping/fengshui_mailer.htm From mlh at idi.ntnu.no Tue Jul 3 19:33:25 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Wed, 4 Jul 2001 01:33:25 +0200 Subject: Eiffel better than Python ? References: <f20ea932.0107030100.6c740683@posting.google.com> <oVp07.429552$oc7.62655172@news2.rdc2.tx.home.com> Message-ID: <9htko5$gi6$1@tyfon.itea.ntnu.no> "Rainer Deyke" <root at rainerdeyke.com> wrote in message news:oVp07.429552$oc7.62655172 at news2.rdc2.tx.home.com... > "Tomasz Stochmal" <tom at peresys.co.za> wrote in message > news:f20ea932.0107030100.6c740683 at posting.google.com... > > I have read the following book which gives C/C++ heavy bashing > > > > http://www.elj.com/cppcv3/ > > > > Conclusion is to use Java or even better choice is Eiffel > > The conclusions of those who prefer Java over C++ should not be taken > seriously. What an utterly arrogant thing to say... Do you have any arguments behind this statement? (I hope this was meant humoristically...) > -- > Rainer Deyke (root at rainerdeyke.com) > Shareware computer games - http://rainerdeyke.com > "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor -- 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 skip at pobox.com Tue Jul 24 00:45:05 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 23 Jul 2001 23:45:05 -0500 Subject: proposed language change to int/int==float (was: PEP0238 lament) In-Reply-To: <LNBBLJKPBEHFEDALKOLCEEIJLAAA.tim.one@home.com> References: <15196.14524.979058.576152@beluga.mojam.com> <LNBBLJKPBEHFEDALKOLCEEIJLAAA.tim.one@home.com> Message-ID: <15196.64849.278950.776622@beluga.mojam.com> >> You're pissing off a fairly significant fraction of the language's >> existing constituency in hopes of attracting some non-programmers to >> the language who may not come anyway for various other reasons. Tim> I don't detect any trace of that hypothesized motive in Guido. He Tim> wants to repair what he has come to believe is a serious design Tim> error, and is wrestling with ways to get that done. What a Tim> remarkably different world it would be if people tried to help Tim> <wink>. And I did send a summary to Moshe of the objections to the current proposal as I saw them, just not on the list where they'd get buried in the slew of messages on the subject. I think a lot of people feel that unlike most changes considered for Python, scant attention is being paid to whether or not the proposed change will break existing code. There's ample anecdotal evidence to suggest that this will break a lot of code and require a fair amount of effort just to check code that is probably correct. Skip From tjreedy at home.com Sat Jul 28 13:52:07 2001 From: tjreedy at home.com (Terry Reedy) Date: Sat, 28 Jul 2001 17:52:07 GMT Subject: How to break? (was Re: A modest PEP0238 suggestion) References: <3b5c6e08.27535083@aplnews> <9jjk9g$8tk$1@newsy.ifm.liu.se> <9jun6j$c5$1@panix2.panix.com> Message-ID: <bZC87.37029$EP6.9803880@news1.rdc2.pa.home.com> "Aahz Maruch" <aahz at panix.com> wrote in message news:9jun6j$c5$1 at panix2.panix.com... > Phrased that way, I think it *has* to be true that there is never a > future in which old code can break silently. It is the nature of semantic substitutions to silently break code in either the forward or backward directions. Unfortunately, in a language with runtime compilation (of user imput, for instance) any feature addition implicity substitutes 'do the new thing' for 'raise exception' . The addition of 'yield expression' may silently break programs that compile user-input into Python functions. Bug fixes may silently break programs that compensate for the bug. One way to never break code, silently or otherwise, is to never change the interpreter. Another is to make current behaviour (including bugs) the default forever and forever require explicit import of every change ever made since freeze time, with runtime compilations handled separately. Another is to go ahead and make new meanings the default but forever identify every construct that once had a different meaning and issue a warning so that the change is never completely silent. Any others? Terry J. Reedy From sholden at holdenweb.com Fri Jul 13 11:50:47 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 13 Jul 2001 11:50:47 -0400 Subject: HTTP through multiple NICs References: <mailman.995022383.31577.python-list@python.org> Message-ID: <YJE37.19257$uJ3.626094@e420r-atl2.usenetserver.com> "Gardiner, Geoff" <ggardiner at accelrys.com> wrote in message news:mailman.995022383.31577.python-list at python.org... > I need to send HTTP traffic through multiple NICs (multihoming with > different IP addresses AND different MAC addresses) on a single PC. The > traffic doesn't need to be simultaneous (I think I'll try to walk before I > run). > > I've got a working single-NIC test suite in Python, but haven't worked out > how to direct traffic to more than one NIC - I'm a complete novice in this > area. I can't find anywhere obvious in httplib or its superclasses for a NIC > identifier or local IP address to be used to select the NIC. > > Can anyone suggest where I start with this - before I rush out and buy the > NICs? I'm running Win NT at present, but could switch to Linux if that > helps! > You don't say whether you are writing HTTP clients, servers, or both. Generally speaking, on any well-behaved TCP/IP platform (i.e. at least Windows and Linux), the network layer will direct client traffic out on the correct NIC to route it to the destination. For servers, just use an address of "" and the server will bind to all interfaces. Hope this helps. regards STeve -- http://www.holdenweb.com/ From sandra at ccuec.unicamp.br Mon Jul 16 17:12:30 2001 From: sandra at ccuec.unicamp.br (Sandra Regina) Date: Mon, 16 Jul 2001 17:12:30 -0400 Subject: passwd not echoed by getpass Message-ID: <3B5358BE.CD031688@ccuec.unicamp.br> Hi ALL, I have installed MAILMAN 2.0.5 which uses python2.0 getpass , but when I run it , the following message appears : apolo# ./newlist Enter the name of the list: asdf Enter the email of the person running the list: asdf Warning: Problem with getpass. Passwords may be echoed. <<<------ I search for it at newlist program and It uses getpass like this : .... import getpass .... list_pw = getpass.getpass("Initial %s password: " % listname) What could be wrong... ? It's installed on a sun with solaris 2.5.1 Thanks- Sandra sandra at ccuec.unicamp.br From hgg9140 at seanet.com Sat Jul 28 07:04:03 2001 From: hgg9140 at seanet.com (Harry George) Date: 28 Jul 2001 04:04:03 -0700 Subject: Newbie Q: PYTHONPATH_1 vs PYTHONPATH_2? References: <3b6222b8.1007348@news.onemain.com> Message-ID: <m3zo9pxql8.fsf@wilma.localdomain> engsol at teleport.com writes: > I have an "old" copy of Python on my NT machine. I've tailored > PYTHONPATH to know about myfiles and mylib, etc. > > But I've now installed Python 2.1.1 in a different directory, and > would like to create PYTHONPATH_2, so as to not have to expand the > vanilla PYTHONPATH forever as new versions are available. > > Is this do-able? > For each version of python, make a script. E.g., for running python 2.0: /usr/local/bin/py20: #!/bin/sh export PYTHONHOME=/usr/local export PYTHONPATH=/usr/local/lib/python2.0: (no line break) /usr/local/lib/python2.0/site-packages /usr/local/bin/python2.0 $@ Then you can run interactive or batch by using py152,py20, py21, etc. > Thanks....engsol -- Harry George hgg9140 at seanet.com From grayson-wilson at home.com Sun Jul 8 23:52:14 2001 From: grayson-wilson at home.com (EricIDLE) Date: Mon, 09 Jul 2001 03:52:14 GMT Subject: Make an *.EXE Using Python. References: <oAI17.647550$166.13393459@news1.rdc1.bc.home.com> <7b515e0f.0107081724.56b2a434@posting.google.com> Message-ID: <OT927.657477$166.13612439@news1.rdc1.bc.home.com> I just used the one off the py2exe website it is as follows. # setup.py from distutils.core import setup import py2exe setup(name="test", scripts=["test.py"], ) Is that bad or whats the story? eric_brake <brakedon at hotmail.com> wrote in message news:7b515e0f.0107081724.56b2a434 at posting.google.com... > "EricIDLE" <grayson-wilson at home.com> wrote in message news:<oAI17.647550$166.13393459 at news1.rdc1.bc.home.com>... > > Hello, > > I was wondering is there a way to make a exe using Python? > > I seem to remeber vagely that there was a "Make EXE" choice under the file > > menu but its no longer there (If it ever was) so if you can give me a hand > > with this it would be great. > > You will need to create a "setup.py" file. Here is the working code that I use. > > from distutils.core import setup > import py2exe > setup(name = "filename", #not sure what this does, but it doesn't hurt anything > version = "1.0", #meta info, shows up in the exe you make > author = "John Doe", #meta info, your name > author_email = "johndoe at somewhere.com",#meta info, author email > scripts = ["yourfile.py"])#target script, the script you want to make an > #exe with From paul at boddie.net Wed Jul 25 06:38:39 2001 From: paul at boddie.net (Paul Boddie) Date: 25 Jul 2001 03:38:39 -0700 Subject: re bad leadership References: <0+yM4IAgmKX7EwIQ@jessikat.fsnet.co.uk> <mailman.995988041.22317.python-list@python.org> Message-ID: <23891c90.0107250238.590ff414@posting.google.com> Thomas Wouters <thomas at xs4all.net> wrote in message news:<mailman.995988041.22317.python-list at python.org>... > On Mon, Jul 23, 2001 at 11:48:00PM +0100, Robin Becker wrote: > > > it doesn't matter what the leadership says is right. The popular vote is > > against the stupid float '/' operator. > > Really ? I don't see a popular vote. I just see a very long and very heated > discussion with a small group of repeat offenders (oops, did I say > offenders ? I meant posters) that just keep on proclaiming their > righteousness with little in the way of new arguments (either way, for that > matter.) On the contrary, I see some pretty strong arguments for not changing the behaviour of the / operator. The argument that changing the existing semantics breaks potentially huge amounts of existing code, cannot be trivially tested for, and is therefore highly undesirable, has not been adequately refuted. It is not sufficient to say that "new style division" is nicer, looks better, or is "the way we wanted it from the start"; such statements do not constitute a response to that concern - they merely attempt to change the subject of discussion. I see that the burden should be on those proposing these changes to address the existing strong arguments against them, rather than being on those against the changes to raise countless arguments only to see them brushed aside in an ideological haze by people unwilling to consider legitimate points of view. The PEP document in question does not summarise the valid concerns of the community, many of which have emerged in the recent discussions. I can understand the author not having time to update it since these discussions started - I have much less ambitious documents to maintain myself, and it can be weeks before I get the chance to implement changes in them - but I cannot believe that the original document did not consider such obvious pitfalls in the proposed scheme, especially before an implementation was produced. Until such time as the PEP attempts to summarise the issues properly, this discussion will continue with all sides feeling that their views have not been heard, taken into account, or addressed. > I strongly suspect the change will actually *fix* more code that was relying > on float inputs than it will break code that depended on int/int being > special-cased. No-one ever fixes code, or should seek to have their code fixed, by having the ground rules changed. Paul From amuys at shortech.com.au Thu Jul 12 22:41:06 2001 From: amuys at shortech.com.au (Andrae Muys) Date: 12 Jul 2001 19:41:06 -0700 Subject: What's object-oriented? References: <GyiZ6.2264$Bp1.299293@newsread2.prod.itd.earthlink.net> <9h4rto$fmc$1@newshost.accu.uu.nl> Message-ID: <7934d084.0107121841.1aab5693@posting.google.com> m.faassen at vet.uu.nl (Martijn Faassen) wrote in message news:<9h4rto$fmc$1 at newshost.accu.uu.nl>... > zoodoo <zoodoo at infantry.com> 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). > Indeed. In fact most good OOP books tend to use this as their introduction to the concept of an Object/Class. However while it is historically correct --- in fact now I have learnt OOP my structured code shows even stronger tendencies towards this approach --- I have never found it a useful approach to actually understanding how to use Objects. (Note this is my personal experience, it may or may not generalise) Personally about half way through GoF, Fowler's book on Refactoring, and Langr's book on Java Implementation Style I finally realised that I could treat a well designed object as a State Machine. Once I realised that, most of the material in those three books became 'obvious'[1]. To summarise the approach I take. The classical state machine has inputs, state, next state logic, and outputs. These map to methods, members, implementaion, and attributes. Now as soon as I accepted this analogy, I immediately started finding exceptions, but it did mean that patterns such as Visitor, Strategy, and State, started making much more sense. Also, alot of the exceptions seem to me to be OOP analogues of FP constructs (one of the reasons why I like Python so much :). All in all my engineering rather then CS background may explain why I find this approach to understanding OOP useful. I wouldn't be surprised if the utility of this approach dosn't generalise, but I thought I might share it as hopefully it will. Andrae Muys amuys at shortech.com.au [1] cue old maths joke about the 10 blackboards of deriviations to recognise the proof as obvious From skip at pobox.com Thu Jul 12 13:09:45 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 12 Jul 2001 12:09:45 -0500 Subject: Newbie Question: Regular Expressions In-Reply-To: <200107121639.f6CGdhJ30999@vela.tradersdata.com> References: <200107121639.f6CGdhJ30999@vela.tradersdata.com> Message-ID: <15181.55769.940584.551650@beluga.mojam.com> Daniel> I have a really dumb program that i would like to make smarter. Daniel> I need to take a file on my hard drive and filter out everything Daniel> except for the standings which are written in it. I have tried Daniel> to use regular expressions with no success, but i still think Daniel> that they are probably the best way. Assuming "League Standings" is the marker, try something like this: sawstandings = 0 f = open('rawdata', 'r') for line in f.readlines(): if line.strip() == "league standings": print line, sawstandings = 1 elif sawstadings: print line, No regular expressions needed. Obviously, if the league standings aren't the last thing in the file you will need a similar test to decide when to break out of the loop. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From paulp at ActiveState.com Mon Jul 30 20:08:21 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Mon, 30 Jul 2001 17:08:21 -0700 Subject: Large-scale Python (was: Language Niches (long)) References: <8beb91f5.0107280407.5a30341d@posting.google.com> <mailman.996429234.13926.python-list@python.org> <Ej5QPKA1WHZ7EwvP@jessikat.fsnet.co.uk> <mailman.996442753.17197.python-list@python.org> <C2D62BF6D2E4F577.D8696582805EEB21.2093367A0D5F09C4@lp.airnews.net> Message-ID: <3B65F6F4.EBEEFE65@ActiveState.com> Cameron Laird wrote: > >... > > Without contesting any of Paul's larger points, what > are the facts here? I believe: > * Python is good for team-work > and big projects; and > * There is increasing recogni- > tion and use of Python in > this role. > What role has "language change" played in this, though? > I don't think Python's syntax or semantics support > modularization and packaging significantly better than > in '96 (Paul, do you have a Jython point in mind?). I can't remember that far back. One feature I depend upon for large-scale programming is threads and they are certainly the sort of thing that you can imagine would be added in the transition from "scripting" language to "general purpose OOP" language. And the scalability of Python threads could also be improved. I also think that the deprecation and assertion features are very useful in large projects. Nevertheless I concede that Python was always designed as if it were meant for "real work" so it didn't have to change a great deal to be considered appropriate for large projects. > Does performance improvement in hardware which makes > raw speed less frequently a constraint constitute a > "language change"? > ... Not really. I have a sense that there are certain project-size and scope threshholds that push languages to mature and Python smoothed over the first one pretty easily because it was designed to scale in the first place. I would not be surprised if future ones require more changes such as interfaces, multi-processor threading and optional static type checking. And of course performance improvements! Or maybe it just *seems* like bigger programs need those extra features and when we get there we will find that they do not. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From JoeSalmeri at home.com Tue Jul 17 20:54:00 2001 From: JoeSalmeri at home.com (Joe Salmeri) Date: Wed, 18 Jul 2001 00:54:00 GMT Subject: Python ASP Bug with traceback information References: <Y9357.17749$Ek3.6722336@news1.rdc1.md.home.com> Message-ID: <I6557.18067$Ek3.6855030@news1.rdc1.md.home.com> Mark, Thanks. I was going crazy fighting that one. While I waiting/hoping you would reply I ran across something interesting. When I created my test cases I tried to narrow things down to as small a chuck of code as possible. In the real world here is what I am doing: *** Joe.ASP *** try: import exception_handler import joe joe.dosomething() except: exception_to_handle = sys.exc_info() exception_handler.exception_handler(Server, Application, Session, Request, Response, exception_to_handle) *** End of Joe.ASP *** Using this method I have been able to print out complete traceback information. Strange or could it be because the code has moved out of the ASP file and into a py module? P.S. The HTTP Server error that we talked about still happens. When 2.1.1 is released I am going to upgrade and see if that fixes the problem. P.S.S. It does not have to do with old installs because I bought a new machine so everything was a fresh install. "Joe Salmeri" <JoeSalmeri at home.com> wrote in message news:Y9357.17749$Ek3.6722336 at news1.rdc1.md.home.com... > Can someone please confirm whether this is a known bug using Python with > ASP? > > Web Server is IIS 5.0 > OS is Windows 2000 SP2 > Python is BeOpen Python 2.0 > Win32All is build 138 > > When an exception occurs in a script under ASP the contents of the line that > the traceback occurred on do not appear to exist in the traceback. > I have tried most of the functions available in the traceback module but in > all cases the contents of the line that normally appears in the > traceback is lost when using ASP. When using CGI/Python there are no > problems. > > I have narrowed down my problem to the simple test scripts listed below: > > Have I found a new bug? Is there a workaround available? > > > **** File 1: joe.py **** > print 'Content-Type: text/html' > print > > import StringIO > import sys > import traceback > > try: > 1/0 > except: > e = sys.exc_info() > f = StringIO.StringIO() > traceback.print_exception(e[0], e[1], e[2], file=f) > print f.getvalue() > > **** File 2: joe.asp **** > <%@language="Python"%> > > <% > import StringIO > import sys > import traceback > > try: > 1/0 > except: > e = sys.exc_info() > f = StringIO.StringIO() > traceback.print_exception(e[0], e[1], e[2], file=f) > Response.Write(f.getvalue()) > %> > > **** joe.py output **** > Traceback (most recent call last): > File "P:\Home\Joe\Web\Rolo\j.py", line 10, in ? > 1/0 > ZeroDivisionError: integer division or modulo > > **** joe.asp output **** (NOTE: you must view source of the asp page because > I did not Encode the ASP output) > Traceback (most recent call last): > File "<Script Block >", line 7, in ? > ZeroDivisionError: integer division or modulo > > > > > > > > > > > > > From jblazi at hotmail.com Sat Jul 28 23:52:33 2001 From: jblazi at hotmail.com (Janos Blazi) Date: Sun, 29 Jul 2001 05:52:33 +0200 Subject: Opening a file, second attempt References: <3b6384c7_6@news.newsgroups.com> Message-ID: <3b6388b5_6@news.newsgroups.com> Sorry, problem solved. J.B. -----= 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 robin at jessikat.fsnet.co.uk Fri Jul 6 11:41:43 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 6 Jul 2001 16:41:43 +0100 Subject: PEP scepticism References: <mailman.993747643.21070.python-list@python.org> <9hfqb5$dsllb$3@ID-89274.news.dfncis.de> <3dhex01n1m.fsf@ute.cnri.reston.va.us> <cphewzlbis.fsf@cj20424-a.reston1.va.home.com> <9hlcp4$eiphi$2@ID-89274.news.dfncis.de> <cppubkkbhf.fsf@cj20424-a.reston1.va.home.com> <9hqc3i$f1dia$2@ID-89274.news.dfncis.de> <cpith6l3ip.fsf@cj20424-a.reston1.va.home.com> Message-ID: <iZR5BIA3wdR7EwJx@jessikat.fsnet.co.uk> In article <cpith6l3ip.fsf at cj20424-a.reston1.va.home.com>, Guido van Rossum <guido at python.org> writes .... >Well duh! > >If we left the design of programming languages to the *average* >programmer, the field would never make progress. Please give us >language designers some credit. We're programmers and we know what >programmers need! > >This whole thread has disappointed me. > ... well, all known languages have been produced by people/bees/bacteria etc and I know of no goodness criterion for languages except perhaps some notions of expressivity and the like. There are some rather abstract and little used notions of parseability, but these have no relevance on whether a language actually gets used. No matter that the vast majority of languages aren't understandable by humans, for any language there will be a whole (infinite) family of utilities which show that language to be optimal. Presumably the designers/creators of P*** are also making similar assertions and are as equally right/wrong. Dictators often assume they know best, but observation shows them to be uniformly wrong. -- Robin Becker From justin at iago.org Tue Jul 24 00:13:23 2001 From: justin at iago.org (Justin Sheehy) Date: Tue, 24 Jul 2001 00:13:23 -0400 Subject: PEP0238 lament In-Reply-To: <LNBBLJKPBEHFEDALKOLCEEEILAAA.tim.one@home.com> ("Tim Peters"'s message of "Mon, 23 Jul 2001 03:26:52 -0400") References: <LNBBLJKPBEHFEDALKOLCEEEILAAA.tim.one@home.com> Message-ID: <x7vgkjt15o.fsf@ra.iago.org> "Tim Peters" <tim.one at home.com> writes: > Good thing you stopped before mentioning Perl (yes, 1/2 is 0.5 there) Sure, but 1 == "1" there as well. Ugh. -Justin From db3l at fitlinxx.com Tue Jul 31 15:05:41 2001 From: db3l at fitlinxx.com (David Bolen) Date: 31 Jul 2001 15:05:41 -0400 Subject: Need for help with Pythonic realization of win32 network concept References: <B5204290C8C6A0E1.C46EAEACFB4DA997.B48C0E799B4DD389@lp.airnews.net> Message-ID: <uitg8udfe.fsf@ctwd0143.fitlinxx.com> claird at starbase.neosoft.com (Cameron Laird) writes: > import win32api > import win32con > > reg_key = win32api.RegOpenKeyEx(win32con.HKEY_USERS, ... > gives me a result I want--on "My Computer". How do I navigate > to the same point on "\\\\other_node"? My guess is I have to > open a hive with a \\other_node indirection--but none of my > attempts with Python's win32api have given me what I want. Use RegConnectRegistry to open a root key on a remote machine. From there, you can navigate beneath that root with the standard RegOpenKey/RegQueryValueEx and so on. > What documentation do folks use for win32api? Microsoft Documentation (e.g., MSDN) for the underlying Win32 API, of which win32api is but the slimmest of wrappers. You can get the MSDN library reference on the web at http://msdn.microsoft.com/library. Most of the stuff you would want would be under the Platform SDK under Windows Development. The Registry overview is at (URL is all one line): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/hh/sysmgmt/regapi_9bzt.asp -- -- 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 Fri Jul 13 15:03:36 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Fri, 13 Jul 2001 12:03:36 -0700 Subject: PEP: Defining Unicode Literal Encodings References: <3B4EE391.19995171@lemburg.com> Message-ID: <3B4F4608.207DBA7B@ActiveState.com> "M.-A. Lemburg" wrote: > > Please comment... I think that there should be a single directive for: * unicode strings * 8-bit strings * comments If a user uses UTF-8 for 8-bit strings and Shift-JIS for Unicode, there is basically no text editor in the world that is going to do the right thing. And it isn't possible for a web server to properly associate an encoding. In general, it isn't a useful configuration. Also, no matter what the directive says, I think that \uXXXX should continue to work. Just as in 8-bit strings, it should be possible to mix and match direct encoded input and backslash-escaped characters. Sometimes one is convenient (because of your keyboard setup) and sometimes the other is convenient. This proposal exists only to improve typing convenience so we should go all the way and allow both. I strongly think we should restrict the directive to one per file and in fact I would say it should be one of the first two lines. It should be immediately following the shebang line if there is one. This is to allow text editors to detect it as they detect XML encoding declarations. My opinions are influenced by the fact that I've helped implement Unicode support in an Python/XML editor. XML makes it easy to give the user a good experience. Python could too if we are careful. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From aleaxit at yahoo.com Wed Jul 18 18:01:54 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 19 Jul 2001 00:01:54 +0200 Subject: Language change and code breaks References: <mailman.995479471.31821.python-list@python.org> Message-ID: <9j50tq01k6r@enews3.newsguy.com> "Michael Chermside" <mcherm at destiny.com> wrote in message news:mailman.995479471.31821.python-list at python.org... ... > I'm very surprised to hear this. Yes, I've taught lots of beginners, and > I've found that they often complain about the case sensitivity. But I > tell them that "Computers are EXTREMELY literal", and "you must be VERY > precise when programming", and they get it. I also get complaints (not I guess you're lucky that your beginners don't have a smattering of Pascal or DOS, or other case-insensitive computers and programming environments, or they'd challenge your generalization. Of course you must be very precise when programming in Pascal, say, but that precision doesn't have to be artificially extended to case sensitivity. > Don't encourage sloppy habits: require case sensitivity. First time I heard that Pascal "encourages sloppy habits" -- with all the valid criticisms one can level at it, this one seems ridiculous. Alex From tim at vegeta.ath.cx Thu Jul 5 02:47:30 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Thu, 05 Jul 2001 06:47:30 GMT Subject: Eiffel better than Python ? References: <f20ea932.0107030100.6c740683@posting.google.com> <slrn9k5efg.ru.tim@vegeta.ath.cx> <9huenl$49q$1@panix3.panix.com> <slrn9k6vbl.1rv.tim@vegeta.ath.cx> <9i08r5$eq3$1@panix2.panix.com> Message-ID: <slrn9k8424.22v.tim@vegeta.ath.cx> Aahz Maruch <aahz at panix.com> wrote: > In article <slrn9k6vbl.1rv.tim at vegeta.ath.cx>, > Tim Hammerquist <tim at vegeta.ath.cx> wrote: > > > >Also, I guess I'm a bit defensive, as so many here _do_ make little > >snide comments about Perl and such. > > I do -- feel free to take me to task when I do make such comments, but > not otherwise. I'm sorry. The honest original intention of the post was to explain the Perl to Pythonistas, as they may likely not know Perl. You were never intended to be a target and I apologize if I inadvertently offended you. Best regards. -- -Tim Hammerquist <timmy at cpan.org> Not all who wander are lost. -- J.R.R. Tolkien From tim.one at home.com Fri Jul 27 01:22:41 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 27 Jul 2001 01:22:41 -0400 Subject: Eliminating upgrade risk In-Reply-To: <3B601811.4B68578B@interet.com> Message-ID: <LNBBLJKPBEHFEDALKOLCIEJKLBAA.tim.one@home.com> [James C. Ahlstrom] > ... > The problem is that the new Python features, as wonderful as they are, > are chosen for Computer Science Purity, not day-to-working-day > importance to someone actually trying to write a widely used bullet > proof program. As my physicists friend like to say, "that's not even wrong". Write a PEP. while-compsci-purists-denounce-python-for-its-pragmatism-ly y'rs - tim From skip at pobox.com Mon Jul 23 12:08:53 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 23 Jul 2001 11:08:53 -0500 Subject: PEP0238 lament In-Reply-To: <cEN67.17775$EP6.4652917@news1.rdc2.pa.home.com> References: <mailman.995839419.19134.python-list@python.org> <cEN67.17775$EP6.4652917@news1.rdc2.pa.home.com> Message-ID: <15196.19477.866414.443805@beluga.mojam.com> Terry> (Just noticed: http://python.sourceforge.net/peps/pep-0238.html Terry> now proposes a *2 year* int/int warning period starting with 2.3. Terry> It still needs a stipulation that someone write an intdiv checker Terry> to help automate replacements.) Here's a quick div finder (got some off-by-one errors trying to track NEWLINE tokens, hence the self.line hack). Skip import tokenize import sys class TokenSorter: def __init__(self, f): self.tokens = {} self.filename = f self.line = "" self.linenumber = 0 self.lastprinted = 0 def tokeneater(self, typ, val, (sr, sc), (er, ec), line): if self.line != line: self.linenumber += 1 self.line = line if (tokenize.tok_name[typ] == "OP" and val == "/" and self.lastprinted != self.linenumber): print "%s(%d): %s" % (self.filename, self.linenumber, line.rstrip()) self.lastprinted = self.linenumber def main(): for fn in sys.argv[1:]: try: f = open(fn) except IOError: pass else: ts = TokenSorter(fn) try: tokenize.tokenize(f.readline, ts.tokeneater) except tokenize.TokenError: pass if __name__ == "__main__": main() From duncan at NOSPAMrcp.co.uk Mon Jul 23 04:19:26 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Mon, 23 Jul 2001 08:19:26 +0000 (UTC) Subject: py2exe problem References: <mailman.995667696.25448.python-list@python.org> Message-ID: <Xns90E75CF8B731Aduncanrcpcouk@127.0.0.1> Jay Parlar <jparlar at home.com> wrote in news:mailman.995667696.25448.python-list at python.org: > One note: This program is intended to run as a COM local server > (controlled by an IE comm band). Could that possibly be the problem? > Does py2exe not take kindly to folks trying to use COM in their Python > code? We're not even trying to run it with IE yet, there is a way to > start it independently, but neither way will produce screen output on a > machine that doesn't have Python installed. There a few tricks you have to do to get py2exe running properly with COM servers. This URL has a useful post from Thomas Heller with a working example (edit it to one line if it gets split in transit): http://groups.google.com/groups?selm=9eag5l%241muh3%241%40ID-59885.news.df ncis.de Also you will find life a lot easier if you avoid using the -w flag while you are trying to get your application working. Without -w everything should run visibly on the screen and you can see uncaught exceptions or put print statements where you wish (even if it is running as a COM server). Only after you can build the exe and run it successfully on another Python- free machine should you consider using the -w flag. Another thing I have found useful is that my code (which is based on the example referenced above) is wrapped in code that replaces sys.stdout and sys.stderr with a cStringIO file and also catches and prints exceptions (including any exceptions raised by importing the rest of my code). the original stdout and stderr are restored during the call to localserver.main(), but otherwise at the end of the program I get any data written to stdout/stderr and, if there is any, it goes in a call to win32ui.MessageBox. The effect of this is that the messages indicating the server was registered or unregistered are displayed in a popup box, but more importantly the stack backtraces telling me what failed are also shown when something goes wrong. (Actually the code is a bit more complex because I also found it useful to add a --quiet option to suppress the registration popups so that I could register the control quietly from the setup program.) -- 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 tjreedy at home.com Mon Jul 23 22:32:26 2001 From: tjreedy at home.com (Terry Reedy) Date: Tue, 24 Jul 2001 02:32:26 GMT Subject: from __past__ import integerDivision (was Re: A modest PEP0238 suggestion) References: <3b5c6e08.27535083@aplnews> <kr2pltsb9gmehe4vtqm8so37924tdfs59s@4ax.com> <9jiak1$3s96$3@node21.cwnet.roc.gblx.net> Message-ID: <_6577.22568$EP6.5469979@news1.rdc2.pa.home.com> > I think this is what the PEP is proposing: Suggest you read it -- more carefully than I did a month ago. > // is current / behaviour No, x//y = floor(x/y) for both ints and floats, so that (x//y)*y + x%y = x as close as possible 8//3 = 2, 8.0//3.0 = 2.0 which is similar to 8+3 = 11, 8.0+3.0 = 11.0 > / is new int/int --> fp x/y is result with fraction so that (x/y)*y = x more or less From tim.one at home.com Mon Jul 23 22:24:08 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 23 Jul 2001 22:24:08 -0400 Subject: A use for integer quotients In-Reply-To: <3b5cbf31.247227744@wa.news.verio.net> Message-ID: <LNBBLJKPBEHFEDALKOLCGEIHLAAA.tim.one@home.com> [Bengt Richter] > I wonder if the implementation is factored to where not using > floating point would let you substitute small exception-raising > stubs for otherwise large (?? usually, floating point carries a > lot of baggage along in the C/C++ world) chunks concerned with ? floating point. No, it is not. > Then that could be a make option. I was wondering if someone's > been there done that. These folks have: http://www.abo.fi/~iporres/python/ Their patch is against 1.5.1, but I bet the principle still applies <wink>. From mac4-devnull at theory.org Sat Jul 7 06:00:19 2001 From: mac4-devnull at theory.org (Neil Macneale) Date: Sat, 07 Jul 2001 03:00:19 -0700 Subject: Limiting thread intruction count Message-ID: <3b46ddb2$0$332$8eec23a@newsreader.tycho.net> Is there a way to limit the number of instructions executed by a thread to a certain number? I want to start several threads and give them all the same number of instructions to work, then have them all stop after they have reached that point. Then I would like to resume all of those threads again for another 'round' of instruction batches. The idea is that I have a game where people play there code against others, and I would like to have some granularity in the number of intructions each thread executes in a given time frame. I think this may be impossible, but any suggestions would be great! Neil Macneale -- To reply to me via email, remove the '-devnull' from my address. From s713221 at student.gu.edu.au Mon Jul 23 00:02:06 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Mon, 23 Jul 2001 14:02:06 +1000 Subject: Insensitive Dictionaries (Was: Language change and code breaks) References: <XFMail.20010720091207.mikael@isy.liu.se> <cpn15zfywd.fsf@cj20424-a.reston1.va.home.com> <9jfh2u$11b6$1@news.btv.ibm.com> <3B5BA116.28A32BC1@student.gu.edu.au> Message-ID: <3B5BA1BE.8F4BB08E@student.gu.edu.au> Joal Heagney wrote: > Version three rewritten so it's consistent about try/except and if has_key else: > >>> class InsensitiveDict3(UserDict): > def __getitem__(self,key): > if self.data.has_key(key) > return self.data[key] > else: > if type(key) == type(""): > for i in self.data.keys(): > if i.lower() == key.lower(): > return self.data[i] > else: > raise IndexError > def __setitem__(self,key,value): > if self.data.has_key(key): > self.data[key] = value > else: > if type(key) == type(""): > for i in self.data.keys(): > if i.lower() == key.lower(): > del self.data[i] > self.data[key] = value > else: > self.data[key] =value > > -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From aleaxit at yahoo.com Tue Jul 31 05:57:29 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 31 Jul 2001 11:57:29 +0200 Subject: portability References: <9k5u2c$p542@news.rd.francetelecom.fr> Message-ID: <9k5vec01p4b@enews4.newsguy.com> "franck delarue" <franck.delarue at rd.francetelecom.com> wrote in message news:9k5u2c$p542 at news.rd.francetelecom.fr... > hello everyone, > i'm working on python on linux red hat and i'm wandering if all the code > that i've written would be portable to unix or windows (except the system > calls of course). I know that python works a little like java ( on a virtual > machine), but is Python as portable as java ? Python isn't quite as portable as Java, because Java by defaults shields you from all platform-dependencies, while Python's general attitude is to give you access to platform-dependent features -- which may not be there on another platform. So, writing portable, cross-platform code in Python, while quite feasible and not all that hard, DOES require more conscious attention and care than it does in Java (you can of course use Jython, Python for the Java Virtual Machine, in order to write Python code but get Java portability). While most non-portability issues with Python's standard library are indeed with "system calls" (e.g., you won't get os.fork on Windows platforms, because the operating system doesn't support that -- it's for Unix and Unix-like platforms only), there are (unfortunately, I would say) some (IMHO) less forgivable portability holes. For example, module time exposes a parsing function strptime on SOME platforms only -- those whose underlying C library supplies strptime (and if the underlying platform's strptime is flaky or non-standard, so is Python's time.strptime). There are pure Python versions of strptime around, but for some reason the Python core team never decided to integrate those in the standard Python library so that time.strptime would be usable on all platforms -- in the pure-Python version if need be, in a native-code one (for speed) if available & reliable. This is, unfortunately I feel, rather a good symbol of Python's overall approach to portability: quite achievable *if you work at it* (it's less work to make your Python code portable, than it would be for, say, C, or C++), but definitely a secondary issue (it takes a lot MORE work to make your Python code portable than it would take for, say, Java, or Tcl). Alex From foodbar at mit.edu Sun Jul 29 18:29:12 2001 From: foodbar at mit.edu (Alex) Date: 29 Jul 2001 18:29:12 -0400 Subject: Need help in creating a simple package in python References: <9k20ih$jq3$1@news.netvision.net.il> Message-ID: <etdr8uzbc93.fsf@pickled-herring.mit.edu> This is the third post you've sent about creating python packages. You've gotten responses to them, but you send almost the same post each time. Are the responses to your posts not getting through? Alex. > Hi > > Can you help me ? > > I am new with Python and I would like to ask several questions: > > 1. For creating a package I have to create a *.py script that will > group selected modules and contain the following script > __init__.py. -> Can you elaborate on this script definition (give an > example how the script should be written ). > > 2. I have tried to create a package that contains 2 modules and > succeeded in importing the package itself but not a module inside the > package for example 'import pkg.fib1' - what was wrong ? > > Thanks > > Yossi From brian_zhou at agilentNOSPAM.com Sun Jul 1 02:20:06 2001 From: brian_zhou at agilentNOSPAM.com (Brian Zhou) Date: Sat, 30 Jun 2001 23:20:06 -0700 Subject: Python for Windows CE 3.0 References: <YRq%6.44315$mK4.4754231@news6-win.server.ntlworld.com> Message-ID: <993968395.50097@emperor.labs.agilent.com> See http://groups.google.com/groups?q=jython+j9&btnG=Search&meta=site%3Dgroups I'm happily running Jython on iPaq now. Thanks to Java's WORA, it's a no-effort port; just some configuration. But also thanks to Java, it's not lightning fast, only got 49 pystones. So I'm looking forward to the native port. Sample session: Jython 2.1a1 on java1.2.2 subset (JIT: null) Type "copyright", "credits" or "license" for more information. >>> import math >>> 4.0 * math.atan(1.0) 3.141592653589793 >>> import java >>> java.util.Date() Sat Jun 30 22:57:36 PDT 2001 >>> import sre >>> sre.compile("\d+").findall("-12.345") ['12', '345'] >>> [n * 2 + 1 for n in [0, 1, 2]] [1, 3, 5] >>> Cheers, -Brian "Tom wright" <thomas.wright1 at ntlworld.REMOVETHIS.com> wrote in message news:YRq%6.44315$mK4.4754231 at news6-win.server.ntlworld.com... > 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 db3l at fitlinxx.com Tue Jul 31 22:23:13 2001 From: db3l at fitlinxx.com (David Bolen) Date: 31 Jul 2001 22:23:13 -0400 Subject: Arg decoding with a template? References: <ljidmtouqj6som2t9ecagbkj95c53kjaeh@4ax.com> <4oA97.5883$9i1.519137@e420r-atl1.usenetserver.com> <duodmt0itqq9t1kq6bs5dhpnk9io64p2sj@4ax.com> <ulml5sz7m.fsf@ctwd0143.fitlinxx.com> <rdeemts4mrarb8b5ghqieio68n1jv32tl1@4ax.com> <u8zh4u0b6.fsf@ctwd0143.fitlinxx.com> <lyH97.7737$9i1.681152@e420r-atl1.usenetserver.com> Message-ID: <uwv4oselq.fsf@ctwd0143.fitlinxx.com> "Steve Holden" <sholden at holdenweb.com> writes: > Was this the one that allowed to you define command lines like > > COPY FROM <file> TO <file> > > and variations could be deduced from the noise words? I seem to remember a > college chum of mine working in BCPL with a scheme like this, circa 1978, > but have only this fading memory. The term "noise" words (while I'm sure it's generic) reminds me of the TOPS-10/20 parsing that another poster wrote about (still in use in some Columbia applications like MM or Kermit - in fact there's a C CCMD library around made for that, although the TOPS stuff was built as a system JSYS which I tended to use in MACRO). In such a case, you actually defined parse tables that were incrementally parsed and control was passed off to various routines as the parsing continued, which could then dynamically vary the remainder of the parsing. Along the way you could define "noise" words so if the user allowed auto-completion (normally TAB or ESC) the completed word would be printed followed by the noise words in parenthesis afterwards to give a hint as to what to type next. Took a lot of set up work to do though in the code, and it was best for interactive parsing (where you got the most benefit), although since it was there it also got used for command lines. But even it had a convention for options and values as opposed to the native text in the command. The readline library is somewhat similar in construction but less dynamic and flexible. Actually, come to think of it, a wrapper around the CCMD library might be an interesting idea as a Python extension for interactive parsing, although I suppose with limited target base nowadays. -- -- 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 lekatsas at EE.Princeton.EDU Tue Jul 3 01:54:08 2001 From: lekatsas at EE.Princeton.EDU (Haris Lekatsas) Date: Tue, 3 Jul 2001 01:54:08 -0400 (EDT) Subject: problem with sending email In-Reply-To: <Pine.LNX.4.21.BCL.0107030943150.720-100000@suzi.com.onego.ru> Message-ID: <Pine.SOL.4.31.0107030150090.17815-100000@ivy.ee.princeton.edu> This works thanks! Unfortunately it makes my scripts less portable as the path to sendmail has to be specified (not always at /usr/sbin/sendmail) but this seems to be the only solution I have so far. I wonder if python's smtplib is broken. Thanks again Haris Lekatsas > On Tue, 3 Jul 2001, Haris Lekatsas wrote: > > > How can I do that from a CGI script? > > One way: > > os.system("""/usr/sbin/sendmail -t << EOMESSAGE > From: %(from)s > To: %(towhom)s > Subject: %(subject)s > > Message > > EOMESSAGE""" % vars()) > > Another way is to open sendmail thru the pipe: > > file = os.popen("/usr/sbin/sendmail -t", "w") > ... > file.write(letter) > ... > file.close() > > > > In article <mailman.994069322.26388.python-list at python.org>, Roman Suzi says... > > > > > >On 2 Jul 2001 piet at cs.uu.nl wrote: > > > > > >> >>>>> Haris Lekatsas <nospam at newsranger.com> (HL) writes: > > >> > > >> HL> I have a problem running the script below on FreeBSD. When I run it from the > > >> HL> UNIX prompt it runs fine and it sends a file (bigtextfile) of any size to > > >> HL> the recipient address. Whenever a run the exact same script from a web > > >> HL> browser as a CGI script it will send only about 17K of the bigfile and not > > >> HL> the whole thing. I tried many different files and all of them get cut off > > >> HL> at around 17K. It seems on other OS this problem does not appear. Any ideas > > >> HL> why this is happening would be appreciated. > > > > > >What if you try to send mail by piping to "sendmail -t"? > > > > > >Sincerely yours, Roman A.Suzi > > >-- > > > - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - > > Sincerely yours, Roman A.Suzi > -- > - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - > > > From guido at python.org Tue Jul 24 15:51:00 2001 From: guido at python.org (Guido van Rossum) Date: Tue, 24 Jul 2001 19:51:00 GMT Subject: Language change and code breaks References: <Pine.LNX.4.33.0107191316390.24983-100000@bms> <mailman.995571273.18192.python-list@python.org> <9j7gv8$9mg@dispatch.concentric.net> <cppuawfqbm.fsf@cj20424-a.reston1.va.home.com> <Pine.LNX.4.33.0107231434170.15565-100000@oliphant.ee.byu.edu> <532qlt453irrepptskcvp213d44r3so2e2@4ax.com> Message-ID: <cp4rs2qf6p.fsf@cj20424-a.reston1.va.home.com> Courageous <jkraska1 at san.rr.com> writes: > The moment using "tools" with Python becomes an essential part of > creating Python programs, the language is dead to me. All of this > pent-up rancor of mine comes with my open contempt for Lisp environ- > ments which more or less simply require you to use Emacs. I think you've got that backwards. The whole point of putting case insensitivity in the tools it *not* to force you to use the tool. The language would remain case-sensitive, and you would be free to use it that way in any tool you chose, but there would be a separate tool available that enforced case-preserving case-sensitivity for those who prefer it. BTW, this would happen in a distant future, and that's all I'm going to say about case-insensitivity for now. --Guido van Rossum (home page: http://www.python.org/~guido/) From chat at linuxsupreme.homeip.net Wed Jul 11 17:48:50 2001 From: chat at linuxsupreme.homeip.net (Chad Everett) Date: 11 Jul 2001 16:48:50 -0500 Subject: Freeing memory from Python lists! References: <cdd0bc89.0107111041.c3f8209@posting.google.com> <qebpktoe7n33altfhpar744nhak7hf4b6u@4ax.com> Message-ID: <slrn9kpj0n.mi0.chat@linuxsupreme.homeip.net> On 11 Jul 2001 14:53:06 -0500, Chris Spencer <clspence at one.net> wrote: > I can confirm these results. Why would a deleted list retain 90% of its >memory usage after being deleted? Sounds like a pointer is getting lost >somewhere. > >Chris. > >On 11 Jul 2001 11:41:25 -0700, msimpson at ioindustries.com (Mike Simpson) wrote: > >>I can't figure out how to free the memory used in the creation of a >>large list in Python. >>I am running the Python 2.1 interpreter on Windows 2000 Professional >>to run the following piece of code: >> >>result = [] >>for count in xrange(510*478): >> result.append(count) >>del result >> >>By using Windows Task Manager I was able to determine that 4332K of >>memory was used up until the end of the for loop, but only 960K of >>memory was returned to the system after the call to "del". Is there >>any way to return the other 3372K of memory to the system without >>quitting the Python interpreter? >> Nothing has been lost. As other responses have pointed out, you are seeing a manifestation of the OS memory management algorithms. To show you that nothing has been "lost" do the following: 1. run python and get a python prompt 2. look at your memory allocation 3. do your: result = [] for count in xrange(510*478): result.append(count) 4. look at memory usage 5. delete the result list del result 6. look at memory usage 7. now build the list again result = [] for count in xrange(510*478): result.append(count) 8. look at memory usage and you'll see it has only gone back up to the same amount of memory at step 4. -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From aahz at panix.com Sat Jul 28 15:03:39 2001 From: aahz at panix.com (Aahz Maruch) Date: 28 Jul 2001 12:03:39 -0700 Subject: How to break? (was Re: A modest PEP0238 suggestion) References: <3b5c6e08.27535083@aplnews> <9jjk9g$8tk$1@newsy.ifm.liu.se> <9jun6j$c5$1@panix2.panix.com> <bZC87.37029$EP6.9803880@news1.rdc2.pa.home.com> Message-ID: <9jv2ab$ffo$1@panix2.panix.com> In article <bZC87.37029$EP6.9803880 at news1.rdc2.pa.home.com>, Terry Reedy <tjreedy at home.com> wrote: > >One way to never break code, silently or otherwise, is to never change >the interpreter. > >Another is to make current behaviour (including bugs) the default >forever and forever require explicit import of every change ever made >since freeze time, with runtime compilations handled separately. > >Another is to go ahead and make new meanings the default but forever >identify every construct that once had a different meaning and issue a >warning so that the change is never completely silent. > >Any others? Yup: make the old behavior an error but also require a directive to enable the new behavior. -- --- 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 Fortune cookie: Watch your relations with other people carefully, be reserved. From qrczak at knm.org.pl Sun Jul 29 02:44:00 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 29 Jul 2001 06:44:00 GMT Subject: Some Python (Monty) Perspective (was Re: Language change and code breaks) References: <Pine.LNX.4.33.0107191316390.24983-100000@bms> <mailman.995571273.18192.python-list@python.org> <9j7gv8$9mg@dispatch.concentric.net> <cppuawfqbm.fsf@cj20424-a.reston1.va.home.com> <mailman.995734717.26373.python-list@python.org> <3B5DF101.9B2E4631@earthlink.net> <cpofq9a858.fsf@cj20424-a.reston1.va.home.com> <9jmqp3$9n1@dispatch.concentric.net> <slrn9lttn5.69.grante@isis.visi.com> <ni92mt4a7e2k64b1vn6rm0jaqlkf525mjp@4ax.com> <jQg87.29709$B7.4412083@ruti.visi.com> Message-ID: <slrn.pl.9m7c5g.na4.qrczak@qrnik.zagroda> Fri, 27 Jul 2001 16:40:47 GMT, Grant Edwards <grante at visi.com> pisze: > An argument could be made that mixing ints and floats is A Bad > Thing(tm). I strongly disagree. The most natural way to cut a float into a half is x/2 As long as literals like 2 have type int, mixing ints and floats should be fully supported. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From piet at cs.uu.nl Mon Jul 16 15:05:04 2001 From: piet at cs.uu.nl (Piet van Oostrum) Date: 16 Jul 2001 21:05:04 +0200 Subject: Failing gracefully when installed Python is too old? References: <7MF47.17793$B7.2997540@ruti.visi.com> Message-ID: <wzy9po8zkv.fsf@sunshine.cs.uu.nl> >>>>> grante at visi.com (Grant Edwards) (GE) writes: GE> I can't figure out a way for a Python program to fail GE> gracefully if somebody attempts to run it with a version of GE> Python that's too old. GE> Checking sys.hexversion at runtime won't work because the GE> program might not even parse. For example, attempting to run GE> a program containing list comprehensions under 1.5.2. GE> Is there any way to check the version at compile time? You can write anothe very small module that just imports the main module and catches the exception. -- Piet van Oostrum <piet at cs.uu.nl> URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From kosh at aesaeion.com Sat Jul 21 18:05:59 2001 From: kosh at aesaeion.com (kosh) Date: Sat, 21 Jul 2001 22:33:59 +0028 Subject: Language change and code breaks (fwd) References: <mailman.995574754.22146.python-list@python.org> <3b5873ba.2423857703@wa.news.verio.net> <9jbp9l$90f$1@apollo.csd.net> <mailman.995756077.11446.python-list@python.org> Message-ID: <9jdl47$362$1@apollo.csd.net> Skip Montanaro wrote: > > >> That does bring up the subject of machine-generated symbols though. > >> And case sensitivity in dictionaries. I use base52 [A-Za-z] encoded > >> md5's in certain contexts. If I use those as keys, will it break? > > kosh> Losing case sensitivity in dictionaries would screw me pretty > kosh> badly also. > > I think case-sensitivity as we are discussing in this thread runs only to > identifier and attribute names, not the contents of strings, so while > > date = 1 > DATE += 1 > print Date > > should print "2" by my understanding, > > dict = {"date": 1, > "DATE": 2, > "Date": 3} > > would create a dictionary of length 3. > However self.date and self.__dict__['date] and getattr(self, 'date') are the same things at this point. So how could self.data be case insensitive without the dicts being case insensitive? Otherwise I could just set the items however I wanted by using the __dict__ directly or even better override the setattr and getattr methods to use the __dict__ so that I could still do case sensitive stuff. Overall it seems that if case insensitive is desired then case sensitive dicts have to go. In which case that will probably be the end of my use of python and many others. From nperkins7 at home.com Sat Jul 14 23:48:24 2001 From: nperkins7 at home.com (Nick Perkins) Date: Sun, 15 Jul 2001 03:48:24 GMT Subject: Need help with "global" variables References: <yH747.348232$p33.7087093@news1.sttls1.wa.home.com> Message-ID: <co847.478507$eK2.99254456@news4.rdc1.on.home.com> Your modules are going to have to import the globals. You could put them all in a separate file, call it "my_globals.py", and then in each file (including the 'main' file), you would have: from my_globals import * "Pugsley" <europax at home.com> wrote in message news:yH747.348232$p33.7087093 at news1.sttls1.wa.home.com... > I'm converting a number crunching program from C to Numeric Python, and > I'm really getting stuck on how to deal with global variables. > > For example, there are about 30 variables that are defined in the main > program that I want to be global and available in the functions in the > modules. (the modules are seperate files that I import). A simple > example would be: > > def foo(arg1, arg2): > > global bar1, bar2, bar3, etc. > > result= bar1+bar2+bar3+ arg1+arg2 > > return result > > > > But all I get are errors stating that the global variables have not been > defined. This behavior seems to run counter to what is implied in some > books that I've been reading. > > What am I doing wrong? Thanks, Rob. From Tom_Good1 at excite.com Fri Jul 20 12:31:08 2001 From: Tom_Good1 at excite.com (Tom Good) Date: 20 Jul 2001 09:31:08 -0700 Subject: trouble installing Python-2.2a1.exe References: <ac677656.0107191230.767b041d@posting.google.com> Message-ID: <ac677656.0107200831.1e94f7b1@posting.google.com> Tom_Good1 at excite.com (Tom Good) wrote in message news:<ac677656.0107191230.767b041d at posting.google.com>... > I downloaded the Python-2.2a1.exe installer from SourceForge, and > verified that the MD5 sum is correct. When I run it under Windows > 2000 Professional [Version 5.00.2195], I get an error dialog that > says: > > 16 bit Windows Subsystem > > The NTVDM CPU has encountered an illegal instruction. > CS:020c IP:0115 OP:0f 00 00 00 00 Choose 'Close' to terminate the > application. > Sorry, I had thought that this was a problem with the installer, but it really turned out to be a problem with my Windows configuration. I fixed it. From owen at astrono.junkwashington.emu Fri Jul 13 12:14:23 2001 From: owen at astrono.junkwashington.emu (Russell E. Owen) Date: Fri, 13 Jul 2001 09:14:23 -0700 Subject: Cross-platform GUI app -- Tkinter? References: <3b4e211f$1@news.blarg.net> Message-ID: <9in6p1$h36$1@nntp6.u.washington.edu> In article <3b4e211f$1 at news.blarg.net>, steveha at animal.blarg.net (Steve R. Hastings) wrote: >Hello. I am new to Python, studying books to come up to speed. > >I have one question I have not really seen discussed in FAQs and such: > >If I want to make a GUI application with menus and such, and I want it to >be easily portable to multiple platforms, what is the best way to do it? >At this point I suspect Tkinter is the way to go. How cross-platform? If you mean Mac, Windows and unix then Tkinter or Jython (Python running on Java) are your only options in Python. I have not used Jython, but am about to try it, because Tkinter has some serious limitations and some nasty problems on the Mac (including: file events don't work -- a known problem -- and custom menus cause crashes, at least on my machines). I would start with Jython -- or pick another language. If you only mean various flavors of Windows and unix, then there are additional packages to choose from, including wxPython. If you have additional platforms in mind, I'm afraid I can't offer any advice. As to learning Tkinter... An Introduction to Tkinter, by Fredrik Lundh, is excellent but incomplete (I'm not sure if it's a work in progress or that's as far as it's going to go; I hope the former). In any case, see links from PythonWare Library <http://www.pythonware.com/library/index.htm> for HTML and PDF versions. John Grayson's book "Python and Tkinter Programming" is fine and well worth having. It's also the only book I know of on the subject. You'll probably also want one ore more Tk references. I've been pleased with "Effective Tckl/Tk Programming" by Harrison and Mclennan. It doesn't try to cover everything, but has useful info about some subtler aspects of making real, usable GUIs with Tk. Tkinter is an odd mix of strengths and weaknesses. The Canvas class, for line drawings and such, is quite powerful. On the other hand Tk has limitations that are bizarre in a toolkit as mature as this one, including: - "copy and paste" of text don't "just work", and it's a real pain to implement them (I've still not finished the job for my app, but at least I've gotten some common cases working). I suspect this is a side effect of a toolkit originally written for unix. - there is no good way to implement a text display that allows users to copy info but not change it. This is a famous FAQ and the usual solution is an ugly hack. -- Russell From dale at riverhall.NOSPAMco.uk Mon Jul 30 10:19:17 2001 From: dale at riverhall.NOSPAMco.uk (Dale Strickland-Clark) Date: Mon, 30 Jul 2001 15:19:17 +0100 Subject: Loaded module list and attributes References: <o2mamt4qtis8r77maqnsmjg7h193aa80t4@4ax.com> <fQd97.3473$9i1.231823@e420r-atl1.usenetserver.com> Message-ID: <m6ramt0abep6khir1fdq4fsf9sdt12e8le@4ax.com> "Steve Holden" <sholden at holdenweb.com> wrote: >Probably you want to iterate over sys.modules -- one way to do this is: > > for k in sys.modules.keys(): > module = sys.modules[k] > print module.__version__ > >However you will need to ensure that a particular module HAS a __version__ >attribute before referencing it, or trap the AttributeError exception which >will result when it doesn't. > >regards > STeve Excellent. Thanks. -- Dale Strickland-Clark Riverhall Systems Ltd From dcarr1 at hotmail.com Wed Jul 25 18:55:50 2001 From: dcarr1 at hotmail.com (Dudley Carr) Date: 25 Jul 2001 15:55:50 -0700 Subject: Sorting Lists References: <lSh77.64029$2V.13507417@news3.rdc1.on.home.com> Message-ID: <35fda446.0107251455.6a3339e@posting.google.com> "Colin Meeks" <colin at meeks.ca> wrote in message news:<lSh77.64029$2V.13507417 at news3.rdc1.on.home.com>... > I have a list that comprises of First Name, Surname, Age > The list looks something like > > [["Mickey","Mouse","50"],["Stan","Mantz","3"],["Junior","Wilst","40"],["Kim" > ,"Bean","15"]] > > How can I sort the list to rearrange it by either First Name, Surname, Age > data = [["Mickey","Mouse","50"], ["Stan","Mantz","3"], ["Junior","Wilst","40"], ["Kim","Bean","15"]] data.sort(lambda elem1, elem2: cmp(elem1[2], elem[2])) That ought to sort the list on the age. Dudley From db3l at fitlinxx.com Wed Jul 25 16:07:58 2001 From: db3l at fitlinxx.com (David Bolen) Date: 25 Jul 2001 16:07:58 -0400 Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <mailman.995989601.30748.python-list@python.org> <cp3d7lbo89.fsf@cj20424-a.reston1.va.home.com> Message-ID: <ubsm8epr5.fsf@ctwd0143.fitlinxx.com> Guido van Rossum <guido at python.org> writes: > "Bjorn Pettersen" <BPettersen at NAREX.com> writes: > > > I think perhaps an equally interesting example is something like: > > > > 2L**128/2 > > > > which currently gives an exact result, but under the proposed new > > semantics would give an approximation... > > Have you read the PEP? The PEP only returns a float if the int result > would yield a remainder. Does it? While returning an integral value in the above case, wouldn't it would in fact be a float data type (barring the addition of rationals), as per: (from PEP238) "The type of a/b will be either a float or a rational, depending on other PEPs[2, 3]. However, the result will be integral in all case the division has no remainder." And given that, what happens if float can't represent the resulting precision necessary? Of course, this is only true later when this is the default, right? Until then, the "future" implementation is an addition of 0.0 to the divisor, so the result would definitely be float, and not necessarily integral. Unless you meant something other than the data type involved by "returns a float". -- -- 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 dinu at reportlab.com Sat Jul 21 10:09:59 2001 From: dinu at reportlab.com (Dinu Gherman) Date: Sat, 21 Jul 2001 14:09:59 GMT Subject: Help with PDF References: <mailman.995677535.12211.python-list@python.org> <20010721.071302.1704365084.1761@d150-169-166.home.cgocable.net> Message-ID: <3b598d0f.252655609@news.t-online.de> On Sat, 21 Jul 2001 11:01:04 GMT, "Mark Nenadov" <mnenadov at stclairc.on.ca> wrote: >The best solution for Python and PDF that I have found is PDF-Lib >(www.pdflib.com). I have used it with Python, and it also work with a >wide variety of other languages. What do you mean by "best"? ;-) Dinu -- Dinu C. Gherman dinu at reportlab dot com http://www.reportlab.com ................................................................ "The only possible values [for quality] are 'excellent' and 'in- sanely excellent', depending on whether lives are at stake or not. Otherwise you don't enjoy your work, you don't work well, and the project goes down the drain." (Kent Beck, "Extreme Programming Explained") From johann at physics.berkeley.edu Wed Jul 18 12:26:27 2001 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 18 Jul 2001 09:26:27 -0700 Subject: Python 2 times slower than Perl References: <mailman.995443830.26172.python-list@python.org> <3B55724D.465E8A44@engcorp.com> Message-ID: <mt7kx6b3v0.fsf@astron.berkeley.edu> Peter Hansen writes: > In practice, we've found Python to be somewhere between > 30 and 100 times slower than C, clearly depending on the > algorithm and without really much effort to optimize. > (That is, our Python code could probably withstand > some significant optimization, if we cared to.) I've been playing with ocaml, so I thought I'd try the results on my computer, a Mac PowerBook G3/400. Things don't look so good for the G3/400 processor though, at least on OS X. I get: cc -O2 0.28 cc 0.62 ocamlopt 1.26 (compiled) ocaml 9.42 (interpreted) perl 28.9 python 66.8 Hm. I'm beginning to wonder if I compiled python with -O2 or not. Plus, I'm becoming more and more fond of ocaml. The python function I used was the basic def test (): i = 2.5 j = 2.5 while i < 1e7: j = 2.5 * 2.5 i = i + 1.0 print "%f %f\n" % (i, j) if __name__ == '__main__': test () --Johann From moshez at zadka.site.co.il Sun Jul 22 14:40:49 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Sun, 22 Jul 2001 21:40:49 +0300 Subject: PEP0238 lament In-Reply-To: <15195.2349.947801.54567@beluga.mojam.com> References: <15195.2349.947801.54567@beluga.mojam.com>, <mailman.995814276.15005.python-list@python.org> <cp66clexxt.fsf@cj20424-a.reston1.va.home.com> Message-ID: <E15OO9p-0003oJ-00@darjeeling> On Sun, 22 Jul 2001 12:11:09 -0500, Skip Montanaro <skip at pobox.com> wrote: > Guido, > > I just reread the PEP at > > http://python.sourceforge.net/peps/pep-0238.html > > It looks like it hasn't been updated since March. I see no support for the > argument that the current integer division semantics are confusing, only a > claim that the current semantics are a problem. Perhaps there's a more > recent version of the PEP available that hasn't been released to the > website. Not really. I'm working on the PEP, and hopefully there will be a new version tommorow with some more meat. -- gpg --keyserver keyserver.pgp.com --recv-keys 46D01BD6 54C4E1FE Secure (inaccessible): 4BD1 7705 EEC0 260A 7F21 4817 C7FC A636 46D0 1BD6 Insecure (accessible): C5A5 A8FA CA39 AB03 10B8 F116 1713 1BCF 54C4 E1FE From steve at lurking.demon.co.uk Sun Jul 22 08:45:26 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Sun, 22 Jul 2001 13:45:26 +0100 Subject: BURNING EARTHSHAKING Tuple Question References: <5e8bd451.0107191249.3c0d9f21@posting.google.com> <3B58EBF4.F24E5129@alcyone.com> Message-ID: <pmglltoiomis08cg8s18ogql1psmb4knkj@4ax.com> On Fri, 20 Jul 2001 19:41:56 -0700, Erik Max Francis <max at alcyone.com> wrote: >kevin parks wrote: > >> By the way is tuple pronounced tOOple (god i hope it is), or is it >> pronounced >> like the word "couple". Tuple like "couple" would be too high brow. > >I've always heard it pronounced to rhyme with _couple_, but a >mathematician friend of mine insisted that it was pronounced the other >way. When I checked a dictionary it said both were legal. Funny - the guy who last taught me maths insisted on the rhymes-with-couple version. tOOple sounds too high brow to me - British snobs tend to say things the longest, most stretched out and emphasised way they can - presumably they need to make up for the lack of content by at least making their words sound as impressive as possible. American high brows, I presume, are too busy making money to waste time saying 'oo' when they can just say 'u' ;-) From aleaxit at yahoo.com Tue Jul 31 12:22:29 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 31 Jul 2001 18:22:29 +0200 Subject: Arg decoding with a template? References: <ljidmtouqj6som2t9ecagbkj95c53kjaeh@4ax.com> Message-ID: <9k6m0702ofn@enews4.newsguy.com> "Dale Strickland-Clark" <dale at riverhall.NOSPAMco.uk> wrote in message news:ljidmtouqj6som2t9ecagbkj95c53kjaeh at 4ax.com... > Is there a class that simplifies high-level argument decoding under the control of a template? > > Such a class would take a string as a template and the arg list and return another list populated > with keys, values and switches taken from the args. > > I've spent the last hour going through the global module list. If it's there, its got a daft name! You mean, standard module getopt? That's pretty much a traditional name I think, although getopt's functionality is rather minimal compared with other implementations. Alex From tjenkins at nospiced.ham.devis.com Tue Jul 24 11:39:01 2001 From: tjenkins at nospiced.ham.devis.com (Tom Jenkins) Date: Tue, 24 Jul 2001 15:39:01 GMT Subject: A use for integer quotients References: <3B5BC73B.2D52E5E2@alcyone.com> <3B5BA29B.E08FEEE9@alcyone.com> <yCK67.17615$EP6.4467503@news1.rdc2.pa.home.com> <mailman.995860718.9550.python-list@python.org> <mailman.995862939.15013.python-list@python.org> <mailman.995883879.12071.python-list@python.org> <apaolto6pr6cevpk0lgudiapnbrttaj8u9@4ax.com> <m2wv4yhm6v.fsf@mycroft.actrix.gen.nz> <Vqg77.3375$Xk6.761103@news2.rdc2.tx.home.com> Message-ID: <3B5D977C.7010203@nospiced.ham.devis.com> Rainer Deyke wrote: > "Paul Foley" <see at below> wrote in message > news:m2wv4yhm6v.fsf at mycroft.actrix.gen.nz... > >>If you want integers, write floor(a,b) [or floor(a/b)], since that's >>what you really mean. >> > > That would be incorrect though. When I write "a / b", I mean "the largest > integer 'c' such that c * b <= a". I don't mean "some approximation loosely > resembling a / b", which floating point calculations give me. > Correct, that would be incorrect <3.0/4 wink>. To _really_ get what one wants, one would have to write divmod(a,b)[0] which is, ummm, well, just plain ugly. now-i-wonder-how-Parrot-handles-this-ly yours Tom From martin at strakt.com Mon Jul 30 08:35:04 2001 From: martin at strakt.com (Martin Sjögren) Date: Mon, 30 Jul 2001 14:35:04 +0200 Subject: 100,000 messages celebration? In-Reply-To: <3B654A3B.61D17D7E@student.gu.edu.au> References: <25b2e0d9.0107291052.7780d1f8@posting.google.com> <3B64BA49.C105612B@student.gu.edu.au> <5D997.52$Nq1.2409@nreader1.kpnqwest.net> <3B654A3B.61D17D7E@student.gu.edu.au> Message-ID: <20010730143504.A3191@strakt.com> On Mon, Jul 30, 2001 at 09:51:23PM +1000, Joal Heagney wrote: > Francis Meyvis wrote: > > > > This would be great! > > I remember in the very very beginning > > a lot of people were posting silly jokes on the list. > > I think they thought this list was about the Monty Python thing. > > Much to the frustration of some "serious" clerics. > > At that time it were my first experiences with the "net". > > Very enjoyable it was! > > Well I'm a late-comer, so all the "great exploits" of the c.l.py group > are only myth and legend to me. Though I did cruise the www.python.org > site to find out what the #$*%)-was-with-the-ly-y'rs- ly-yr's. I only recently subscribed, and I've been a bit curious about it too. Not that I can be bothered to actually search for it :-) -- Martin Sj?gren martin at strakt.com ICQ : 41245059 Phone: +46 (0)31 405242 Cell: +46 (0)739 169191 GPG key: http://www.strakt.com/~martin/gpg.html From rnd at onego.ru Tue Jul 10 11:52:04 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 10 Jul 2001 19:52:04 +0400 (MSD) Subject: Python for air traffic control? In-Reply-To: <01af01c1091f$c7e9a9a0$0e4ab43f@kens> Message-ID: <Pine.LNX.4.21.BCL.0107101948450.1573-100000@suzi.com.onego.ru> BTW, it just occured to me that Forth system may be a language of choice for ATC programming. I remember somebody told me that some airports use such systems quite successfully and COMFORTably. (They used COMFORT). http://www.forth.com aslo mentions this kind of usage. Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From phd at phd.fep.ru Thu Jul 12 09:51:34 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Thu, 12 Jul 2001 17:51:34 +0400 (MSD) Subject: ZODB address list question (source is listed)... In-Reply-To: <4a249347.0107120538.6cf71cba@posting.google.com> Message-ID: <Pine.LNX.4.33.0107121750340.29439-100000@phd.fep.ru> On 12 Jul 2001, Robert wrote: > I am a newbie at both Python and ZODB so I thought I would modify the > ZODB demo that Mr. Pelletier did. It does the Listing, Adding and > Quiting fine. But when I add a duplicate it does not tell me that that > "name" is already in the database. It doesn't - it just replaces old record. You are supposed to test it yourself: if not root.has_key(name): root[name] = value. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From m-turk at nwu.edu Tue Jul 31 12:51:41 2001 From: m-turk at nwu.edu (Matthew Turk) Date: 31 Jul 2001 16:51:41 GMT Subject: C/Cygwin/Python Message-ID: <slrn9mdold.1snq.m-turk@dhcp101054.res-hall.nwu.edu> Hi there. I'm working on some 'back-end' stuff that I'm doing in C - and I'm struggling through compiling it properly, which is an entirely different question. Essentially, I want to be able to use it on computers that don't run Cygwin. Is this going to work? I certainly *don't* want to resort to Visual C, since I have no idea how to operate in that environment, nor do I own a copy. I know that cygwin has the -Wno_cygwin or something flag that'll compile without CYGWIN.DLL, but will that be sufficient for compiling a python extension? Thanks! mjt -------------------------------------------------- Matthew J. Turk <m-turk at nwu.edu> ICQ: 3856787 "Music is the Best." - FZ www.dailyvault.com From grayson-wilson at home.com Wed Jul 11 22:33:12 2001 From: grayson-wilson at home.com (EricIDLE) Date: Thu, 12 Jul 2001 02:33:12 GMT Subject: Help With filter(). References: <XA537.678643$166.13965187@news1.rdc1.bc.home.com> <3B4CEF3C.D664D82A@Lugoj.Com> Message-ID: <I%737.679443$166.13999728@news1.rdc1.bc.home.com> I Still Dont Get It. Could you explain it in simpiler terms? James Logajan <JamesL at Lugoj.Com> wrote in message news:3B4CEF3C.D664D82A at Lugoj.Com... > EricIDLE wrote: > > > > What does filter do? I don't understand when I read it other places. > > newlist = filter(somefunc, somelist) > #### is roughly the same as doing: > newlist = [] > for entry in somelist: > if somefunc(entry): > newlist.append(entry) > #### > > So the newlist will have only those entries for which somefunc returns a > true value. Note that if you do: > newlist = filter(None, somelist) > #### this is roughly the same as: > newlist = [] > for entry in somelist: > if entry: # Notice change here. > newlist.append(entry) > #### > > Note that if somelist is a string or tuple, then newlist will be a string or > tuple. From paulp at ActiveState.com Sun Jul 1 00:05:52 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sat, 30 Jun 2001 21:05:52 -0700 Subject: Support for "wide" Unicode characters References: <mailman.993767684.13828.python-list@python.org> <5zn%6.2300$Z6.1039816@news1.rdc2.pa.home.com> Message-ID: <3B3EA1A0.87855C7C@ActiveState.com> Terry Reedy wrote: > >... > > 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? Okay: Code point If you imagine Unicode as a mapping from integers to characters, each integer is a code point. In other words a code point is an integer between 0 and TOPCHAR. Some code points are really mapped to characters. Some will someday be used for characters. Some are guaranteed never to be used for characters. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From pinard at iro.umontreal.ca Wed Jul 4 19:21:11 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 04 Jul 2001 19:21:11 -0400 Subject: SPAM again [was: Re: .BIZ .INFO domain extensions] In-Reply-To: <UTC200107042223.AAA18879@zeus.cwi.nl> References: <UTC200107042223.AAA18879@zeus.cwi.nl> Message-ID: <oqhewsxouw.fsf@lin2.sram.qc.ca> Hi, people. We still get SPAM from this list once in a while, which is annoying. I wonder if something could be done about it at the list level. I noticed that two recent SPAM were sent to `python-list at cwi.nl' instead of `python-list at python.org', so we might think of ruling out that old address. On the other hand, valid postings are still made to the `cwi.nl' address, even if rarely. I fear some members might find rude being forced to switch to `python.org'. And besides, I'm sure `python.org' will get included in all spammers' lists, sooner or later, so this would be just postponing the real problem. Sigh! My attitude about SPAM, and am not sure I am fully right, is that I rely on mailing lists to filter the SPAM they get before forwarding it to me, while I consider this is more my responsibility to filter the rest, which directly gets addressed to me without going through mailing lists. Opinions? Suggestions? > Attention: Internet Domain Registrant [...] > ####################################################################### > This message is sent in compliance [...] -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From guido at python.org Fri Jul 27 17:43:51 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 27 Jul 2001 21:43:51 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <eppstein-03540D.13070222072001@news.service.uci.edu> <LNBBLJKPBEHFEDALKOLCOECNLAAA.tim.one@home.com> <mailman.995899647.346.python-list@python.org> <tclolt053o18f8q0ntb7n4aggitdkmeg4h@4ax.com> <Io_67.23543$B7.3779351@ruti.visi.com> <slrn9lp2m5.vp.Gareth.McCaughan@g.local> <p56plt8q4rs3bgcqbepk61q2r3g0tr2vhe@4ax.com> <slrn9ls3ae.2fm.Gareth.McCaughan@g.local> <cpitghbq05.fsf@cj20424-a.reston1.va.home.com> <MWD77.27751$EP6.6983549@news1.rdc2.pa.home.com> <9jnt9p$qhe$1@newsy.ifm.liu.se> <SYV77.27286$B7.4239335@ruti.visi.com> <cpitgf7itx.fsf@cj20424-a.reston1.va.home.com> <WIY77.27607$B7.4257794@ruti.visi.com> <cp3d7j75jv.fsf@cj20424-a.reston1.va.home.com> <024c01c1162f$5e7b56e0$6501a8c0@pacbell.net> <mailman.996238555.25095.python-list@python.org> <3b61d4ae.580834796@wa.news.verio.net> Message-ID: <cpr8v2120n.fsf@cj20424-a.reston1.va.home.com> bokr at accessone.com (Bengt Richter) writes: > On Fri, 27 Jul 2001 08:54:13 -0400, Guido van Rossum <guido at zope.com> wrote: > [...] > >Assuming we'll adopt a variation of Scheme's numerical tower (which > >I'm currently in favor of, more or less), this won't happen. Floats > >and complex would always be considered inexact (and ints and rationals > >exact), and inexact numbers are not allowed as sequence indices, even > >if their exact value is an integer. > > > Why would complex have to be inexact if both its > real and imaginary parts were exact? > > This looks exact, but will it be? > >>> (1+2j)**2 > (-3+4j) Probably not -- I don't think it's worth to have a separate exact and inexact complex numbers, especially since exact numbers will probably be represented as rationals (with ints and long ints as a special-case optimization), while inexact numbers will probably all use some form of floating point (binary or decimal). --Guido van Rossum (home page: http://www.python.org/~guido/) From root at rainerdeyke.com Sun Jul 1 22:00:51 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Mon, 02 Jul 2001 02:00:51 GMT Subject: Augmented Assignment (was: Re: PEP scepticism) References: <mailman.994035602.29848.python-list@python.org> Message-ID: <nBQ%6.417370$oc7.58837743@news2.rdc2.tx.home.com> "Delaney, Timothy" <tdelaney at avaya.com> wrote in message news:mailman.994035602.29848.python-list at python.org... > > >>> b = (1,2,3) > > >>> id(b) > > 15261292 > > >>> b += (4,5) > > >>> b > > (1, 2, 3, 4, 5) > > >>> id(b) > > 18736580 > > >>> > > Actually, that's not quite true. It would be quite legal for id(b) to be > identical in one case - since b is the only reference to the tuple, the > original tuple could be collected, and a new tuple with the same id() could > be allocated. It's unlikely, but possible. An interesting (and AFAIK legal) optimization would be to make tuples act as mutable objects with respect to augmented assignment if their reference is 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 new_name at mit.edu Mon Jul 16 11:02:48 2001 From: new_name at mit.edu (Alex) Date: 16 Jul 2001 11:02:48 -0400 Subject: timed event?? References: <tl5t1fprkuobd@corp.supernews.com> Message-ID: <etdk818rk6f.fsf@quiche-lorraine.mit.edu> Try "pydoc time" at the command line. Alex. From akuchlin at mems-exchange.org Sat Jul 28 13:37:08 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 28 Jul 2001 13:37:08 -0400 Subject: re bad leadership References: <0+yM4IAgmKX7EwIQ@jessikat.fsnet.co.uk> <9juspa$8p0$1@panix2.panix.com> Message-ID: <3dsnfhq7jv.fsf@ute.cnri.reston.va.us> aahz at panix.com (Aahz Maruch) writes: > In article <0+yM4IAgmKX7EwIQ at jessikat.fsnet.co.uk>, > Robin Becker <robin at jessikat.fsnet.co.uk> wrote: > >MDFL > What does this stand for? Misguided DFL? Another thread expanded that as Malevolent, but that seems unduly harsh. --am"When in doubt, assume good will"k From rnd at onego.ru Tue Jul 10 05:48:36 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 10 Jul 2001 13:48:36 +0400 (MSD) Subject: import namespace issues In-Reply-To: <yv2lmlxgnji.fsf@lionsp093.lion-ag.de> Message-ID: <Pine.LNX.4.21.BCL.0107101330370.1573-100000@suzi.com.onego.ru> On 10 Jul 2001, Harald Kirsch wrote: > THE PROBLEM: > I have to separate a module's function into two .py-files. Now I would > like to import both in a way that they behave like they are one file. Strange. If functions are so closely related, their place is in one module. After I read what you've written below, I concluded that probably you need to rethink your modules' decomposition to have less dependent modules. For example, create the third module and put low-level routines there second.py and first.py will import from lowlevel.py and be happy. I see no real reason this can't be done. > FIRST TRY: > Suppose the files are called first.py and second.py. I put a > > from second.py import * from second import * BTW > > into first.py. This does not work as necessary since functions in > second.py don't find functions defined in first.py. Same story when > using __import__(). > > FINDINGS: > What I gathered from experiments is that even with `from ... import' Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From grumble at usa.net Wed Jul 11 12:56:46 2001 From: grumble at usa.net (jcm) Date: 11 Jul 2001 16:56:46 GMT Subject: Python speed References: <roG27.666914$166.13798179@news1.rdc1.bc.home.com> <9ifjjh$1e3$1@news.mathworks.com> <3B4B562F.77C1B79@yahoo.com> <9ifo90$4hh$1@news.mathworks.com> <9ihspn$c3o$1@panix3.panix.com> Message-ID: <9ii0ge$coj$1@news.mathworks.com> Aahz Maruch <aahz at panix.com> wrote: > In article <9ifo90$4hh$1 at news.mathworks.com>, jcm <grumble at usa.net> wrote: >> >>Well, I say this because I've written a mud engine in Python and it's >>slow. Using this engine on a PII 266 running RedHat 6.1, 400 >>wandering monsters (with nothing else going on in the mud) will peg >>the cpu. In a production mud, you might want to do something >>intelligent about wandering monsters (like have them stop wandering if >>no players are nearby to save cpu-time), but there will also be lots >>else going on. > What we have here is a clear failure to communicate. > Look, if you have *one* monster sitting in a computation-intensive loop, > you're going to peg the CPU no matter what language you're using. The > question is, how efficient and fast is each pass through the loop, and > how responsive is the loop to external input? Don't make the mistake of > measuring the wrong things. Sure, you can have your monsters do fractal-generation if you want and you'll use up lots of cpu time. But analyzing the cpu-cost of wandering monsters seems like a reasonable thing to do. Maybe I shouldn't have bothered bringing up a specific example unless I was prepared to go into more detail. Anyway, I maintain that network-speed isn't the only thing that can reasonably slow down a mud. From gtcopeland at earthlink.net Tue Jul 3 09:40:16 2001 From: gtcopeland at earthlink.net (Greg Copeland) Date: 03 Jul 2001 08:40:16 -0500 Subject: Python for air traffic control? References: <134704696.994123281122.JavaMail.root@boots> <mailman.994128604.28588.python-list@python.org> <bebbba07.0107022044.106d9da8@posting.google.com> <mailman.994140484.20380.python-list@python.org> Message-ID: <m2r8vym8qn.fsf@mouse.copelandconsulting.net> William Park <opengeometry at yahoo.ca> writes: > William Park, Open Geometry Consulting, <opengeometry at yahoo.ca> > 8 CPUs cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc. > Now in my kill file!!! From cribeiro at mail.inet.com.br Mon Jul 2 08:07:12 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Mon, 02 Jul 2001 09:07:12 -0300 Subject: The standard library In-Reply-To: <9hpm6i$i5c$1@newshost.accu.uu.nl> References: <mailman.993968402.11577.python-list@python.org> <mailman.994024802.8132.python-list@python.org> <9hoe39$8ce$1@newshost.accu.uu.nl> <mailman.994055582.10768.python-list@python.org> Message-ID: <5.0.2.1.0.20010702090521.0277ae10@mail.inet.com.br> At 11:33 02/07/01 +0000, Martijn Faassen wrote: >Even though it was 3 lines and had been lingering like that for almost a >year. :) I haven't heard from Barry yet, but that was one of my questions >when submitting it to him; should I contact Eric Raymond about this? You can do either of two things: contact Eric Raymond, as the original PEP owner; or post something on the list, maybe not the full PEP, but at least the proposed abstract. This would raise the discussion, and it may help to bring more attention to this particular issue. I don't see a problem here. Carlos Ribeiro From sill at optonline.net Fri Jul 27 13:55:57 2001 From: sill at optonline.net (Andrei Kulakov) Date: Fri, 27 Jul 2001 17:55:57 GMT Subject: Case insensitivity References: <mailman.995506711.21636.python-list@python.org> <cpvgkofyru.fsf@cj20424-a.reston1.va.home.com> <93d9a839.0107200315.4a0a8c28@posting.google.com> <4n4klt8ud0es25jep3u2v9pj02dctnte0u@4ax.com> <slrn9m0lp9.l0b.quinn@yak.ugcs.caltech.edu> <3ui1mt0e07vgp1b18306jd70pdufs91uva@4ax.com> <slrn9m25oe.gfe.quinn@hork.ugcs.caltech.edu> <vs82mtogpknka9ln0e7t9s9gc79mrh9d8l@4ax.com> Message-ID: <slrn9m3ahb.114.sill@sill.silmarill.org> On Fri, 27 Jul 2001 08:19:46 GMT, Courageous <jkraska1 at san.rr.com> wrote: > >>>Because when identifier and someone else writes IdEnTIFIER, I want >>>to kill them Actually, I'd like to kill them for changing the case at all. >> >>But if the language is the same, their editor would warn them about the case >>mismatch, and the code would crash, just like yours would. It would be just >>like your editor, only yours won't warn about those things. > > Oh right. Just _my_ editor. Right. Isolated little ole me, I'm the only small > sole in the whole wide world who wants to use vim. You're just not getting > this, I can tell. > > C// > I think the misunderstanding here is that you think you'll see code like identifier = 0 Identifier = 5 do_stuff(IdenTifier) in your vim or emacs or notepad or whatever. If I understood this proposal right, you won't. One possibility, for instance, is that *their* user friendly editor will auto-change case of a variable when typed to the first used case.. i.e. you type identifier = 0; Identifier = 5 Just as you finished writing Identifier, it turns into identifier. Another possibility would be that it doesn't change it on screen, but changes it when it's written to a disk. OR it could merely display a warning, saying that this identifier was spelled differently, but it's the same thing.. In any case, you won't see any difference at all, *except* that when you're looking at their code, there won't any variables that only differ in case. -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: http://silmarill.org/cymbaline From hinsen at cnrs-orleans.fr Wed Jul 11 15:16:39 2001 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 11 Jul 2001 21:16:39 +0200 Subject: Language change and code breaks References: <wuN27.13377$Y6.4240331@news1.rdc2.pa.home.com> <cplmlvh6dx.fsf@cj20424-a.reston1.va.home.com> <6A%27.454703$eK2.93741234@news4.rdc1.on.home.com> Message-ID: <m3k81fb7jc.fsf@chinon.cnrs-orleans.fr> "Nick Perkins" <nperkins7 at home.com> writes: > but why not leave int/int->int alone, > and use // for int//int->float. > > No code breaks, and it is almost as easy for the newbies. Sounds like a good idea. Just the existence of two division operators would help newbies to recognize that there is a nontrivial problem. And a//b definitely beats (a+0.)/b, which does the trick, but is not at all evident. 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 mcfletch at home.com Wed Jul 4 00:31:56 2001 From: mcfletch at home.com (Mike C. Fletcher) Date: Wed, 4 Jul 2001 00:31:56 -0400 Subject: PyDoc: How to exclude from x import * objects? Message-ID: <001001c10442$426d5a60$a9807018@cr706570a> I'm just sitting down to do some serious documentation for PyOpenGL and OpenGLContext. Much of this will likely be in the form of in-module documentation using PyDoc to generate nicely formatted HTML documentation. However, OpenGL is one of those packages (like wxPython, Tkinter, Numeric, etceteras) where the only practical way to use the system is to do from OpenGL.GL import *, so the namespace of each module often has hundreds of extraneous values (consider that a single module might import OpenGL.GL.* OpenGL.GLU.* OpenGL.GLUT.* and wxPython.wx.*). I'm wondering if there is a simple way to specify a list of names and/or objects to be excluded from the pydoc documentation run. >From what I can see, around line 801 is the likely place to do the scanning if everything is done at a "explicit exclude" level. I.e. filter each of the key, value lists to eliminate the specified objects. This doesn't seem really spectacularly elegant, but I don't see any other really obvious places to do the elimination. Thoughts, suggestions, already-implemented-solutions welcome, Mike From gerhard.nospam at bigfoot.de Sun Jul 1 00:41:31 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Sun, 1 Jul 2001 06:41:31 +0200 Subject: Unix Scripting Host Message-ID: <slrn9jt7s3.a56.gerhard.nospam@lilith.hqd-internal> Please excuse this off-topicish post. I was looking for something similar to the Windows Scripting Host in the Unix world: a library where an application can register functions and types that can then be used by any scripting language that bothers to implement the "Unix Scripting Host" interface. The application language should not be limited to C or C++. The closest thing I could find was XPCOM from the Mozilla project. I thought that KDE2 or GNOME might offer this already, but I didn't find anything (except the relatively heavyweight CORBA approach). Any suggestions/pointers? Gerhard -- mail: gerhard <at> bigfoot <dot> 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 jkraska1 at san.rr.com Mon Jul 30 04:38:40 2001 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 30 Jul 2001 08:38:40 GMT Subject: Language Niches (long) References: <8beb91f5.0107280407.5a30341d@posting.google.com> <3B62FAFF.BB987077@Lugoj.Com> <mailman.996347633.4448.python-list@python.org> <8beb91f5.0107282158.4785ae5e@posting.google.com> <UK2E1VAMB+Y7EwX$@jessikat.fsnet.co.uk> <mailman.996429234.13926.python-list@python.org> <vko8mtotv7s6mopits06ntammk5ibe4905@4ax.com> <mailman.996437578.30803.python-list@python.org> <sln9mtgfkd0mdrjbj6vtlihitollc1f4ka@4ax.com> <eppstein-2999C5.23384429072001@news.service.uci.edu> Message-ID: <hv6amtsmkkjq93nul8jtmgioo4lbnanbfi@4ax.com> >> Why would anyone ever write anything in C or other standard compiled >> languages? > >I'm not sure you were serious here, but I'll answer anyway: >Because it runs quickly and you have very good control of memory. I was being ironic; shame on me for not being more clear. The irony is that the Python interpreter itself is written in C, as well as large numbers of its objects. The finally-honed implementation of Python's dictionary, for example, depends critically on being written in C. Tight inner loops in almost all Python applications are governed by how much time its dictionary is consuming. >E.g. a student here has been working on a program which needs to store a >small amount of information for a half-billion objects -- easy in C to >allocate a byte per object in a big array, harder if each object has >multiple bytes of overhead. Of course most other languages will let you >allocate byte arrays but then you lose their object oriented advantages. >And, the program currently runs in around 16 hours -- imagine how much more >time it might take if written in an interpreted language. 16 hours? Woozies. C// From JamesL at Lugoj.Com Tue Jul 3 13:35:37 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Tue, 03 Jul 2001 10:35:37 -0700 Subject: Eiffel better than Python ? References: <f20ea932.0107030100.6c740683@posting.google.com> Message-ID: <3B420269.B3E1AB8C@Lugoj.Com> Tomasz Stochmal wrote: > > I have read the following book which gives C/C++ heavy bashing > > http://www.elj.com/cppcv3/ If C had been recently invented, it would deserve *some* bashing. But for something invented 30 years ago, it deserves no bashing. It was an excellent portable language for machines of that era. And in the hands of a competent programmer it is still an excellent tool. As for C++, that deserves a moderate amount of bashing. But opinions are like nipples: most everyone has some. From kirschh at lionbioscience.com Fri Jul 20 02:48:37 2001 From: kirschh at lionbioscience.com (Harald Kirsch) Date: 20 Jul 2001 08:48:37 +0200 Subject: Case insensitivity References: <mailman.995506711.21636.python-list@python.org> <cpvgkofyru.fsf@cj20424-a.reston1.va.home.com> Message-ID: <yv28zhk2j0a.fsf@lionsp093.lion-ag.de> Guido van Rossum <guido at python.org> writes: > My own intuition and experience tells me that there seem to be two > kinds of people: some folks think case-sensitively, others think > case-insensitively. I guess it depends a bit on their (natural language) mother tongue. In German (at least) many words must be written with uppercase first letter, and there are sometimes non-obvious rules for it, and the teacher at school normally really trains the pupils on that. Consequently they might develop a strong feeling that case matters. ... would make a nice diploma thesis for a social psychology student to find some statistical evidence here :-) Harald Kirsch -- ----------------+------------------------------------------------------ Harald Kirsch | kirschh at lionbioscience.com | "How old is the epsilon?" LION bioscience | +49 6221 4038 172 | -- Paul Erd?s *** Please do not send me copies of your posts. *** From Darren.Watson3 at ntlworld.com Sat Jul 14 20:06:27 2001 From: Darren.Watson3 at ntlworld.com (Darren Watson) Date: Sun, 15 Jul 2001 01:06:27 +0100 Subject: Re-sizing images in Python? Message-ID: <q6547.41446$B56.8781902@news2-win.server.ntlworld.com> I would be very grateful for any advice that fellow list members can provide about Pythons ability to resize image files (jpg and gif). I would like to write a script that can process all the files in a directory and resize the images to a specified size (passed in as an argument). However, I am not sure if this is a task that Python 2.1 can perform or if it is, which library to use. If possible I would like the script to scale images in order to 'best fit' a particular area. Many Thanks -- Darren Watson From hao-nghi.au at fr.thalesgroup.com Thu Jul 19 11:01:50 2001 From: hao-nghi.au at fr.thalesgroup.com (hao-nghi.au at fr.thalesgroup.com) Date: Thu, 19 Jul 2001 17:01:50 +0200 Subject: Variable Substitution in commands or funtion names? Message-ID: <33105F8B185CD51182E300306E06473E2701B0@hermes.isr.thomson-csf.com> Hi fleet, Just learn that when you write : from cust import CurCust ==> CurCust becomes local and you have to reference to it by : print CurCust["street"] regards, Hao-Nghi Au -----Original Message----- From: fleet at teachout.org [mailto:fleet at teachout.org] Sent: Thursday, July 19, 2001 2:26 PM To: python list Subject: Variable Substitution in commands or funtion names? I think I may have gotten myself into a box. I have a module "cust.py" that contains several dictionaries - each references a different customer with address info, etc. such as: smith={"busname":"Smitties", "street":"123 West Ave"} Parsing the csv output of a spreadsheet allows me to assign "smith" to a variable - CurCust. Now I want to do something like: from cust import CurCust print cust.CurCust["street"] Spent the evening trying to solve this (Learning Python, and Sam's Teach Yourself Python) then tried the archives. The little I found on "variable substitution" almost seems to say "no way!" ??? (I know someone is going to suggest a database. That's a little further up the learning curve. I can see it from here; but I'm not there yet.) Thanks for any assistance, - fleet - -- http://mail.python.org/mailman/listinfo/python-list From philh at comuno.freeserve.co.uk Mon Jul 9 18:44:17 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Mon, 9 Jul 2001 23:44:17 +0100 Subject: Bug in rfc822 References: <slrn9khcjv.c7q.philh@comuno.freeserve.co.uk> <QFc27.8798$e5.1167735@newsb.telia.net> <2ih27.49242$he.3402812@e420r-atl1.usenetserver.com> <cp66d2i59b.fsf@cj20424-a.reston1.va.home.com> Message-ID: <slrn9kkcu1.gh1.philh@comuno.freeserve.co.uk> On Mon, 09 Jul 2001 13:50:14 GMT, Guido van Rossum <guido at python.org> wrote: >"Steve Holden" <sholden at holdenweb.com> writes: > >> "Fredrik Lundh" <fredrik at pythonware.com> wrote ... >> > phil hunt wrote: >> > > I have just found out that rfc822.py doesn't conform to >> > > RFC2822. >> > >> > sounds like it's time to rename that module ;-) >> > >> It would be even better to rewrite it. rfc822 builds so many lists of >> characters which are later returned as strings by joining the lists, a good >> C optimization would yield huge performance benefits. Pity I'm not better at >> C. > >I think Barry's mimelib may have a replacement already. > > http://mimelib.sourceforge.net/ I am currently writing a program that reads emails, modifies them in various ways (adding headers, encryption, etc) and outputs the result. As part of this program, I'm writing a mail module that (when finished) could be hacked into a replacement for rfc822. rfc822's functionality is to read mail headers and allow interrogation of their values easily. My module is conceptually on a higher level; containing a MailHeader class which can be used to write as well as read ascii representations of email, and a Mail class that includes the header and the body; again for composition as well as reading emails. (for now, it uses rfc822 to parse incoming headsers). When it is written, perhaps it could be considered for eventual inclusion in the standard library (I say eventually, because IMO it'll take me a few attempts to get the API exactly right) My module doesn't know anything about Mime; which is good because IMO there is room for a library that is higher-level than rfc822 but lower levelb than knowing about Mime. What is the process of getting a module in the standard library? -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From plakal-nospam at nospam-cs.wisc.edu Thu Jul 26 04:15:17 2001 From: plakal-nospam at nospam-cs.wisc.edu (Manoj Plakal) Date: Thu, 26 Jul 2001 08:15:17 GMT Subject: Use "quotient"? (was Re: proposed language change to int/int==float (was: PEP0238 lament)) References: <eppstein-03540D.13070222072001@news.service.uci.edu> <slrn9ls3ae.2fm.Gareth.McCaughan@g.local> <cpitghbq05.fsf@cj20424-a.reston1.va.home.com> <52Q77.181728$mG4.85523836@news1.mntp1.il.home.com> Message-ID: <pkQ77.181752$mG4.85533256@news1.mntp1.il.home.com> Manoj Plakal <plakal-nospam at nospam-cs.wisc.edu> wrote on Thursday 26 July 2001 02:55: > - currently, the symbol `/' in Python programs signifies > two different operators depending on the arguments: > - the QUOTIENT operator with 2 integer arguments > > - the DIVISION operator with at least 1 float > argument > > - the proposed change is to make '/' always signify the > DIVISION operator and '//' always signify the QUOTIENT > operator Forgot to add that in the future, when we do unify ints and longs and bring in rationals, then we again end up overloading the '/' operator to mean two things: - a constructor of rationals (with 2 integer arguments) - the DIVISION operator (with at least 1 float argument) Is this correct? Or maybe when we've unified everything into a single number type, these will actually be the same thing: you represent the number as a rational when you can and as a real number otherwise. It's still "division". I would be curious to know if other languages have a unified number type (Scheme? Smalltalk?) and how they handle the various operators and when to choose a certain representation (rational vs real). Manoj From mal at lemburg.com Wed Jul 18 10:21:37 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Wed, 18 Jul 2001 16:21:37 +0200 Subject: PEP: Defining Python Source Code Encodings Message-ID: <3B559B71.C08C6145@lemburg.com> Here's an update of the pre-PEP. After this round of comments, the PEP will be checked into CVS (provided Barry assigns a PEP number, hi Barry ;-) -- PEP: 0263 (?) Title: Defining Python Source Code Encodings Version: $Revision: 1.2 $ Author: mal at lemburg.com (Marc-Andr? Lemburg) Status: Draft Type: Standards Track Python-Version: 2.3 Created: 06-Jun-2001 Post-History: Requires: 244 Abstract This PEP proposes to introduce a syntax to declare the encoding of a Python source file. The encoding information is then used by the Python parser to interpret the file using the given encoding. Most notably this enhances the interpretation of Unicode literals in the source code and makes it possible to write Unicode literals using e.g. UTF-8 directly in an Unicode aware editor. Problem In Python 2.1, Unicode literals can only be written using the Latin-1 based encoding "unicode-escape". This makes the programming environment rather unfriendly to Python users who live and work in non-Latin-1 locales such as many of the Asian countries. Programmers can write their 8-bit strings using the favourite encoding, but are bound to the "unicode-escape" encoding for Unicode literals. Proposed Solution I propose to make the Python source code encoding both visible and changeable on a per-source file basis by using a special comment at the top of the file to declare the encoding. To make Python aware of this encoding declaration a number of concept changes are necessary with repect to the handling of Python source code data. Concepts The PEP is based on the following concepts which would have to be implemented to enable usage of such a magic comment: 1. The complete Python source file should use a single encoding. Embedding of differently encoded data is not allowed and will result in a decoding error during compilation of the Python source code. 2. Handling of escape sequences should continue to work as it does now, but with all possible source code encodings, that is standard string literals (both 8-bit and Unicode) are subject to escape sequence expansion while raw string literals only expand a very small subset of escape sequences. 3. Python's tokenizer/compiler combo will need to be updated to work as follows: 1. read the file 2. decode it into Unicode assuming a fixed per-file encoding 3. tokenize the Unicode content 4. compile it, creating Unicode objects from the given Unicode data and creating string objects from the Unicode literal data by first reencoding the Unicode data into 8-bit string data using the given file encoding 5. variable names and other identifiers will be reencoded into 8-bit strings using the file encoding to assure backward compatibility with the existing implementation ISSUE: Should we restrict identifiers to ASCII ? To make this backwards compatible, the implementation would have to assume Latin-1 as the original file encoding if not given (otherwise, binary data currently stored in 8-bit strings wouldn't make the roundtrip). Comment Syntax The magic comment will use the following syntax. It will have to appear as first or second line in the Python source file. ISSUE: Possible choices for the format: 1. Emacs style: #!/usr/bin/python # -*- coding: utf-8; -*- 2. Via a pseudo-option to the interpreter (one which is not used by the interpreter): #!/usr/bin/python --encoding=utf-8 3. Using a special comment format: #!/usr/bin/python #!encoding = 'utf-8' 4. XML-style format: #!/usr/bin/python #?python encoding = 'utf-8' Usage of a new keyword "directive" (see PEP 244) for this purpose has been proposed, but was put aside due to PEP 244 not being widely accepted (yet). Scope This PEP only affects Python source code which makes use of the proposed magic comment. Without the magic comment in the proposed position, Python will treat the source file as it does currently to maintain backwards compatibility. Copyright This document has been placed in the public domain. Local Variables: mode: indented-text indent-tabs-mode: nil End: -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From ransen_spam_me_not at nemo.it Wed Jul 25 15:29:52 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Wed, 25 Jul 2001 19:29:52 GMT Subject: control-C not responding, short example program References: <3b5d7220.664033@news.newsguy.com> <3b5e59a7.3927973@news.newsguy.com> <tltvf78i1vus91@news.supernews.com> Message-ID: <3b5f1e1e.1334462@news.newsguy.com> On Wed, 25 Jul 2001 10:12:18 -0700, "John Roth" <johnroth at ameritech.net> wrote: >Of course, that will take IDLE down with it. Thanks, but no thanks! ;) -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From ken_chiba at hotmail.com Thu Jul 12 06:26:22 2001 From: ken_chiba at hotmail.com (Ken) Date: Thu, 12 Jul 2001 10:26:22 GMT Subject: MySQLdb - possible without install? References: <3b4d0ea7.11581823@news1.on.sympatico.ca> <slrn9kqr2k.p1.gerhard.nospam@lilith.hqd-internal> Message-ID: <3b4d7a61.39160079@news1.on.sympatico.ca> I'm no expert with this at all... could I get some pointers? I'm assuming that you're saying that I need to compile MySQLdb with the MySQL and Python versions that my provider uses. This will result in the creation of a MySQLdb directory in the site-packages directory of Python. Does it produce anything else? After this is created, do I just copy that directory (MySQLdb) to a MySQLdb directory on the provider side (in this case.. within cgi-bin)? And finally, what line can I put within my scripts to pull this information in? (ie.: import ??) How can this keep track of what directory MySQL and Python are in? (or are there configuration files that I can change - AFTER the compile?) Thanks for your help, kc On Thu, 12 Jul 2001 11:55:50 +0200, gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) wrote: >On Thu, 12 Jul 2001 02:44:29 GMT, Ken <ken_chiba at hotmail.com> wrote: >>Just curious. I'm with an ISP that allows running of scripts, and has >>MySQL database access. They have a perl API installed, but nothing to >>support Python. I was wondering if it was possible to just copy over >>the MySQLdb directory from the site-packages area of Python, and just >>"import" it into the scripts? > >Yes, this works. MySQLdb needs a compiled extension module, however. You'll >need a compiled version for the platform your provider uses. > >Gerhard >-- >mail: gerhard <at> bigfoot <dot> 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 Sat Jul 7 13:56:02 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 7 Jul 2001 13:56:02 -0400 Subject: PEP scepticism In-Reply-To: <iZR5BIA3wdR7EwJx@jessikat.fsnet.co.uk> Message-ID: <LNBBLJKPBEHFEDALKOLCKEOPKMAA.tim.one@home.com> [Robin Becker] > ... > Dictators often assume they know best, but observation shows them > to be uniformly wrong. Heh. Replace "Dictators" with "Humans", and I expect the truth-value of that assertion would be unaffected. BTW, in case newcomers are wondering, Guido didn't become BDFL by assassinating his predecessor, nor does he maintain Absolute Power by force of arms. Although he's been thinking about it <wink>. From dereks at mip.com Mon Jul 30 11:00:40 2001 From: dereks at mip.com (Derek S, Smigelski) Date: Mon, 30 Jul 2001 15:00:40 GMT Subject: need help converting .py to an exe for windows Message-ID: <sEe97.180669$Bz6.213801@sjc-read.news.verio.net> I have tried both py2exe and installer. I currently have py2exe installed now. Here's the scoop. I have python 2.1 installed to c:\python21, and distutils installed to c:\python21\distutils. I have a directory for my scripts that I wish to be converted into exes located at c:\python21\dsscripts When I attempt to follow the instructions from Heller's py2exe site here's what I get: C:\Python21\DSSCRI~1>python setup.py py2exe --help File "setup.py", line 2 from distutils.core import setup ^ SyntaxError: invalid syntax C:\Python21\DSSCRI~1> The setup.py file looks like this: # setup.py from distutils.core import setup import py2exe setup(name="txlotto", scripts=["txlotto.py"], ) C:\Python21\DSSCRI~1> Any Ideas? Thanks, Derek Smigelski DerekS at mip.com From junaftnoon at moc.oohay Fri Jul 27 19:30:22 2001 From: junaftnoon at moc.oohay (June Kim) Date: Sat, 28 Jul 2001 08:30:22 +0900 Subject: Typing system vs. Java References: <871yn2zdch.fsf@complete.org> <3B61D9A3.FDFF109F@home.net> Message-ID: <GKm87.107196$ph7.18077464@news.hananet.net> First of all, Python's dynamic typing nature can be a definite godsend when combined with proper disciplines -- such as UnitTesting, TestFirstProgramming and RefactorMercilessly from XP. XP is one of the new agile methdologies, which is quite a hot issue over the IT world. Dave Thomas, who wrote the wonderful book "The Pragmatic Programmer", wrote about the benefits of dynamic typing: http://www.c2.com/cgi/wiki?DavidThomasOnTheBenefitsOfDynamicTyping. And there are some other stuffs including hot discussions worth while to read on the same site: http://www.c2.com/cgi/wiki?DynamicTypesEaseRefactoring, http://www.c2.com/cgi/wiki?BenefitsOfDynamicTyping My link is broken, but I believe you can find the forum lead by Rob C. Martin (aka Uncle Bob) at http://forums.itworld.com/, which discussed about cons and pros of dynamic typing (mainly on pros) and how to take advantage from it. It might look like a deficiency that Python doesn't have static typing at first, as it looked so to me, but you'll see it's rather liberating than constraning, moreover, with strong confidence on the code. Best wishes, June Kim ps. Python doesn't have compile-time type checking but you can substitute it with unit tests if you want. From robin at jessikat.fsnet.co.uk Mon Jul 23 10:52:46 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Mon, 23 Jul 2001 15:52:46 +0100 Subject: A use for integer quotients References: <mailman.995866298.23496.python-list@python.org> <cpzo9veuml.fsf@cj20424-a.reston1.va.home.com> <230720010741551768%jwbaxter@spamcop.com> Message-ID: <6XVfCJA+oDX7EwaP@jessikat.demon.co.uk> In article <230720010741551768%jwbaxter at spamcop.com>, John W. Baxter <jwbaxter at spamcop.com> writes >In article <cpzo9veuml.fsf at cj20424-a.reston1.va.home.com>, Guido van >Rossum <guido at python.org> wrote: > >> Of course, I'm well aware of the issues around maintaining old code. >> We will have to carry around "from __future__ import division" for a >> loooooong time. Python 2.2 is the first opportunity to introduce it, >> so let's not be shy. > >This is encouraging and discouraging: > >Encouraging in that it suggests strongly that 2.3 isn't the target; >discouraging in that it gives running code even longer to sit in the >basement with people who know it moving on before it breaks. > >It's also discouraging because it means the change does seem to be on >the way, with argument useless. > > --John the arguments presented by the leadership are 1) dumb down the language 2) it's ok because we have a discussion mechanism 3) the decision has already been made 4) we'll do extra work to make you do extra work not good -- Robin Becker From BrianQ at ActiveState.com Tue Jul 17 17:41:14 2001 From: BrianQ at ActiveState.com (Brian Quinlan) Date: Tue, 17 Jul 2001 14:41:14 -0700 Subject: Python 2 times slower than Perl In-Reply-To: <6957F6A694B49A4096F7CFD0D900042F27D552@admin56.narex.com> Message-ID: <003101c10f09$3426e0d0$b503a8c0@activestate.ca> > > > if you put the code in a function, it will be a fair bit faster > > > since global variable access is slower than local variable access. > Actually, it increases performance by ~15%. That is too be expected. Fast load and save opcodes are not generated for globals. From jim at publishingresources.com Tue Jul 31 11:05:25 2001 From: jim at publishingresources.com (Jim Abrams) Date: Tue, 31 Jul 2001 15:05:25 -0000 Subject: PythonPath for ASP References: <996471911.551564@emperor.labs.agilent.com> <uMn97.12165$ar1.37961@www.newsranger.com> Message-ID: <Xns90EF706268DFFjimpublishingresourc@207.126.101.100> Levente Sandor <nospam at newsranger.com> wrote in <uMn97.12165$ar1.37961 at www.newsranger.com>: >In article <996471911.551564 at emperor.labs.agilent.com>, Brian Zhou >says... > >> Is there a place I can set that makes C:\Python21\PIL in PythonPath? > >Create a file with the extension ".pth" in your Python installation >directory, then add the line PIL >to it. You can add more (both relative and absolute) paths to the Python >path in this way, each one in a new line. (You must restart the Python >interpreter after doing this.) >Or: you can do it (temporarily) anywhere in your script: >import sys >sys.path.append("c:\\python21\\pil") >import Image Remember that the sys module is cached, so repeat calls to this would pollute the path. Maybe: if "c:\\python21\\pil" not in sys.path: sys.path.append("c:\\python21\\pil") >Another way goes trough the Windows Registry but I never tried that. HKLM/Software/Python/PythonCore/2.1/PythonPath With 2.1 being whatever version you have. Also site-packages isn't in your path. You might want to add it. It doesn't seem to get in there on windows. From igor at arzamas.nnov.ru Sat Jul 28 06:05:21 2001 From: igor at arzamas.nnov.ru (Igor) Date: 28 Jul 2001 03:05:21 -0700 Subject: Colon and underscores Message-ID: <39506f84.0107280205.1638011@posting.google.com> It would be really nice to know the reasons behind some syntax features. What is the real purpose of the colon ":" after each if, def, etc... Is it really required and cannot be made optional? Why__ do __Python__ programs __need to __look__ like __swarms__ of __underscores ? Is it OK that one must dig in underscores instead of having a normal English word for private symbols, for example? Regards. From bokr at accessone.com Sat Jul 28 21:43:13 2001 From: bokr at accessone.com (Bengt Richter) Date: Sun, 29 Jul 2001 01:43:13 GMT Subject: PEP 238 (revised) References: <mailman.996352253.17238.python-list@python.org> Message-ID: <3b636863.684184555@wa.news.verio.net> On Sat, 28 Jul 2001 16:29:18 -0400, "Tim Peters" <tim.one at home.com> wrote: >[Tim] >> > Multiplying by 1.0 preserves the sign of a 754 zero, but adding 0.0 >> > (of either sign) may not; > My intel pentium book is plainly wrong, ignore previous doubt about *1.0 ;-) >>> math.atan2( 0.0,-0.0*1.0) 3.1415926535897931 >>> math.atan2( 0.0, 0.0*1.0) 0.0 >[Marcin 'Qrczak' Kowalczyk] >> Why adding a negative zero may not? If 0.0+(-0.0) is specified to be >> 0.0, then I don't see where it breaks. > >The result of 0+(-0) is -0 in the to-minus-inf rounding mode. The result of >multiplying by 1.0 is independent of rounding mode. > >obviously-correct-is-better-than-subtly-broken-ly y'rs - tim > > From wqh-2 at 263.net Tue Jul 31 08:44:36 2001 From: wqh-2 at 263.net (sdf) Date: Tue, 31 Jul 2001 20:44:36 +0800 (CST) Subject: simple question:the count of array Message-ID: <3B66A834.15767@mta3> >>> a=['a','b','c'] >>> b=a.count() Traceback (most recent call last): File "<pyshell#9>", line 1, in ? b=a.count() TypeError: count() takes exactly 1 argument (0 given) >>> then how I get the number of a,I mean how much values in a,in this case it should be 3 __________________________________________ DVD??????????10?? http://shopping.263.net/category02.htm ?????????????????????? http://shopping.263.net/category10.htm From steve at lurking.demon.co.uk Mon Jul 23 02:39:16 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Mon, 23 Jul 2001 07:39:16 +0100 Subject: PEP0238 lament References: <3B5B3676.40F39389@alcyone.com> <mailman.995826216.11537.python-list@python.org> <eppstein-03540D.13070222072001@news.service.uci.edu> <mailman.995836120.7223.python-list@python.org> <220720011959361323%jwbaxter@spamcop.com> <995861189.362184@yabetcha.drizzle.com> Message-ID: <f7gnltouvi56luruj79k06iaol0nc10q4k@4ax.com> On Mon, 23 Jul 2001 04:06:30 -0000, Donn Cave <donn at drizzle.com> wrote: >Quoth "John W. Baxter" <jwbaxter at spamcop.com>: >... >| By the way, in .../lib/module-math.html (I keep my own copy on my end >| of my 56K frame connection), it is not stated whether the input to >| sin() (and the others where it applies) is degrees or radians. An >| experiment is necessary, or a reference to my rapidly waning C >| knowledge or a visit to the C standard (which I'd rather not do, for >| reasons of marginal sanity). >| >| >>> math.sin(1) >| 0.8414709848078965 >| >| is a conclusive experiment...which I had to run before making the "also >| unlikely" claim. > >Right! and I don't think it's what the common folk expect either. >Someone should write up a PEP to change these functions to take >degrees (not on my account, but it would seem to be a potential >stumbling block for the uninitiated, wouldn't it?) Of course - and the chaos that would cause for people working with engineering or mathematical notations where radians are natural irrespective of the language or even the use of a computer should of course be completely ignore ;-) From nperkins7 at home.com Wed Jul 11 18:30:14 2001 From: nperkins7 at home.com (Nick Perkins) Date: Wed, 11 Jul 2001 22:30:14 GMT Subject: ActivePython word wrap in Shell or PythonWin during list printout References: <3b4cc843$0$172@wodc7nh6.news.uu.net> Message-ID: <Wr437.455475$eK2.94084815@news4.rdc1.on.home.com> module pprint does a nice job. I use it like this: from pprint import pprint as pp >>> pp(dir()) ...etc "Rufus V. Smith" <nospam at nospam> wrote in message news:3b4cc843$0$172 at wodc7nh6.news.uu.net... > I am running the latest Python from ActiveState and I have a > problem that when I print a long list (Like dir()), the entire list > prints out on one line and I have to scroll over to read it. > > Is there an environment setting to force word wrap at > a certain line length? > > Or is there a list function that can take a list and > pretty print it with word wrap. > > (Not having one gave me an opportunity to learn > some Python scripting as I wrote my own, but > if there was a library standard, that might be better. ) > > > def marginprint(L,margin=80): > b="" > for a in L: > if len(str(a)+b)+3 >= margin : > print b > b = "'"+str(a)+"'" > else: > if b: b+="," > b += "'"+str(a)+"'" > if b: print b > b="" > > > With this function, I just type marginprint(dir()) > and it will respect the margins. > > Only I have to load this into my environment every time > I bring it up. > > > > > > > From db3l at fitlinxx.com Mon Jul 2 17:21:39 2001 From: db3l at fitlinxx.com (David Bolen) Date: 02 Jul 2001 17:21:39 -0400 Subject: Python and DB support (was: Re: Is Python Dead?) References: <mailman.994100826.19440.python-list@python.org> Message-ID: <ug0cfdo2k.fsf@ctwd0143.fitlinxx.com> Roman Suzi <rnd at onego.ru> writes: > However, my collegues were not satisfied with it. One somplain was that in > ASP/IIS it is "very easy" to receive a "recordset" from database and then > apply it in different situations in the ASP-page, because recordset is an > object and even subqueries could be made without quering DB again. Just curious, but did your colleagues try using Python's COM interface to ADO to retrieve an actual recordset object that they could manipulate the same in Python as in other ASP languages? At least under Windows, it would seem that having solid ODBC and COM support should pretty much cover in Python anything you'd do elsewhere. On other environments, direct support for a particular database is likely to be more desirable, as it's more typical in those environments, but as you've noted, there's a plethora of support modules for various databases - some at various levels. -- -- 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 qrczak at knm.org.pl Tue Jul 31 06:34:47 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 31 Jul 2001 10:34:47 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <mailman.995989601.30748.python-list@python.org> <cp3d7lbo89.fsf@cj20424-a.reston1.va.home.com> <ubsm8epr5.fsf@ctwd0143.fitlinxx.com> <cp7kww92ph.fsf@cj20424-a.reston1.va.home.com> <m266cg73ig.fsf@mycroft.actrix.gen.nz> <3b60d65e.219212588@news.eircom.net> <cpy9pa4hnh.fsf@cj20424-a.reston1.va.home.com> <m2snfh3h05.fsf@mycroft.actrix.gen.nz> <slrn.pl.9m4r1a.eqf.qrczak@qrnik.zagroda> <3b64d4ce.777475039@wa.news.verio.net> <slrn.pl.9m9ug6.gim.qrczak@qrnik.zagroda> <3b659613.826951783@wa.news.verio.net> Message-ID: <slrn.pl.9md2e6.dma.qrczak@qrnik.zagroda> Mon, 30 Jul 2001 18:58:48 GMT, Bengt Richter <bokr at accessone.com> pisze: > Then you are not interested in whether a bit pattern transformation > that implements a mathematical operation results in a bit pattern > that exactly represents the infinite precision mathematical result? I'm not. Because I don't use float at all when I need exact results, and I don't care if it happened to be exact in case I don't need exactness (and used float). > The designers of the fp hardware apparently thought it was useful. > They supply a hardware status bit for that purpose, and automatically > re-tag to inexact when an operation causes that. Blame language designers > and compiler writers, not floating point hardware. I didn't know that. And I never heard of using it. Perhaps it's not that useful :-) I don't blame language designers; IMHO it's not worth the complication. > Right, and the hardware knows when that happens. What do you mean by > artificial conditions? E.g., the double format can handle anything > the int (32 bit) format can handle exactly, and more. Would those > be artificial? If numbers are integers, I use int, not float. It's very rare when I must use float in order to represent data *and* they can be exact. >>In effect sometimes by accident you might get an exact result, but >>it's not guaranteed that the same computation of different data will >>give an exact result. It's better to statically known that results >>of a computation are not exact in general. > I'm not sure what you mean by "the same computation of different data." There is a function which does some computation. We give it data tagged as exact and the result happens to be tagged as exact. It only tells us that this particular result is exact; results on different exact data will not necessarily be exact. But exactness is usually a static property. Either we need it, because for example correctness of the computation depends on comparisons of true mathematical results, or because we want the result to be independent of the language implementation - or we don't need exactness and don't care. *We* set up the program in order to preserve exactness or to run fast and in predictable space (and we can't have both). If we need exactness, it's too late when the compiler said us that we didn't get it. If we don't need exactness, we can't easily tell how much inexact the result really is, so why to make a special significance to the rare case when it happened to be exact? -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From Marc.Poinot at onera.fr Wed Jul 11 04:35:32 2001 From: Marc.Poinot at onera.fr (Marc Poinot) Date: Wed, 11 Jul 2001 10:35:32 +0200 Subject: European Python Meeting report Message-ID: <3B4C0FD4.CC283F07@onera.fr> Hi you all galactictely spread out lovers of Python, here's a little report of Libre Software Meeting Python Track. --- The meeting starts Wed, 4th of July with a plenary session*. Each topic has presented its agenda, including the goals they would like to reach within the week. The Python track goals were: - Meet together - Learn Python things - Try to gather European Python users in some annual event. LSM stops Staturday evening, with a plenary session. The Python track conclusion was: - Presentations were always interesting and lively (We often explode the schedule, but discussions were fruitful for us) - We enjoy meet together and share our ideas (actually, Python is way of thinking, I think there is kind of osmosis between the langage and the user). - We were not a lot of Python users (about 20), and it looks like we have a lot of work to make it an European event. But the Python users there though it was worth trying again. --- About 500 people were expected, while the actual total people at LSM, during all the week, has been evaluated as 400+ As a matter of fact, we had German, Dutch, Italian, UK, Portugal... and French people. The Python track had an audience of 10/25 persons, depending on the presentations, and including the speakers themselves in most cases. There also was some "private" discussions in classrooms, about many questions or topics related to Python. This is a specific point in LSM, there are a lot of open classrooms, and people spontaneously gather in little work groups. There was a Python-LSM-attendees-group of about 10 people, not including some of the speakers, and this look likes starting a European group. Actually, there is a need for such an event. Many users do not money and/or time enough to flight to the USA or to register to a open-but-not-free-of-charge-conference. Now it seems we do not make enough announces around the event, or the annouces were to late. We also had the first European Python Meeting supper in Bordeaux downtown (with foie gras and wine), nine of us where there. We thank here the LSM organisation, which was a little surprised by the success of this 2nd LSM, but always succeed in solving our tiny problems. I also want to thank all speakers for the quality of their work, for their patience, and for the spirit they gave to this Python track. All presentations (PDF, html... and source code) will appear on the LSM web site by the end of July. You can also find there a lot of pictures, or links to other web sites including pictures, flow the "LIVE" link of first web page. http://lsm.abul.org --- The Python European speakers we had were: - Marc-Andre Lemburg - Marc-Andre explains us some secrets of Unicode, and the implementation he has done into Python. Now, thanks to Marc-Andre, we know about the UTF-32 in strings. - Martin von Loewis - A very complete presentation about the XML libraries for Python. It was a struggle between Martin and XML, but Martin won ! - Konrad Hinsen - He explains us Numerical Python, how to make Python arrays. This was a robust and portable presentation, with slides and blackboard. - Moshe Zadka - He made a lively presentation about Python Mailing System. (we adopt here Moshe as European user ;) - Dinu Gherman and John Precedo - They presented the ReportLab libs and tools. A nice presentation with tax forms examples :( and color demos. - Benoit Lacherez - He has driven the French translation group. We had a very interesting afternoon work with Martin von Loewis about doc translation, either on the contents point of view, but also about the structure of the docs. We will share our ideas and have a proposal soon in the DOC SIG. - Stefane Fermigier - He presents internet with Python, and then explains some basics about the Zope way of life. The audience was so interested that they continue with a half a day Zope training in a classroom. - Marc Poinot - I had a two-half-days first-level tutorial in French** We had a really nice feedback, and this definitely shows the need of slow, easy and introductive Python lessons, even in very technical conferences. And at last, but not at least, I'd like to thank Tim Couper for his lively and continuous support during all these days. I'm pretty sure we will have a chance to finally have a drink at "the Frog and the Rosbeaf" pub in Bordeaux. --- Now, we are thinking about the 2nd European Python Meeting. I don't know yet if this is worth creating a private mailing list. Let me know... I'm starting to think and organize this meeting... now! Comments are welcome, as well as help! --- Marcvs [alias Don't ask me about an UTF-128 encoded XML tree of this report] * Yes, it was the 4th of July, but there was no champagne around. So we decided to have an UTF-8 oyster-pizza party, with PDF cherry champagne, but it looks like we had no success at all :( ** The choice of making it in French has lead to many discussions, before and after the tutorial. From nperkins7 at home.com Fri Jul 20 03:33:44 2001 From: nperkins7 at home.com (Nick Perkins) Date: Fri, 20 Jul 2001 07:33:44 GMT Subject: Conway's Life References: <3B57AF54.F909FD36@.com> Message-ID: <s9R57.510752$eK2.107335359@news4.rdc1.on.home.com> "Doug Newhouse" <n at .com> wrote in message news:3B57AF54.F909FD36 at .com... .. > I should be able to figure out the algorithms and stuff, it's just that > I have no idea how to do graphics.... .. Yes, Tk would be a good place to start. The python interface is called tkinter, and there is good tutorial.. Tkinter is easy to program, compared to other toolkits. http://www.pythonware.com/library/tkinter/introduction/ WxPython is a little faster, more windows-looking, has more sophisticated building blocks, but is a bit harder to program in python, for a beginner. http://www.wxpython.org/ Of course, you could do the whole thing in Jython and use the native AWT or Swing GUI stuff, which is actually a lot easier than it sounds. http://www.jython.org/ All that being said, I can't resist adding my two cents worth about the data structures to use for the algorithm, a subject which seems to be sparking the imagination of several previous respondents. I have done a similar type of program, (but more of maze-thing), which i switched from using numeric arrays to using a sort of linked graph structure, where each cell keeps a list of references to it's immediate neighbors. Then you can write the whole algorithm without messing around with (x,y) coordinates. It was a bit faster that way, but of course, results will vary. Try doing it a couple of different ways. Have fun, good luck. From roy at panix.com Sun Jul 8 19:46:43 2001 From: roy at panix.com (Roy Smith) Date: Sun, 08 Jul 2001 19:46:43 -0400 Subject: Confusion about dictionaries - keys use value or identity? References: <mailman.994626615.9894.python-list@python.org> Message-ID: <roy-2F9DAF.19464308072001@news1.panix.com> "Tim Peters" <tim.one at home.com> wrote: > BTW, if you want, say, "aa" not to be the same key as "a"+"a", in what sense > is this dict indexed by strings? That is, it's unclear what strings have to > do with this. Well, OK, that's a fair question. Here's what I really want to do... I'm writing a parser for a kind of text file we use a lot. The main loop of the parser is a state machine. In each state, the current input line is tested to see if it matches one or more regular expressions, and based on which (if any) it matches, you do some processing and advance to the next state. Something like: state = "cvsid" for line in inputfile.readlines(): if state == "cvsid": if re.match ("^\s*$\s*Id:([^$]*)$\s*$", line): state = "header" elif state == "header": if re.match ("big ugly pattern", line): do some stuff state = "what comes after the header" and so on. I'll end up with about a dozen different states, with perhaps 2 dozen different regex's. Here's the dilema. If I write it as I did above, the regex's will get compiled each time they're evaluated, which is clearly inefficient in the extreme. The alternative would be to re.compile() all the regex's once, at the top, then use the stored programs, something like this: cvsPattern = re.compile ("^\s*$\s*Id:([^$]*)$\s*$") [...] if cvsPattern.match (line): state = header and so on. This would certainly work, but it moves the regex's away from where they are used, making (IMHO) the program more difficult to read and understand. It reminds me of the bad old days when we would collect all our FORTRAN format statements at the back of the deck. See http://www.python.org/doc/Humor.html#habits for why I don't want to do that any more :-) So, here's my plan. I was thinking that I might write a thin wrapper around the re class which kept a cache of regexes it had compiled. myRe.match would take the passed-in regex, look it up in the cache, and if it found it, just use the cached compiled version. I figure it would be very close to the speed of storing the pre-compiled versions in the mainline code, as shown above, but still have the convenience and comprehensibility of keeping the regex string at the place where it's used. So, that's what got me going on this. Thinking about it again (and reading what people have written here), I'm starting to realize the default key algorithm is probably fast enough for what I'm trying to do, but it's still an interesting thing to think about. From gradha at iname.com Sat Jul 21 09:54:23 2001 From: gradha at iname.com (gradha at iname.com) Date: Sat, 21 Jul 2001 15:54:23 +0200 Subject: What's the best way to delete duplicated entries in a list? Message-ID: <fi1cj9.8qm.ln@127.0.0.1> Hi. Given a list of strings, I am doing the following to delete duplicated entries: my_list.sort() x = 0 while x < len (my_list) - 1: if my_list[x] == my_list[x+1]: del my_list[x+1] else: x = x + 1 Is there some more elegant, fast, algorithm? Is this the only one obvious way to do it? -- Grzegorz Adam Hankiewicz gradha at terra.es http://gradha.infierno.org From philh at comuno.freeserve.co.uk Sat Jul 14 12:21:28 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Sat, 14 Jul 2001 17:21:28 +0100 Subject: Language change and code breaks References: <mailman.994958301.16016.python-list@python.org> <3B4E586D.35460F68@engcorp.com> <cpelrk39t9.fsf@cj20424-a.reston1.va.home.com> <3B4FAC17.48377423@engcorp.com> <cp7kxb351p.fsf@cj20424-a.reston1.va.home.com> Message-ID: <slrn9l0sc8.2nh.philh@comuno.freeserve.co.uk> On Sat, 14 Jul 2001 15:22:14 GMT, Guido van Rossum <guido at python.org> wrote: >Peter Hansen <peter at engcorp.com> writes (after much good stuff about >transitioning): > >> After the transition period, screw the professional programmers >> who won't take the time to modify their existing code and yet >> who selfishly insist that their wonderful program *must* be >> allowed to continue running under the new Python without >> problem. > >Well, I don't know about you, but *I* am reluctant to say "screw you" >to all those people who depend on Python script written by >professional programmers who no longer work there. > >I also don't want to fork the code base. Does that imply that you sare no longer interested in making radical changes to Python, such as case-insensitive identifiers mentioned in CP4E? >There are *still* folks >using Perl4 scripts who can't upgrade. Sure they can, they can upgrade to python :-) -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From neil at qualica.com Wed Jul 18 03:55:45 2001 From: neil at qualica.com (neil bromehead) Date: 18 Jul 2001 00:55:45 -0700 Subject: python vs kung fu References: <50220745.0107170521.24f1c18b@posting.google.com> <3B544778.CFC9293B@engcorp.com> Message-ID: <50220745.0107172355.4ca25c32@posting.google.com> Peter Hansen <peter at engcorp.com> wrote in message news:<3B544778.CFC9293B at engcorp.com>... > neil bromehead wrote: > > > > It seems that, just like in chinese kung fu circles, lots of people > > are trying to justify their style (python in this case) to themselves, > > myself included. why ?, all styles can be equally effective , it > > depends on how you use them ! > > Without debating whether all styles are equally effective (see > Ultimate Fighting for example :-), I think there's another point > you aren't considering. (And clearly Shorinji-ryu Karate is > superior to chinese kung fu! ;-) > > > so rather than get into endless arguments with java guys or perl guys > > about the virtues of python , lets just try to beat them at their own > > game ! > > Many of us are idealists who feel saddened that so many are > effectively wasting their time with languages which are holding > them back. We feel the urge (obviously an irresistable one :) to > try to convince those miscreants^H^H^H^H^H poor misguided souls > that they could better spend their time with Python. That they > would be more productive, enjoy their work more, produce higher > quality results, and spend more time programming and less time > debugging. That pragmatism and simplicity are far more > important than optimization and the ability to write entire > applications in one line. > > We are not so much arguing as trying to show them that we > _understand_ their points, and in fact used to think the same > way, but that we have found a better way and want to see them > try it out for themselves. Definitely sounds like religion: > probably indistinguishable, but that doesn't mean we should > all stop and silently use Python for our own applications and > never breathe a word of it to another soul... thats not really what I meant , Noise is good , and we have to make as much as possible , but maybe not by arguing with them , rather make them jealous about a python developers innate sense of superiorority, ooh and industrial sabotage is always good ! i started using python, without the consent of my employers, to tie up loose ends in projects i was working on , got the jobs done before deadlines , and they work , who can argue with that . now i dont have to justify python to anyone in my office and no-ones minds if i use it. in fact perl and java guys in my office come to me and say how would you handle this in python and often end up using my code. and some guys are coding a bit of their own now i get the feeling that if we argue with these guys we are just showing them even python developers are still trying to justify why on earth they chose their style in the first place , so we lose our spirit ! or alternatively how would you feel if Crane guys were saying Shorinji-ryu Karate is bad and that you should be doing Crane for these reasons ? if it was me , i would get angry and stop listening , its like the art of war , their are much more subtle ways of getting people to take python seriously, and in the end theyre probably much noisier ! but i do wish there were more job announcements with Python Developer Wanted written at the top - see further down the string . From ngps at madcap.dyndns.org Thu Jul 26 11:39:26 2001 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 26 Jul 2001 15:39:26 GMT Subject: [ANNOUNCE] M2Crypto 0.06 Message-ID: <9jpdje$gbj$1@clematis.singnet.com.sg> Hi, I'm pleased to announce that M2Crypto 0.06 has been released. - M2Crypto now works with (and requires) SWIG 1.3.6. - ZServerSSL has been updated to work with Zope 2.4.0. - Beginnings of unit tests for M2Crypto.SSL. (Uses fork/exec, so presently Unix only.) Going forward, I'm aiming for the following: - SSL HOWTO - Better documentation - XML-dsig implementation - SRP implementation - More unit tests of everything Get M2Crypto here: http://www.post1.com/home/ngps/m2/ As usual, feedback is appreciated. -- Ng Pheng Siong <ngps at post1.com> * http://www.post1.com/home/ngps Quidquid latine dictum sit, altum viditur. -- Ng Pheng Siong <ngps at post1.com> * http://www.post1.com/home/ngps Quidquid latine dictum sit, altum viditur. From gerhard.nospam at bigfoot.de Sat Jul 28 08:08:13 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Sat, 28 Jul 2001 14:08:13 +0200 Subject: Newbie Q - Py for Linux on Disk?? References: <554a464b.0107280303.1c0be0f6@posting.google.com> Message-ID: <dv9uj9.674.ln@gargamel.hqd-internal> On 28 Jul 2001 04:03:37 -0700, Dick Van Kirk <dickvan at quicktel.com> wrote: >Please tell me where I can purchase Python for Linux on disk that I can >quickly and easily install ?? ??? Python is Open Source Software. You download it from http://www.python.org for free. If you want an easily installed Python, you can just buy a copy of any major Linux distribution if you don't have one already. Any one that I know of has Python included. Gerhard -- mail: gerhard <at> bigfoot <dot> 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, [chr(ord(x)^42) for x in list('zS^BED\nX_FOY\x0b')]) From anthony at interlink.com.au Wed Jul 18 03:59:30 2001 From: anthony at interlink.com.au (Anthony Baxter) Date: Wed, 18 Jul 2001 17:59:30 +1000 Subject: PyDNS? In-Reply-To: Message from Erik de Castro Lopo <nospam@mega-nerd.net> of "Fri, 13 Jul 2001 21:04:49 GMT." <3B4F626E.5DDEAD49@mega-nerd.net> Message-ID: <200107180759.f6I7xUC17035@mbuna.arbhome.com.au> >>> Erik de Castro Lopo wrote > This version has exactly the same filename as Anthony Baxter's original. > Maybe its time to add version info to the name of the tarball :-). bah! :) What, datestamps on the files in the tarball aren't good enough? sheesh. Anthony From mwh at python.net Wed Jul 4 07:04:56 2001 From: mwh at python.net (Michael Hudson) Date: 04 Jul 2001 12:04:56 +0100 Subject: Pushing the standard library References: <4E42BD2538CACF79.9FD7275B6CD3244E.A70BBB4C060B585B@lp.airn ews.net> <5.0.2.1.0.20010703215513.02c01d90@mail.inet.com.br> <mailman.994215787.1351.python-list@python.org> Message-ID: <m3bsn1ymxz.fsf@atrus.jesus.cam.ac.uk> Gustavo Niemeyer <niemeyer at conectiva.com> writes: > Hello Carlos! > > [...] > > As it's impossible to clone an army of timbots to solve this problem, we > > must try to find another solution. I don't believe that we can sort this > > issue without some involvement of PythonLabs and the core Python-dev guys. > > The problem is not lack of good modules, but lack of *standard* modules. To > > make a module standard, some level of Python-dev commitment is a *must*. > [...] > > Agreed. Indeed, I think that the first step to start this out is to > discover which libraries currently have a poor implementation, or which > ones should start do be developed ASAP. shutil is pretty crappy, both in terms of interface and implementation (it loses on the Mac, for instance). distutils.file_utils is much better, and should probably be moved into the core. just-my-vote-ly y'rs m. -- Hey, if I thought I was wrong, I'd change my mind. :) -- Grant Edwards, comp.lang.python From skip at pobox.com Mon Jul 23 14:48:50 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 23 Jul 2001 13:48:50 -0500 Subject: Alternate numeric proposal In-Reply-To: <011901c11335$1a8c95e0$0101010a@local> References: <011901c11335$1a8c95e0$0101010a@local> Message-ID: <15196.29074.910090.697520@beluga.mojam.com> Chris> Why don't we add a hook to Python to control the numeric Chris> evaluation rules directly? Paul DuBois wrote a PEP on numeric kinds that seems to point in this direction. Take a look at http://python.sourceforge.net/peps/pep-0242.html He doesn't directly address the int division thing, but does discuss having some runtime control over some numeric properties. Perhaps this could be extended to allow programmers to dictate the default result of int division on a per-module basis. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From thomas at xs4all.net Sat Jul 7 18:39:35 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Sun, 8 Jul 2001 00:39:35 +0200 Subject: Comment on PEP-0238 In-Reply-To: <LNBBLJKPBEHFEDALKOLCAEPLKMAA.tim.one@home.com> Message-ID: <20010708003935.M8098@xs4all.nl> On Sat, Jul 07, 2001 at 06:13:33PM -0400, Tim Peters wrote: > I'm sorry, Alex, but `` is here to stay. Guido is insanely fond of it! > Meaning no more than that he doesn't hate it <0.9 wink>. I see something > like > print ``1`+`2`` > and to this day I still have no idea how Python manages to parse it > correctly. Holy crap! I can't believe Python parses that correctly -- for some form of correctly, anyway, because I wouldn't know what it does without trying, and that still doesn't say much about what the writer wanted :-) Still, great parsers notwithstanding, I'd like to second Alex's idea of deprecating `` -- with appropriate warnings, of course. -- Thomas Wouters <thomas at xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From quacko at lists.postmastergeneral.com Mon Jul 16 13:42:01 2001 From: quacko at lists.postmastergeneral.com (Quacko Lotto) Date: Mon, 16 Jul 2001 13:42:01 EDT Subject: Best Odds Of Winning On The Net! Message-ID: <200107161751.LAA44489@s0219.pm0.net> QUACKO LOTTO! http://lotto.quacko.com - Play Everyday - Win up to $1,000,000.00 - Best Odds of Winning on the Net! Guess Odds You Win 3 out of 6 1:57 3 Free Tickets 4 out of 6 1:1,032 6 Free Tickets 5 out of 6 1:54,200 $100.00 in Cash 6 out of 6 1:13,983,816 $1,000,000.00 in Cash Also, All players are automatically enetered into our weekly draw for a DVD Player or $2000.00 in Cash! http://lotto.quacko.com ************************************************ Here's a fantastic opportunity! FREE MONEY! http://www.supremecasino.com ************************************************ Play SupremeCasino's hottest casino games with Free Money. Get a 100% Bonus up to $75 FREE!! You're closer than ever to winning. Valid for All Valued Customers, with every Visa, MasterCard, PayPal or NETeller deposit, we will give you up to $75 FREE! Incredible! Register now and get in the game!! http://www.supremecasino.com *********************************************************** RED CARPET REWARDS AT GRAND BANKS CASINO http://www.grandbankscasino.com/default.asp?from=1072 *********************************************************** Red Carpet Rewards! The best way to earn free credits! Grand Banks casino is rolling out the Red Carpet for our patrons! For every $10 in real bets that you place, Grand Banks will credit your account with one comp point. Collect 100 comp points and you will receive one casino credit! It's so simple and calculated automatically for you. Example: Place a $100 wager on one hand of Blackjack and receive 10 Red Carpet Reward points. Do this 10 times & regardless of the outcome you will have amassed 100 Red Carpet Points. These 100 points now automatically convert to a FREE Grand Banks Casino credit! http://www.grandbankscasino.com/default.asp?from=1072 The Red Carpet Rewards Premier Program: For our more serious players we offer an even more aggressive plan to help you amass points more quickly! The structure is the same, but you will receive 1 Red Carpet point for every $7.50 placed in bets! Please note that Grand Banks reserves the right to invite patrons into the Premier program only. http://www.grandbankscasino.com/default.asp?from=1072 <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> * 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 zessin at decus.de Sat Jul 28 06:09:06 2001 From: zessin at decus.de (zessin at decus.de) Date: Sat, 28 Jul 2001 12:09:06 +0200 Subject: Python for OpenVMS version 2.1.1-V001 now available Message-ID: <009FFAE6.9046CFEB.25@decus.de> Please see http://www.decus.de/~zessin/python2/ for details. Don't forget to check the 'notes' link at '~zessin/python2/notes.html' for last-minute changes. -- Uwe Zessin From JamesL at Lugoj.Com Fri Jul 20 13:01:34 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Fri, 20 Jul 2001 10:01:34 -0700 Subject: Language change and code breaks References: <XFMail.20010720091207.mikael@isy.liu.se> <cpn15zfywd.fsf@cj20424-a.reston1.va.home.com> Message-ID: <3B5863EE.F9047098@Lugoj.Com> Guido van Rossum wrote: > If you use this > a lot (message = Message() etc.) your code is less readable than it > should be. Um, you've got that precisely reversed! If I see "message" anywhere in my code, I know immediately that it is an instance of the class Message. Think of it as an advanced form of Hungarian notation that tells you what type of thing the variable is holding. (Although I'm no fan of Hungarian per se.) I've gone through several identifier naming conventions over the last couple of decades and I've settled on the one you think is "less" readable. Fortunately, most of the programmers I've worked with not only don't have a problem with it, most use it. A few, like you, think there is something wrong with it, but none has ever had a problem with reading code that contains that kind of thing. Some of those latter even do it when they are "in a hurry" and then apologise for doing it! Like you, I always "thought" that convention was bad. But having had to use it a lot, I've grown to enjoy it and unless you can show me more than your opinion, you can expect a nasty disagreement. > It also makes it harder to discuss code in person or over > the phone -- spoken language is not case-preserving, as anyone who has > tried to give someone a URL over the phone knows. :-) How about discussing indented code blocks? Spoken language is not white-space preserving. It is not new-line preserving. It isn't a lot of things. So what precisely does discussing code on the phone have to do with this issue!? From jkraska1 at san.rr.com Tue Jul 24 01:37:57 2001 From: jkraska1 at san.rr.com (Courageous) Date: Tue, 24 Jul 2001 05:37:57 GMT Subject: Language change and code breaks References: <Pine.LNX.4.33.0107191316390.24983-100000@bms> <mailman.995571273.18192.python-list@python.org> <9j7gv8$9mg@dispatch.concentric.net> <cppuawfqbm.fsf@cj20424-a.reston1.va.home.com> <Pine.LNX.4.33.0107231434170.15565-100000@oliphant.ee.byu.edu> Message-ID: <532qlt453irrepptskcvp213d44r3so2e2@4ax.com> On Mon, 23 Jul 2001 14:37:06 -0600, Travis Oliphant <oliphant at ee.byu.edu> wrote: >> > As a member of this group, who is especially fond of Python for how >> > easy it is to pick up where I left off days or weeks before, I would >> > very much prefer a case *insensitive* language with tools that >> > enforce *uniform* case usage. This would annoy the hell out of me, as I use and will continue to use vim as my primary code editor. Anyone who builds a development environment which requires specialized tools for the environment -- -- even if the requirement is indirect because things don't function quite right without the tools -- loses my business forthright. The moment using "tools" with Python becomes an essential part of creating Python programs, the language is dead to me. All of this pent-up rancor of mine comes with my open contempt for Lisp environ- ments which more or less simply require you to use Emacs. Puke-o-rama. C// From peter at engcorp.com Thu Jul 26 21:51:00 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 26 Jul 2001 21:51:00 -0400 Subject: Couple of newbie questions... References: <5a140c6d.0107261705.3a4f7db3@posting.google.com> Message-ID: <3B60C904.A21992A3@engcorp.com> Scott Taylor wrote: > > 1) time.sleep doesn't seem to release time back to the Win32 > subsystem. I had a tight loop, and CPU was maxed out at 100% even if > I did a PumpWaitingMessages w/ a time.sleep. To actually get the loop > to return slices of time back to windows and not max out the CPU I had > to do a PumpWaitingMessages followed by a win32api.Sleep(0) call. My > question is - shouldn't time.sleep actually make the process sleep w/o > hogging CPU? It does on my system. Try executing this in a DOS prompt and compare with your other situation: python -c "import time; time.sleep(30)" On my machine (Win98 release 1) System Monitor shows only its usual 30% or so, same as when I am just sitting at a DOS prompt... (Disclaimer: no, I don't believe System Monitor is an appropriate tool for this purpose, but I also know time.sleep() does not busy-wait under Windows in any case I've ever seen.) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From bokr at accessone.com Tue Jul 31 01:59:12 2001 From: bokr at accessone.com (Bengt Richter) Date: Tue, 31 Jul 2001 05:59:12 GMT Subject: Language change and code breaks References: <Pine.LNX.4.33.0107191316390.24983-100000@bms> <mailman.995571273.18192.python-list@python.org> <9j7gv8$9mg@dispatch.concentric.net> <cppuawfqbm.fsf@cj20424-a.reston1.va.home.com> <Pine.LNX.4.33.0107231434170.15565-100000@oliphant.ee.byu.edu> <cp7kwyqfce.fsf@cj20424-a.reston1.va.home.com> <3B61EEA5.9050306@home.com> <3B659A4C.96DE8CCA@home.net> Message-ID: <3b66416a.870814825@wa.news.verio.net> On Mon, 30 Jul 2001 10:33:00 -0700, Chris Barker <chrishbarker at home.net> wrote: [...] >lives on!. In fact, I think that if Fortran 77 introduced dynamic memory >allocation, it would be living even larger than it is: that was kind of >a deal killer for a lot of stuff. By the way, Fortran 90/95 is pretty >darn nice language. Does 90/95 have it? I jiggered the Fortran runtime library for a version of DEC fortran on the PDP-11 to provide dynamic memory allocation. Used two-dimensional array trick subverting array access to use an allocation handle in one index instead of a normal one. Call the trick allocation for a handle and index into the allocated space 1-dimensionally with the other index from the POV of the Fortran program. That was in the 70's ;-) I used it to pass parameters in a cooperative multitasking program that essentially did between dispatched fortran subroutines what windows does with its message passing. The main dispatching loop was a Fortran do loop. I was also painting multiple rectangular sub-windows on a screen with cursors and responding to an asynchronous mix of inputs, including a track ball. In a parallel universe I'm sure I'm a billionaire ;-)) From kodtest99 at yahoo.com Tue Jul 17 11:45:58 2001 From: kodtest99 at yahoo.com (kodtest99 at yahoo.com) Date: Tue, 17 Jul 2001 15:45:58 GMT Subject: Help me please in one test. Message-ID: <W4Z47.14371$M6.5423139@news.rt.ru> This is test. Answer me please for test message. Thanks, Robert. ---------------------------------- | FREE Vacation! FANTASNIC offer! | | | | http://linkresort.fasturl.it | ---------------------------------- From tim.one at home.com Mon Jul 23 00:00:30 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 23 Jul 2001 00:00:30 -0400 Subject: subclassing Exceptions In-Reply-To: <wkpuascphn.fsf@mail.connact.com> Message-ID: <LNBBLJKPBEHFEDALKOLCGEDMLAAA.tim.one@home.com> [phawkins at spamnotconnact.com] > ... > import exceptions > ... > class CameraError(exceptions.Exception): > def __init__ (self, args = None): > self.args = args Just noting that Exception is in the builtin namespace, so there's no need to import the exceptions module first. That is, you can drop the import, and change the declaration to class CameraError(Exception): i-was-surprised-too-when-barry-taught-me-that!-ly y'rs - tim From jwbaxter at spamcop.com Sun Jul 15 18:46:39 2001 From: jwbaxter at spamcop.com (John W. Baxter) Date: Sun, 15 Jul 2001 15:46:39 -0700 Subject: PEP: Defining Unicode Literal Encodings (revision 1.1) References: <Pine.LNX.4.30.0107141805550.5125-100000@rnd.onego.ru> <mailman.995126666.3898.python-list@python.org> Message-ID: <150720011546398405%jwbaxter@spamcop.com> In article <mailman.995126666.3898.python-list at python.org>, M.-A. Lemburg <mal at lemburg.com> wrote: > I already mentioned allowing directives in comments to work around > the problem of directive placement before the first doc-string. > > The above would then look like this: > > #!/usr/local/bin/python > # directive unicodeencoding='utf-8' > u""" UTF-8 doc-string """ > > The downside of this is that parsing comments breaks the current > tokenizing scheme in Python: the tokenizer removes comments before > passing the tokens to the compiler ...wouldn't be hard to > fix though ;-) (note that tokenize.py does not) I don't like the idea that removal of a comment changes the meaning of the non-comment part of the source text...program text really should mean the same thing without the comments. But, I dislike this less than most of the previous ideas for dealing with unicode docstrings. Elsewhere, In article <mailman.995139510.24509.python-list at python.org>, Tim Peters <tim.one at home.com> wrote: > Another alternative: > > #!/usr/local/python > directive unicodeencoding 'utf-8' > > __doc__ = u""" > This is a Unicode doc-string > """ > > That is, the module docstring is just the module's __doc__ attr, and that > can be bound explicitly (a trick I've sometimes use for *computed* module > docstrings). Ah...this may well be the way out. It doesn't hurt the docstring tools which use import. Since it's already legal Python (isn't it?)--and is used sometimes by Tim--it doesn't break a parsing docstring tool which isn't already broken (although it may make the problem show up more often). And it doesn't affect those modules whose docstrings aren't unicode and are done in the usual way. The __doc__ = ... method seems better than any of the things *I* muttered about in earlier posts, which are now "inoperative" (USA-centric joke) and never were particularly sensible. --John From peter at engcorp.com Wed Jul 18 22:59:36 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 18 Jul 2001 22:59:36 -0400 Subject: Language change and code breaks (fwd) References: <mailman.995499932.8750.python-list@python.org> Message-ID: <3B564D18.4F6B31EA@engcorp.com> Bjorn Pettersen wrote: > > > From: Peter Hansen [mailto:peter at engcorp.com] > > > > Bjorn Pettersen wrote: > > > But being a web hoster, with no knowledge about Python, would _you_ > > > expect a version change from 2.2 to 2.3 to fundamentally change > > > semantics? > > > > I'm pretty sure nobody has seriously proposed making this change > > in a non-major revision. [snip] > > I could be wrong about this though... > > Well, at http://python.sourceforge.net/peps/ pep 238 is still listed > under consideration for 2.2... Yes, but the PEP implies that the initial change proposed for 2.2 is only the first of several steps reasonably clearly described which would lead to the final, code-breaking change *in later releases*. Nothing in the PEP implies that the first step to be made for 2.2 would be one which breaks existing code. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From greg at cosc.canterbury.ac.nz Thu Jul 12 22:11:04 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 13 Jul 2001 14:11:04 +1200 Subject: Comment on PEP-0238 References: <mailman.994892540.32695.python-list@python.org> <3B4D2AF6.7F76CBA1@cosc.canterbury.ac.nz> <9iklh6$gfv$1@agate.berkeley.edu> Message-ID: <3B4E58B8.B97DC92A@cosc.canterbury.ac.nz> Edward Jason Riedy wrote: > > For many geometric and scientific codes using floating-point, > this is exactly what you want. You bump the precision up > once, or you multiply it after trying to get a good-enough > answer. Yes, I can see that this is a different sort of precision problem. Even so, I wouldn't like the idea that some piece of code I have no control over could lower the precision and mess up the results from *my* code. So I still don't think it should be a piece of global state, not even per-thread. Some sort of scope control is needed. -- 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 woetzel at gmd.de Wed Jul 25 06:02:16 2001 From: woetzel at gmd.de (Gerd Woetzel) Date: 25 Jul 2001 10:02:16 GMT Subject: Future division patch available (PEP 238) References: <GNZwEiAJepW7Ew0F@jessikat.fsnet.co.uk> <mailman.995776716.24336.python-list@python.org> <mailman.995825018.9832.python-list@python.org> <9jfjd6$ad4$2@newshost.accu.uu.nl> <7u6nltoqdnqjjdiquu6ngtaruflhvbvdl5@4ax.com> <j4g0bof3jv.fsf@informatik.hu-berlin.de> <p8unltsi5qda8rpdavja4iemj6r1s2ak4a@4ax.com> <j48zhfgbny.fsf@informatik.hu-berlin.de> <23891c90.0107230531.4fb02b12@posting.google.com> <cpd76qqfow.fsf@cj20424-a.reston1.va.home.com> <3B5DEA88.553AF758@home.net> Message-ID: <9jm5f8$bgs$1@hop.gmd.de> Chris Barker <chrishbarker at home.net> writes: [...] >As of Python 2.2 (or 2.3, whatever, as long as it is as soon as any >backward incompatibility is introduced) require something at the top of >every source file: a line like: >#version 2.3 >This is now an indicator of what version of Python the code runs under. >If that line is not there, it is assumed that it is for a version less >that 2.3: In that case, the interpreter has a backward compatibility >mode, and runs that code in that mode. This could probably be a change >at the compiling level, and the resultant byte code could be compatible. >The nice thing about this approach is that it: >A) will not break old code. Ever. At all. >B) It sets up a system for other changes that might be backward >incompatible as well. Let them be few and far between! >C) it restricts the different dialects to being only version changes, >and only a one way street. I think this is a good thing: I don't want >Python coders in the future to be able to use a version that has, for >example: >the old division, but case insensitive [...] Yes, *very* good -- and so simple! (not so for the developers of new Python releases, of course) Furthermore, D) the Python compiler can give up with a nice user (customer) friendly error message like "This sofware needs at least Python version 2.3, please upgrade" or (e.g. Python 3000 might state that) "Cannot understand this ancient Python 2.3 stuff" >Guido, (and everyone else) I'd love to hear your take on this proposal, >I'm sure it's full of holes, but I don't what they are. I started a >thread about it, and have gotten responses, but no one has actually >commented on the proposal itself. I'm listening too .. -- Gerd Woetzel | email: gerd.woetzel at gmd.de GMD FIT.CSCW | phone: ++49 2241 142648 (fax: 142084) D-53754 Sankt Augustin | www: http://orgwis.gmd.de/~woetzel/ From paulp at ActiveState.com Mon Jul 2 23:12:28 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Mon, 02 Jul 2001 20:12:28 -0700 Subject: New PEP: Quality Guidelines For Standard Modules References: <5.0.2.1.0.20010701213736.0277d700@mail.inet.com.br> Message-ID: <3B41381C.589E9E48@ActiveState.com> We all know that there will be legitimate reasons for violating these guidelines. It occurs to me that the way to minimize violations without being totally heavy handed is to require violations to be documented and justified (inline, or in the module documentation, or in some kind of PEP, or whatever.) So for FileInput there would be a paragraph somewhere that says: "The fileinput module violates the restriction on global variables in order to simplify the common case of doing X Y Z. If you want to use it in a threaded (or otherwise sophisticated) context, you can use the FileInput class instead of the global functions." Documenting the deviation from the spec allows us all to read and determine whether the deviation is justified and, more important, demonstrates that the author understood the spec and took it into account. Like a PEP, it also (in theory) will reduce the likelihood of repeated arguments because the arguments will be captured in a document. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From anthony at interlink.com.au Wed Jul 18 22:34:43 2001 From: anthony at interlink.com.au (Anthony Baxter) Date: Thu, 19 Jul 2001 12:34:43 +1000 Subject: PyDNS? In-Reply-To: Message from Michael =?iso-8859-1?Q?Str=F6der?= <michael@stroeder.com> of "Wed, 18 Jul 2001 11:34:09 +0200." <3B555811.BAA3981E@stroeder.com> Message-ID: <200107190234.f6J2Yho32643@mbuna.arbhome.com.au> >>> Michael =?iso-8859-1?Q?Str=F6der?= wrote > Anthony, if you have a local CVS tree of the DNS module I'd prefer > to let the SourceForge people import that and I will commit my few > changes afterwards. I've got an RCS repository of it - I'll convert it to a CVS tree and put in a request for the SF project (I think you need to specify the initial cvs tarball at the same time...) - will do it this evening. Or have you already put in the SF request? Anthony From donn at u.washington.edu Thu Jul 26 12:56:38 2001 From: donn at u.washington.edu (Donn Cave) Date: 26 Jul 2001 16:56:38 GMT Subject: Eliminating upgrade risk References: <tlu596rosgngd9@news.supernews.com> <mailman.996105586.6334.python-list@python.org> <biDHvIAmJ2X7Ewtm@jessikat.fsnet.co.uk> <3B601811.4B68578B@interet.com> Message-ID: <9jpi46$13jg$1@nntp4.u.washington.edu> Quoth "James C. Ahlstrom" <jim at interet.com>: [... re research language priorities ] | I am afraid I have to agree with Robin here. My company "solved" | this problem by staying with Python 1.5.2. I do plan to upgrade when | I have the time, but absent any tools to at least flag incompatibilities | this may never happen. | | My new Red Hat 7.1 system reports that its Python version is 1.5.2. | Apparently I am not alone. I believe many Python users are at 1.5.2. We're up to 2.0 here, but you got me thinking about it and I checked - we still have 1.5.2 installed on at least one host, if I need to verify that something actually works on 1.5.2. Hope folks will do that when possible. I do like some things about 2.0, but 1.5.2 has what you need to write a working program if you don't want to introduce gratuitous incompatibilities with the Red Hat et al. base. Even those who plan to keep up with Python's evolution have a stake in its reputation as a useful programming environment, and eventually it's up to us. Donn Cave, donn at u.washington.edu PS I used a C++ class binding technique per your report in a long ago workshop, http://www.python.org/workshops/1995-12/papers/ahlstrom1.html, for the BeOS native C++ API, and it has worked out OK. The details are somewhat different by now (not necessarily for the better - my class hierarchy module division still needs some work!) but it does what it needs to with those user-defined virtual functions. Thanks! From mnenadov at stclairc.on.ca Sat Jul 21 07:12:20 2001 From: mnenadov at stclairc.on.ca (Mark Nenadov) Date: Sat, 21 Jul 2001 11:12:20 GMT Subject: If you want to see Python people complaining... References: <3B54497F.B98D34CF@jam.rr.com> Message-ID: <20010721.072418.846942590.1761@d150-169-166.home.cgocable.net> In article <3B54497F.B98D34CF at jam.rr.com>, "Rob Andrews" <rob at jam.rr.com> wrote: > Take a look at today's User Friendly poll. ("Web code of choice: > Perl/mod_perl, *sh, C/C++, ASP, Javascript, Cold Fusion, JSP, PHP"). At > the time I checked, there were more complaints about Python not being > listed as there were comments on any of the actual choices offered. Rob > I think they have a pretty good reason to complain. I can guarantee more people do more web stuff in Python than C/C++. Especially if you consider Zope to be Python code. Also, I would surmise that Python has OO support better than any of those languages with the *possible* exception of Java(JSP) and C++. With all due respect to those language/environments (I have programmed in 4 of them), I feel Python deserves to be on there. ~Mark Nenadov (author/editor for http://ww.coffeecode.com) From simonb at webone.com.au Wed Jul 11 23:23:15 2001 From: simonb at webone.com.au (simonb at webone.com.au) Date: Thu, 12 Jul 2001 13:23:15 +1000 Subject: python and applications References: <V%337.677940$166.13952126@news1.rdc1.bc.home.com> Message-ID: <3B4D1823.4090708@webone.com.au> These are hard questions! i don't know much about muds, but python is a serious language designed to handle the real stuff... One great feature of python is the ability to code high level algorithms really fast (maybe 10 times faster than c), this should be a win for, say, experimenting with muds. As for speed, if it ends up being important (this depends on many factors), the standard technique is to re-write the critical parts in c. I am working on a python environment for disabled people, in my spare time. My problem is arms with a very limited bandwidth. I'll keep blind people in mind. :) Simon tyler spivey wrote: >could you write a fast mud in python? >having a lot of monsters like dikumuds do? >how many blind programmers use python? and is python just a toy language? >can it do more or as much as c? could you create a roguelike in it? >I am blind myself. > From aahz at panix.com Tue Jul 31 10:38:13 2001 From: aahz at panix.com (Aahz Maruch) Date: 31 Jul 2001 07:38:13 -0700 Subject: Python Threads on Linux References: <d396b814.0107302239.6341a93@posting.google.com> Message-ID: <9k6fsl$1rd$1@panix2.panix.com> In article <d396b814.0107302239.6341a93 at posting.google.com>, Ronan Viernes <Ronan.Viernes at onsemi.com> wrote: > >1. Is it normal for threads on LINUX to have their own process id >thereby displayed in "ps -ef"? Yup. Linux threads are processes. Sort of. >2. How do i exit gracefully from a thread? After exiting the thread, >is the thread 'process' automatically closed? I noticed in our system >that after exiting the thread, the 'process' are still present as >evidenced by the "ps -ef" . Please post some short code that illustrates this. -- --- 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 "activist for accuracy" --SJM From vvainio at karhu.tp.spt.fi Tue Jul 17 01:50:44 2001 From: vvainio at karhu.tp.spt.fi (Ville Vainio) Date: 17 Jul 2001 08:50:44 +0300 Subject: howdoI: Exception in thread - terminating the program? Message-ID: <yox7kx83xzf.fsf@karhu.tp.spt.fi> Is there some "standard" or canonical way to make programs die when an unhandled exception occurs in a thread (other than main)? Off the top of my head, I can think of having a threading.Event blocking at the main, all threads set to Daemons, and having the run() in catch-all try-except block (and save/print traceback, trigger the blocking event in main inside except). Am I missing some obvious, easier method? How do you people handle such cases in your own projects? I do know that eventually all exceptions will be handled in their proper places, but just to prepare for the unexpected... (no pun intended) -- 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 gustafl at algonet.se Sat Jul 14 13:04:38 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 14 Jul 2001 17:04:38 GMT Subject: Importing XML modules in py2exe or Installer? References: <Xns90DE9C2957BDgustaflalgonetse@194.213.69.152> <Xns90DE68B66343Agmcmhypernetcom@199.171.54.154> Message-ID: <Xns90DEC227B102Cgustaflalgonetse@194.213.69.148> Gordon McMillan <gmcm at hypernet.com> wrote: >Doesn't help to use py2exe args with Installer! Sorry, misunderstood this first. Haven't used ConfigParser before. >Edit myscript.cfg and put >packages=_xmlplus >in the PYZ section. It don't work. Here's what I have done: 1. Extracted Installer in e:\installer. 2. Moved all my project files to e:\python\gustaf, which is in my Python path (sys.path). The project consists of jane.py + 4 other .py files with classes and functions. 3. Went to e:\python\gustaf and typed: python e:\installer\simple.py jane.py All 5 .py files modules were compiled into .pyc files. Apart from that, I also got the following new files: Install_jane.exe jane.exe jane.cfg gen_install.pyc gen_install.py Builder.log installzlib.pyz jane.pyz 5. Opened the jane.cfg file: [MYINSTALL] type= INSTALL name= Install_jane.exe bindepends= jane.py zlib = INSTALLZLIB misc= MYSTANDALONE debug = 0 excludes = pywintypes, win32api [MYSTANDALONE] type= STANDALONE name= jane.exe script= jane.py zlib = APPZLIB userunw = 0 support = 0 debug = 0 [APPZLIB] name= jane.pyz dependencies= jane.py excludes= dospath, posixpath, macpath [INSTALLZLIB] name = installzlib.pyz dependencies = installutils includes = installutils excludes = dospath, posixpath, macpath Either these header sections are not documented as they appear, or I'm looking in the wrong place. The Installer docs talk about PYZ, COLLECT, CARCHIVE, STANDALONE, FULLEXE and INSTALL. 6. Added a [PYZ] header section + a 'packages' property in the jane.cfg file: [PYZ] packages=_xmlplus 7. Ran Builder.py on the new jane.cfg: E:\python\gustaf>python e:\installer\builder.py jane.cfg W: exec statment 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 your PATH if .dlls are not found Traceback (most recent call last): File "e:\installer\builder.py", line 596, in ? main(args) File "e:\installer\builder.py", line 541, in main target = makeTarget(cfg, section) File "e:\installer\builder.py", line 479, in makeTarget return dispatch[cfg.get(section, 'type')](cfg, section, optcnvrts) File "e:\installer\builder.py", line 110, in __init__ Target.__init__(self, cfg, sectnm, cnvrts) File "e:\installer\builder.py", line 45, in __init__ self.__name__ = self.name AttributeError: PYZTarget instance has no attribute 'name' And here I am. If you need to see the code, the project files can be found at: http://www.algonet.se/~gustafl/dev/jane/code/ Regards, Gustaf Liljegren From fredrik at pythonware.com Mon Jul 9 18:11:02 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 09 Jul 2001 22:11:02 GMT Subject: Language Shootout References: <mailman.994689198.3317.python-list@python.org> <3B49F724.1F3DF6B3@yahoo.com> Message-ID: <WZp27.2221$z21.439450@newsc.telia.net> Paul Winkler wrote: > Doing it iteratively is much, much faster. does your fastest iterative solution beat this one? import sys def fib(n): if n < 2: return 1 return fib(n-2) + fib(n-1) def fib(n, fib=fib, memo={}): v = memo.get(n) if v is None: v = memo[n] = fib(n) return v def main(): N = int(sys.argv[1]) print fib(N) </F> From anamax at earthlink.net Sat Jul 21 00:23:28 2001 From: anamax at earthlink.net (Andy Freeman) Date: 20 Jul 2001 21:23:28 -0700 Subject: OO misconceptions References: <mailman.994969462.27792.python-list@python.org> <hevsktcrnpckttnkgi1arcue5kjjsbrrb5@4ax.com> <mailman.995046506.2514.python-list@python.org> <9ir1l7$3ja$1@panix2.panix.com> <9irfbc11jaq@enews1.newsguy.com> <slrn9l49me.p58.tim@vegeta.ath.cx> <mailman.995268208.1394.python-list@python.org> <slrn9l6kci.qqs.tim@vegeta.ath.cx> <3B538E16.65394C9D@engcorp.com> <slrn9l7a8r.rpe.tim@vegeta.ath.cx> <9j0rko025gf@enews3.newsguy.com> <slrn9l9k6t.va1.tim@vegeta.ath.cx> Message-ID: <8bbd9ac3.0107202023.197c4c3c@posting.google.com> > I cling to the philosophy that there is no "better" language and that a "no language is superior to all other languages in all circumstances" does not imply that there are not languages x and y such that x is superior to y in all circumstances. In fact, the original statement is fairly weak; it doesn't seem to imply anything interesting. For example, the original statement doesn't rule out a language P that happens to be superior to all known languages in all circumstances. The "fact" that P is inferior to some unknown language in some circumstance doesn't do much for those of us who have to live with existing languages. -andy From careye at spamcop.net Tue Jul 10 21:33:15 2001 From: careye at spamcop.net (Carey Evans) Date: 11 Jul 2001 13:33:15 +1200 Subject: Comment on PEP-0238 References: <mailman.994532533.10229.python-list@python.org> <9ichdv$rik$1@tomm.stsci.edu> <yAm27.8553$Y6.2987762@news1.rdc2.pa.home.com> <slrn.pl.9kjuov.nlq.qrczak@qrnik.zagroda> Message-ID: <87bsmss10k.fsf@psyche.dnsalias.org> Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl> writes: > I would prefer it to mean integer division of fractional numbers, e.g. > 1.3 div 0.3 == 4 > 1.3 mod 0.3 == 0.1 If it gets defined in terms of divmod(), as Guido would like to do (see <cppubbipxg.fsf at cj20424-a.reston1.va.home.com>), then this would be: 1.3 div 0.3 == 4.0 1.3 mod 0.3 == 0.1 which is pretty much what you want. -- Carey Evans http://home.clear.net.nz/pages/c.evans/ "Quiet, you'll miss the humorous conclusion." From sheila at spamcop.net Thu Jul 12 01:48:01 2001 From: sheila at spamcop.net (Sheila King) Date: Thu, 12 Jul 2001 05:48:01 GMT Subject: LAMBDA IS IT USELESS? References: <tO837.679712$166.14009323@news1.rdc1.bc.home.com> Message-ID: <bdeqktshfugcoh0fhge7k1j2mbhhejeeel@4ax.com> I'm interested to see what responses you will get to this query, as I don't fully understand the lambda functions either. However, I'm currently working through the chapters on Tkinter in Programming Python, 2nd ed., and apparently, there are cases when issuing callbacks for events, that in order to be able to pass parameters to the callback function, one must use lambda functions. I don't entirely understand why, at this time. But it was mentioned in the book. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ On Thu, 12 Jul 2001 03:27:21 GMT, "EricIDLE" <grayson-wilson at home.com> wrote in comp.lang.python in article <tO837.679712$166.14009323 at news1.rdc1.bc.home.com>: :Ok well I dont quite grasp the Lambda concept heres an example. : :def mult(x,y): : return x * y :f = reduce(lambda x,y: x*y,n) :print f : :*NOTE The varible N is defined in the code before this excerpt. : :Anyways back to the point the book says this is easier!?!? : :But comon sense tells me this is easier. : :def mult(x,y): : return x * y :f = reduce(mult,n) :print f : :Isnt that easier?? : :Or do I not get lambda? From hostmaster at bemarnet.es Mon Jul 2 11:44:00 2001 From: hostmaster at bemarnet.es (Antonio Navarro Navarro) Date: Mon, 2 Jul 2001 17:44:00 +0200 Subject: Windows RAS manipulation Message-ID: <6723776458.20010702174400@bemarnet.es> Hi all, I need to write a stand-alone Python application that will run like a daemon (started at windows boot) to create a Phonebook entry on a Windows 95 machine, start up a connection, make some FTP transfers and then hang up and delete the connection. I have been reading the mailing list and have found several references to win32ras.CreatePhonebookEntry, EditPhonebookEntry, etc, but I don't know if this functions are fully functional. Where can I find more info, for example a working script that creates-connect-disconnect-deletes a phonebook entry in Python ? Do you think It will be better to use a different approach ? (I prefer not to use rasdial.exe, because I need to obtain full control of the connection process). Thank you in advance, best regards, Antonio Navarro Navarro BemarNet Management http://www.bemarnet.es hostmaster at bemarnet.es From phawkins at spamnotconnact.com Sat Jul 21 13:41:59 2001 From: phawkins at spamnotconnact.com (phawkins at spamnotconnact.com) Date: 21 Jul 2001 13:41:59 -0400 Subject: design patterns in python References: <3b2786d5$1_3@newsfeeds> <3b4ee55f.102689870@news.t-online.de> Message-ID: <wksnfqw55k.fsf@mail.connact.com> Well, some patterns get posted to the Python Cookbook. Perhaps this should be an additional category? http://aspn.activestate.com/ASPN/Cookbook/Python -- Patricia J. Hawkins Hawkins Internet Applications, LLC From garyp at asti-usa.com Thu Jul 26 15:35:52 2001 From: garyp at asti-usa.com (Gary Perez) Date: Thu, 26 Jul 2001 15:35:52 -0400 Subject: SuSE 7.2 + apache/mod_python Message-ID: <3B607117.12A36377@asti-usa.com> Hi, all. I've asked the mod_python list about this twice already (no luck there). I'm having problems getting mod_python to work under apache. Here's the relevant info: SuSE Linux 7.2, kernel 2.4.4, reiserfs Apache 1.3.19 + Python 2.0 + mod_python 2.7.2 Installed (and reinstalled) apache, python (no threads) and mod_python a few times. Set up the test directives in httpd.conf, proper .py module in the htdocs/test directory as per the documentation. When I hit the target URL, apache kicks out an internal server error... ERROR LOG [Wed Jul 18 15:58:02 2001] [notice] Apache/1.3.19 (Unix) (SuSE/Linux) mod_layout/1.0 mod_throttle/3.0 mod_fastcgi/2.2.2 mod_ssl/2.8.3 OpenSSL/0.9.6a PHP/4.0.4pl1 mod_perl/1.25 mod_dtcl mod_python/2.7.2 Python/2.0 configured -- resuming normal operations [Wed Jul 18 15:58:02 2001] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec) [Wed Jul 18 15:58:18 2001] [error] [client 192.168.100.100] python_handler: Dispatch() returned nothing. If anyone has any experience in this area or ideas as to what I can do to figure out this annoying behavior, I'd greatly appreciate any help. Thanks very much, -Gary From BPettersen at NAREX.com Tue Jul 24 11:44:57 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Tue, 24 Jul 2001 09:44:57 -0600 Subject: proposed language change to int/int==float (was: PEP0238 lament) Message-ID: <6957F6A694B49A4096F7CFD0D900042F27DBA3@admin56.narex.com> > From: Klaus-G. Meyer [mailto:klaus-gerd.meyer at de.bosch.com] > > > those guys. It *is* odd to have to do something like: > > x = float(y)/z > > to get best-possible division in Python. > > But what is with the "best possible" multiplication? > > 99999*99999 -> integer overflow > > Why not an long integer result? (or maybe float) > > You must explicit type: > 99999*99999L or 99999*99999. > > Is that not the same thing as type 1./3 ??? I think perhaps an equally interesting example is something like: 2L**128/2 which currently gives an exact result, but under the proposed new semantics would give an approximation... This is only one of the reasons why I think it's a mistake to look at integer division by itself. If we're going to change basic behaviors it would be better if we had a consistent semantic model first. -- bjorn From grumble at usa.net Fri Jul 13 09:36:08 2001 From: grumble at usa.net (jcm) Date: 13 Jul 2001 13:36:08 GMT Subject: Python speed References: <roG27.666914$166.13798179@news1.rdc1.bc.home.com> <9ik9kd$nch$1@news.mathworks.com> <9ikc0m$bmg$1@panix2.panix.com> <9ikee9$rpv$1@news.mathworks.com> <9iluu2$bmb$1@panix2.panix.com> Message-ID: <9imtg8$bqe$1@news.mathworks.com> Aahz Maruch <aahz at panix.com> wrote: > In article <9ikee9$rpv$1 at news.mathworks.com>, jcm <grumble at usa.net> wrote: >>Aahz Maruch <aahz at panix.com> wrote: >>> In article <9ik9kd$nch$1 at news.mathworks.com>, jcm <grumble at usa.net> wrote: >>>> >>>>If you'd like, reread my point as "muds are likely to be CPU-bound >>>>programs". >>> >>> Fine, but in that case, what *is* your point? >> >>Muds are likely to be CPU-bound programs. > If that is the entirety of your point, why are you posting? Go back and read the first post in this thread. Someone wanted to know if Python's speed would be an issue in writing a mud. And, in my experience, the answer is "maybe". But I think we've gone over this already... From arildh at stud.cs.uit.no Mon Jul 2 19:42:01 2001 From: arildh at stud.cs.uit.no (Arild Hansen) Date: Tue, 3 Jul 2001 01:42:01 +0200 Subject: Recording wav files Message-ID: <Pine.LNX.4.33.0107030139470.20530-100000@arildh.pasta.cs.uit.no> Hello, What is the easiest way to record wav files in a python program using pyEsd or possibly some other third party library (except snack or whatever it is called)? Does the python 2.0 wave module permit recording of wav files from /dev/dsp? The system is Linux 2.4.0, OSS for sound, python 2.0. Thx for helping out, AH From tim at digicool.com Mon Jul 23 15:18:52 2001 From: tim at digicool.com (Tim Peters) Date: Mon, 23 Jul 2001 15:18:52 -0400 Subject: PEP0238 lament In-Reply-To: <9jgvbc$dos$1@newshost.accu.uu.nl> Message-ID: <BIEJKCLHCIOIHAGOKOLHAEFKCDAA.tim@digicool.com> [Martijn Faassen] > This discussion is entirely self selected too. What I'm pointing > out is that your 3/4 number is fairly meaningless in this discussion. In context, it was a directly relevant response to a question of Arthur's that had gone unanswered. Out of context, it may was well be blue cheese. I'm afraid this whole thread has turned into too much "typical Usenet" excess to be worth the effort of following it anymore. lemme-know-how-it-turns-out<wink>-ly y'rs - tim From matthewm at ihug.co.nz Mon Jul 9 23:57:50 2001 From: matthewm at ihug.co.nz (Matthew) Date: Tue, 10 Jul 2001 15:57:50 +1200 Subject: Postscript for PythonCOM & Office. Arrgh! Message-ID: <3B4A7D3E.E16FA838@ihug.co.nz> Using Office97. From bokr at accessone.com Fri Jul 13 16:34:04 2001 From: bokr at accessone.com (Bengt Richter) Date: Fri, 13 Jul 2001 20:34:04 GMT Subject: Is Python Dead? Long Live Python! References: <mailman.994943120.433.python-list@python.org> <3B4E483C.4379E84E@engcorp.com> <mailman.994988062.18418.python-list@python.org> <3B4E68C5.E47D5F0F@engcorp.com> <mailman.994998742.17624.python-list@python.org> Message-ID: <3b4f538f.1825798619@wa.news.verio.net> On Thu, 12 Jul 2001 21:30:43 -0700, Paul Prescod <paulp at ActiveState.com> wrote: >Peter Hansen wrote: >> >> ... >> >> Well, maybe if we could measure, sometime in the future when the >> user base of Python and PHP is identical (not sure which is >> actually larger now, mind you), publisher revenues from the books, >> I might still be sort of right... I can't believe Python will >> end up with the volume of five-inch thick books that PHP and >> its ilk have barfed forth. > >I still think that you have too much faith that the actual technical >features of the topic have any real effect on the structure of the books >(or the market). Once you move past the first ten books written by >zealots and early adopters, the rest are written by people like "the >Deitels" who have a structure and are looking for content to pour into >it. > >That isn't necessarily a bad thing -- people who buy a book from the >Deitels (or the Dummies series or ...) know exactly what they are going >to get! As long as they don't do too much damage to the content pouring >it into their form, it doesn't seem so terrible. Sometimes books by the >"writing experts" are better than those by the technical experts. And >sometimes they are worse. >-- I have a theory that a fair number of books (and computers!) are bought for the rabbit's-foot effect. I.e, if you just own it, it will give you magical powers. Publishers try to cash in on that by the kind of design and cover hype that will trigger an impulse purchase. The other kind of book is for actual use by professionals (or amateurs as in Olympics rules). The hallmarks tend to be good indexing and cross referencing, unobtrusive but pleasant and effective layout, conciseness and clearness, and also good physical characteristics: coated paper, handy size, good fonts. For my money, David Beazley and New Riders deserve a plug for hitting close to the mark with the Python Essential Reference. I hope the new edition is as good. (That's not to say it's the best book for everyone, but it is the kind I like). From quinn at yak.ugcs.caltech.edu Sun Jul 22 16:06:34 2001 From: quinn at yak.ugcs.caltech.edu (Quinn Dunkan) Date: 22 Jul 2001 20:06:34 GMT Subject: Hello, References: <mailman.995736253.29035.python-list@python.org> <etd3d7qxi88.fsf@w20-575-7.mit.edu> <9jeafl$46q$1@nntp9.atl.mindspring.net> Message-ID: <slrn9lmcia.c1q.quinn@yak.ugcs.caltech.edu> On Sun, 22 Jul 2001 06:43:18 +0500, Tom Bryan <tbryan at python.net> wrote: >Alex wrote: > >> Not really. There are some ways you could speed up the python code: > >I'm also not really sure why one would want to do this, but... > >> There's the additional problem that >> opening "err" will truncate the log file, and if an error occurs while >> you're writing the new version back, you could lose messages. > >here's a version that makes a copy of the file before prepending a >new message to avoid that problem. It also uses seek to avoid having I suggest appending the normal way, but viewing it with 'tac' :) From travis at grub.atlantic.net Thu Jul 5 04:11:35 2001 From: travis at grub.atlantic.net (Travis Whitton) Date: Thu, 5 Jul 2001 04:11:35 -0400 Subject: ANNOUNCE: ChemRound.py v0.1 Message-ID: <Pine.LNX.4.21.0107050406090.2616-100000@grub.atlantic.net> ChemRound.py is a small python class that performs .5 based rounding on whatever numbers you pass into it. It is free of the performance bottlenecks imposed by regexps and tries to do as much of it's calculations as possible mathematically. I wrote it because I couldn't find any pre-existing implementations of it's functionality; however, I'm not a math expert or a python expert for that matter, so I would like to ask any of you with the time/inclination to do a peer review and respond to me at whitton at atlantic.net. The URL for download is: http://grub.atlantic.net/ChemRound Thanks, Travis Whitton <whitton at atlantic.net> From aahz at panix.com Wed Jul 4 10:38:45 2001 From: aahz at panix.com (Aahz Maruch) Date: 4 Jul 2001 07:38:45 -0700 Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <9htgsb$ck3@news1.gtech.com> <9huo4n01jfl@enews1.newsguy.com> <slrn9k605n.esf.jajvirta@sirppi.helsinki.fi> Message-ID: <9hv9pl$5c7$1@panix6.panix.com> In article <slrn9k605n.esf.jajvirta at sirppi.helsinki.fi>, Jarno J Virtanen <jajvirta at cc.helsinki.fi> wrote: >Wed, 4 Jul 2001 11:37:25 +0200 Alex Martelli wrote: >> >> My impression is that most development shops >> underestimate the importance of keeping their best programmers and >> attracting other super-performers -- because it's not acknowledged >> yet that the individual performance variation between the best >> programmer in the best environment, and a mediocre programmer in >> a mediocre environment, is MANY orders of magnitude (easily a >> factor of 1,000 -- look at those *hundreds of times performance >> ratios* above-quoted for best-Python vs worst-C...!!!). Once this >> little fact does start to be realized, we may move into a kind of >> "superstar economy" for developers, as is currently in force in >> sports, show-business, CEO's, traders, and some professions (lawyers, >> doctors), where top performers earn _disproportionately_ more than >> mediocre counterparts -- which will have its own problems (and how!), >> but very different ones from today's relative "flattening" (where a >> performance that's 1,000 times better is only rewarded 10 or 20 >> times better, if that). > >[not that you didn't know this already ..] > >Isn't this just what Frederick Brooks claimed in "The Mythical >Man-Month"? > >quoting from the anniversary edition: > >a) Adding people to a software project increases the total effort > necessary in three ways: the work and disruption of repartitioning > itself, training the new people, and added intercommunication. > > ("hence" Brooks's Law: Adding manpower to a late software project > makes it later.) > >b) Very good professional programmers are ten times as productive as > poor ones, at same training and two-year experience level. > (Sackman, Grant and Erickson) > >therefore: > > A small sharp team is best -- as few minds as possible. Sure. You snipped Alex's main point, though, which is that we now have more real data to *prove* this assertion. -- --- 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'm not tense, i'm just terribly, terribly alert" --unknown From guido at python.org Fri Jul 27 14:01:36 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 27 Jul 2001 18:01:36 GMT Subject: (in)exactness of complex numbers References: <mailman.996249232.22459.python-list@python.org> Message-ID: <cp4rry2qvh.fsf@cj20424-a.reston1.va.home.com> Skip Montanaro <skip at pobox.com> writes: > Once these numeric changes are all implemented, if I define a complex > constant with either integer real or imaginary parts, e.g. > > c = 1+2.1j > > d = 1.2+5j > > e = 4+7j > > should I get an integer back (exact) or a float (inexact) when asking for an > attribute that was originally an integer? In general, can complex numbers > be considered to have two exactness attributes? That's probably not worth the implementation complexity. I expect that all floats and complex will be considered inexact, and all rationals and ints exact. That seems to be the most practical set of rules, even if it doesn't satisfy everybody. --Guido van Rossum (home page: http://www.python.org/~guido/) From mirko.liss at web.de Sun Jul 1 07:38:35 2001 From: mirko.liss at web.de (Mirko Liss) Date: Sun, 1 Jul 2001 13:38:35 +0200 Subject: Discussions and developing In-Reply-To: <tnp%6.1094$847.221276@news1.rdc1.mb.home.com> References: <mailman.993918166.28645.python-list@python.org> <tnp%6.1094$847.221276@news1.rdc1.mb.home.com> Message-ID: <20010701113841.11B7E661.NOFFLE@niccolo.ke4.de> On Sat, 30 Jun 2001, Brad Bollenbach wrote: > 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. Complaints like that do in fact regularly come up in in almost *any* newsgroup or mailing list. I guess there a three major approaches to deal with the low signal - to - noise - ratio of a many newsgroups: a. Subdivide the group. Maybe comp.lang.python could spawn something like comp.lang.python.newusers, comp.lang.python.developers or comp.lang.python.install . Perhaps this will in fact be done, since the newsgroup's traffic increases as Python gains popularity. b. Apply threading, filtering or scoring mechanisms to your newsreader. There's something like a "food chain of excellence" in many diskussions. Experts discuss advanced topic with advanced users but ignore common problems. Advanced users often volunteer answering questions of newbies, but choose to ignore esoteric threads. Common news and mail readers feature very comfortable tools to skew your personal horizont. Supposedly you have already mentioned several useful keywords these programs can work with. c. Be patient and suffer. Useless talk do always happen. Complaints about other peoples` boring ideas might not help matters. We are all just humans out there. I guess a combination of a., b. and c. might approximate a solution to your problem. Friendly regards, Mirko Liss PS: To those of you who aren't human: Please refrain from sending me personal mail how to "get rich quick". You will be brutally scored and filtered. ;-) From BPettersen at NAREX.com Thu Jul 19 15:49:57 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Thu, 19 Jul 2001 13:49:57 -0600 Subject: Language change and code breaks Message-ID: <6957F6A694B49A4096F7CFD0D900042F27D55F@admin56.narex.com> > From: Guido van Rossum [mailto:guido at digicool.com] > > > I'm still wondering what advantage there is to crippling the > > expressivity of a language for the sake of a small group of > > non-programmers. > > IMO there are two non-truths in this statement. > > (1) The expressivity of the language is not crippled. > > (2) Potentially, the group of non-programmers is much larger than the > group of programmers (and it's easier to teach programmers an > arbitrary rule than non-programmers). TRuE, tHe ExPRESsiVity oF ThE lANGuaGE is ProBAbLY nOt cRipPled, hOWEvEr, tHere ARe SigNIficantLy FeweR ideNtIFIeRs AVaILABlE whICh mEAns iT is LESs eXPRessIvE. IN pArTicULar, cOMmON Idioms liKE naMiNg CLASseS stArTiNg WiTh UppER cASE lETtERS, AND instaNCeS OF THose cLAsSes begINNiNG with A lOwER caSE LettER CaN NO LongeR Be usED. AS fAR aS thE Size Of thE VARious camPs, I haVE YeT tO sEe a coMPeLLinG aRGuMeNt thAT THE grOup of noN-pRoGRaMmeRS THat WILl taKe up pRoGRAmmInG, ANd wiLL DO sO in PYTHon InsTEad oF VisUal BasiC, Is any LARGeR Than The groUp of ProgRAmmERs. -- bJoRn From peter at engcorp.com Tue Jul 31 09:33:22 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 31 Jul 2001 09:33:22 -0400 Subject: Typing system vs. Java References: <mailman.996524288.7635.python-list@python.org> <jonathan-D4822F.08343331072001@news.easynet.co.uk> <Xns90EF65598E954michaelrcpcouk@194.238.50.13> Message-ID: <3B66B3A2.F47BA3E2@engcorp.com> Michael Abbott wrote: > > I for one would like to see a strongly typed variant > of Python: if for nothing else, I'd like to be able to compile my code. How would that let you compile your code? Lack of compile-time type checking is hardly the only thing making it difficult to develop a Python compiler. More to the point, why would you want to compile your Python code? If for packaging reasons, there are effective alternatives in the form of, for example, py2exe. If for performance, the better approach is perhaps to profile your code, then rewrite the performance-critical portions as C extensions. Then you have pretty much the best of both worlds. > Let me just observe this: statically typed Python would need to be a > different language from standard Python, though hopefully close enough to > interoperate and have the same name. It would be interesting, perhaps, to see how well such a beast would be adopted by the programming community. I can just see the "marketing war" triggered as both sides try to promote their own version of Python as the One True Way to program... -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From robin at jessikat.fsnet.co.uk Tue Jul 17 15:23:59 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Tue, 17 Jul 2001 20:23:59 +0100 Subject: viewcvs rlog error References: <74f2f0e9.0107171115.25248606@posting.google.com> Message-ID: <RNr1kKAPDJV7EwP1@jessikat.demon.co.uk> In article <74f2f0e9.0107171115.25248606 at posting.google.com>, Jeanie M. Schwenk <jschwenk at oregon.idt.com> writes >I just installed viewcvs 0.7 and it gives python exceptions if the >directory has any files in it. Not terribly useful. It appears to >be some kind of rlog error but I can't duplicate it from the command >line so I must assume it's something to do with the python scripts. >I'm new to python so any useful suggestions would be nice. > >Traceback (most recent call last): > File "/opt/viewcvs0.7/lib/viewcvs.py", line 2514, in run_cgi > main() > File "/opt/viewcvs0.7/lib/viewcvs.py", line 2477, in main > view_directory(request) > File "/opt/viewcvs0.7/lib/viewcvs.py", line 1091, in view_directory > fileinfo, alltags = get_logs(full_name, rcs_files, view_tag) > File "/opt/viewcvs0.7/lib/viewcvs.py", line 1035, in get_logs > raise 'error during rlog: '+hex(status) >error during rlog: 0x7f00 I'm getting the identical error after struggling a bit with my freeBSD system. I'll have to go back to 0.5. -- Robin Becker From Peter.Mayne at au1.ibm.com Fri Jul 27 06:32:20 2001 From: Peter.Mayne at au1.ibm.com (Peter Mayne) Date: Fri, 27 Jul 2001 20:32:20 +1000 Subject: Importing from Another Path References: <mailman.995997582.18776.python-list@python.org> <3B5DE390.2F35B36A@accessforall.nl> <mailman.996010131.21356.python-list@python.org> Message-ID: <9k1vpt$e2e$1@news.btv.ibm.com> > Ype Kingma wrote: > > > > sys.path.append("..\\common") > > Actually I just meant that it wasn't portable between Windows and Linux > because I'm using backslashes in the path. Windows is perfectly happy to accept "/" in a filename path. Try sys.path.append('../common') However, this won't help when someone runs the script on an OS that doesn't accept either form. > This works, but a) I don't need sys so importing it seems like a waste, Why not just from sys import path path.append('../common') ? PJDM -- Peter Mayne IBM GSA (but the opinions are mine) Canberra, ACT, Australia This post is covered by Sturgeon's Law. From ljohnson at resgen.com Mon Jul 2 10:45:03 2001 From: ljohnson at resgen.com (Lyle Johnson) Date: Mon, 2 Jul 2001 09:45:03 -0500 Subject: Is Python Dead? References: <MNS%6.355$Xs4.225014@news.pacbell.net> Message-ID: <tk11vfi415gn08@corp.supernews.com> Python's not dead, he's just stunned. Pythons stun easily. From sheila at spamcop.net Tue Jul 3 16:03:57 2001 From: sheila at spamcop.net (Sheila King) Date: Tue, 03 Jul 2001 20:03:57 GMT Subject: Calculus References: <mailman.994185546.12116.python-list@python.org> <ct74kt4mfce48k1hoae9s50fh6nqdq90a5@4ax.com> Message-ID: <6994kto993a0cmsooshv3fhg6v48hilgjf@4ax.com> On Tue, 03 Jul 2001 19:49:49 GMT, Sheila King <sheila at spamcop.net> wrote in comp.lang.python in article <ct74kt4mfce48k1hoae9s50fh6nqdq90a5 at 4ax.com>: :Yes, it seems that Voltaire was making fun of Leibnitz. The full text of :Candide can be found here: :http://eserver.org/fiction/candide.txt Here is an even better link of Candide/Voltaire resources: http://www.ericjonas.com/features/candide/home.asp -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From db3l at fitlinxx.com Thu Jul 26 22:42:41 2001 From: db3l at fitlinxx.com (David Bolen) Date: 26 Jul 2001 22:42:41 -0400 Subject: how on earth do i get a drive list? References: <9jpqlh$phf$1@uranium.btinternet.com> <uwv4vut4n.fsf@ctwd0143.fitlinxx.com> <3B60C000.F15559C0@engcorp.com> Message-ID: <ulmlbum72.fsf@ctwd0143.fitlinxx.com> Peter Hansen <peter at engcorp.com> writes: > I'm curious why mine[**] returns lower-case results while > yours gives upper case. I'm on Windows 98 first release, > running from the DOS prompt. Is even this trivial thing > inconsistent across different versions of the Win32 API?! Probably - I'm on NT4, but also get uppercase under 2K. -- -- 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 guido at python.org Thu Jul 26 09:50:29 2001 From: guido at python.org (Guido van Rossum) Date: Thu, 26 Jul 2001 13:50:29 GMT Subject: [Python-Dev] Re: Static method and class method comments References: <9jn382$lqf$1@license1.unx.sas.com> <3B5F565C.5F452AC5@ActiveState.com> <mailman.996105287.5932.python-list@python.org> Message-ID: <cpy9pb7qar.fsf@cj20424-a.reston1.va.home.com> Skip Montanaro <skip at pobox.com> writes: > Even better yet, why not simply reuse the class keyword in this context: > > class C: > def class foo(x, y): > print "classmethod", x, y I'm not convinced we need new syntax for this, since I think it's a rarely used feature, but here's a syntax proposal due to Jack Jansen that I like better: class C: def foo(class, x, y): "this is a static method" def foo(class c, x, y): "this is a class method" --Guido van Rossum (home page: http://www.python.org/~guido/) From pinard at iro.umontreal.ca Tue Jul 17 21:49:08 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 17 Jul 2001 21:49:08 -0400 Subject: OO misconceptions In-Reply-To: <sI457.17380$sx2.759471@e420r-atl3.usenetserver.com> References: <OFDDCD86D9.4BF13213-ON88256A8C.00600A1B@i2.com> <mailman.995405733.8874.python-list@python.org> <sI457.17380$sx2.759471@e420r-atl3.usenetserver.com> Message-ID: <oqd76zatwr.fsf@lin2.sram.qc.ca> [Steve Holden] > Having been involved with Snobol in a previous incarnation I really > liked Icon. I did like Snobol, and worked a lot with it. It was a quite powerful language. I found it very good for Kleenex programs, that is, those you use once or twice, then throw away! :-) I remember how painful it was to _punch_ Snobol code. And later, many people told me great good about Icon. > Not the fastest language, like Python it ended up interpreting bytecodes. Nevertheless, it was quite fast for what it was doing. The interpreter was relatively small (maybe two or three inches thick, once printed). I'm not sure I remember correctly, but I think it was using a peculiar and unusual representation for internal strings: packing up to 7 characters, then a pointer to the rest, up to 7 characters, then a pointer to the rest, etc. > > I'm still dreaming about an automatic Perl to Python converter. > Suppose a Perl-to-Python conversion were possible (and I'm not suggesting > it isn't): would it be the kind of Python you'd want to use to teach the > language? Surely not. The idea is not to use it to teach Python, but to help quickly migrating already written Perl code to Python. > Given that Perl is ubiquitous, would there really be any point? Besides converting one's programs, the point might be to move over Perl libraries or modules for being able to use them within Python with much simplicity, without having to resort to bigger tools like, say, Minotaur. > I'd rather do something new in Python and keep the trusty old Perl scripts > around, performing day in and day out, than translate them into Python > just to avoid using Perl. I've surely nothing against using Perl per se, as long as I do not much have to maintain the scripts, or otherwise dive in the code. Preventing translation to Python is a way to aggressively dissolve the maintenance fear, but it requires energy. In any case, if a Perl to Python converter produces horrible Python, we would not gain much in this area, and I guess it might be rather difficult producing legible Python from such a conversion. > > If I could swallow that snake [of tokenizing/parsing Perl] , the rest > > would not necessarily be easy, but at least, it would be fun! :-) > Ah, well, if you'd do it for fun I have no objection at all. Oops! Each thing in its proper proportion... There might be some miscommunication, here. There are a lot, really a _lot_ of projects that are more attractive than a Perl to Python converter. It is only that it seems that such a tool, if it existed, would solve a recurrent request on this mailing list, and thus, presumably, a need. Perl probably helped itself by providing sed-to-Perl and awk-to-Perl converters rather soon in its history. Maybe it would be worth for the Python cause to have such tools. Maybe not? -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From sholden at holdenweb.com Mon Jul 9 20:48:13 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 9 Jul 2001 20:48:13 -0400 Subject: Help with reduce(). References: <3ur27.663627$166.13698874@news1.rdc1.bc.home.com> Message-ID: <Sds27.29662$F%5.1909477@e420r-atl2.usenetserver.com> "EricIDLE" <grayson-wilson at home.com> wrote in message news:3ur27.663627$166.13698874 at news1.rdc1.bc.home.com... > Ok well I have ANOTHER problem with one of the examples in my book (By The > Way, "Teach yourself python in 24 hours" is an extremely poorly written book > and I do not reccomend it to any newbies who are just starting off) > any ways the example is as follows. > > n = range(1,11) > def mult(x,y): > return x * y > f = reduce(mult,n) > print f > > I get everything up to reduce. I relize mult() takes the first two numbers > in range N which would be 1, 2 and multiplys them together to get 2... ok > fine im good ... now comes the tricky part!! what does reduce do? Does it > take the whole range and make it into a number (12345678910) then subtract 2 > (the result of the function mult) or what does it do. > The reduce() function takes a function as its first argument and a sequence as its second. There's also an optional third argument, which we can ignore for now. The function is applied to the first two items of the sequence, then to that result and the third item of the sequence, then to that result and the fourth item, and so on until the sequence is exhausted. Here's a loop that might make it a bit clearer: >>> def mult(x, y): ... return x * y ... >>> for i in range(2, 11): ... n = range(1, i) ... print i, ":", reduce(mult, n) ... 2 : 1 3 : 2 4 : 6 5 : 24 6 : 120 7 : 720 8 : 5040 9 : 40320 10 : 362880 Each result extends the value by one multiplication (by one less than I because of the way range works). > And i have another question (not related to first question) > > x = ['Thu', 'Aug', '5', '06:06:27', 'MDT', '1999'] > def strp(x,y): > return x + ' ' + y > r = reduce(strp,x) > print r > > my problem is this line return "x + ' ' + y" what does it return the value > of. I would understand it if it was x + y but the qutation marks are what > throw me off what do they mean? > This is another case where the interactive interpreter is your friend. Try it and see... >>> x = 'one' >>> y = 'two' >>> x + y 'onetwo' >>> x + ' ' + y 'one two' You can see that the second statement constructs a string from *three* values: the string bound to x, the string consisting of a single space, and the string bound to y. So all your second example does is append al lthe strings together, with spaces in between them. It takes 'Thu' and 'Aug" and puts them together with a space in between them, that takes *that* result and '5' and puts them together with a space between them, and ... you probably see the point now. When you give reduce() a thrid argument, it starts with that and the first element of the sequence rather than the first two elements of the sequence, allowing you to put an initial value into the string of function evaluations: >>> x = ['Thu', 'Aug', '5', '06:06:27', 'MDT', '1999'] >>> def strp(x, y): ... return x + ' ' + y ... >>> print reduce(strp, x, "Date is:") Date is: Thu Aug 5 06:06:27 MDT 1999 I hope the book also (though possibly later) points out that a much better way to do the same thing would be x = ['Thu', 'Aug', '5', '06:06:27', 'MDT', '1999'] r = string.join(x, " ") which uses a function from the string module. And, using string methods, you could even abreviate it to: " ".join(x) which tells the string containing a single space to insert itself between the elements of the list, returning the resulting long string. But that probably won't appear until you're about ten hours into the book! Good luck. regards Steve -- http://www.holdenweb.com/ From paulp at ActiveState.com Fri Jul 13 13:46:49 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Fri, 13 Jul 2001 10:46:49 -0700 Subject: Long Live Python! References: <mailman.994969462.27792.python-list@python.org> <hevsktcrnpckttnkgi1arcue5kjjsbrrb5@4ax.com> Message-ID: <3B4F3409.5BFC8954@ActiveState.com> Dennis Roark wrote: > > James_Althoff at i2.com wrote: > > > > > > >What is it about Python that would, in your experience, make it only "good > >for short programs <100 lines". > > > >Jim > > > > Lack of type safety; lack of forcing variable names to be > declared before use. There are many of us out there like James who have used Python to build very large systems. Is your faith in static typing so strong that it overwhelms the clear evidence to the contrary? Python allows you to build larger systems because it allows a looser binding between granular components, it allows more to be done in less code and it makes testing so much easier that the loss of compiler warnings is trivial. > (In a long program, how hard it is to > find a bug that is simply the misspelling of a variable!) No, it isn't hard to find a misspelled variable in a program. That's what unit tests (and, ideally, code coverage tools) are for. If you don't have good unit tests, it is going to be very hard to write robust code in any language. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From zhough at 263.net Thu Jul 26 02:04:16 2001 From: zhough at 263.net (Zhou, Ganhong) Date: Thu, 26 Jul 2001 06:04:16 +0000 (UTC) Subject: The error of building Python on HP UX Message-ID: <9jobt0$nh7$1@mail.cn99.com> When I run make to build the python. I met with some problems. The gcc version is as following: Reading specs from /usr/local/cygnus/bin/../lib/gcc-lib/hppa2.0w-hp- hpux11.00/2.9-hppa-000310/specs gcc version 2.9-hppa-000310 The enviroment is HP-UX B.11.00 B 9000/800 The error information is as following: gcc -Wl,-E -Wl,+s -Wl,+b/home/zhough/bin/python/lib/python2.1/lib-dynload - o python \ Modules/python.o \ libpython2.1.a -lnsl -ldld -ldl -lpthread -lm /usr/local/cygnus/bin/../lib/gcc-lib/hppa2.0w-hp-hpux11.00/2.9-hppa- 000310/../../../../hppa2.0w-hp-hpux11.00/bin/ld: cannot open +s: No such file or directory collect2: ld returned 1 exit status I look up the help information of gcc, and found that '+s' is not a option for linker. Why the Makefile generated by configure script contains this option? Has anybody met with the problem? Later I use the following options to run configure: configure -without-gcc -without-cxx It's ok for building. But "make install" report some errors. This line is the source for error: $(INSTALL) -d -m $(DIRMODE) $$i; INSTALL=/opt/imake/bin/install, but I found that the install script has no -d option. How can I deal with it? From paulp at ActiveState.com Sun Jul 1 16:11:56 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sun, 01 Jul 2001 13:11:56 -0700 Subject: Is this a true statement: Part II References: <9hiifr$sjs$1@taliesin.netcom.net.uk> <mailman.993843346.4433.python-list@python.org> <fFD%6.19908$zT1.1099537@e420r-atl3.usenetserver.com> Message-ID: <3B3F840C.A4652564@ActiveState.com> Kragen Sitaker wrote: > >... > >You could write an operating system that could only be directly > >programmed in Python. > > I'm not sure how. Nobody has yet come up with an operating system that > could only be directly programmed in C, or Lisp, or Algol, or Java, > despite implementing operating systems in all four. I think some of > the Burroughs machines required special god privileges to run the > assembler, but there was still an assembler. The word "directly" is pretty vague but the point is that you choose one language's runtime model as the model supported by the APIs. Then every other language has to translate into their model. So on some operating systems, strings are null-terminated and have no length pointer. Programming against those operating systems "directly" from Python is impossible. Someone needs to put in PyString_FromString and PyString_AsString calls. Similarly, if you made an operating system that exposed all objects as PyObjects then C++ programmers would have to translate them into native C types to do meaningful computation. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From vvainio at karhu.tp.spt.fi Fri Jul 6 01:59:10 2001 From: vvainio at karhu.tp.spt.fi (Ville Vainio) Date: 06 Jul 2001 08:59:10 +0300 Subject: Tracebacks & bug-squashing (was Re: [TO]What's the big deal with EJB? [Re: PEP scepticism] References: <mailman.993747643.21070.python-list@python.org> <9hfqb5$dsllb$3@ID-89274.news.dfncis.de> <3dhex01n1m.fsf@ute.cnri.reston.va.us> <etdk81vduw0.fsf_-_@lola-granola.mit.edu> <3d8zib16g7.fsf@ute.cnri.reston.va.us> <Xns90D3694AD53FBbeablebeable@30.146.28.98> <yoxd77fh4pr.fsf@karhu.tp.spt.fi> <9i201402voe@enews1.newsguy.com> <mailman.994350172.18735.python-list@python.org> <9i2jva23cm@enews2.newsguy.com> Message-ID: <yox1ynu4mz5.fsf_-_@karhu.tp.spt.fi> "Alex Martelli" <aleaxit at yahoo.com> writes: > Python, and for those (small extensions) it seems I'm about 4 > times more productive in Python than in C++. I have no personal And even more important than raw development-phase productivity is how quickly bugs that surface in a production environment are fixed. I would assume that pythons traceback dump would give it a 100x speed boost compared to C++'s protection faults... after a month of running, and with not-fine-grained-enough log entries. Automatic traceback is god. With C++ (VC++ & windows), I don't even get an automatic description of the exception thrown. With quake & such obvious C++ projects, I could hardly care less but in a mission critical environment... -- 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 aahz at panix.com Wed Jul 11 11:16:52 2001 From: aahz at panix.com (Aahz Maruch) Date: 11 Jul 2001 08:16:52 -0700 Subject: An unspeakable act References: <ib0lktkade28a9ci198b1jpn9jejqjbtlj@4ax.com> <994786203.24889.0.nnrp-10.d4e48e5c@news.demon.co.uk> Message-ID: <9ihql4$ah7$1@panix2.panix.com> In article <994786203.24889.0.nnrp-10.d4e48e5c at news.demon.co.uk>, Jeremy Henty <jeremy at chaos.org.uk> wrote: >In article <ib0lktkade28a9ci198b1jpn9jejqjbtlj at 4ax.com>, > Daniel Klein <danielk at aracnet.com> writes: >> >>This person says that dynamically typed languages produce bug-ridden >>programs > >Then this person will be distressed to learn that Java is effectively >dynamically typed! > >See http://www.pragmaticprogrammer.com/cgi-local/pragprog?JavaIsUntyped ! !!! That is seriously interesting. -- --- 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 "How come we choose from just two people for President but more than 50 for Miss America?" --AEN From rnd at onego.ru Wed Jul 11 08:39:50 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 11 Jul 2001 16:39:50 +0400 (MSD) Subject: Bug in __imul__ In-Reply-To: <9ihg33$irjha$1@ID-11957.news.dfncis.de> Message-ID: <Pine.LNX.4.21.BCL.0107111635570.6523-100000@suzi.com.onego.ru> On Wed, 11 Jul 2001, Emile van Sebille wrote: > Does it bother anyone that > > a *= 3 + 4 > > returns a different value from > > a = a * 3 + 4 > > ?? There is a joke about americans: they were confused that Excel give different result from pocket calculator: [5] [+] [3] [*] [4] [=] | 32 | is different from 5+3*4 | 17 | as calculated by Excel. Where is the bug? Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From FenZhao at mit.edu Wed Jul 18 14:55:39 2001 From: FenZhao at mit.edu (Man Vehicle Laboratory) Date: Wed, 18 Jul 2001 14:55:39 -0400 Subject: sys.argv not found References: <3B55962C.63F7E2EF@mit.edu> <bkh57.21065$PF1.1027936@e420r-atl2.usenetserver.com> <3B55B2C2.74A8FB3D@mit.edu> <HOi57.20158$sx2.1076301@e420r-atl3.usenetserver.com> Message-ID: <3B55DBAB.EB900433@mit.edu> Fiddling with the script some more, it seems like Vrut somehow runs the script again when vrut.go() is called. I placed print statements all throughout the code, which shows up in the interactive window until vrut.go() is called. Then in the vrut window, it gives the Attribute Error. I'm going to have to muck through the vrut code itself to see what's going on. Thanks for everyone's help! Fen Steve Holden wrote: > "Man Vehicle Laboratory" <FenZhao at mit.edu> wrote in message > news:3B55B2C2.74A8FB3D at mit.edu... > > > > I've tried putting a print statement right after I import sys. I have the > same > > error as before: > > > > > > > **************************************************************************** > ** > > > > * WINVRUT 2.4a Copyright 1995-2001 University of California, Santa > > Barbara * > > * Massachusetts Institute of > > Technology * > > > **************************************************************************** > ** > > > > VRUT 2.4a > > voicekey Voicekey 0.9 > > serialthrustmaster Serial thrustmaster 1.0 > > avstu AvatarStudio 1.1 > > Traceback (most recent call last): > > File "<string>", line 1, in ? > > File "N:\FenZhao\E3_sid_data\e3_sid_data2.py", line 61, in ? > > print sys.argv > > AttributeError: argv > > > Well, this traceback looks very suspicious. I assume that the file you are > taking about is indeed e3_sid_data2.py? Maybe not ... it is quite weird > that sys appears to have no argv attribute. I can only conclude that perhaps > some other portion of your code assigns to sys? But you say below this is > NOT the case. Aaarrgghh... > > > The error I get from vrut is from my code looking at argv, not vrut (error > > message w/out print statement: > > > > Traceback (most recent call last): > > File "<string>", line 1, in ? > > File "N:\FenZhao\E3_sid_data\e3_sid_data2.py", line 62, in ? > > mode=string.atoi(sys.argv[1]) > > AttributeError: argv > > > The first line of the tracebacks implies that some code is being executed > from a strng variable. If none of your code does anything like that (uses > eval/exec, let's say) then the obvious suspect is the vrut module... > > Your module doesn't by any chance import itself, does it? > > > So whatever my first operation is dealing with sys.argv, there's an > attribute > > error with argv) > > > > What confuses me is that this error is displayed in the VRUT window; VRUT > opens > > two windows, a display window that shows the 3D VR scene, and a text > window that > > will display print statements and error messages from python. Logically, > if > > argv can't be found, an error message will end the program before vrut > ever gets > > started. > > > Oh. Is it possible that importing the vrut module modifies > sys.stdout/sys.stderr, leaving something weird in place before the vrut.go() > call creates the windows? > > > I've also tried importing vrut after looking at sys.argv in case vrut does > > something funky in it's initialization/import. Same problem. Yet > commenting > > out the vrut.go() command, and the sys.argv is fine. > > OK, so what you are telling us is that the presence of a function call you > have not yet executed is somehow affecting the sys module's namespace. That > sounds pretty funky to me, and frankly I'm beginning to wonder whether you > have programmed a time machine :-) > > > > > --Fen > > > > PS. I hope this helps: all of my code up to the call to vrut (minus > > comments)... there's not much there, can't figure out what's making it > work > > improperly. None of the modules that I wrote and imported do anything > with sys > > > I can understand your confusion. I hope the rest of the list will feel free > to dive in with suggestions about what's wrong! :-0 > > > > Put "import sys; print sys.argv" here to make sure your program does indeed > see the correct value for the argument list. > > > import vrut > > Put "import sys; print sys.argv" here too, to verify that the import > statement makes no changes to sys. > If you see output from the first print bu not the second then the module is > indeed doing something funky. > > > import sid > > > > > > import string > > import math > > import time > > > > > > import speeds > > import e3_dataAn > > import sys > > > > mode=string.atoi(sys.argv[1]) > > ARGFILE_stim=sys.argv[2] > > ARGFILE_calib=sys.argv[3] > > OUTFILE=sys.argv[4] > > SUMFILE=sys.argv[5] > > sidOutfile=sys.argv[6] > > VECTION_DURATION=string.atoi(sys.argv[7]) > > path=sys.argv[8] > > > > vrut.go(vrut.NICE) > > > > > > > > Steve Holden wrote: > > [ various apparently irrelevant things ] > > I'm currently betting that a recursive import is somehow messing things up. > Otherwise I'm a little stumped, and we'll have to proceed with debugging > step by step. > > regards > Steve > -- > http://www.holdenweb.com/ From fdrake at acm.org Mon Jul 23 18:04:50 2001 From: fdrake at acm.org (Fred L. Drake) Date: Mon, 23 Jul 2001 18:04:50 -0400 (EDT) Subject: [development doc updates] Message-ID: <20010723220450.33D4428932@beowolf.digicool.com> The development version of the documentation has been updated: http://python.sourceforge.net/devel-docs/ Various minor updates. From bsass at freenet.edmonton.ab.ca Sat Jul 28 14:07:30 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Sat, 28 Jul 2001 12:07:30 -0600 (MDT) Subject: proposed language change to int/int==float (was: PEP0238 lament) Message-ID: <Pine.LNX.4.33.0107281207030.16003-100000@bms> On Fri, 27 Jul 2001, Tim Peters wrote: <...> > Scheme has literal notations allowing to explictly say that an integer > literal is inexact, and that a floating literal is exact, when appropriate. This is the first scheme I've noticed mentioned that recognizes the difference between a number and the representation of a number. Does `float' having a hardware implementation elevate it to being a number? Does it matter? > exactness-is-neither-a-type-nor-an-operation-property-ly y'rs - tim and-a-representation-alone-is-not-know-to-be-exact-ly y'rs - Bruce From sdm7g at Virginia.EDU Fri Jul 20 13:47:07 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Fri, 20 Jul 2001 13:47:07 -0400 (EDT) Subject: List Question In-Reply-To: <tlgptk32ve8o27@corp.supernews.co.uk> Message-ID: <Pine.NXT.4.21.0107201337300.259-100000@localhost.virginia.edu> The new list comprehensions work nice for that: >>> a = [ [0]*3 for x in range(3) ] >>> a [[0, 0, 0], [0, 0, 0], [0, 0, 0]] >>> a[1][1] = 9999 >>> a [[0, 0, 0], [0, 9999, 0], [0, 0, 0]] You can also use a loop or a lambda: >>> l = [] >>> for i in range(3): ... l.append( [0]*3 ) ... >>> map( lambda i: [0]*3, range(3) ) The essential thing is that the expression that creates the inner list ([0]*3) gets evaluated multiple times, not just replicated. Replicating the inner list with "*" : >>> x = [[0]*3]*3 >>> x[1][1] = 9999 >>> x [[0, 9999, 0], [0, 9999, 0], [0, 9999, 0]] is what gives you multiple copies of the SAME list. -- sdm From skip at pobox.com Sat Jul 7 14:00:14 2001 From: skip at pobox.com (Skip Montanaro) Date: Sat, 7 Jul 2001 13:00:14 -0500 Subject: Comment on PEP-0238 In-Reply-To: <9ngektgqnrl17er73ukukqids95p5158dp@4ax.com> References: <mailman.994427714.26169.python-list@python.org> <cpsngaja4g.fsf@cj20424-a.reston1.va.home.com> <FFv17.1178$Y6.656565@news1.rdc2.pa.home.com> <cpelrskgrr.fsf@cj20424-a.reston1.va.home.com> <9i7a7k$h9ks6$1@ID-11957.news.dfncis.de> <9ngektgqnrl17er73ukukqids95p5158dp@4ax.com> Message-ID: <15175.20014.876425.627044@beluga.mojam.com> Guido> (Hm. For various reasons I'm very tempted to introduce 'yield' Guido> as a new keyword without warnings or future statements in Python Guido> 2.2, so maybe I should bite the bullet and add 'div' as well...) C//> If one is going to add keywords to a language, I suggest that a C//> list of possible future keywords -- even ones that aren't planned C//> on being supported any time soon -- be reserved at the same time. And that warnings be issued for their use for at least one version. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From grante at visi.com Thu Jul 12 11:42:30 2001 From: grante at visi.com (Grant Edwards) Date: Thu, 12 Jul 2001 15:42:30 GMT Subject: How popular is Python, anyway? (was: Long Live Python!) References: <E566B020833BD311B6610008C791A39705CA5230@il93exm04.css.mot.com> <mailman.994804336.23495.python-list@python.org> <slrn9koofo.mjk.philh@comuno.freeserve.co.uk> <slrn9kpr3e.527.sill@sill.silmarill.org> Message-ID: <Gzj37.13006$B7.2564502@ruti.visi.com> In article <slrn9kpr3e.527.sill at sill.silmarill.org>, Rainy wrote: >I doubt I'll find a job using python any time soon. :/ Probably not if you wait around for management to tell you to start using it. I use Python on my job because I decided to. I'm probably luckier than most when it comes to being able to choose my tools. -- Grant Edwards grante Yow! Is this my STOP?? at visi.com From JamesL at Lugoj.Com Wed Jul 25 23:42:18 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Wed, 25 Jul 2001 20:42:18 -0700 Subject: [Q]pmw.selectiondialog References: <5PL77.884$A3.10100@vixen.cso.uiuc.edu> Message-ID: <3B5F919A.CBDE31DB@Lugoj.Com> Seung-won Hwang wrote: > I'm looking for a widget just like selectiondialog but allows multiple > selection.. Is there any widget doing the functionality I'm looking for? I'd > appreciate your answer very much. You mean select multiple rows? The Pmw SelectionDialog widget can be made to support this. You need to be able to get access to the ListBox widget inside it and set the configuration variable selectmode to MULTIPLE. Something like: >>> from Tkinter import * >>> import Pmw >>> root = Tk() >>> s = Pmw.SelectionDialog(root) >>> slist = s.component("scrolledlist") >>> slist.setlist(["a1", "b2", "c3"]) >>> slist.configure(listbox_selectmode = MULTIPLE) From bernhard at intevation.de Mon Jul 9 20:01:35 2001 From: bernhard at intevation.de (Bernhard Reiter) Date: 10 Jul 2001 00:01:35 GMT Subject: PEP scepticism References: <mailman.993747643.21070.python-list@python.org> <9hfqb5$dsllb$3@ID-89274.news.dfncis.de> <3dhex01n1m.fsf@ute.cnri.reston.va.us> <cphewzlbis.fsf@cj20424-a.reston1.va.home.com> <9hlcp4$eiphi$2@ID-89274.news.dfncis.de> <cppubkkbhf.fsf@cj20424-a.reston1.va.home.com> <9hqc3i$f1dia$2@ID-89274.news.dfncis.de> <cpith6l3ip.fsf@cj20424-a.reston1.va.home.com> Message-ID: <9idgkv$i7i92$1@ID-89274.news.dfncis.de> In article <cpith6l3ip.fsf at cj20424-a.reston1.va.home.com>, Guido van Rossum <guido at python.org> writes: > [Bernhard] >> What I've noticed is that I believe that the majority of people >> contributing to the decisions are not the average python programmer >> and therefore more likely to be in favour of things which might >> be unnecessary for the average user. I thought this was valuable to >> share so you can keep it in mind. > Well duh! > If we left the design of programming languages to the *average* > programmer, the field would never make progress. This is an argument I often hear against usability tests for webpages. You should not leave the decision to them, but make your decision based on what they need and can use to make good code. This is sometimes hard to find out and I know that there is no practical solution to this problem. > Please give us language designers some credit. > We're programmers and we know what programmers need! I do. (And just because I do not participate very actively in Python's programming design does not mean I know nothing about designing programming languages.) > This whole thread has disappointed me. Fortunatly I did not produce most of it. :) >> Apard from that I am grateful to the whole python development team >> and the community for its good work. > Thanks. May-you-design-python-in-peace-ly-yours, Bernhard From joonas at olen.to Mon Jul 16 06:21:00 2001 From: joonas at olen.to (Joonas Paalasmaa) Date: Mon, 16 Jul 2001 10:21:00 GMT Subject: command substitution References: <newscache$vy7kgg$wzn$1@news.freegates.be> Message-ID: <3B52C0AD.93608611@olen.to> Raphael Bauduin wrote: > > Hi! > > I was looking for a solution like in bash, which let you put the standard > output of a command in a variable(in bash, you can do it like OUT=`ls` or > OUT=$(ls) ). > > If you have another way to take the standard output of a command and put it > in a variable, it would be helpfull too. out = popen("ls", "r").read() And if you want a list of files. out = popen("ls", "r").readlines() From junkster at rochester.rr.com Sun Jul 1 10:15:14 2001 From: junkster at rochester.rr.com (Benjamin Schollnick) Date: Sun, 01 Jul 2001 14:15:14 GMT Subject: Odd problem with converting string to Hex? Message-ID: <junkster-AB6FEA.10163501072001@typhoon1-0.nyroc.rr.com> Folks, This is odd.... or at least I think it is.... Using Python v2.1.... Here's a snippet of the data: ('.1.3.6.1.2.1.2.2.1.6.2', '\x00\x90\x83H\x11\x0f'), ('.1.3.6.1.2.1.2.2.1.6.1', '\x00\x90\x83H\x11\x0f'), ('.1.3.6.1.2.1.2.2.1.2.4', 'RF Upstream Interface') I've tried using: eval (data[1]) hex (data[1]) str(data[1]) What gets returned is: Unknown - Mac? ---> ??H Hex: Long: Which os definetly not what I'm looking for.... I'm attempting to decode this in pure hexadecimal... I suspect it's due to the "\x" in the string, but I can't pull up the documentation, since when I tried I wasn't getting a response from python.org..... Conceptually I'm trying to output it, similiar to: 00-90-83-11-0f Assuming I'm reading the returned data properly. - Benjamin From whats_really_hot at hotmail.com Fri Jul 6 08:07:47 2001 From: whats_really_hot at hotmail.com (whats_really_hot) Date: Fri, 6 Jul 2001 15:07:47 +0300 Subject: any books for python for downloading? References: <993939668.727430@athnrd02.forthnet.gr> <0yX%6.1611$h45.10769@news.uk.colt.net> Message-ID: <994421184.483900@athnrd02.forthnet.gr> yea.great sites but they don't have any books for downloading, only for web reading and this requires time -internet time, which is unfortunately expensive. so, any other proposals for sites that contain text about python tutoring? every recommendation is welcome! thanks in advance! From michael.g.abbott at ntlworld.com Wed Jul 25 09:24:05 2001 From: michael.g.abbott at ntlworld.com (Michael Abbott) Date: Wed, 25 Jul 2001 13:24:05 GMT Subject: PEP0238 lament References: <mailman.995814276.15005.python-list@python.org> <cp66clexxt.fsf@cj20424-a.reston1.va.home.com> <9jhbfj$79s$1@pea.uk.research.att.com> <mailman.995930743.17137.python-list@python.org> <9jjfts$9k2$1@pea.uk.research.att.com> <3B5DBAC8.4B89E271@alcyone.com> <Xns90E959B81DE49duncanrcpcouk@127.0.0.1> Message-ID: <Xns90E991EA4D715michaelrcpcouk@194.168.222.9> Duncan Booth <duncan at NOSPAMrcp.co.uk> wrote in news:Xns90E959B81DE49duncanrcpcouk at 127.0.0.1: > When it comes down to it, real beginners (5 to 7 years old?) will have > been told that if you divide 9 by 2 you get 4 with 1 left over. Which > is EXACTLY what you get at present. Floating point is a MUCH more > sophisticated concept which, as has been shown repeatedly on this > newsgroup, is hard even for most programming professionals. > Hear hear! Floating point isn't even associative; there seems to be a real misconception that by making all results floating point then all numerical problems will magically vanish. Far from it. And I'm afraid that going to rational numbers (as has been suggested in a number of places) only puts the problem off a little. From kirschh at lionbioscience.com Wed Jul 25 03:55:56 2001 From: kirschh at lionbioscience.com (Harald Kirsch) Date: 25 Jul 2001 09:55:56 +0200 Subject: size of a file References: <3b5dd418_8@news.newsgroups.com> <eppstein-223C39.13240524072001@news.service.uci.edu> Message-ID: <yv2hew14f3n.fsf@lionsp093.lion-ag.de> David Eppstein <eppstein at ics.uci.edu> writes: > In article <3b5dd418_8 at news.newsgroups.com>, > "Janos Blazi" <jblazi at hotmail.com> wrote: > > > How can I find out the length of a file. I have a descriptor fd of the file > > (I am using the os module). > > When I wanted to do this recently, I used > > f = open(fn) # open file, fn is a string containing the filename > f.seek(0,2) # go to end of file > fsize = f.tell() > f.close() You probably might want to check if fn denotes a device file or named pipe in which case this will fail. Harald. -- ----------------+------------------------------------------------------ Harald Kirsch | kirschh at lionbioscience.com | "How old is the epsilon?" LION bioscience | +49 6221 4038 172 | -- Paul Erd?s *** Please do not send me copies of your posts. *** From skip at pobox.com Wed Jul 4 05:36:15 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 4 Jul 2001 04:36:15 -0500 Subject: tuple2csv snipplet In-Reply-To: <280f26fb.0107032303.64df7a48@posting.google.com> References: <280f26fb.0107032303.64df7a48@posting.google.com> Message-ID: <15170.58255.665757.136667@beluga.mojam.com> Shakeeb> ... convert tuples (generated from an SQL query) into comma Shakeeb> separated values.... is there a better way to do this? Without reimplementing what you and others have already done, I suggest that instead of stringifying the tuple and using regular expressions to convert the fields that you consider looping over the tuple and constructing a list of values that contains the appropriate strings, which you can then string.join with commas: def tuple2csv(t): import types newt = [] for elt in t: if elt is None: newt.append("") continue if (isinstance(elt, types.IntType) or isinstance(elt, types.FloatType)): newt.append(str(elt)) continue if isinstance(elt, types.StringType): ... do the more complex string quote escaping, etc ... return ",".join(newt) -- Skip Montanaro (skip at pobox.com) (847)971-7098 From joonas.paalasmaa at nokia.com Thu Jul 12 03:51:24 2001 From: joonas.paalasmaa at nokia.com (Joonas Paalasmaa) Date: Thu, 12 Jul 2001 07:51:24 GMT Subject: connecting to Oracle database References: <mailman.994917679.17455.python-list@python.org> Message-ID: <3B4D5795.CD6001E1@nokia.com> reddykkk at yahoo.com wrote: > > hi all, i am learning Pyhton now. I am facing problems in connecting > to Oracle database. plz guid me how to start with. More information about databases supported by Python can be found at http://www.python.org/topics/database/modules.html I think, that mxODBC can do the job. - Joonas From philh at comuno.freeserve.co.uk Wed Jul 18 08:29:08 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Wed, 18 Jul 2001 13:29:08 +0100 Subject: Language change and code breaks References: <mailman.994958301.16016.python-list@python.org> <3B4E586D.35460F68@engcorp.com> <cpelrk39t9.fsf@cj20424-a.reston1.va.home.com> <3B4FAC17.48377423@engcorp.com> <cp7kxb351p.fsf@cj20424-a.reston1.va.home.com> <slrn9l0sc8.2nh.philh@comuno.freeserve.co.uk> <cp1ynf3da9.fsf@cj20424-a.reston1.va.home.com> Message-ID: <slrn9lb08k.v3.philh@comuno.freeserve.co.uk> On Tue, 17 Jul 2001 13:13:36 GMT, Guido van Rossum <guido at python.org> wrote: >philh at comuno.freeserve.co.uk (phil hunt) writes: > >> >I also don't want to fork the code base. >> >> Does that imply that you sare no longer interested in making >> radical changes to Python, such as case-insensitive identifiers >> mentioned in CP4E? > >I still have the same end goal, but I believe there must be a way to >obtain it without too much disturbance. Hmmm. I'm not sure about that, it feels to me like its opening up a can of worms. >Case-sensitivity, for >example, may be a tool feature rather than a language feature, or it >may be a user option or a langage-level choice. Say I write a module in the current (case-sensitive) Python. Then you write one in case-insensitive python. Your code calls one of my routines or variables; how does it get the case-sensitivity right? Does it do so at run time or compile time? Compile time might be difficult, for example if I have an object that dynamically creates instance variables for itself. What if I have an object ob with both ob.variable and ob.VARIABLE? What does your code use when it resolves philsModule.ob.variable? Case matching up at run-time is likely to make the language slower. (One way I might consider fixing it would be to have the new language explicitly say when it is dealing with old-python modules and be case sensitive there; consider C++'s name mangling and the extern keyword they used to link to C code.) > (Not that I've >figured out exactly how to do this, but TeachScheme makes this an >option.) Note that case-sensitivity is also controversial: the Alice >folks found it a problem, but the VPython folks have not confirmed >this (while they did confirm the integer division trap). Who are the Alice people? -- #===== Philip Hunt == philh at comuno.freeserve.co.uk ======# Herbivore: effort-free public key encryption. See: <http://www.vision25.demon.co.uk/oss/herbivore/intro.html> ** First software release coming soon! ** From oconnor at bioreason.com Tue Jul 31 11:23:33 2001 From: oconnor at bioreason.com (Jay O'Connor) Date: Tue, 31 Jul 2001 09:23:33 -0600 Subject: 2.2 features References: <mailman.996258542.15795.python-list@python.org> <cpwv4u16rx.fsf@cj20424-a.reston1.va.home.com> <mailman.996270412.11895.python-list@python.org> <cpofq524lr.fsf@cj20424-a.reston1.va.home.com> <slrn9m61bs.atb.quinn@retch.ugcs.caltech.edu> Message-ID: <3B66CD75.A66DF2F2@bioreason.com> Quinn Dunkan wrote: > > On Sat, 28 Jul 2001 02:02:40 GMT, Guido van Rossum <guido at python.org> wrote: > >Kirill Simonov <kirill at xyz.donetsk.ua> writes: > > > >> It would be nice to have 'in' operator for types: > >> > >> assert (num in int) > >> assert (msg in str) > > This implies (at least to me) that 'in' would be a general shorthand for > 'isinstance'. But then I would sort of expect '3 in [1,2,3,4]' to behave like > 'isinstance(3, [1,2,3,4])' > > Or you could just say that type objects implement a __contains__ method that > does an isinstance. But if classes and types are unified, that would get in > the way of classes that define __contains__. You'd have to think of it as a > class method (or a metaclass method), which is in a different namespace than > instance methods. Or something. > > It's a nice syntax, but it seems a bit confusing to me. One thing to think about is the Smalltalk distinction of #isMemberOf: versus #isKindof:: One indicates that x is indeed an instance of the class Y; the other indicates that x is an instance of y or any subclass of y | c | c := OrderedCollection new. c isMemberOf: OrderedCollection. => returns true c isMemeberOf: Collection. ==> returns false c isKindOf: Collection. => returns true because OrderedCollection is a subclass of Collection In Python, I could see use for the same thing.... c = Car() c.isMemberOf (Car) => returns 1 c.isMemberOf (Vehicle) => returns 0 c.isKindOf (Car) => returns 1 This may not work as well for primitives as there is no real inheritance. IntType and FloatType are not subclasses of a generic NumberType so the following wouldn't work def doSomething (aValue): assert (aValue.isKindOf(types.NumberType)) which would be very useful for asserting that aValue is any numberic type ( I can think of the use of ListType, TupleTyupe and DictType all being a SequenceType as well) If you like the x in y syntax, than maybe that could be expanded to include "of" as well c = Car() c in Car => returns 1 c in Vehicle => returns 0 c of Vehicle => returns 1 Take care, Jay O'Connor oconnor at bioreason.com From wtanksle at dolphin.openprojects.net Wed Jul 25 15:14:10 2001 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Wed, 25 Jul 2001 19:14:10 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <eppstein-03540D.13070222072001@news.service.uci.edu> <LNBBLJKPBEHFEDALKOLCOECNLAAA.tim.one@home.com> <mailman.995899647.346.python-list@python.org> <tclolt053o18f8q0ntb7n4aggitdkmeg4h@4ax.com> <Io_67.23543$B7.3779351@ruti.visi.com> <slrn9lp2m5.vp.Gareth.McCaughan@g.local> <p56plt8q4rs3bgcqbepk61q2r3g0tr2vhe@4ax.com> <slrn9ls3ae.2fm.Gareth.McCaughan@g.local> <cpitghbq05.fsf@cj20424-a.reston1.va.home.com> <9jlo4v$rhbl$1@sky.inp.nsk.su> <mailman.996073073.17868.python-list@python.org> Message-ID: <slrn9lu6k1.4ua.wtanksle@dolphin.openprojects.net> On Wed, 25 Jul 2001 10:55:57 -0400, Frank "Cookie Jar" Lomax wrote: > > To many of us, programmers, 1/2 is 0 with 1 as a reminder:) > > We are like children, and any child will say _for sure_ that 1 > > cookie for two children means one cookie for 1 child and 0 > > cookies for another:) >No, 1 cookie for 2 children always means no cookies for either child, >lots of crumbs for the dog to lick up, and years of therapy for the >entire family. _Exactly_ like floating point! Look at what it did to poor Tim. -- -William "Billy" Tanksley From 9nick9m at alum.mit.edu Wed Jul 18 16:24:35 2001 From: 9nick9m at alum.mit.edu (Nick Mathewson) Date: Wed, 18 Jul 2001 20:24:35 GMT Subject: What is happening with this program References: <mailman.995478810.30770.python-list@python.org> Message-ID: <slrn9lbs78.2fd.9nick9m@localhost.localdomain> On Wed, 18 Jul 2001 12:52:08 -0500, Kemp Randy-W18971 <Randy.L.Kemp at motorola.com> wrote: >#!/usr2/ActivePython-2.1/bin/python >import string, os >import ftplib >import glob >filename = os.path.join("usr2", "websoftware", "oraclebackupfiles", "pdsweb") This value above is never used. >listname = string.join( > os.listdir('/usr2/websoftware/oraclebackupfiles/pdsweb'),',') Neither is this one, unless the print below is intentional. >print listname >ftp = ftplib.FTP('999.999.999.999') #specify host >ftp.connect() # defaults to port 21, check docs for further options >ftp.login(user='fudd',passwd='elmer',acct='looney') # user info >ftp.cwd('/usr2/pdsweb/oraclebackupfiles2/pdsweb/') > >for filename in glob.glob('/usr2/websoftware/oraclebackupfiles/pdsweb/*'): It looks like you could use "glob.glob(filename)" > name = string.split(filename, '\\')[-1] This line above is your error: you're splitting on '\\' (which windows uses as a directory separator). Unix uses '/'. Instead, try: name = os.path.split(filename)[1] > print "filename = " + 'filename' + "\n" > print "name = " + 'name' + "\n" These lines don't do anything useful. Did you mean to use `backquotes`? Also, the "\n" is probably unnecessary, unless you mean to generate an extra newline here. > ftp.storbinary("STOR " + name, open(filename, 'rb')) >ftp.retrlines('LIST') # list directory contents >ftp.quit() Suggested rewrite: -------------------------------------------------- #!/usr2/ActivePython-2.1/bin/python import string, os, ftplib, glob localpath = os.path.join("usr2", "websoftware", "oraclebackupfiles", "pdsweb") ftppath = '/usr2/pdsweb/oraclebackupfiles2/pdsweb/' localfiles = os.listdir(localpath) #print localfiles ftp = ftplib.FTP('999.999.999.999') #specify host ftp.connect() # defaults to port 21, check docs for further options ftp.login(user='fudd',passwd='elmer',acct='looney') # user info ftp.cwd('/usr2/pdsweb/oraclebackupfiles2/pdsweb/') for localfile in localfiles: fullname = os.path.join(localpath, localfile) ftp.storbinary("STOR " + localfile, open(fullname, 'rb')) ftp.retrlines('LIST') # list directory contents ftp.quit() -------------------------------------------------- HTH, -- Nick Mathewson <9 nick 9 m at alum dot mit dot edu> Remove 9's to respond. No spam. From tundra at tundraware.com Tue Jul 3 14:00:07 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: Tue, 03 Jul 2001 18:00:07 GMT Subject: Calculus References: <mailman.994172346.18277.python-list@python.org> Message-ID: <3B42067B.2BC73E7A@tundraware.com> Kemp Randy-W18971 wrote: > > Wait a minute! Wasn't Gottfried Wilhelm Leibniz one of the founders of Calculus? And wasn't he also a philosopher, who with his world of monads, said that this is the best of all possible worlds? And didn't the gentlemen direct his question to the Python group? In essence, he is following the philosophy of Leibniz. I thought it was Voltaire who said we live in the best of all possible world (in 'Candide')... -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From rnd at onego.ru Tue Jul 3 01:12:51 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 3 Jul 2001 09:12:51 +0400 (MSD) Subject: newbie apply() question In-Reply-To: <C_b07.778$ei5.255138@typhoon2.gnilink.net> Message-ID: <Pine.LNX.4.21.BCL.0107030911560.720-100000@suzi.com.onego.ru> On Tue, 3 Jul 2001, Aaron Edsinger wrote: > hi. i'm stumped on something that seems easy. why doesn't this work: import sys > x=4 > apply(sys.stdout.write,x) #fails > apply(sys.stdout.write,(x,)) #fails > > is there a way to make this work? probably, x must be a string. Then variant 2 will work fine. > thanks, > aaron > Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From rnd at onego.ru Fri Jul 6 14:08:55 2001 From: rnd at onego.ru (Roman Suzi) Date: Fri, 6 Jul 2001 22:08:55 +0400 (MSD) Subject: Short form of file names In-Reply-To: <39916145.20010707010418@tomsk.net> Message-ID: <Pine.LNX.4.30.0107062205310.15616-100000@rnd.onego.ru> On Sat, 7 Jul 2001, Mikhail Astafiev wrote: >[Env: Win2k, Win98, Python 1.52] > >Hi! > >Is there some Python module for converting Windows long paths to short >form, i.e. 8.3? os.path.normpath() does not do this.. Is there any standard for doing such conversion? AFAIK, there is no way to convert individual files to 8.3, only whole directories of them, because otherwise there will inevitable be name conflicts. Programs such as mtools or cdrecord have some algorithms. It's not too hard to rewrite them in Python >Thanks in advance, >Mikhail. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Friday, July 06, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ ""Stupid" is a boundless concept." _/ From bokr at accessone.com Sun Jul 8 17:28:45 2001 From: bokr at accessone.com (Bengt Richter) Date: Sun, 08 Jul 2001 21:28:45 GMT Subject: Tkinter and printf in C ... References: <3B455B5D.544A2EF5@larc.ee.nthu.edu.tw> <9Jh17.38316$he.2456932@e420r-atl1.usenetserver.com> <3B48076E.B16ACF5B@larc.ee.nthu.edu.tw> Message-ID: <3b48ccc7.1398139267@wa.news.verio.net> On Sun, 08 Jul 2001 15:10:38 +0800, Chyr-Pyng Su <cpsu at larc.ee.nthu.edu.tw> wrote: >Thanks in advance to help me writing the GUI program.. Actually I intended to >contruct a >buttom so that when I press it, it will trigger a wrapped function originally >written in C. >And capture those dumped message, show them in ScrolledText() widget.. > >Sorry, I can't figure out what the self.index is... besides, where should I >place these codes.. >in the callback function or in top level... :O > I'm a complete tkInter newbie, but here is something I hacked together to do what you want (I think). The button is kind of clunky (how do you make it less tall without going to a bitmap?) Of course you can hard code the command line for your C program in place of the interactive input. BTW, you can just hit Enter instead of clicking the button, because of the binding of <return>. I borrowed liberally from the sample directories, but Guido and Matt are not responsible ;-) HTH Watch out for some wrapped lines below. "echo hello" (w/o quotes) might be a good command to try first ______________________________________________________________________ # tkDoCmd.py - Illustrates running an arbitrary command # via popen and displaying result # # WARNING - THIS IS NOT AN INTERACTIVE SHELL INTERFACE!! # You can screw things up with the wrong command, # so watch what you're typing! # import os from Tkinter import * from ScrolledText import ScrolledText class App: def __init__(self, master): self.hd = Label(master,anchor=W,text='(No command yet)',font='courier 10 bold') self.hd.pack(side=TOP,fill=X,expand=1) self.frame = Frame(master) self.frame.pack(side=BOTTOM) self.te = Entry(self.frame, width=40, relief=SUNKEN, borderwidth=2) self.te.pack(side=LEFT) self.te.bind('<Return>', self.do_cmd) self.te.focus_set() self.sp = Label(self.frame,width=2) self.sp.pack(side=LEFT) self.do = Button(self.frame, text="Do Command", command=self.do_cmd) self.do.pack(side=LEFT) self.tx = ScrolledText(master, {'height': 20, 'width': 80, 'wrap': 'none', 'relief': 'raised', 'font': 'courier 10', 'bd': 2}) self.tx.pack(side=LEFT, fill=BOTH, expand=1) def do_cmd(self,ev=None): cmd = self.te.get() self.tx.delete(0.0,END) self.hd.config(text='Trying command "'+cmd+'" ...') p = os.popen(cmd, 'r') if not p: self.tx.insert(END,'Pipe Blew up??') return while 1: s=p.read(4096) if not s: break self.tx.insert(END,s) cmdStatus = p.close() if cmdStatus: cmdStatus= `cmdStatus` else: cmdStatus = 'Ok' self.hd.config(text='Result of command "'+cmd+'": (Status='+cmdStatus+')') root = Tk() app = App(root) root.mainloop() __________________________________________________________________ From nas at python.ca Thu Jul 5 16:38:37 2001 From: nas at python.ca (Neil Schemenauer) Date: Thu, 5 Jul 2001 13:38:37 -0700 Subject: Best method for updating pickled data objects? In-Reply-To: <79179cf5.0107051214.19990222@posting.google.com>; from rupe@metro.yak.net on Thu, Jul 05, 2001 at 01:14:26PM -0700 References: <79179cf5.0107051214.19990222@posting.google.com> Message-ID: <20010705133837.A31145@glacier.fnational.com> Rupert Scammell wrote: > Deleting and recreating the pickle file, then writing out the data > object from memory each time seems horribly inefficient to me > (especially for large data objects). There's got to be a better way to > do this. Any suggestions would be appreciated. You want ZODB: http://www.amk.ca/zodb/ Its sounds complicated and scary but its really easy to use. Neil From just at letterror.com Mon Jul 23 04:13:40 2001 From: just at letterror.com (Just van Rossum) Date: Mon, 23 Jul 2001 10:13:40 +0200 Subject: A use for integer quotients References: <mailman.995866298.23496.python-list@python.org> <eppstein-E19F08.00451323072001@news.service.uci.edu> Message-ID: <3B5BDCB4.A2010560@letterror.com> David Eppstein wrote: > Ok, you convinced me to look more carefully at all the divisions in my > recent small project, a program to generate web pages from collections of > JPEGs. I found: > > 3 instances of simplifying numbers prior to output (e.g. I want file size > in kbytes rather than bytes). > [ ... ] Do you really want 2047 bytes to be shown as 1 kbyte? Integer division is a lousy tool in this particular example... Just From gbreed at cix.compulink.co.uk Tue Jul 10 12:44:15 2001 From: gbreed at cix.compulink.co.uk (gbreed at cix.compulink.co.uk) Date: 10 Jul 2001 16:44:15 GMT Subject: getting argument names from a function References: <6%F27.4784$yh2.453987@weber.videotron.net> Message-ID: <9ifbcv$3uu$1@plutonium.compulink.co.uk> In article <6%F27.4784$yh2.453987 at weber.videotron.net>, dan at eevolved.com (dan) wrote: > def aFunction(arg1, arg2): > print arg1, arg2 > > is there a way I can get to the arguments of aFunction (i.e. 'arg1' and > 'arg2')? > > I've tried dir(..) on the function object and subsequent object and > can't find what I'm looking for. Is it possible to do what I want? aFunction.func_code.co_names seems to do the trick Graham From sholden at holdenweb.com Sat Jul 14 11:03:56 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sat, 14 Jul 2001 11:03:56 -0400 Subject: Light Speed Socket Connections References: <d01baf67.0107112132.34e70d03@posting.google.com> <3b4d6184.1698299906@wa.news.verio.net> <mailman.994949372.17704.python-list@python.org> <NCk37.1777$u76.55241@e420r-atl3.usenetserver.com> <EbJ37.5150$z21.530071@newsc.telia.net> Message-ID: <38Z37.25588$uJ3.1077859@e420r-atl2.usenetserver.com> Thanks for the excellent clarification, /F. -- http://www.holdenweb.com/ "Fredrik Lundh" <fredrik at pythonware.com> wrote in message news:EbJ37.5150$z21.530071 at newsc.telia.net... > Steve Holden wrote > > > Well, after this little experiment on PythonWin 2.0/Win95 I'm no longer > > sure what is going on: > > > > >>> for i in range(10): > > ... time.sleep(2.5) > > ... print time.time(), time.clock() > > ... > > 994956779.3 5.86667560636e-006 > > 994956781.88 2.55270956603 > > 994956784.41 5.0637313733 > > 994956786.94 7.58865720176 > > 994956789.41 10.1181121038 > > 994956791.99 12.6327050403 > > 994956794.46 15.1421897786 > > 994956796.99 17.6518547076 > > 994956799.51 20.1890552976 > > 994956802.04 22.7061055331 > > > > Is my CPU usage really ~100% during those sleeps? > > from the Python library reference: > > clock() > > Return the current CPU time as a floating point > number expressed in seconds. The precision, and > in fact the very definition of the meaning of ''CPU > time'' , depends on that of the C function of the > same name > > ANSI C leaves the "era" and resolution open, and Microsoft > has defined it as: > > The clock function's era begins (with a value of 0) > when the C program starts to execute. It returns > times measured in 1/CLOCKS_PER_SEC (which > equals 1/1000 for Microsoft C). > > In recent version, I think "when the C program starts to > execute" means "when the C program first calls the clock > function", but you get the idea. > > Cheers /F > > From cjc26 at nospam.cornell.edu Sun Jul 29 10:53:02 2001 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Sun, 29 Jul 2001 14:53:02 GMT Subject: What RE would i use to match this whole word? References: <9jv3mi$5lv$1@neptunium.btinternet.com> <20010729003831.2A193BED.NOFFLE@niccolo.ke4.de> <9k10qe$n8n$1@neptunium.btinternet.com> Message-ID: <irV87.147995$EF2.19745941@typhoon.nyroc.rr.com> * G. Willoughby <thecalm at NOSPAM.btinternet.com> menulis: | this is the code im using for a 'file file' kinda program: | | [snip] | | def search(resultPane, dir, files): | searchString = re.compile(str(entryField.get()), re.IGNORECASE) # Get | search string | for file in files: | if searchString.search(file) == "None": None is *not* a string, it's a unique object. Since search() never returns a string, your comparison always fails and your else: branch always gets executed no matter what. Change this line to: if searchString.search(file) is None: or if not searchString.search(file): to make it work. -- Cliff Crawford http://www.sowrong.org/ A sign should be posted over every campus toilet: "This flush comes to you by courtesy of capitalism." -- Camille Paglia From Gareth.McCaughan at pobox.com Mon Jul 23 17:09:22 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Mon, 23 Jul 2001 22:09:22 +0100 Subject: PEP0238 lament References: <mailman.995872488.11031.python-list@python.org> Message-ID: <slrn9lp4k2.vp.Gareth.McCaughan@g.local> Tim Peters wrote: > FYI, PEP 42 (the "small feature request" PEP) contains > > - New math module radians() and degrees() functions. > > Somebody quick add grads before Python becomes obsolete <wink>. Only if that new operator gets called "div". and-the-new-url-canonicalizing-function-will-be-called-curl-ly y'rs, -- Gareth McCaughan Gareth.McCaughan at pobox.com .sig under construc From steve at lurking.demon.co.uk Sun Jul 22 00:43:57 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Sun, 22 Jul 2001 05:43:57 +0100 Subject: Is anybody coming from Pascal? References: <slrn9li6so.4r2.edmund@ngetal.fsnet.co.uk> <mailman.995755776.9405.python-list@python.org> Message-ID: <p8akltsg70nsi7jmsls62ijogrp4dmq1sg@4ax.com> On Sat, 21 Jul 2001 16:47:53 -0600, Paul Sidorsky <paulsid at home.com> wrote: >I'm not an expert in object-oriented design, but nested functions seem >kind of anti-OO too me. Can behaviours (methods) really have their own >behaviours (nested functions), or does the behaviour (nested function) >actually belong to the object (class)? And for non-OO use they seem >completely unnecessary to me. About all they seem to do is keep the >global namespace a bit less polluted, but that's going to happen in >non-OO anyhow. But maybe I'm missing something... Nested functions are handy, but not the kind of thing people can't live without. Functions are often written not so much to be re-usable, but to separate excess low level detail out of a higher level function and make things more readable. If a function is never intended to be called outside the context of another function, it makes sense to limit its availability to that function. If it's not applicable to the wider class, it shouldn't be available to the wider class. Hiding internal details (whether you call it data hiding or whatever) is certainly an important part of object orientation, but it's a much older idea than OO and doing it on a per-function basis has also been a useful facility in several non-OO imperative languages including Pascal, Modula 2 and Ada. Nested classes are supported in C++, so the idea of lower level abstractions within higher level abstractions does exist within that language too. And I believe that the GNU C/C++ compiler has optional support for nested functions. An important aspect of a function within a function is that it cannot be called by other functions. Therefore, when you change the outer function you can safely change the inner function in the knowledge that nothing else will be broken - not even other member functions of the same class. Most useful programs will need maintenance by people other than those who wrote them at some point. Limiting the scope of what you need to understand makes this easier. In some cases, it's the only reason maintenance is possible at all. I have to admit, though, that I've never needed a nested function in Python. > >> I conclusion, and in reviewing this post, I seem to have been rambling a >> bit (it's a bit late/early in the day) but I'd be interested to get a >> response from anybody else who rates Mr Wirth, and in how any such people >> finding the transition. I'd also be curious to hear from anybody who has >> tried object Pascal. > >Object Pascal is okay. I don't have much experience with it, but >personally I'd hate to have to learn object-oriented concepts on it. It >shares the same problem with C++ as being an extension to an existing >language, so the implementation of OO features is kind of glued on. I >think it's better to pick up OO concepts on Python (or even Java) before >trying Object Pascal. Pythons object orientation was glued onto a pre-existing non-OO version of the language as well ;-) The definitive OO language is always supposed to be Smalltalk. Certainly it was the first, and designed to be pure OO. I've never used it myself, though. >Anyhow, I hope you stick with Python. You'll get a lot of the >convenience of Pascal merged with a cleaner and much more well-designed >language! Agreed. Remember, even Wirth didn't settle for Pascal - though that is possibly unfair, as his other languages had different target users. Pascal was only intended for teaching, though - like BASIC - to get people used to imperative (and structured, in Pascals case) programming before they moved on to programming larger applications in languages suited for those tasks - at the time, that probably meant Fortran (scientific), COBOL (business), Algol (?), CORAL (real time?) and a few others. From steve at lurking.demon.co.uk Mon Jul 23 19:05:12 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Tue, 24 Jul 2001 00:05:12 +0100 Subject: A use for integer quotients References: <mailman.995866298.23496.python-list@python.org> <eppstein-E19F08.00451323072001@news.service.uci.edu> <3B5BDCB4.A2010560@letterror.com> <3B5C48A0.56D88724@alcyone.com> <7ikoltclv5sjr376ua6m1jlk3a9l1qftju@4ax.com> <3b5c990b.237461111@wa.news.verio.net> Message-ID: <dk9plto33uqab4t2ooil3t543kr7siekmr@4ax.com> On Mon, 23 Jul 2001 21:34:51 GMT, bokr at accessone.com (Bengt Richter) wrote: >On Mon, 23 Jul 2001 19:15:33 +0100, Steve Horne <sh at ttsoftware.co.uk> wrote: >[...] >> >>Fixed point arithmetic emulated by using integers with a scale factor, >>though, works very nicely. Better still when there's a language >>feature to do this automatically, but if we added fixed point types to >>Python we'd need *another* division operator - four so far including >>the rational one ;-) >> >This reminds me, is Python configurable to run on a platform with no >floating point support? I believe so - there was even a Python for Psion palmtops at one point, and the 3 series certainly doesn't have hardware floats. All it requires, I imagine, is that the C or C++ (not sure which) compiler that you build Python on must have a correctly implemented 'double' type - the implementation of the floats in software or hardware should be irrelevant bar performance concerns. Linux Python is distributed both as source and as binary, and a source distro will compile and install itself with very little fuss if you know the basics of Linux. It should just install and work. From skip at pobox.com Fri Jul 6 11:27:10 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 6 Jul 2001 10:27:10 -0500 Subject: pb with xmlrpclib In-Reply-To: <slrn9kbilr.4h3.alf@leo.logilab.fr> References: <slrn9kbfd5.42n.alf@leo.logilab.fr> <3b45c3c4$1_7@news5.uncensored-news.com> <slrn9kbilr.4h3.alf@leo.logilab.fr> Message-ID: <15173.55502.89929.930194@beluga.mojam.com> Alexandre> However, right now, I'm just using xmlrpc as a nice, quick Alexandre> and lightweight way of doing rpc between two python Alexandre> applications. (if someone can suggest another method, as easy Alexandre> as this one, I'll be glad to give it a try). You can always wrap your strings as base64 and pass them that way. >>> server.echo(xmlrpclib.Binary('\231'))[0] <xmlrpclib.Binary instance at 815d090> You might also want to search the archives of the XML-RPC mailing list: http://groups.yahoo.com/group/xml-rpc The whole subject of non-ASCII content in XML-RPC has been hashed and rehashed repeatedly. Bottom line is that Dave Winer of Frontier (XML-RPC's analog to our BDFL) doesn't want to change XML-RPC for fear of interoperability problems (mostly unfounded I believe, but that's his stance). -- Skip Montanaro (skip at pobox.com) (847)971-7098 From sholden at holdenweb.com Mon Jul 9 10:27:43 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 9 Jul 2001 10:27:43 -0400 Subject: socket.connect timeout References: <9icas4$lvp$1@news1.xs4all.nl> Message-ID: <K9j27.20247$i8.1580848@e420r-atl3.usenetserver.com> "Twan van der Schoot" <twanvds at xs4all.nl> wrote in message news:9icas4$lvp$1 at news1.xs4all.nl... > Hi there, > > How do I increase the timeout period on a socket.connect()? > A peek in the source code of the socket object does reveal anything usefull. > > > FWI: I'm using Python 2.1 from ActiveWare for WinNT (running on NT4.0SP6). > > thanks! > There's a module called timeoutsocket.py (take a look in the vaults of Parnassus), which allows you much better control over the timeouts on your sockets. Without this you can have problems. regards Steve -- http://www.holdenweb.com/ From dennis at dennis-voss.de Mon Jul 9 12:26:16 2001 From: dennis at dennis-voss.de (Dennis Voss) Date: Mon, 09 Jul 2001 18:26:16 +0200 Subject: Writing documentation References: <mailman.994690455.6338.python-list@python.org> Message-ID: <3B49DB28.F9955406@dennis-voss.de> > I'd like to document my Python modules in the same way the standard > modules are documented, with LaTeX and the Python styles and things. It's > not exactly a howto, and it'l look a lot like a mini-library reference, > right? So how do I compile it? How do I generate all the nifty HTML? Take a look at: http://py-howto.sourceforge.net/writing.html They are using LaTeX (why not docbook?) for doing so. There are tools in every TeX distribution for generating PS, PDF, HTML ... Dennis From pinard at iro.umontreal.ca Wed Jul 25 10:57:27 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 25 Jul 2001 10:57:27 -0400 Subject: HOWTO: exit In-Reply-To: <cXt77.49466$k33.5017307@typhoon.kc.rr.com> References: <mailman.995826636.14065.python-list@python.org> <cXt77.49466$k33.5017307@typhoon.kc.rr.com> Message-ID: <oqg0blgip4.fsf@lin2.sram.qc.ca> [Brendan O'Connor] > import sys > sys.exit() I'm curious. What about "raise SystemExit"? Does it have the same effect? It looks cleaner to me, as one does not even need to import "sys". -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From akuchlin at mems-exchange.org Wed Jul 18 21:24:38 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 18 Jul 2001 21:24:38 -0400 Subject: newbie question: what does "<...>" or "<input>" signify? References: <e71960c5.0107161807.5fe749eb@posting.google.com> Message-ID: <3du209pv6x.fsf@ute.cnri.reston.va.us> doug_bartholomew99 at yahoo.com (doug) writes: > i am new to python and i have seen references in its documentation and > code to name strings with greater-than and less-than signs, such as > filename="<input>". i have looked high and low for an explanation of > what a string with < and > on both ends means, but have found none. They don't mean anything special to Python; the author of the docs simply meant that you'd provide the filename for your input file as a string, filename="/tmp/input.txt" or whatever. --amk From guido at digicool.com Wed Jul 11 14:55:49 2001 From: guido at digicool.com (Guido van Rossum) Date: Wed, 11 Jul 2001 14:55:49 -0400 Subject: Language change and code breaks In-Reply-To: Your message of "Wed, 11 Jul 2001 14:35:35 EDT." <Pine.NXT.4.21.0107111427580.379-100000@localhost.virginia.edu> References: <Pine.NXT.4.21.0107111427580.379-100000@localhost.virginia.edu> Message-ID: <200107111855.f6BItnF13792@odiug.digicool.com> > Is it possible that changes to built-in types to allow subclassing could > be made to also allow redefining operators for built-in types ? > > Then "/" could be mapped to either behaviour, and gradual introduction > could be a matter of changing the default behaviour in a future version. I'm currently working on subclassing built-in types, but redefining operations for existing built-in types is not part of my agenda, for various reasons (most of which have to do with boring implementation details, but are real showstoppers nevertheless). So alas, no relief from that angle. Maybe we'll have to accept a directive. --Guido van Rossum (home page: http://www.python.org/~guido/) From rnd at onego.ru Wed Jul 4 00:41:42 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 4 Jul 2001 08:41:42 +0400 (MSD) Subject: Not enough Python library development [was PEP scepticism] In-Reply-To: <3B428CC9.1F944ECD@seebelow.org> Message-ID: <Pine.LNX.4.30.0107040834040.6839-100000@rnd.onego.ru> On Tue, 3 Jul 2001, Grant Griffin wrote: >Roman Suzi wrote: >> >... >> CPyAN is much more complex task, because there are: >... > >I think the problem here might be one of marketing, combined with a lack >of corporate sponsorship. To that end, I propose this resource be >called "Python Program Archive Network", or PyPAN, for short. That might Maybe PyCAN ;-) (C for components) >help it attract funding from Mrs. Smith's and Sara Lee. (Heck, if >nothing else, maybe those ladies can contribute something tasty to the >Python Cookbook.) > ><sorry> > >Seriously, folks, I never was a big fan of CPAN: in fact, for me, it was >just another part of my overall poor user-interface experience with Perl ><wink>. Although CPAN is impressive in terms of sheer girth, the CPAN >concept seemed to encourage large interdependencies between modules. >Although this seems like good thing in some ways (because it indicates a >lot of software reuse), I found it nightmarish to install even fairly >simple packages. (I never could get the automatic CPAN installer gizmo >to work well--at least without giving it a great deal of manual help.) > >Having a very large standard library seems a better solution. (Of >course, Perl also comes with a large standard library.) I never seem to >have large cross-package dependency problems with Python; my experience >has been that nearly all packages require zero or one other packages. >Presumably, this is a fortunate aftertaste of the fact that PyPAN is >still just a half-baked idea. I do not think large standard library is a must. Probabaly, there could be uniform way to download missing components and probably bare Python distribution could contain a references of modules which could be downloaded if user need them. This will solve problem with large initial download of lots of unneeded things. >But maybe an increasingly large standard library isn't totally >practical. An alternative that I think would be very helpful is >"application-targeted" distributions. For example, someone could make a >"Numeric" bundle of Python, including NumPy and related modules; >likewise, there could be a "webmaster" bundle. Of course, this takes a >lot of time and effort for somebody to create and maintain. >(ActiveState folks, are you listening?--given that you somehow make >money by giving away software, the more software you give away, the more >money you'll make <wink>.) Its the way of Slackware Linux: they thought the same way and labeled packages as "A", ... "K", "X" ,... package-sets. The better way is that of rpm or apt-get enabled distros. The problem is the lack of knowledge. There need to be some central storage + mirroring network and mentioning PyPAN contents in the core Python distribution (with links and such). Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Wednesday, July 04, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Mediocrity requires aloofness to preserve it's dignity" _/ From aahz at panix.com Mon Jul 9 01:22:35 2001 From: aahz at panix.com (Aahz Maruch) Date: 8 Jul 2001 22:22:35 -0700 Subject: Most important text processing examples References: <mailman.994302849.7562.python-list@python.org> <mailman.994357450.6939.python-list@python.org> <3B44D0BD.63A3F795@home.net> <3dofqzqbvo.fsf@ute.cnri.reston.va.us> Message-ID: <9ibf2r$le9$1@panix3.panix.com> In article <3dofqzqbvo.fsf at ute.cnri.reston.va.us>, Andrew Kuchling <akuchlin at mems-exchange.org> wrote: >Chris Barker <chrishbarker at home.net> writes: >> >> Anyone writing a computer book should read this: >> http://philip.greenspun.com/wtr/dead-trees/story.html >> It's interesting (and humorous) reading for the rest of us as well. > >Indeed; that page cured me of my desire to write a book for physical >publication. Sure, there's the ego-thrill of a big wad of paper with >your name on the front, but it also means you have to work to a >deadline, errors in the final product can't be corrected, and you have >to cope with potentially clueless editorial interference (sure, maybe >your editor will offer lots of good suggestions -- what if they >don't?). Putting things on Web pages, you can fix errors whenever you >like, write sections whenever you like, and can get direct feedback >directly from readers; the advantages are all in the Web's favor. Many people still prefer the solid feel of paper. As for the other problems, that's why smart people work with O'Reilly. ;-) -- --- 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 "How come we choose from just two people for President but more than 50 for Miss America?" --AEN From matthewm at ihug.co.nz Tue Jul 10 21:51:23 2001 From: matthewm at ihug.co.nz (Matthew) Date: Wed, 11 Jul 2001 13:51:23 +1200 Subject: PythonCOM and Office. Arrgh! References: <mailman.994793537.30396.python-list@python.org> <9ig91u$ii5co$1@ID-11957.news.dfncis.de> Message-ID: <3B4BB11B.97268EC2@ihug.co.nz> So, definitely looks like a config issue of some kind. Just out of interest, what build of win32all are you running with 1.5.2? As Bill rightly noted from my original post , passing keyword args does absolutely nothing under my combos of win/python/win32all - no error, nor 'effect'. I'm begining to wonder whether Office97 PythonCOM stuff only works with similar vintage win32all builds. Will check it out and report back. any other ideas? regards, matthew. Emile van Sebille wrote: > "Bill Bell" <bill-bell at bill-bell.hamilton.on.ca> wrote in message > news:mailman.994793537.30396.python-list at python.org... > > > > "Emile van Sebille" <emile at fenx.com> wrote, in part: > > > This worked for me. Win2ksp1, excel2k, Python 2.1 > > > > > > >>> import win32com.client > > > >>> xl = win32com.client.Dispatch("Excel.Application") > > > >>> xlc = win32com.client.constants > > > >>> xl.Workbooks.Open('test',Password='fred') > > > <COMObject Open> > > > >>> xl.Visible=1 > > > > > > What do you get when you try this? > > > > Using Win95, Excel 97 SR-1, Python build 203 > > > <snip error info> > > This seems to be what the thread's originator experienced. > > Tentatively, appears to relate to version or configuration. > > > > I agree. With win98, excel8 and python1.52 it still works for me. > > -- > > Emile van Sebille > emile at fenx.com From sh at ttsoftware.co.uk Mon Jul 23 10:08:15 2001 From: sh at ttsoftware.co.uk (Steve Horne) Date: Mon, 23 Jul 2001 15:08:15 +0100 Subject: PEP0238 lament References: <mailman.995839419.19134.python-list@python.org> <9jgvbc$dos$1@newshost.accu.uu.nl> Message-ID: <62aolt82hraa6m4620am93ba089oj2mcvo@4ax.com> On 23 Jul 2001 10:47:08 GMT, m.faassen at vet.uu.nl (Martijn Faassen) wrote: >Tim Peters <tim.one at home.com> wrote: >> [Martijn Faassen] >>> ... >>> The audience was entirely self-selected; > >> Unlike, say, the participants in this discussion? Hmm. You set a rather >> high standard here, Martijn <wink>. > >This discussion is entirely self selected too. What I'm pointing out is that >your 3/4 number is fairly meaningless in this discussion. Anyway, we don't need to prove the Anti-PEP0238 opinion representative - we only need prove the Pro-PEP0238 vote is not. In the absence of good solid reasons for change, stability should be the rule. All the reasons given for change are clearly a matter of opinion. -- Steve Horne Home : steve at lurking.demon.co.uk Work : sh at ttsoftware.co.uk From db3l at fitlinxx.com Wed Jul 25 20:50:15 2001 From: db3l at fitlinxx.com (David Bolen) Date: 25 Jul 2001 20:50:15 -0400 Subject: Version compatibility in division References: <mailman.996097129.15274.python-list@python.org> Message-ID: <usnfkcy48.fsf@ctwd0143.fitlinxx.com> "Tim Peters" <tim.one at home.com> writes: (changing int()/long() to truncate) This post is mostly tongue-in-cheek... > There are no known platforms on which that will make a lick of difference, > except to make Python run slower. But that doesn't mean no such platforms > exist. And making a particular Python operation run slower can change the > behavior of, e.g., threaded apps. Of course, this isn't the best example, since threaded apps by their nature must be written to be safe in such variations, and a given platform on a given day might vary timing of the application even without changes. > It's also the case that platforms > certainly vary even now in how int(infinity) and int(NaN) behave (since C89 > is silent on those cases), and that they may suffer some different > accidental behavior in these cases after the change. Now, that could be a compatibility argument, but only if the existing behavior were well defined. I don't think compatibility needs to be inclusive of undefined behavior - if the old platform said that some behavior was undefined, then no change really violates that. The largest concerns for compatability should be concerned with conforming to pre-existing definitions of behavior and interfaces. Sure, some old code might just happen to work if the behavior was lucky for the code, but that's a hard argument to care about breaking. > So is this a change we should be frightened of? Do we need a > > from __future__ import int_and_long_guaranteed_to_truncate > > statement to enable it? > > I think that would be absurd, but from an implementer's point of view it's > the plain truth that no change is without consequences. Agreed (to both points). But it's probably realistic to consider that changing any existing feature (or even a functional interface) such that previously defined behavior changes, will probably require some such support for the change. Of course, that leaves a whole wide range of stuff that either changes undefined behavior, or just adds behavior. And as I've said before, clearly some pragmatism can come into play such that changes can be judged on a case by case basis. -- -- 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 com-nospam at ccraig.org Tue Jul 3 16:47:25 2001 From: com-nospam at ccraig.org (Christopher A. Craig) Date: 03 Jul 2001 16:47:25 -0400 Subject: PEP scepticism References: <mailman.993760063.4583.python-list@python.org> <3dels41dhs.fsf@ute.cnri.reston.va.us> <19v0kt462nkvid15t0fnrpclmem3epc61g@4ax.com> Message-ID: <87k81p7naa.fsf@elbereth.ccraig.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Steve Horne <sh at ttsoftware.co.uk> writes: > Sometimes I think that the drive to proove that Python can do > anything that other languages can do misses an essential point - > Python is extremely good (and getting better) at scripting and glue > style tasks. That is where its main strength lies. Being good at > everything is a pretty tall order. I think many people would disagree that that is "where its main strength lies". I, for one, frequently use Python for mathematical modeling, and find it a superb tool for the task. I have a friend who does microprocessor and microcontroller modeling in Python because he can turn out a prototype faster in it than VHDL, and if he actually decides to burn a core he can translate it later. RedHat uses Python for nearly all of its user interfaces. Google started out using a great deal of Python (I imagine it is mostly C by now). CVSWeb (and thus SourceForge's CVS viewer) uses Python for its web presentation. Python is not the best tool for every job, but it is a good one for quite a few of them. - -- Christopher A. Craig <com-nospam at ccraig.org> I develop for Linux for a living, I used to develop for DOS. Going from DOS to Linux is like trading a glider for an F117. - Lawrence Foard - -- Christopher A. Craig <com-nospam at ccraig.org> Perl is worse than Python because people wanted it worse -- Larry Wall -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: Processed by Mailcrypt iEYEARECAAYFAjtCL10ACgkQjVztv3T8pzvmpACdF1Q+mlIUCizlvu5Oolnz4iJM XkgAoJEFVIfmxi27ExFiIpxBu7V1yRKl =OeRy -----END PGP SIGNATURE----- From tim at vegeta.ath.cx Mon Jul 16 22:39:59 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Tue, 17 Jul 2001 02:39:59 GMT Subject: OO misconceptions References: <mailman.994969462.27792.python-list@python.org> <hevsktcrnpckttnkgi1arcue5kjjsbrrb5@4ax.com> <mailman.995046506.2514.python-list@python.org> <9ir1l7$3ja$1@panix2.panix.com> <9irfbc11jaq@enews1.newsguy.com> <slrn9l49me.p58.tim@vegeta.ath.cx> <3B52314B.F7F73ED5@engcorp.com> <slrn9l4h8v.p58.tim@vegeta.ath.cx> <slrn9l77cb.91.sill@sill.silmarill.org> Message-ID: <slrn9l7a23.rpe.tim@vegeta.ath.cx> Me parece que Rainy <sill at optonline.net> dijo: > On Mon, 16 Jul 2001 01:24:40 GMT, Tim Hammerquist <tim at vegeta.ath.cx> wrote: > > All very good points. I have certain reservations, tho. I dread > > waiting for Microsoft Word to startup as it is, written in compiled C++. > > I fear for the speed of anything of that scale and complexity > > implemented in Python. > > I don't know this for a fact, but I heard someone saying that he/she > received some errors in Word97 (or maybe 2k) that demostrated word's > internal reliance on some sort of scripting language, most likely > VBscript. Can anybody confirm this? Microsoft provides VBA (Visual Basic for Applications) as a glue language to script all of its 'Office (9\d|2000)' applications. It's like VBScript'ing ASP, but with a different environment. I don't know if this is what this person found, but it's likely. But I don't think that Word et al. "rely" on it. -- But the price of getting what you want is getting what you once wanted. -- Morpheus, The Sandman From thomas_barket at yahoo.com Wed Jul 25 22:21:39 2001 From: thomas_barket at yahoo.com (tom barket) Date: 25 Jul 2001 19:21:39 -0700 Subject: New User Question: extension types and python 2.2/class/type Message-ID: <758d4715.0107251821.3ee9dda4@posting.google.com> Hello, I am relatively new to python and am about to embark on my first significant "extension type" project (which will involve wrapping and exposing some large c++ classes i have - and no, i dont think SWIG can accommodate my c++). Having followed the class/type unification discussions somewhat and read Guido's "Unifying types and classes in python 2.2" tutorial, it seems to me that chapter 2 "Defining New Types" in the "Extending and Embedding the Python Interpreter" doc is about to become obsolete (in the sense that what it describes will shortly *not* be the prefered way to define/import new types). Since this was going to be my guide for my own extension type endeavor, I would like to ask how can i get instructions for correctly writing an "extension type" under the new (or actually soon-to-be-new) regime. Can someone kindly offer me advice on how to proceed? I have not yet implemented any metaclasses, but i am familiar with their concept. I would rather do this correctly under the new regime the first time if possible, so i dont have to go back and change it in 2 months. Thanks, Tom thomas_barket at yahoo.com From aahz at panix.com Wed Jul 4 10:45:45 2001 From: aahz at panix.com (Aahz Maruch) Date: 4 Jul 2001 07:45:45 -0700 Subject: Alternate Syntax for dictionary elements References: <3b421046.1836046@news.t-online.de> <slrn9k471b.hhl.quinn@hork.ugcs.caltech.edu> <3b421cec.5073656@news.t-online.de> <LNz07.1653$h45.11048@news.uk.colt.net> Message-ID: <9hva6p$6a6$1@panix6.panix.com> In article <LNz07.1653$h45.11048 at news.uk.colt.net>, Graham Ashton <graham at coms.com> wrote: >In article <3b421cec.5073656 at news.t-online.de>, "Gerson Kurz" ><gerson.kurz at t-online.de> wrote: >> >> 2 reasons for using dicts rather than classes: >> >> - You can easily create the data an object stores *dynamically*, i.e. >> from user input. > >What can you do dynamically with a dictionary that you can't do with >setattr() and getattr()? (that's a real question, not a cocky way of >pointing out you might have missed something) Well, you can use any immutable type as the key. -- --- 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'm not tense, i'm just terribly, terribly alert" --unknown From chris.gonnerman at newcenturycomputers.net Tue Jul 24 08:59:45 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Tue, 24 Jul 2001 07:59:45 -0500 Subject: re bad leadership References: <XFMail.20010724142502.mikael@isy.liu.se> Message-ID: <00af01c11440$87a53c20$0101010a@local> ----- Original Message ----- From: "Mikael Olofsson" <mikael at isy.liu.se> > > On 23-Jul-2001 Robin Becker wrote: > > MDFL you are wrong! Give up gracefully now! > > I've seen BDFL referring to GvR, and I know the interpretation of that. > Here, obviously, MDFL suddenly referres to the very same GvR. What's > with that M? I'm guessing here, but I'd bet from the tone of his postings that Robin means Malevolent Dictator For Life While I'm not happy with Guido over this change (because it makes cross- version code very ugly, and introduces errors in meaning that may be hard to detect) I would not call him such a rude name. From JamesL at Lugoj.Com Tue Jul 10 00:50:17 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Mon, 09 Jul 2001 21:50:17 -0700 Subject: An unspeakable act References: <ib0lktkade28a9ci198b1jpn9jejqjbtlj@4ax.com> Message-ID: <3B4A8989.414C01B9@Lugoj.Com> Daniel Klein wrote: > > I did the unspeakable and got into a discussion (with another person on another usenet group) on > Python vs Java. You got into a _discussion_? Well shucks, that doesn't sound unspeakable. If you got into an angry, venom spitting, eye-gouging, knee-into-the-groin fight, then it might have been "unspeakable". Or not. > This person says that dynamically typed languages produce bug-ridden programs and > that there are no reliable large applications (especially network apps) written in Python and that > it is just used for small to medium scripting. I know better but I don't have any proof. Look, you have got off on the wrong foot. You are trying to think logically. That gives the other person a leg up on you. (But you admit that you know better without proof, so you aren't totally out-matched.) You should have put the burden of proof on the other person: demand proof that there exists a large project attempted in Python that was a failure for the reason he/she states. That'll shut the bugger up for a while. Even he/she digs something up, it'll take so long that lurking readers will consider you the winner. And that is all that matters in Usenet "discussions". > Can anyone > point me at a list of companies and the applications they have written (I already know about Zope > and I can't find the list of companies on the Python website since they moved the page to PSA). Me: What is your quest? Daniel: I seek the holy Grail... From robin at jessikat.fsnet.co.uk Wed Jul 25 08:34:33 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Wed, 25 Jul 2001 13:34:33 +0100 Subject: PEP0238: overriding // (__intdiv__) ?? References: <snatltotvlevdqc7kaj1m8v82o5fv51543@4ax.com> Message-ID: <hPsZULAZzrX7Ew5X@jessikat.demon.co.uk> In article <snatltotvlevdqc7kaj1m8v82o5fv51543 at 4ax.com>, Kirby Urner <urner at alumni.princeton.edu> writes > >Maybe I missed it. Did the PEP specify what we'd use >to override the // operator in a class? __intdiv__ and >__rintdiv__ ? Seems we'd need something like this, to >have our objects play along. And I'd think this wrinkle >should become available simultaneously with //. > >Kirby > > If and when the grand type class unification takes place and ints, longs, floats rationals and the like are all properly sub-classable, will it possible to inject behaviours into those types? If so then I can trivially change '/' by changing the base implementations for the various types. I suppose that there are efficiency arguments involved, but the compiler must issue a divide instruction anyhow and leave it up to the operand classes to decide what to do. That way we could begin to treat this as a properly abstract programming language. It could of course lead to utter confusion. -- Robin Becker From peter at engcorp.com Sat Jul 14 09:01:54 2001 From: peter at engcorp.com (Peter Hansen) Date: Sat, 14 Jul 2001 09:01:54 -0400 Subject: Partition Problem References: <tku1tt92ac2g8e@corp.supernews.co.uk> <3B4FBEA0.D5A6DC8A@engcorp.com> <9ioru22pc9@enews4.newsguy.com> Message-ID: <3B5042C2.F821D916@engcorp.com> Alex Martelli wrote: > > "Peter Hansen" <peter at engcorp.com> wrote [...]: > ... > > If you have algorithms, why not post them? Are you hoping somebody > > will write this from scratch just for you? (Someone might, but he's > > in a different timezone and wasting his time creating it.comp.lang.python, > > free.it.python, actually, so the time isn't wasted -- the newsgroup is > working just fine:-). Brilliant! "Free IT - use Python". I like it! -deliberately-misinterpreting-ly yr's, -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From 18k11tm001 at sneakemail.com Mon Jul 2 16:06:57 2001 From: 18k11tm001 at sneakemail.com (Russ) Date: 2 Jul 2001 13:06:57 -0700 Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> Message-ID: <bebbba07.0107021206.70a22aa8@posting.google.com> I agree that the quality of the design is paramount. BTW, I would like to thank everyone who responded to my query. I should probably point out that I am an aerospace engineer with some experience in C++ and Tcl/Tk, but I am a Python beginner. As for function prototyping, it seems to me that argument passing by keyword in Python can be used to advantage. If all procedure arguments are passed by keyword, there is much less chance that a procedure will be called incorrectly, particularly when a procedure interface is changed. Contrast that with C++. The C++ compiler will catch only some of those kinds of errors. If I change the order of two ints in a function interface, for example, the C++ compiler won't have a clue that the interface has changed. What would be very desirable for Python is some kind of static checker that can guarantee BEFORE run time that all procedures are called correctly. Does anyone know of anything that does that? Also, can anyone give specific examples of Python being used in safety-critical applications? Thanks. "GerritM" <gmullerNoSpam at worldonline.nl> wrote in message news:<9hlfbn$6ok$1 at 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 guido at zope.com Tue Jul 31 13:05:06 2001 From: guido at zope.com (Guido van Rossum) Date: Tue, 31 Jul 2001 13:05:06 -0400 Subject: 2.2 features In-Reply-To: Your message of "Tue, 31 Jul 2001 09:21:40 CDT." <15206.48884.18637.676324@beluga.mojam.com> References: <mailman.996258542.15795.python-list@python.org> <cpwv4u16rx.fsf@cj20424-a.reston1.va.home.com> <mailman.996270412.11895.python-list@python.org> <cpofq524lr.fsf@cj20424-a.reston1.va.home.com> <slrn9m61bs.atb.quinn@retch.ugcs.caltech.edu> <slrn.pl.9m6a5m.kmu.qrczak@qrnik.zagroda> <cpae1lzio7.fsf@cj20424-a.reston1.va.home.com> <15206.48884.18637.676324@beluga.mojam.com> Message-ID: <200107311705.NAA16444@cj20424-a.reston1.va.home.com> > Guido> I love it. 'x in type' as a shorthand for isinstance(x, type). > Guido> Checked into CVS! > > How about 'x in type' as a shorthand for 'issubclass(x, type)' if x is a > type or class instead of an instance? No, that would be ambiguous. A subclass is not an instance. A class or type represents a set of instances, so 'in' is justified in a sense. --Guido van Rossum (home page: http://www.python.org/~guido/) From JoeSalmeri at home.com Tue Jul 24 18:40:55 2001 From: JoeSalmeri at home.com (Joe Salmeri) Date: Tue, 24 Jul 2001 22:40:55 GMT Subject: Python 2.1.1 ASP/Response object does not HONOR Response.End() Message-ID: <XPm77.38567$Ek3.14226736@news1.rdc1.md.home.com> When using Python/ASP if you call the Response.End() method the rest of the script is still processed For Example: ** Script ** <@language="Python"%> <% Response.Write("This is line 1") Response.Write("This is line 2") Response.End() Response.Write("This is line 3") %> This should NOT appear. ** End Script ** "This is line 3" and "this should NOT appear." both appear in the page results. Testing the same script with VBScript produces the correct results. Is this a known bug? From reddykkk at yahoo.com Thu Jul 12 02:00:37 2001 From: reddykkk at yahoo.com (reddykkk at yahoo.com) Date: Thu, 12 Jul 2001 06:00:37 -0000 Subject: connecting to Oracle database Message-ID: <9ijee5+6ea8@eGroups.com> hi all, i am learning Pyhton now. I am facing problems in connecting to Oracle database. plz guid me how to start with. thanks all, kranthi From pinard at iro.umontreal.ca Thu Jul 26 15:36:18 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 26 Jul 2001 15:36:18 -0400 Subject: Case insensitivity In-Reply-To: <slrn9m0lp9.l0b.quinn@yak.ugcs.caltech.edu> References: <mailman.995506711.21636.python-list@python.org> <cpvgkofyru.fsf@cj20424-a.reston1.va.home.com> <93d9a839.0107200315.4a0a8c28@posting.google.com> <4n4klt8ud0es25jep3u2v9pj02dctnte0u@4ax.com> <slrn9m0lp9.l0b.quinn@yak.ugcs.caltech.edu> Message-ID: <oqofq7eb4d.fsf@lin2.sram.qc.ca> [Quinn Dunkan] > On Sat, 21 Jul 2001 23:42:37 GMT, Courageous <jkraska1 at san.rr.com> wrote: > >I tried fiddling with Lisp-without-Emacs for most of a year. It didn't > >work out. I can think of few programming-related things more onerous > >than a programming language which requires you to learn its editor. > > > >Never again. > Most 'vi's have paren matching and lisp indent, but I've also happily > used acme, which has neither of these. Hey, hey! Courageous is not so courageous, after all! I learned LISP on punched cards, and believe me, the keypunch artillery had no special `plonk' noise for a mismatched parenthesis :-). Re-indenting the body of a function could take a lot of minutes of work even to an experienced puncher. People have thin skins! :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From sailwong at alumni.cuhk.edu.hk Tue Jul 10 09:58:16 2001 From: sailwong at alumni.cuhk.edu.hk (Steve S.L. Wong) Date: Tue, 10 Jul 2001 21:58:16 +0800 Subject: Newbie asks: How to do this line of C in Py? Message-ID: <tkm2bef90nsic1@news.supernews.com> if (sscanf(command, "%d", &num) != 1 ) { } From aleaxit at yahoo.com Tue Jul 17 04:53:07 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 17 Jul 2001 10:53:07 +0200 Subject: String Splice Assignment References: <4e3a8319.0107161357.690b5120@posting.google.com> <kuitgsgxre.fsf@lasipalatsi.fi> Message-ID: <9j0udj027sf@enews3.newsguy.com> "Erno Kuusela" <erno-news at erno.iki.fi> wrote in message news:kuitgsgxre.fsf at lasipalatsi.fi... > In article <4e3a8319.0107161357.690b5120 at posting.google.com>, > gervaserules at yahoo.com (eAndroid) writes: > > | Why don't strings support splice assignment, and what are some > | alternatives? > > as others have noted, strings are immutable. probably because > the python "everything is a reference" semantics would make > accidentally change someone else's string a frequent bug, and > for efficiency reasons. > > you can use the array module, or a list, if you need a mutable > sequence of characters. lists are a bit less hassle, use array if you > need to worry about memory usage. Easiest, IMHO, is to use the MutableString class from the standard UserString module: D:\>python Python 2.1.1c1 (#19, Jul 13 2001, 00:25:06) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. Alternative ReadLine 1.4 -- Copyright 2001, Chris Gonnerman >>> import UserString >>> x=UserString.MutableString("initialvalue") >>> print x initialvalue >>> x[7:7]=' ' >>> print x initial value >>> Alex From peter at engcorp.com Tue Jul 31 20:12:51 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 31 Jul 2001 20:12:51 -0400 Subject: Large pages using Zope References: <9k766t$dc0$04$1@news.t-online.com> <3B674802.C730D678@engcorp.com> Message-ID: <3B674983.8CB67B84@engcorp.com> Peter Hansen wrote: > > Achim Domma wrote: > > > > I would like to use Zope, > [...] > > (Note: we are using Zope quite successfully in the > company I work for right now. It is fast enough, > just as Python is, for our needs, and is *very* > stable. You shouldn't take someone's word for it, > however, as your own needs and standards may vary. > Give it a test drive yourself, if you are interested.) But don't miss this link that was posted by Titus Brown under a different subject line just after yours: http://zope-is-evil-666.idyll.org/ It's at least humorous, definitely valid in some respects, but still uncertain in its conclusion (read to the final disclaimer), just as with many other Zope users' opinions... -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From BPettersen at NAREX.com Tue Jul 3 16:54:00 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Tue, 3 Jul 2001 14:54:00 -0600 Subject: Hiding Console? Message-ID: <6957F6A694B49A4096F7CFD0D900042F27D4DC@admin56.narex.com> > From: G. Willoughby [mailto:thecalm at NOSPAM.btinternet.com] > > Is there a way in your script to include a command that when run on a > WinME/32 platform the console does not appear? such as the > IDLE ide. I wanna > write apps with neat little gui's using Tkinter but i dont > want the console > there when there run, any ideas? Just name your file foo.pyw (note the extra 'w'). -- bjorn From robin at jessikat.fsnet.co.uk Wed Jul 18 04:08:01 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Wed, 18 Jul 2001 09:08:01 +0100 Subject: viewcvs rlog error References: <74f2f0e9.0107171115.25248606@posting.google.com> <RNr1kKAPDJV7EwP1@jessikat.demon.co.uk> Message-ID: <XwAkbgAhPUV7Ewd6@jessikat.fsnet.co.uk> In article <RNr1kKAPDJV7EwP1 at jessikat.demon.co.uk>, Robin Becker <robin at jessikat.fsnet.co.uk> writes >In article <74f2f0e9.0107171115.25248606 at posting.google.com>, Jeanie M. >Schwenk <jschwenk at oregon.idt.com> writes >>I just installed viewcvs 0.7 and it gives python exceptions if the >>directory has any files in it. Not terribly useful. It appears to >>be some kind of rlog error but I can't duplicate it from the command >>line so I must assume it's something to do with the python scripts. >>I'm new to python so any useful suggestions would be nice. >> >>Traceback (most recent call last): >> File "/opt/viewcvs0.7/lib/viewcvs.py", line 2514, in run_cgi >> main() >> File "/opt/viewcvs0.7/lib/viewcvs.py", line 2477, in main >> view_directory(request) >> File "/opt/viewcvs0.7/lib/viewcvs.py", line 1091, in view_directory >> fileinfo, alltags = get_logs(full_name, rcs_files, view_tag) >> File "/opt/viewcvs0.7/lib/viewcvs.py", line 1035, in get_logs >> raise 'error during rlog: '+hex(status) >>error during rlog: 0x7f00 >I'm getting the identical error after struggling a bit with my freeBSD >system. I'll have to go back to 0.5. OK it seems we need to install rlog, to get this to work. -- Robin Becker From db3l at fitlinxx.com Tue Jul 17 14:07:22 2001 From: db3l at fitlinxx.com (David Bolen) Date: 17 Jul 2001 14:07:22 -0400 Subject: OO misconceptions References: <mailman.994969462.27792.python-list@python.org> <hevsktcrnpckttnkgi1arcue5kjjsbrrb5@4ax.com> <mailman.995046506.2514.python-list@python.org> <9ir1l7$3ja$1@panix2.panix.com> <9irfbc11jaq@enews1.newsguy.com> <slrn9l49me.p58.tim@vegeta.ath.cx> <mailman.995268208.1394.python-list@python.org> <slrn9l6kci.qqs.tim@vegeta.ath.cx> <mailman.995328450.15230.python-list@python.org> <slrn9l7alj.rpe.tim@vegeta.ath.cx> Message-ID: <uae234eg5.fsf@ctwd0143.fitlinxx.com> tim at vegeta.ath.cx (Tim Hammerquist) writes: > AFAIK, the only larger source of aggression than the anti-Perl > Pythonistas is the anti-C++ Smalltalkers. <wink> Maybe I'm just too forgiving, but I'm having a hard time thinking of all the "anti-Perl Pythonistas" that I've read posts from here. Perhaps they hang out elsewhere that I don't frequent? It's true that Perl rarely gets suggested as an alternative to Python (except perhaps in selected pure text processing applications, before the speedups in recent Python releases), but it seems pretty rare that it is rejected harshly, as opposed to Python simply being favored. And I find it pretty typical to get a reasoned explanation for why as opposed to a knee-jerk response. I also expect that you'll find a larger subset of people (at least here) that did do a lot of Perl in the past and then found their way to Python - as you say, it does get mentioned in that vein on some of the c.l.perl lists. I don't think the reverse happens anywhere near as much, so there's probably some pre-selection (at least here) towards preferring Python over Perl in any comparison. But again, I rarely perceive that as a violent reaction, as opposed to the voice of experience. -- -- 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 Jul 29 16:10:34 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sun, 29 Jul 2001 13:10:34 -0700 Subject: Language Niches (long) References: <8beb91f5.0107280407.5a30341d@posting.google.com> <3B62FAFF.BB987077@Lugoj.Com> <mailman.996347633.4448.python-list@python.org> <8beb91f5.0107282158.4785ae5e@posting.google.com> <UK2E1VAMB+Y7EwX$@jessikat.fsnet.co.uk> <mailman.996429234.13926.python-list@python.org> <vko8mtotv7s6mopits06ntammk5ibe4905@4ax.com> Message-ID: <3B646DBA.8362A98E@ActiveState.com> Courageous wrote: > > > * Java was the only way to do client-side graphics and then evolved > >into "Servlets" and "EJBs" > > Note that this quickly went by the way side. The vast majority of all > web-served client-side graphic technologies are not Java. Javascript > (which is most emphatically not Java) dominates the landscape here. Yes, it is clear that languages can outgrow their original niches. That's why I mentioned Servlets and EJBs. My understanding is that use of these technologies allow you to achieve scalability easier than in languages where you must do it all "yourself". But that's just hearsay. > > * Perl was also the defacto way to do CGI in the early web > > Funny, too, as it never had to be, and you could easily gen up a > C program which did your CGI duties with vastly higher efficiency > (n.b.: assuming you didn't badly screw up in string management). Why would you write ten or a hundred times as much code to solve your problem? Early CGIs tended to be small and simple so Perl's maintainability was not that big of an issue. > >cross-platform general-purpose rapid application development. Moore's > >law is slowly making type declarations irrelevant.... > > While I actually agree with this sentiment, note well that in compile- > time type checking communities, the primary argument in favor is > compile-time error checking, not speed. The speed argument is > actually close to dead, because a good optimizing jit VM can > achieve speeds nearly equivalent to C within about a factor of 2 > much of the time, even without declared type information. I agree. But the type check argument is abstract and therefore weaker than the performance algorithm. If someone asked me if they could write a commercially competitive relational database in Python I would have to say: "No." If they asked me "could you build a large system in Python" I would at least have a chance of convincing them. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From mhuening at zedat.fu-berlin.de Wed Jul 18 16:14:55 2001 From: mhuening at zedat.fu-berlin.de (Matthias Huening) Date: Wed, 18 Jul 2001 22:14:55 +0200 Subject: How to set a timeout? References: <9j446n$lom9k$1@fu-berlin.de> <PTg57.32687$d4.1085713@e420r-atl1.usenetserver.com> <9j4ntg$m8l0k$1@fu-berlin.de> <JCl57.22558$PF1.1107141@e420r-atl2.usenetserver.com> Message-ID: <9j4qns$lu982$1@fu-berlin.de> Steve Holden <sholden at holdenweb.com> wrote: > You might find you need to examine the HTTP response headers and access > another page. I think that httplib does that for you, but you will have to > code it yourself with asyncore. Here's a trace from a proxy trying to access > that page on my browser's behalf. Did I get anything wrong? I cam certainly > access the page in IE. In this case the server might not have liked the > apparently-spoofed "Host:" header which the proxy just dumbly echoes out. > Hhmm, I don't know. I'll ask our sys-admin. Perhaps she knows... Thanks a lot, Matthias From bokr at accessone.com Tue Jul 24 13:43:17 2001 From: bokr at accessone.com (Bengt Richter) Date: Tue, 24 Jul 2001 17:43:17 GMT Subject: FYI: PEP 5 Verbatim Message-ID: <3b5db288.309948953@wa.news.verio.net> [home] [index] [PEP source] PEP: 5 Title: Guidelines for Language Evolution Version: $Revision: 1.1 $ Author: paul at prescod.net (Paul Prescod) Status: Active Type: Informational Created: 26-Oct-2000 Abstract In the natural evolution of programming languages it is sometimes necessary to make changes that modify the behavior of older programs. This PEP proposes a policy for implementing these changes in a manner respectful of the installed base of Python users. Implementation Details Implementation of this PEP requires the addition of a formal warning and deprecation facility that will be described in another proposal. Scope These guidelines apply to future versions of Python that introduce backward-incompatible behavior. Backward incompatible behavior is a major deviation in Python interpretation from an earlier behavior described in the standard Python documentation. Removal of a feature also constitutes a change of behavior. This PEP does not replace or preclude other compatibility strategies such as dynamic loading of backwards-compatible parsers. On the other hand, if execution of "old code" requires a special switch or pragma then that is indeed a change of behavior from the point of view of the user and that change should be implemented according to these guidelines. In general, common sense must prevail in the implementation of these guidelines. For instance changing "sys.copyright" does not constitute a backwards-incompatible change of behavior! Steps For Introducing Backwards-Incompatible Features 1. Propose backwards-incompatible behavior in a PEP. The PEP must include a section on backwards compatibility that describes in detail a plan to complete the remainder of these steps. 2. Once the PEP is accepted as a productive direction, implement an alternate way to accomplish the task previously provided by the feature that is being removed or changed. For instance if the addition operator were scheduled for removal, a new version of Python could implement an "add()" built-in function. 3. Formally deprecate the obsolete construct in the Python documentation. 4. Add an an optional warning mode to the parser that will inform users when the deprecated construct is used. In other words, all programs that will behave differently in the future must trigger warnings in this mode. Compile-time warnings are preferable to runtime warnings. The warning messages should steer people from the deprecated construct to the alternative construct. 5. There must be at least a one-year transition period between the release of the transitional version of Python and the release of the backwards incompatible version. Users will have at least a year to test their programs and migrate them from use of the deprecated construct to the alternative one. From sholden at holdenweb.com Mon Jul 16 08:09:44 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 16 Jul 2001 08:09:44 -0400 Subject: COM: VB client, Python server: NULL result ... References: <q5J37.19922$uJ3.727435@e420r-atl2.usenetserver.com> <3B521442.1080103@ActiveState.com> Message-ID: <mOA47.1406$sx2.94294@e420r-atl3.usenetserver.com> "Mark Hammond" <MarkH at ActiveState.com> wrote in message news:3B521442.1080103 at ActiveState.com... > Steve Holden wrote: > > > On three separate systems I am experiencing the same problem trying to > > create an Python COM object from VB. The VB satetement > > > > Set obj = CreateObject("Python.Dictionary") > > > > (or any other Python COM object) gives the dreaded error 80004005, with the > > message: > > > > Unexpected Python Error: exceptions.SystemError: NULL result without > > error in call_object > > > If you are using a debug COM object, it may be a bug in win32trace.pyd - > this has been fixed in the latest ActivePython and win32all. Creating > Python.Dictionary from WSH works fine for me. > > Mark. Thanks, Mark -- hopes you might be lurking. I was indeed using debugging: I thought it would help! I'll try updating the win32 and see if this fixes things. regards Steve -- http://www.holdenweb.com/ From aleaxit at yahoo.com Tue Jul 3 11:16:34 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 3 Jul 2001 17:16:34 +0200 Subject: modifying sys.path on win98...? References: <3b40d94c.3665104@news.mailops.com> Message-ID: <9hsnkk02cj7@enews1.newsguy.com> "chajadan" <me at charliedaniels.com-1.net> wrote in message news:3b40d94c.3665104 at news.mailops.com... > I'm trying to update the sys.path for python on win98... > > I altered the registry, under local machine, seemingly correct. But > when I access the sys.path to check it, my alterations don't show, > even after rebooting. > > I can use sys.path.append, but the change only lasts until I close > python. Then it reverts back to its original state. > > How do I make the alteration 'permanent' ? You can write in PYTHONHOME (typically C:\Python21 on a Win98 installation of Python 2.1) a textfile with an arbitrary name and extension .pth. Such files are read and processed by site.py on every run of Python (except when the run uses a -S to explicitly bypass site installation, but then all bets are off:-). Blank lines, and lines starting with #, are skipped. Lines starting with import are executed. All other lines are added to sys.path, one directory per such line, if the directory that a line names does actually exist. So, to "permanently" add, say, directory "C:/Blippo" to your sys.path, one simple way is (Python 2.1): import sys, os.path, time pth_file = open(os.path.join(sys.prefix, "Blippo.Pth"), w) pth_file.write("# created by AddBlippo.py on %s\n" % time.asctime()) pth_file.write("C:/Blippo\n") pth_file.close() assuming you want to do it in a Python script -- you can also perfectly well do it with a text editor, of course:-). After site.py has finished preparing sys.path, it also tries to import sitecustomize.py, so, if you need to, you can further tweak the path at this point. E.g., directories added by .pth files tend to go at the END of sys.path -- if you need to have C:/Blippo right at the START of the path (because it must shadow and hide other directories on the path), you'd better see to it in sitecustomize.py (or other custom script import'ed from a .pth file, of course). I think this is decently well documented in the library reference (under module site). Alex From gnb at itga.com.au Thu Jul 12 19:48:38 2001 From: gnb at itga.com.au (Gregory Bond) Date: 13 Jul 2001 09:48:38 +1000 Subject: Not enough Python library development [was PEP scepticism] References: <mailman.994221787.10379.python-list@python.org> Message-ID: <864rsh4skp.fsf@hellcat.itga.com.au> Roman Suzi <rnd at onego.ru> writes: > Maybe PyCAN ;-) > (C for components) As in PyCAN pie? From Tom_Good1 at excite.com Thu Jul 19 14:06:02 2001 From: Tom_Good1 at excite.com (Tom Good) Date: 19 Jul 2001 11:06:02 -0700 Subject: Exceptions' Behaviour References: <mailman.995459309.19355.python-list@python.org> <ac677656.0107181058.71f62494@posting.google.com> <mailman.995526636.21726.python-list@python.org> Message-ID: <ac677656.0107191006.28da887e@posting.google.com> Martin Sj?ren <martin at strakt.com> wrote in message news:<mailman.995526636.21726.python-list at python.org>... > On Wed, Jul 18, 2001 at 11:58:43AM -0700, Tom Good wrote: > > Martin Sj?ren <martin at strakt.com> wrote in message news:<mailman.995459 > 309.19355.python-list at python.org>... > [snip] > > Yes I know that, but that's not what I'm asking. What I'm asking is why i > n > > >>> raise ("a","b") > > the "b" disappears? IMO that's a pretty weird behaviour. Yes anybody usin > g > non-class exceptions derived from Exception in a real-world program are > insane, but this is a puristic thing of mine. :-) > > Martin I agree, it is kind of weird, and I don't know why it works that way. I would probably expect trying to raise a tuple to generate an error. Tom From Patrick.Bothe at ePost.de Tue Jul 3 08:10:25 2001 From: Patrick.Bothe at ePost.de (Patrick Bothe) Date: 03 Jul 2001 14:10:25 +0200 Subject: Python for Commercial Games? References: <9haoiv$jnv$1@mtc1.mtcnet.net> <tjq5huamq17k11@news.supernews.com> <slrn9k21pe.aqd.kamikaze@kuoi.asui.uidaho.edu> Message-ID: <87d77iw6vi.fsf@gabriel.heim6.tu-clausthal.de> Hi, > However, you're not going to do any modern, graphics intensive > game completely in Python. Hmm ... I do not know how much of "Severance - Blade of Darkness -" is written in Python, but I think this game is a good argument against your statement. And where's the difference between using C++ and for example OpenGl (or any other powerful toolkit) and Python and OpenGl? I think i did not get the point. bye, Patrick -- Der Kopf ist rund, (_ ) damit das Denken die Richtung ?ndern kann. \\\@@ ) ^ \/, \( [Francis Picabia] cXc_/_) From arthur.haas at westgeo.com Fri Jul 20 09:58:14 2001 From: arthur.haas at westgeo.com (Art Haas) Date: 20 Jul 2001 08:58:14 -0500 Subject: Large File Support References: <eiW57.266163$Z2.3224218@nnrp1.uunet.ca> Message-ID: <lru207zoqx.fsf@haasart1.dhcp.wg.waii.com> "Rod MacNeil" <rmacneil at interactdirect.com> writes: > Hello NG, > > I need to build Python to include large file support on Redhat Linux 7.1. > > I tried the following instructions from section 8.1.1 in the Python docs but > it doesn't work: > > On large-file-capable Linux systems, this might work: > > > CC="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" > export CC > ./configure > > > I think this fails because the variable CC is expected to have the compiler > name (gcc). > > Does anyone have any alternative instructions? > Don't set `CC', set `CFLAGS' ... $ CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" $ export CFLAGS $ ./configure ... You'll probably have to go in and edit the Makefile, to set these same flags for the `OPT' variable as well. Or, when you run `configure', you could ... $ ./configure OPT="-O2 ${CFLAGS}" ... and things should work. If you want to have debug info in the compiled program, add a `-g' to the OPT variable. Check the makefile when configure finishes to ensure that the largefile flags are in the OPT variable. -- ############################### # Art Haas # (713) 689-2417 ############################### From skip at pobox.com Tue Jul 24 07:41:53 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 24 Jul 2001 06:41:53 -0500 Subject: Emacs and ecb with python In-Reply-To: <87d76r2bej.fsf@frop.house-net> References: <slrn9lh21d.ls.stefan.heimann@honk.ratzer> <87d76r2bej.fsf@frop.house-net> Message-ID: <15197.24321.885588.437830@beluga.mojam.com> >> Hi! Has anyone a patch to use the emacs code browser with python? Eric> look for oobrowser on sourceforge. it claims to do python. Make that oo-browser and you get a cigar: http://sourceforge.net/projects/oo-browser/ -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From robin at jessikat.fsnet.co.uk Sat Jul 7 22:27:17 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sun, 8 Jul 2001 03:27:17 +0100 Subject: PEP scepticism References: <mailman.993747643.21070.python-list@python.org> <9hfqb5$dsllb$3@ID-89274.news.dfncis.de> <3dhex01n1m.fsf@ute.cnri.reston.va.us> <cphewzlbis.fsf@cj20424-a.reston1.va.home.com> <9hlcp4$eiphi$2@ID-89274.news.dfncis.de> <cppubkkbhf.fsf@cj20424-a.reston1.va.home.com> <9hqc3i$f1dia$2@ID-89274.news.dfncis.de> <cpith6l3ip.fsf@cj20424-a.reston1.va.home.com> <iZR5BIA3wdR7EwJx@jessikat.fsnet.co.uk> <mailman.994456001.2112.python-list@python.org> <6Jd$FLAFotR7EwLP@jessikat.fsnet.co.uk> <3B471314.8B179A92@engcorp.com> <5lh$OIA2rxR7Ewou@jessikat.fsnet.co.uk> <3B47256F.72FE6CD0@engcorp.com> <g3+Z6LALyzR7Ewqz@jessikat.fsnet.co.uk> <cp1ynsk324.fsf@cj20424-a.reston1.va.home.com> Message-ID: <GYdgBLAFU8R7EwdF@jessikat.fsnet.co.uk> In article <cp1ynsk324.fsf at cj20424-a.reston1.va.home.com>, Guido van Rossum <guido at python.org> writes >Robin Becker <robin at jessikat.fsnet.co.uk> writes: > ... >> >> For 250 documents to exist there have to be too many cooks for smooth >> development as many organisational studies suggest that best team sizes >> are between 3 and 7. > >Don't jump to conclusions too fast! PEPs aren't numbered >consecutively. There are only about 75 PEPs. Roughly half of those >are historical documents (already implemented or rejected), some are >meta-documents (numbers below 100). The number under consideration is >theoretically about 25; in practice, half of those will never make it. > >--Guido van Rossum (home page: http://www.python.org/~guido/) so is this like version number or report number inflation? Or perhaps something more sinister with integer arithmetic :) -- Robin Becker From guido at python.org Fri Jul 27 11:35:02 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 27 Jul 2001 15:35:02 GMT Subject: Ints and performance (was Re: PEP0238 lament) References: <mailman.996211014.7234.python-list@python.org> <3B6109E3.624BE2B0@engcorp.com> Message-ID: <cppuam2xnr.fsf@cj20424-a.reston1.va.home.com> Peter Hansen <peter at engcorp.com> writes: > That is my point, though. These integer optimizations are, as we > agree, a clear win. Are these optimizations in danger of being impacted > as a result of this unification, or will we still be able to count > on integer performance being significantly better than that of > less frequently used types. What Tim was trying to say was that under the covers we will still use different representations so this kind of optimization will still be possible. --Guido van Rossum (home page: http://www.python.org/~guido/) From gerhard.nospam at bigfoot.de Fri Jul 13 00:13:50 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Fri, 13 Jul 2001 06:13:50 +0200 Subject: MySQLdb - possible without install? References: <3b4d0ea7.11581823@news1.on.sympatico.ca> <slrn9kqr2k.p1.gerhard.nospam@lilith.hqd-internal> <3b4d7a61.39160079@news1.on.sympatico.ca> <slrn9krt7k.nj.gerhard.nospam@lilith.hqd-internal> <3b4e2495.82731972@news1.on.sympatico.ca> Message-ID: <slrn9ksrdc.sa.gerhard.nospam@lilith.hqd-internal> On Thu, 12 Jul 2001 22:34:46 GMT, Ken <ken_chiba at hotmail.com> wrote: >Thanks for your continued help... I'm hitting a wall: I've compiled MySQLdb >(on python 1.5.2) -- I believe that's what my ISP's using, and I have the >files I (think I) need: > >_mysql.so >_mysql_exceptions.py(c) >MySQLdb > - lots of files, and 'constants' within. > >I've copied these three files, plus the MySQLdb directory to the >cgi-bin directory on the host. I placed a simple python script in the >cgi-bin directory that just has: > >#!/usr/contrib/bin/python (the python path) >import MySQLdb >print "Content-Type: text/html\n\n" (so the browser doesn't choke). Should be ok so far. >I get a server 500 message, and checking the error_log file, I get: > >Traceback (innermost last): > File "test.cgi", line 4, in ? > import MySQLdb > File "MySQLdb/__init__.py", line 27, in ? > import _mysql >ImportError: File not found >[Thu Jul 12 17:25:48 2001] [error] [client 206.47.244.60] Premature >end of script headers: /usr/home/v1/a0005722/html/cgi-bin/test.cgi It looks suspiciously like a problem with file permissions. You should check that _mysql.so has read and execute permissions for "others". Taking away both I could reproduce the above error message. In fact, any files in the cgi-bin directory need to be readable by others, because the webserver usually does run under a different user and group id. >I've placed a copy of _mysql.so in both the root cgi-bin directory, >and into the MySQLdb directory (since __init__.py is located there). >But no luck! I looked for a _mysql file (without the .so), but could >not find one. That's not the problem. The file is really called _mysql.so and only needs to be in the cgi-bin directory. Gerhard -- mail: gerhard <at> bigfoot <dot> 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 hard2bsome1 at yahoo.com.au Thu Jul 19 05:23:43 2001 From: hard2bsome1 at yahoo.com.au (Patrick W.) Date: 19 Jul 2001 19:23:43 +1000 Subject: Python 2 times slower than Perl References: <8f41cfd.0107171238.6ff33b9b@posting.google.com> <9j3rvk$26bt$1@norfair.nerim.net> <3B559B30.61A90EA@jam.rr.com> <9j4af20d2o@enews4.newsguy.com> <ZOw57.375583$p33.7544629@news1.sttls1.wa.home.com> Message-ID: <87elrdtgps.fsf@ivory.localhost> "Greg Jorgensen" <gregj at pdxperts.com> writes: > "Alex Martelli" <aleaxit at yahoo.com> wrote in message > news:9j4af20d2o at enews4.newsguy.com... > > > Perl and Python ruled the roost in Prechelt's tests (from the POV > > of development speed), indistinguishable from each other. C and C++ > > made the fastest executables on average. Java was bad on both > > scores -- very slow programs taking a long time to develop. Other > > scripting languages (Tcl, Rexx) gave intermediate development times > > but extremely slow results. Somebody else claims to have rerun the > > same experiment with Common Lisp, getting runtimes competitive with > > C and C++ and development speed competitive with Perl and Python. > > > > We could definitely do with more such tests...!!! There are links to Erann Gat's follow-up study at: http://www.norvig.com/java-lisp.html > With all respect, why? [...] To get a better understanding of which languages it benefits us to learn and teach. Also to get a better understanding of which languages are best used in the "real world", given a set of tradeoffs between development time and program performance. Sounds reasonable enough to me. From phd at phd.fep.ru Thu Jul 12 15:52:29 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Thu, 12 Jul 2001 23:52:29 +0400 (MSD) Subject: 'import' error in csh In-Reply-To: <1Hk37.2714$yb3.51907@e420r-atl1.usenetserver.com> Message-ID: <Pine.LNX.4.33.0107122351390.1375-100000@phd.fep.ru> On Thu, 12 Jul 2001, Steve Holden wrote: > But, preferably: > > #!/usr/bin/env python You cannot pass parameters this way. For example, you cannot write #!/usr/bin/env python -O Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From SBrunning at trisystems.co.uk Tue Jul 3 09:32:03 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Tue, 3 Jul 2001 14:32:03 +0100 Subject: FTP client module Message-ID: <31575A892FF6D1118F5800600846864D78BE03@intrepid> > From: Kemp Randy-W18971 [SMTP:Randy.L.Kemp at motorola.com] > Does Python have an FTP client module, like FTP::Net, which is part of > libnet on www.cpan.com for Perl? If so, is it part of the core Python > package, or do I have to download it? If I need to get it, what is the > website? ftplib is part of the Python Standard Library - see <http://www.python.org/doc/current/lib/module-ftplib.html> for details. 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 bokr at accessone.com Sat Jul 28 02:29:57 2001 From: bokr at accessone.com (Bengt Richter) Date: Sat, 28 Jul 2001 06:29:57 GMT Subject: PEP 238 (revised) References: <cp4rrz5onj.fsf@cj20424-a.reston1.va.home.com> <3B61C0B0.30477AFB@home.net> Message-ID: <3b62459e.609746999@wa.news.verio.net> On Fri, 27 Jul 2001 12:27:44 -0700, Chris Barker <chrishbarker at home.net> wrote: [...] >so if I want to use the result as an index, I'll need to use: > >int(x/y) > >kind of like I now use: > >int(floor(x/y)) > >What I don't get, is why // couldn't return an integer always? It will >always have an integral value. I suppose one problem is that the range >of integers that a float (C double) can handle is larger than a 32 bit >integer can hold. This could be solved in the future with int/long >inification, what will be the behaviour then? > I think it has to do with being consistent with the idea of using the representation type as an indicator of exactness. Using that idea, float is a visible name and means inexact, and int and long are visible and mean exact. Floor can't turn inexact to exact, so it must return inexact (i.e., float) if it gets an inexact (i.e., float) input. int(x) will effectively be an exactness coercion because of the representation-type linkage. If Dr Who takes us forward a bit, and we have no floats or ints, but just exact and approximate numbers, with exact being integers or rationals, and approximate being approximate[1], then you would have to translate your statement to "What I don't get, is why // couldn't return an exact number always?" [1] Approximate numbers will undoubtedly be implemented as floats, but hiding that will let people think about aspects of approximation instead of the hardware below. And if someone came up with a new approximate number representation for special situations, e.g., an alternate rational with bounded numerator/denominator values, it could be implemented without changing the language. The point is you need to know the effectiveness of the approximation for your purposes, not what representation tricks they have come up with for the latest version of Python. Take us back, Dr Who. If the current numeric literal formats persist, as I think they must, then I think the old formats for float should not automatically become formats for approximate. All the numbers you can reasonably enter as literals can be represented exactly, so why not break the 1.0 -> float-hence-inexact chain, and let 1.0 and 1 signify the same thing? Driving the internal representation with a decimal point is arms-length C programming, not Python, IMHO. Evaluating some expressions will result in approximations, but not all the time. Inputs can be exact all the time. Including 0.1 and 1/3, after number unification. (0.1 just becomes 1/10). From ralf.muschall at alphasat.de Fri Jul 13 11:31:21 2001 From: ralf.muschall at alphasat.de (Ralf Muschall) Date: 13 Jul 2001 17:31:21 +0200 Subject: LAMBDA IS IT USELESS? References: <tO837.679712$166.14009323@news1.rdc1.bc.home.com> Message-ID: <u7ae28eth2.fsf@hpeesof.asc> "EricIDLE" <grayson-wilson at home.com> writes: > f = reduce(lambda x,y: x*y,n) > Anyways back to the point the book says this is easier!?!? It is like using nameless intermediary results. You might expand your code into aux = lambda x,y: x*y f = reduce(aux,n) and then replace my first line with the equivalent pair of lines def aux(x,y): return x*y The whole thing is similar to writing f = a*b*c instead of aux = a*b f = aux*c , just with other types (functions instead of numbers). Ralf From skip at pobox.com Mon Jul 2 03:53:20 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 2 Jul 2001 02:53:20 -0500 Subject: Help parsing XML Message-ID: <15168.10352.110362.156821@beluga.mojam.com> Warning: I am a complete XML novice trying to parse some XML I dreamed up with xml.sax.parse. I wrote a simple subclass of xml.sax.ContentHandler to parse some XML. It defines startElement, endElement and characters methods. If I feed it something simple like so: <events> <event> <performers> <performer>James Taylor</performer> <performer>Carly Simon</performer> </performers> <keywords> <keyword>pop</keyword> <keyword>rock</keyword> <keyword>vocals</keyword> </keywords> <start-date>20010701T20:00</start-date> <end-date>20010701T23:00</end-date> <admission-price>$30</admission-price> <venue-name>Pepsi Arena</venue-name> <city>Albany</city> <state>CA</state> <country>US</country> <submitter-name>Skip Montanaro</submitter-name> <submitter-email>skip at mojam.com</submitter-email> </event> </events> it works fine. However, note the absence of <!DOCTYPE ...> and <?xml ...> tags at the start. If I add them at the start of the XML file like so: <!DOCTYPE events SYSTEM "xml-concerts.dtd"> <?xml version="1.0" encoding-"ISO-8859-1"?> <events> <event> ... Python squawks: Traceback (most recent call last): File "parsexml.py", line 72, in ? xml.sax.parse("concert.xml", h) File "/usr/local/lib/python2.1/xml/sax/__init__.py", line 33, in parse parser.parse(source) File "/usr/local/lib/python2.1/xml/sax/expatreader.py", line 43, in parse xmlreader.IncrementalParser.parse(self, source) File "/usr/local/lib/python2.1/xml/sax/xmlreader.py", line 123, in parse self.feed(buffer) File "/usr/local/lib/python2.1/xml/sax/expatreader.py", line 92, in feed self._err_handler.fatalError(exc) File "/usr/local/lib/python2.1/xml/sax/handler.py", line 38, in fatalError raise exception xml.sax._exceptions.SAXParseException: concert.xml:2:0: xml processing instruction not at start of external entity If I zap the <!DOCTYPE ...> tag I get this: Traceback (most recent call last): File "parsexml.py", line 72, in ? xml.sax.parse("concert.xml", h) File "/usr/local/lib/python2.1/xml/sax/__init__.py", line 33, in parse parser.parse(source) File "/usr/local/lib/python2.1/xml/sax/expatreader.py", line 43, in parse xmlreader.IncrementalParser.parse(self, source) File "/usr/local/lib/python2.1/xml/sax/xmlreader.py", line 123, in parse self.feed(buffer) File "/usr/local/lib/python2.1/xml/sax/expatreader.py", line 92, in feed self._err_handler.fatalError(exc) File "/usr/local/lib/python2.1/xml/sax/handler.py", line 38, in fatalError raise exception xml.sax._exceptions.SAXParseException: concert.xml:1:41: syntax error If you're wondering what sort of XML I'm trying to parse, my first cut at a DTD (I'm a complete novice at DTD writing as well) is at http://musi-cal.mojam.com/~skip/concerts.dtd I suspect this is more a problem with my lack of XML expertise than with anything specific I'm doing wrong with my content handler. Suggestions or pointers to appropriate XML tutorial material would be appreciated. Thanks, -- Skip Montanaro (skip at pobox.com) (847)971-7098 From duncan at NOSPAMrcp.co.uk Tue Jul 10 06:35:21 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Tue, 10 Jul 2001 10:35:21 +0000 (UTC) Subject: backslash woes........ References: <3B4AC7C2.DD53F6BB@westerngeco.com> Message-ID: <Xns90DA74BD3B968duncanrcpcouk@127.0.0.1> Martin Franklin <martin.franklin at westerngeco.com> wrote in news:3B4AC7C2.DD53F6BB at westerngeco.com: > I am having trouble with windows path names (i'm a UNIX'ite) > I want to replace the common prefix of a list of file names > with a relative stub (./) I have this... > > def _removePrefix(self, fullfile): > print r'%s' %fullfile Why are you using a raw string here? And why format it at all? Either: print "%s" % fullfile or print fullfile will have the same effect. >filename=re.sub(r'%s' %self.prefix, r'%s' %os.sep, r'%s' %fullfile) Again the r prefix on each of the "%s" format strings does nothing, and in every case formatting a using a format of '%s' does nothing except to convert the value to a string if it wasn't already a string. So this line is equivalent to: filename=re.sub(self.prefix, os.sep, fullfile) If you want to use arbitrary strings in regular expressions, the best thing is to escape them using re.escape: filename=re.sub(re.escape(self.prefix), os.sep, fullfile) but since your regular expression is actually a constant string, why use regular expressions at all? This is equivalent: filename=fullfile.replace(self.prefix, os.sep) I think you maybe misunderstand what raw strings do. Raw strings simply prevent any backslash character that is present in the string from being interpreted as an escape sequence. They don't affect the processing or use of the string in any way. Since none of your literal strings contain backslashes there is no reason to use raw strings. In regular expressions backslashes are special, but so are many other characters that could appear in filenames, even on Unix. -- 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 dek at cgl.ucsf.edu Fri Jul 20 01:56:23 2001 From: dek at cgl.ucsf.edu (David Konerding) Date: 20 Jul 2001 05:56:23 GMT Subject: python 2.1.1 trouble with addsitedir Message-ID: <slrn9lfi07.5n69.dek@socrates.cgl.ucsf.edu> Hi, I am checking my application's compatibility wiht 2.1.1 and I've run into a snag. We use "site.addsitedir" to add a directory to the loading path. As an example, the following works just fine on Python-2.1: [dek at tolkien dek]$ python Python 2.1 (#2, Jul 19 2001, 20:48:59) [GCC 2.95.3 20010315 (release)] on linux2 Type "copyright", "credits" or "license" for more information. >>> import site >>> site.addsitedir("/tmp") >>> but running it with 2.1.1 gives the following: [dek at tolkien Python-2.1.1c1]$ /var/tmp/python/bin/python Python 2.1.1c1 (#1, Jul 19 2001, 22:49:25) [GCC 2.95.3 20010315 (release)] on linux2 Type "copyright", "credits" or "license" for more information. >>> import site >>> site.addsitedir("/tmp") Traceback (most recent call last): File "<stdin>", line 1, in ? File "/var/tmp/python/lib/python2.1/site.py", line 100, in addsitedir if not dirs_in_sys_path.has_key(sitedircase): NameError: global name 'dirs_in_sys_path' is not defined Did some sort of change occur to how global variables behave? dirs_in_sys_path is defined as a dictionary earlier in the file. Dave From mlh at idi.ntnu.no Tue Jul 3 18:49:34 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Wed, 4 Jul 2001 00:49:34 +0200 Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> <bebbba07.0107021206.70a22aa8@posting.google.com> <mailman.994111084.403.python-list@python.org> <etdofr32d4f.fsf@lola-granola.mit.edu> <mailman.994126144.24483.python-list@python.org> Message-ID: <9hti5u$fhn$1@tyfon.itea.ntnu.no> "William Park" <opengeometry at yahoo.ca> wrote in message news:mailman.994126144.24483.python-list at python.org... > It scales linearly with the number of planes. > What I meant is that for each airplane, he needs to calculate the > distance to every other airplanes; that's O(N^2). ;-) I can see you're not very experienced in the field of computational geometry ;) Alex's point was (i assume) that this _isn't_ necessary. I guess it would be hard to get below Omega(n*log(n)) preprocessing (sorting), though. -- 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 mertz at gnosis.cx Tue Jul 17 20:09:05 2001 From: mertz at gnosis.cx (Lulu of the Lotus-Eaters) Date: Tue, 17 Jul 2001 20:09:05 -0400 Subject: Language change and code breaks (fwd) Message-ID: <hONV7kKkXAWG092yn@bellatlantic.net> |Nevertheless, I want to make the clear point (if I haven't already) |that I'm not suggesting screwing every such programmer... just |those who are actively using code which would be broken, who will |not take the time (however small we might make it) to modify the |source, and yet who "must" have their code work under the new Python. Here's a scenario: I--one of those professional programmers--write a Python script for someone who runs a business, or a non-profit, or an agency, to run on their CGI webserver. This client knows not the first thing about Python or about programming, nor do they maintain the webserver, just rent space on it. But still, this script does something useful for users of the website--order products, or request documents, or send data to a database. I go away, no longer available. The client's web hosting company upgrades the Python installation to Python 3.7 (this is in the future :-)). Client's scripts break. -- ---[ to our friends at TLAs (spread the word) ]-------------------------- Echelon North Korea Nazi cracking spy smuggle Columbia fissionable Stego White Water strategic Clinton Delta Force militia TEMPEST Libya Mossad ---[ Postmodern Enterprises <mertz at gnosis.cx> ]-------------------------- From Randy.L.Kemp at motorola.com Tue Jul 3 10:58:36 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Tue, 3 Jul 2001 09:58:36 -0500 Subject: Calculus Message-ID: <E566B020833BD311B6610008C791A39705CA51EA@il93exm04.css.mot.com> Wait a minute! Wasn't Gottfried Wilhelm Leibniz one of the founders of Calculus? And wasn't he also a philosopher, who with his world of monads, said that this is the best of all possible worlds? And didn't the gentlemen direct his question to the Python group? In essence, he is following the philosophy of Leibniz. -----Original Message----- From: Sheila King [mailto:sheila at spamcop.net] Sent: Tuesday, July 03, 2001 9:05 AM To: python-list at python.org Subject: Re: Calculus On Tue, 03 Jul 2001 08:55:32 -0400 (EDT), Andrew Todd <aetodd at wm.edu> wrote in comp.lang.python in article <mailman.994164981.2922.python-list at python.org>: :I wrote: :>Is there a calculus module? I couldn't find one. : :Sheila King wrote: :>What are you talking about? Do you mean a newsgroup for :>discussing calculus? : :No. I probably was too brief. I meant a module for Python :that has functions commonly used in Calculus. For example, :the Simpsons Rule, and the formula that allows you to find :the error. Sorry for the confusion. Oh, shoot, I canceled that message, about two minutes after I posted it. I see it made it to the mailing list half of this group, though. :( I forgot what newsgroup I was reading when I posted that. (I thought I was in a completely different hierarchy, not even comp.* ) Sorry for my stupid message! -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From philh at comuno.freeserve.co.uk Tue Jul 10 21:09:52 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Wed, 11 Jul 2001 02:09:52 +0100 Subject: Bug in rfc822 References: <slrn9khcjv.c7q.philh@comuno.freeserve.co.uk> <QFc27.8798$e5.1167735@newsb.telia.net> <2ih27.49242$he.3402812@e420r-atl1.usenetserver.com> <cp66d2i59b.fsf@cj20424-a.reston1.va.home.com> <slrn9kkcu1.gh1.philh@comuno.freeserve.co.uk> <mailman.994727597.27647.python-list@python.org> Message-ID: <slrn9kn9r0.l0d.philh@comuno.freeserve.co.uk> rOn Mon, 9 Jul 2001 21:12:17 -0400, Barry A. Warsaw <barry at digicool.com> wrote: > >>>>>> "ph" == phil hunt <philh at comuno.freeserve.co.uk> writes: > > ph> I am currently writing a program that reads emails, modifies > ph> them in various ways (adding headers, encryption, etc) and > ph> outputs the result. > >This actually sound like a good fit for mimelib, which is arguably >misnamed (perhaps it should be called maillib?). My encryption system won't really know about mime; it'll encrypt the whole body of the email, regardless of whether it contains mime attachments or not. (It'll also remove and put encrypted into the body several headers that says things about the email's content such as Subject: and whatever headers Mime uses). > ph> As part of this program, I'm writing a mail module that (when > ph> finished) could be hacked into a replacement for rfc822. > ph> rfc822's functionality is to read mail headers and allow > ph> interrogation of their values easily. My module is > ph> conceptually on a higher level; containing a MailHeader class > ph> which can be used to write as well as read ascii > ph> representations of email, and a Mail class that includes the > ph> header and the body; again for composition as well as reading > ph> emails. (for now, it uses rfc822 to parse incoming headsers). > >mimelib uses rfc822 for some functionality, but it has its own Parser >and Generator class (to go from plaintext -> object tree -> >plaintext). It uses rfc822 for some parts of the implementation, such >as parsing addresses and realnames out of strings (so it's vulnerable >to the RFC 2822 updates as well). > > ph> When it is written, perhaps it could be considered for > ph> eventual inclusion in the standard library (I say eventually, > ph> because IMO it'll take me a few attempts to get the API > ph> exactly right) > >That's the hard part, all right! Indeed. > ph> My module doesn't know anything about Mime; which is good > ph> because IMO there is room for a library that is higher-level > ph> than rfc822 but lower levelb than knowing about Mime. > > ph> What is the process of getting a module in the standard > ph> library? > >Post the code. :) I definitely want to look at what you've got, to >see how well (or if) it fits with mimelib. At the moment it's just a class for reading/writing mail headers: #--------------------------------------------------------------------- """*** The MailHeader class stores headers for a rfc822 email message Creation: ~~~~~~~~~ readFromFileHandle(fh) readFromString(str) read the header lines from a file or string Accessing: ~~~~~~~~~~ getheader(name, default) get(name, default) These do the same thing: return the value of a header line. if no (default) is specified and the line doesn't exist, returns none. put(name, value) Sets the value of header-line (name) to (value). Writing output ~~~~~~~~~~~~~~ __str__() asString() These do the same thing: Output all the header-lines as a string Instance variables: ~~~~~~~~~~~~~~~~~~~ self.h = dictionary containing header lines. If there are >1 lines with a particular header, the value will be a list of all the lines, in the order they appeared self.mess = an instance of rfc822.Message, used internally to decode the header messages ***""" class MailHeader: def __init__(self): self.h = {} def readFromFileHandle(self, fh): # get a message object for parsing: self.mess = rfc822.Message(fh) headerNames = self.mess.keys() for hn in headerNames: hValue = self.mess.getheader(hn) self.putAppend(hn, hValue) def readFromString(self, str): stringToFileWrapper = StringIO.StringIO(str) self.readFromFileHandle(stringToFileWrapper) stringToFileWrapper.close() def getheader(self, name, default =None): return self.get(name, default) def get(self, name, default =None): try: value = self.h[name] return value except: # couldn't return a value, use default return default def put(self, name, value): self.h[name] = value def putAppend(self, name, value): if self.h.has_key(name): v = self.h[name] if type(v)==type([]): print "@@@ self.h[%s] was %s @@@" % (name,self.h[name]) v.append(value) print "@@@ self.h[%s] is %s @@@" % (name,self.h[name]) # not sure if we need to add anything here??? else: # it's a string, change to a list: self.h[name] = [self.h[name], value] else: self.h[name] = value def __str__(self): return self.asString() def asString(self): result = "" for name, value in self.h.items(): if type(value)==type([]): for v in value: result = result + name + ": " \ + self._valueMultiline(v) + "\n" else: result = result + name + ": " \ + self._valueMultiline(value) + "\n" return result def _valueMultiline(self, v): """*** if (v) has more than one line, ensure that lines after the first one begin with a space ***""" sa = string.split(v, '\n') for i in range(len(sa)): if i == 0: continue if not utility.startsWith(sa[i], " "): sa[i] = " " + sa[i] v = string.join(sa, '\n') return v #--------------------------------------------------------------------- I'm also thinking of adding a Mail class that'll contain 2 instance variables, (header) for the header (a MailHeader) and (body) (a string) for the body. There would be a Mail.__str__() method to render the whole thing to ascii. There would also be getBody() and setBody() methods. This class wouldn't understand Mime, but a subclass, MimeMail, could be written that would. Presumably MimeMail.setBody() would throw an exception as this wouldn't be the recomended way of adding mime components. Also I think that it would be nice is these classes could be used effectively with Usenet messages, interfacing to the low level nntplib library. > IMO, if we're going aim at >replacing rfc822.py and all the various and sundry MIME attempts, we >ought to do it right, and simplify the choices end-users have to make >in order to manipulate email messages. I agree. -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From guido at python.org Sun Jul 8 08:38:48 2001 From: guido at python.org (Guido van Rossum) Date: Sun, 08 Jul 2001 12:38:48 GMT Subject: [Fwd: Comment on PEP-0238] References: <3B474536.DE27A538@3-cities.com> <200107071818.f67II2g18846@odiug.digicool.com> <mailman.994532292.9464.python-list@python.org> Message-ID: <cphewnionr.fsf@cj20424-a.reston1.va.home.com> "Chris Gonnerman" <chris.gonnerman at newcenturycomputers.net> writes: > Perhaps it's too inconsistent, but I see no reason why longs can't > continue returning "normal" results forever. When you use a long > you know what you are doing, or at least think you do; so you should > expect integer division results just as always. Well, but there's another proposal (that taken by itself would have few detractors) to blur the distinction between int and long. This would do away with the whole OverflowError problem: int calculations whose result doesn't fit in an int would simply and silently return a long instead. This is PEP 237. I don't expect that this will be added to Python 2.2 because there are lots of little details that need to be taken care of, and backwards incompatibilities (e.g. 1<<100 currently yields 0, but 1L<<100 is the same as 2L**100). But given that that is likely to be the way of the future, it seems best to treat int and long division the same way. > What does it buy us to break longs as well as ints? > > Overall I am in favor of *eventually* automatically promoting ints to float > when division is attempted, and likewise converting longs to floats when > dividing one by the other, but I really think we gain nothing by changing > the semantics of division of longs. This is inconsistent. You are saying that you think we gain nothing from something (long division) that you want to change anyway. > I would also say that, when longs and ints are divided together, you should > probably promote the int to a long rather than performing float division. You're thinking of it the wrong way. The operands are first converted to the same type according to specific rules; then that type is asked to perform the operation. So what you are requesting here is already decided, by the existing rule that says that in "int/long", the int is converted to long before the operation takes place. > I really don't think a newbie will appreciate > > >>> 1 / 2 > Traceback (most recent call last): > File "<stdin>", line 1, in ? > IntDivisionError: integer division is invalid > > any more than they currently understand > > >>> 1 / 2 > 0 Good point. So we should switch directly from 1/2 -> 0 to 1/2 -> 0.5. But it's unavoidable that they will get a warning in some versions... e.g. >>> 1 / 2 __main__:1: DeprecationWarning: integer division semantics will change; use x div y to force integer result or float(x)/y to force float result 0 >>> --Guido van Rossum (home page: http://www.python.org/~guido/) From sholden at holdenweb.com Tue Jul 3 07:40:11 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 3 Jul 2001 07:40:11 -0400 Subject: Eiffel better than Python ? References: <f20ea932.0107030100.6c740683@posting.google.com> Message-ID: <%7i07.25728$he.1340574@e420r-atl1.usenetserver.com> "Tomasz Stochmal" <tom at peresys.co.za> wrote in message news:f20ea932.0107030100.6c740683 at posting.google.com... > I have read the following book which gives C/C++ heavy bashing > > http://www.elj.com/cppcv3/ > > Conclusion is to use Java or even better choice is Eiffel > > Should I stop using Python and jump on Eiffel wagon ? > > Anybody that tried both languages ? > > How do they compare ? You're lucky you didn't read a book that told you jumping in the river was a good thing, otherwise you'd be pretty wet by now... Seriously. You have to use your own judgment on these matters. Clearly there are things "wrong" with every programming language. It's a matter of which suits your purposes best. Alternatively: "Yes, Eiffel is much better than anything else. Especially for air traffic control systems" :-) regards Steve -- http://www.holdenweb.com/ From Lutz.Schroeer at kybernetik-manufaktur.de Mon Jul 9 17:30:13 2001 From: Lutz.Schroeer at kybernetik-manufaktur.de (Lutz Schroeer) Date: 9 Jul 2001 21:30:13 GMT Subject: File processing References: <9id5p9$8r62@interserv.etn.com> Message-ID: <Xns90D9EF22CC848Latzikatz@139.174.2.56> "Chris McMillan" <christopherjmcmillan at eaton.com> wrote in news:9id5p9$8r62 at interserv.etn.com: > I'm trying to write a script that will open a file, delete the first > line, and then save the file with the same name. Can someone please > point me in the right direction? Thanks! * open source file, 'r' * open temporary destination file, 'w' * read first line of source file, throw it away * read remaining source file lines and write them to destination file * delete source file * rename destination file to old source file name There are several variations of implementation but this raodmap should guide you to the right direction. latz From paulp at ActiveState.com Mon Jul 9 16:43:27 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Mon, 09 Jul 2001 13:43:27 -0700 Subject: Is Python Dead? Long Live Python! References: <MNS%6.355$Xs4.225014@news.pacbell.net> <458b194a.0107050711.72007607@posting.google.com> <TH%07.3499$i8.339613@e420r-atl3.usenetserver.com> <458b194a.0107060959.6bd34b3f@posting.google.com> <7sn17.7740$i8.679052@e420r-atl3.usenetserver.com> <458b194a.0107071317.508ef7e4@posting.google.com> <mailman.994599260.9137.python-list@python.org> <5174eed0.0107091109.d3a53f6@posting.google.com> Message-ID: <3B4A176F.6C3D57C2@ActiveState.com> > > From what I can tell, PHP and Ruby > > are flying past Python in acceptance rates. The difference that I see > > in these groups, is a sensitivity to industry, rather than an > > adoration for pure acedemic elegance. I think even the Ruby people would be surprised to hear about Edward's statistics about it flying past Python! I've decided to flame Edward offlist because it becomes increasingly difficult to take him seriously. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From chrishbarker at home.net Wed Jul 25 14:36:19 2001 From: chrishbarker at home.net (Chris Barker) Date: Wed, 25 Jul 2001 11:36:19 -0700 Subject: Sorting Lists References: <lSh77.64029$2V.13507417@news3.rdc1.on.home.com> <0bj77.544176$eK2.114166570@news4.rdc1.on.home.com> Message-ID: <3B5F11A3.A3D8C420@home.net> Nick Perkins wrote: > You don't have to use a custom compare sort. > You can get what you want by creating a temp list, consisting of 'decorated' > values, and sorting that list. These are actually tuples whose second > element is the real data, and the first element is a copy of the field that > you want to sort by. (or a computed value, if you want) Note that this will only work if all the items in your list are sortable, not just the one you actually want to sort by, which is often, but not always, the case. Building your own compare function can get around 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 phillip at transwitch.co.za Fri Jul 20 09:25:34 2001 From: phillip at transwitch.co.za (phillip) Date: 20 Jul 2001 06:25:34 -0700 Subject: AttributeError: 'None' object has no attribute Message-ID: <74cc9702.0107200525.64189e36@posting.google.com> Hi I have the following code : from Tkinter import * import Image, ImageTk class UI(Label): def __init__(self, master=None): im = Image.open('c:\\tm.gif') self.image = ImageTk.PhotoImage(im) Label.__init__(self, master, image=self.image, bd=0) def getSetupValues(): return {'Name': 'Phillip'} if __name__ == "__main__": root = Tk() root.geometry('800x600') root.title('Malaysian Web Site Installation') ui = UI(root).pack() root.leftFrame = Frame(width=400, height=600, bg='gray50', relief=RAISED, bd=4) root.rightFrame = Frame(width=400, height=600, bg='gray50', relief=RAISED, bd=4) setup = ui.getSetupValues() for eachKey in root.setup.keys(): Label(root.leftFrame, text=eachKey, bg='gray50', anchor=E).pack() Label(root.rightFrame, text=setup[eachKey], bg='gray50', anchor=E).pack() root.rightFrame.pack(side=RIGHT) root.rightFrame.pack_propagate(0) root.leftFrame.pack(side=LEFT) root.leftFrame.pack_propagate(0) root.mainloop() Everything is fine if i put the function in the __init__ function, which is not a good idea, I want to keep the code compartmentilized nicely. any ideas? Phill From tksee at yahoo.com Tue Jul 31 13:36:40 2001 From: tksee at yahoo.com (Tksee Lhsoh) Date: Wed, 01 Aug 2001 02:36:40 +0900 Subject: Unicode File References: <3B66179D.1D55B27C@yahoo.com> Message-ID: <3B66ECA8.60313BD0@yahoo.com> Thanks Alex and Margin ! And I have one question. How do you know the encoding of a file ? Is it specific to the application which generated the file? > I recommend to use codecs.open. You'll need to specify the encoding, > e.g. > > s = codecs.open("unicode_filename",encoding="ucs-2").read() > From steve at lurking.demon.co.uk Sat Jul 21 14:30:57 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Sat, 21 Jul 2001 19:30:57 +0100 Subject: Is Python Dead? Long Live Python! References: <MNS%6.355$Xs4.225014@news.pacbell.net> <458b194a.0107050711.72007607@posting.google.com> <TH%07.3499$i8.339613@e420r-atl3.usenetserver.com> <458b194a.0107060959.6bd34b3f@posting.google.com> <7sn17.7740$i8.679052@e420r-atl3.usenetserver.com> <458b194a.0107071317.508ef7e4@posting.google.com> <mailman.994599260.9137.python-list@python.org> <5174eed0.0107091109.d3a53f6@posting.google.com> Message-ID: <5bgjlt4d4psovucjusr93r7mfump3tcch3@4ax.com> On 9 Jul 2001 12:09:23 -0700, web2ed at yahoo.com (Edward Wilson) wrote: >Languages never die; they just fall out of use when they loose touch >with the contemporary. Python will become more or less mainstream >(live or die) on it's own merits. > >A scripting language should be good at scripting. From my >observation, Python appears to be headed in more of an acedemic >direction rather than that of mainstream commerce. Acedemics are >good, it's where technology comes from. Unfortunately, I still >haven't found a way to make money using Python. If I can't make money >with Python, then Python is dead to me. I would imagine my voice >represents a small crowd of developers, who wish they too could make >money with and contribute to Python on a daily basis (on company >time). I'm curious - do 'academic' features include such features as... 1. Nested scopes 2. List comprehensions 3. Iterators 4. Generators If so, maybe you should be aware that I *do* make money from Python, and the first two version 2.x features have *already* made that process much easier and much less of a headache, and my only regret with iterators and generators is that they didn't come sooner - being able to write generators would have made a utility I wrote recently - with its own build-in little-language for the input files - much easier, as the scanner, parser, *and* executor could all have been written in a simple imperative style without needing to worry about preserving state between tokens. The lexical and grammar rules were too simple to bother with tool generated scanners and parsers - designing and expressing grammar rules takes time, as does learning the tools input format - but keeping track of what is, in a sense, three concurrent threads is a pain. I'm always seeking out ways to be more effectively lazy in the future. If any task is awkward, fiddly, repetitive or error-prone, I start thinking there must be a better way - and looking for it - especially if that task is one I earn money from. Any paradigm or language feature that allows me to earn more money with less effort gets my vote - just the same as any pre-existing library. Of course, I'm not writing yet another server-side scripted web site. To have any chance of claiming PHP has greater acceptance than Python implies this form of tunnel vision where only server-side scripted web sites have any relevance. I assume more-or-less the same with Ruby, though in truth I've barely heard of it. I certainly believe that Pythons greatest strength is as a scripting language, and that it's suitability for larger applications merely reflects the fact that it is a *good* scripting language - but it isn't a single purpose language by any stretch. Scripting doesn't just mean generating web pages. I don't think the web even existed when Python started out. Believe it or not, computers were used for a *huge* range of applications before the web was invented, and those applications have *not* gone away. From dsh8290 at rit.edu Tue Jul 3 13:04:34 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 3 Jul 2001 13:04:34 -0400 Subject: New Jersey In-Reply-To: <9hsmop$fsg3i$1@ID-11957.news.dfncis.de>; from emile@fenx.com on Tue, Jul 03, 2001 at 07:57:53AM -0700 References: <1b93da20.0107030529.bb6ca89@posting.google.com> <9hsmop$fsg3i$1@ID-11957.news.dfncis.de> Message-ID: <20010703130434.E22543@arizona.cs.rit.edu> On Tue, Jul 03, 2001 at 07:57:53AM -0700, Emile van Sebille wrote: | Post your questions. You'll likely get a good response here. True, or check out the tutor list -- it is specifically designed for new programmers (or new-to-python programmers). -D From spahievi at vega.bg Sat Jul 21 04:15:59 2001 From: spahievi at vega.bg (Niki Spahiev) Date: Sat, 21 Jul 2001 11:15:59 +0300 Subject: software documentation system? In-Reply-To: <20010718195348.75599.qmail@web10306.mail.yahoo.com> References: <20010718195348.75599.qmail@web10306.mail.yahoo.com> Message-ID: <123395071.20010721111559@vega.bg> 18.7.2001, 22:53:48, Graham Guttocks wrote: GG> Greetings, GG> A Python application of mine is now large enough that I need to get GG> more serious about writing a real manual for it. I'm looking for a GG> documentation system that uses a single source file to produce both GG> online information and printed output. (PS, HTML, etc.) GG> Any recommendations? I work in a UNIX environment and would prefer GG> an opensource alternative. So far I've found GNU texinfo and also GG> SGMLtools which is written in Python, but am open to other GG> suggestions. Look at www.easysw.com for htmldoc. It can make PDF and PS books (with TOC) form HTML. -- Best regards, Niki Spahiev From vvainio at karhu.tp.spt.fi Fri Jul 13 04:59:09 2001 From: vvainio at karhu.tp.spt.fi (Ville Vainio) Date: 13 Jul 2001 11:59:09 +0300 Subject: How popular is Python, anyway? (was: Long Live Python!) References: <E566B020833BD311B6610008C791A39705CA5230@il93exm04.css.mot.com> <mailman.994804336.23495.python-list@python.org> <slrn9koofo.mjk.philh@comuno.freeserve.co.uk> <slrn9kpr3e.527.sill@sill.silmarill.org> <Gzj37.13006$B7.2564502@ruti.visi.com> <slrn9ks0mh.9oi.sill@sill.silmarill.org> Message-ID: <yox4rsh6w82.fsf@karhu.tp.spt.fi> sill at optonline.net (Rainy) writes: > this and that, and getting hired. I actually did use some python at my > previous job (some cgi/image manipulation). I was then asked to redo it > in perl :-/." And that's when you reached for your revolver? I understand why it was your previous job, not current :-). This brings to my mind the techie Prima donna article referenced in slashdot a while ago: http://www.itrecruitermag.com/magazine/display-management101.asp?ContentID=603 I assume it would require quite a "team player" to agree to do something as revolting as turning a beautiful piece of python to a heap of line noise. -- 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 Gareth.McCaughan at pobox.com Thu Jul 26 17:14:30 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Thu, 26 Jul 2001 22:14:30 +0100 Subject: [OT] Number theory [Was: A use for integer quotients] References: <yCK67.17615$EP6.4467503@news1.rdc2.pa.home.com> <mailman.995860718.9550.python-list@python.org> <mailman.995862939.15013.python-list@python.org> <mailman.995883879.12071.python-list@python.org> <3B5C5665.8D41D1F1@tundraware.com> <slrn.pl.9los0f.jh4.qrczak@qrnik.zagroda> <3B5C749A.59F97320@tundraware.com> <JDa77.97061$Rr4.549007@ozemail.com.au> <Xns90E97C9849AD5robindotgarneratinam@172.18.25.3> <IjA77.97824$Rr4.589251@ozemail.com.au> <3b602afa.930850@nntp.sprynet.com> Message-ID: <slrn9m121m.e6f.Gareth.McCaughan@g.local> David Ullrich wrote: [someone else:] >> So strictly speaking, Z (the set of integers) is not a subset of R (the set >> of reals)? > > Strictly speaking yes, but nobody _ever_ speaks this strictly > (except in contexts like the present). > > We math guys have reduced more or less everything to sets these > days - fewer things at the bottom to keep track of. So when we > want to define a "type" with certain "properties" we figure out > how to "code" such a thing as a certain sort of set. But almost > always what set something actually is makes no difference, all > that matters is how it works. > > Strictly speaking the natural number 2 is the set {{},{{}}} Tut. You're failing to distinguish interface from implementation. That's one way to define the number 2, which happens to be the usual one at the moment. It's not the only way. Frege wanted 2 to be the set of *all* unordered pairs {x,y}, and there are versions of set theory in which that definition works. In NF, sometimes 2 is defined as {{{}}}. Or there's the Conway approach, according to which the primitive notion is that of "ordered pair of sets" and 2 is an equivalence class whose "typical" member is ({0,1}, {}). I'm pretty sure you already know all this, but it's worth saying explicitly. :-) > So yes, strictly speaking the integers are not a subset > of the reals. But nonetheless if someone asks "Are the > integers a subset of the reals?" the _right_ answer > is "yes"; the answer becomes "no" only if we're focussing > on the irrelevant aspects of things. Right. And, actually, I'd say that the isomorphic image of (say) Z inside R *is* the integers. For exactly the reasons you mention, what you really mean when you say "the integers" is "anything that behaves like the integers". That copy of Z is such a thing. The fact that for some foundational purposes you start by constructing another copy of Z doesn't invalidate that. So, I say: for *all* purposes "the integers are a subset of the reals", unless for some technical reason you *have* to pick an implementation of the integers *and* can't make it be the one that lives inside R. -- Gareth McCaughan Gareth.McCaughan at pobox.com .sig under construc From aahz at panix.com Fri Jul 27 20:39:48 2001 From: aahz at panix.com (Aahz Maruch) Date: 27 Jul 2001 17:39:48 -0700 Subject: PEP0238 lament References: <3B5B3676.40F39389@alcyone.com> <vyIKbWAP62W7EwC+@jessikat.fsnet.co.uk> <9jg6ei$ges7$1@sky.inp.nsk.su> <e4O67.17873$EP6.4677310@news1.rdc2.pa.home.com> Message-ID: <9jt1kk$en4$1@panix2.panix.com> In article <e4O67.17873$EP6.4677310 at news1.rdc2.pa.home.com>, Terry Reedy <tjreedy at home.com> wrote: > >Moshe's current proposal cleanly separates the two types: '/' will be >fractional result and '//' will be integer result (including >floor(float/float)). So 8/3 = 8.0/3.0 = 2.33333, while 8//3 = 2 and >8.0//3.0 = 3.0, which is the same to within type, just as 3+8 == >(withing type) 3.0+8.0. (I am not sure about complex//complex since I >an not sure if floor(complex) is defined -- floor(x) + floor(y)*j?) >This is arguably what Python should have started with. Uh, I think you meant 2.666666667 and 2.0 up there. -- --- 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 Fortune cookie: Watch your relations with other people carefully, be reserved. From duncan at NOSPAMrcp.co.uk Mon Jul 16 05:53:08 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Mon, 16 Jul 2001 09:53:08 +0000 (UTC) Subject: converting from perl: variable sized unpack References: <roy-B2459F.22112513072001@news1.panix.com> <mailman.995081424.8581.python-list@python.org> <slrn9l4esk.885.quinn@yak.ugcs.caltech.edu> Message-ID: <Xns90E06CD541CC7duncanrcpcouk@127.0.0.1> quinn at yak.ugcs.caltech.edu (Quinn Dunkan) wrote in news:slrn9l4esk.885.quinn at yak.ugcs.caltech.edu: > Ruby allows * notation: > > a, b, *c = sequence # `c' gets the rest of the sequence > > which is cute, but I don't like it. Just another random "convenient" > little trick to remember. It's not half as useful as the 1.6 * apply > trick. Let's go easy on the syntax gimmicks. The Python equivalent to the Ruby trick really isn't that much longer, and to my mind has the advantage of showing more clearly the programmer's intent: (a, b), c = sequence[:2], sequence[2:] -- 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 nperkins7 at home.com Fri Jul 13 18:01:15 2001 From: nperkins7 at home.com (Nick Perkins) Date: Fri, 13 Jul 2001 22:01:15 GMT Subject: static methods and meta classes References: <nIJ37.79679$WT.15186091@typhoon.austin.rr.com> Message-ID: <LcK37.466754$eK2.97121455@news4.rdc1.on.home.com> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52304 "Rod Mancisidor" <rmancisidor at austin.rr.com> wrote in message news:nIJ37.79679$WT.15186091 at typhoon.austin.rr.com... > For reasons that are a bit complicated to explain I have developed a program > that passes classes around quite a bit as parameters. I now need to > associate methods that can be invoked on the class objects themselves as > opposed to the instances of the class. As an example, for a given class: > > class Foo: > def f(self, param): return param + 1 > > I need to invoke Foo.f(10). This obviously won't work given that f is not a > static method. So I thought I could to this: > > class MetaFoo: > def f(self, param): return param + 1 > > class Foo: > __class__ = MetaFoo > > In the hope that python could think of Foo as a class that is also an > instance of MetaFoo and allow me to invoke: > > Foo.f(10) > > This does not work. I wonder why, every other undocumented crazy thing I > have tried in Python works. Does anyone know how to trick Python into > supporting static methods? > > If you have a reply and can also send it to rod at mancisidor.com I would > appreciate it. > > Thanks > > > > From ullrich at math.okstate.edu Sat Jul 28 10:37:08 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sat, 28 Jul 2001 14:37:08 GMT Subject: (in)exactness of complex numbers References: <mailman.996249232.22459.python-list@python.org> <cp4rry2qvh.fsf@cj20424-a.reston1.va.home.com> Message-ID: <3b62cc78.3396597@nntp.sprynet.com> On Fri, 27 Jul 2001 18:01:36 GMT, Guido van Rossum <guido at python.org> wrote: >Skip Montanaro <skip at pobox.com> writes: > >> Once these numeric changes are all implemented, if I define a complex >> constant with either integer real or imaginary parts, e.g. >> >> c = 1+2.1j >> >> d = 1.2+5j >> >> e = 4+7j >> >> should I get an integer back (exact) or a float (inexact) when asking for an >> attribute that was originally an integer? In general, can complex numbers >> be considered to have two exactness attributes? > >That's probably not worth the implementation complexity. I expect >that all floats and complex will be considered inexact, and all >rationals and ints exact. That seems to be the most practical set of >rules, even if it doesn't satisfy everybody. Again, don't get the idea I'm actually saying you should worry about this. But it looks to me like you've missed the point - at least it looks to me like you've missed what it seems to me the point is: If all floats are inexact and ints and rationals are exact fine. But why should the real and imag of a complex be required to be floats in the first place? Why shouldn't they be allowed to be floats or rationals or integers? (Of course that would complicate things, which is why I'm not saying this is how it should be. But I don't think the people talking about complexes being either exact or not are necessarily disputing the idea that ints and rationals should be exact and floats should be inexact. Surely a vector class or a matrix class should allow the entries to be of various types, why shouldn't complexes?) >--Guido van Rossum (home page: http://www.python.org/~guido/) David C. Ullrich From donn at u.washington.edu Tue Jul 10 14:31:28 2001 From: donn at u.washington.edu (Donn Cave) Date: 10 Jul 2001 18:31:28 GMT Subject: File processing References: <9id5p9$8r62@interserv.etn.com> <mailman.994736537.19096.python-list@python.org> <994742167.67214@yabetcha.drizzle.com> <mailman.994784546.10619.python-list@python.org> Message-ID: <9ifhm0$jgc$1@nntp6.u.washington.edu> Quoth Skip Montanaro <skip at pobox.com>: | | Donn> That's cool, but you might be interested to see if tail on your | Donn> platform supports a positive index (bet it does): | | It works, but with no discernable effect Dang, I meant to say tail +2, not tail +1 - off by one, again! Donn Cave, donn at u.washington.edu From max at alcyone.com Tue Jul 10 11:42:31 2001 From: max at alcyone.com (Erik Max Francis) Date: Tue, 10 Jul 2001 08:42:31 -0700 Subject: os.nice (or docs) BUG? References: <mailman.994755195.13246.python-list@python.org> Message-ID: <3B4B2267.9B490F2E@alcyone.com> Roman Suzi wrote: > It's docs inaccuracy or os.nice() bug? Or glibc bug? It's a bug in the documentation; os.nice is just returning the value return by nice(2), which is platform dependent. On Linux, it isn't the new nice value. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ No man is more cheated than the selfish man. \__/ Henry Ward Beecher Esperanto reference / http://mirror/alcyone/max/lang/esperanto/ An Esperanto reference for English speakers. From hobomo at austin.rr.com Wed Jul 25 17:03:28 2001 From: hobomo at austin.rr.com (James Money) Date: Wed, 25 Jul 2001 16:03:28 -0500 Subject: Learning Python References: <20010724.144042.1258638252.27706@localhost.localdomain> Message-ID: <3B5F3420.42BF30C6@austin.rr.com> I recommend 'Learning Python' in the O'Reilly series. If you intend to learn Tkinter also (for the GUI), you might look at 'Tkinter and Python Programming' Paul wrote: > I would like to know what sources are available for learning how to > program with python. Any help would be appreciated very much. > > Thanks in advance. > -- > http://mail.python.org/mailman/listinfo/python-list -- James Money hobomo at austin.rr.com 512-343-1266 From timr at probo.com Wed Jul 18 01:48:44 2001 From: timr at probo.com (Tim Roberts) Date: Tue, 17 Jul 2001 22:48:44 -0700 Subject: python2.1 pythonw.exe base address References: <83weaIAguDV7EwJm@jessikat.demon.co.uk> Message-ID: <me8altkhiogbki58a1u1br7rr41nl33bt1@4ax.com> Robin Becker <robin at jessikat.fsnet.co.uk> wrote: >I don't know how much this is of real interest, but using the latest >proc explorer from http://www.sysinternals.com/ I notice that >pythonw.exe has a base address of 0x1e190000, but that python21.dll >wants to reside at 0x1e100000 and has a length of 0xAF000, the result is >that python21.dll gets relocated. Yes; "link /dump /headers" shows the same thing. Why isn't pythonw.exe based at 00400000 like most well-behaved executables? Rebasing to 1E190000 unnecessarily fragments linear space. >Redefining the base address of pythonw to be something non-controversial >that didn't overlap would be a zero cost win for tk apps. > >as an aside it seems that tcl83.dll and _tkinter.pyd are also relocated, >but I don't know the desired base address. tcl83.dll is at the default base of 10000000. _tkinter.pyd is set to 1E190000, same as pythonw.exe. I have to believe the pythonw.exe base address is a bug. -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From new_name at mit.edu Sat Jul 21 13:45:54 2001 From: new_name at mit.edu (Alex) Date: 21 Jul 2001 13:45:54 -0400 Subject: If you want to see Python people complaining... References: <3B54497F.B98D34CF@jam.rr.com> <20010721.072418.846942590.1761@d150-169-166.home.cgocable.net> Message-ID: <etd7kx2xjjh.fsf@w20-575-7.mit.edu> Enh, who cares? Everyone knows the slashdot poll is the only one that matters, anyway. Alex. From inigoserna at terra.es Tue Jul 3 19:20:44 2001 From: inigoserna at terra.es (=?ISO-8859-1?Q?I=F1igo?= Serna) Date: 04 Jul 2001 01:20:44 +0200 Subject: problems with class initiation In-Reply-To: <Xns90D35C03C7035duncanrcpcouk@127.0.0.1> References: <mailman.994017363.31520.python-list@python.org> <9ho0dl$ri0$1@tyfon.itea.ntnu.no> <JIL%6.24504$zT1.1243653@e420r-atl3.usenetserver.com> <Xns90D35C03C7035duncanrcpcouk@127.0.0.1> Message-ID: <994202445.13668.0.camel@lethe.infernus.org> Thanks to Nick, Magnus, Steve and Ducan for answering. Finally, the best solution was the obvious, so I pass Main's self reference to the constructor of Second class. I didn't like this way, it seemed a bit ugly (perhaps because I don't know much OO... well, in fact I didn't like OO at all until I found python ;-) Ah, and the return value of the __init__ constructor was just because I needed to write a rapid example... Thanks again, I?igo Serna From nospam at nospam Mon Jul 30 14:04:51 2001 From: nospam at nospam (Rufus V. Smith) Date: Mon, 30 Jul 2001 14:04:51 -0400 Subject: re bad leadership References: <0+yM4IAgmKX7EwIQ@jessikat.fsnet.co.uk> <9juspa$8p0$1@panix2.panix.com> Message-ID: <3b65ae3f$0$876@wodc7nh1.news.uu.net> I know what it stands for, but being an acrophobia fan, I couldn't help but thing of a couple crude meanings with the final L standing for "loudly" "Aahz Maruch" <aahz at panix.com> wrote in message news:9juspa$8p0$1 at panix2.panix.com... > In article <0+yM4IAgmKX7EwIQ at jessikat.fsnet.co.uk>, > Robin Becker <robin at jessikat.fsnet.co.uk> wrote: > > > >MDFL > > What does this stand 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 > > Fortune cookie: Watch your relations with other people carefully, be reserved. From peter at engcorp.com Tue Jul 17 09:13:44 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 17 Jul 2001 09:13:44 -0400 Subject: web interface to c program running on different server References: <3B53B116.86535A3@usa.net> <3B53BB43.986D70AE@engcorp.com> <3B53C285.F8405344@usa.net> Message-ID: <3B543A08.5E66740C@engcorp.com> Lee wrote: > > I wasn't asking the readers to provide me with a list of pros and cons - > those would be for me to figure out when I have a few suggestions for > implementations. In other words, "don't think about it, just do it". I get it. <1/2 wink> > As for the the questions, I consider them to be mostly irrelevant but... But you're the one asking for help here. Maybe to those whom you've asked to do the actual replying, they are not irrelevant. [summary of reasonable replies to my other questions] So it's likely a Linux-based, moderate to low performance system written as a student project which is expected to be supported for some time. Some reliability/security issues might have to be addressed. That's a good start. > Random suggestions would be a start, but I hope this has cleared things up > a little... I think it did! Really, although you'll get some random suggestions, around here if you provide enough detail you'll often get far more than that. In all cases, the more background you provide with a question, the more effective your responses. As far as judging pros and cons, you might also consider that the people in this forum are probably in a better position to judge that after learning a little bit about your context, than you are after hearing a little bit about their suggestions. Don't implicitly put down the people who might be about to help you out. (What about the nature of the interface to the C program? How does it produce its output? Writing to a file? Can it be run simultaneously on multiple threads? Is it CPU- bound so that you want some mechanism to serialize accesses or is it so fast that won't matter? Or does it support a socket interface directly to serve up the data, but just not in an HTML compatible way? There are lots of relevant questions revolving around your "server X".) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From aahz at panix.com Sun Jul 15 00:56:23 2001 From: aahz at panix.com (Aahz Maruch) Date: 14 Jul 2001 21:56:23 -0700 Subject: Newbie list question References: <13c69f60.0107130843.5cd7dc38@posting.google.com> Message-ID: <9ir7pn$afo$1@panix2.panix.com> In article <13c69f60.0107130843.5cd7dc38 at posting.google.com>, Matthew Alton <Matthew.Alton at Anheuser-Busch.COM> wrote: > >I am a UNIX/C programmer w/15y experience. Forgive me if my neural >pathways are all about following pointers. The adjustment to >Python-think is bumpy but I'll get by with a little help from my >friends, eh? Python becomes much easier to understand once you switch from "variables" and "references" to "names" and "bindings". A name in Python is bound to an object. Every time you execute the assignment statement, the name gets re-bound. All objects are global; names exist in namespaces. -- --- 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 "How come we choose from just two people for President but more than 50 for Miss America?" --AEN From sholden at holdenweb.com Thu Jul 26 20:59:08 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 26 Jul 2001 20:59:08 -0400 Subject: Language change and code breaks References: <Pine.LNX.4.33.0107191316390.24983-100000@bms> <mailman.995571273.18192.python-list@python.org> <9j7gv8$9mg@dispatch.concentric.net> <cppuawfqbm.fsf@cj20424-a.reston1.va.home.com> <mailman.995734717.26373.python-list@python.org> <3B5DF101.9B2E4631@earthlink.net> <cpofq9a858.fsf@cj20424-a.reston1.va.home.com> Message-ID: <A%287.1144$oc6.134253@e420r-atl3.usenetserver.com> [posted & mailed] "Guido van Rossum" <guido at python.org> wrote ... > > But never mind, I'm giving up on making *Python* case-insensitive. > The hostility of the user community is frightening. > I find this a saddening remark. Perhaps the vehemence of some of the reactions is an indication of how much users value your language. I'm sure you are quite capable of ignoring personal abuse and ill-informed comment that suggests you do not have the best interests of the Python community at heart. I comment on your proposals, as do many others, to offer an alternative point of view (though I'm sure many times my comments have already been thought about). Do I take the emphasis to mean that you are thinking about making *some other language* case-insensitive? regards Steve -- http://www.holdenweb.com/ From gnb at itga.com.au Thu Jul 12 20:29:26 2001 From: gnb at itga.com.au (Gregory Bond) Date: 13 Jul 2001 10:29:26 +1000 Subject: Is this a true statement: Part III References: <9hsckg$4rt$1@taliesin.netcom.net.uk> <9hsmh1$gtt$1@panix2.panix.com> Message-ID: <86vgkx3c49.fsf@hellcat.itga.com.au> aahz at panix.com (Aahz Maruch) writes: > The contractor chose to use C++. The DLL that was > delivered failed miserably in following the spec Surely that says much more about the quality of the contractor than the language they chose to use? From aleaxit at yahoo.com Mon Jul 16 08:12:52 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 16 Jul 2001 14:12:52 +0200 Subject: converting from perl: variable sized unpack References: <roy-B2459F.22112513072001@news1.panix.com> <mailman.995081424.8581.python-list@python.org> <slrn9l4esk.885.quinn@yak.ugcs.caltech.edu> <roy-E01423.21425015072001@news1.panix.com> Message-ID: <9iulp401r93@enews3.newsguy.com> "Roy Smith" <roy at panix.com> wrote in message news:roy-E01423.21425015072001 at news1.panix.com... > quinn at yak.ugcs.caltech.edu (Quinn Dunkan) wrote: > > Even without that, I argue that a bad pattern match should throw an > > exception and not assign None > > I have to admit, that would be somewhat consistant with the way the rest of > the language works, but it sure would make it more complicated to do > something like: > > if re.match (pattern1, string): > do stuff > elif re.match (pattern2, string): > do other stuff > elif re.match (pattern3, string): > etc, etc, etc. I find I can rarely throw away the match-objects in this cavalier way, because they carry much, often-needed information -- so, I don't get to use this idiom anyway. Rather, I have to code: mo = re1.match(thestring) if mo: dostuff(mo) else: mo = re2.match(thestring) if mo: dootherstuff(mo) else: mo = re3.match(thestring) if mo: etcetcetc(mo) else: nomatchatall() which is hardly elegant and clean. If a failing re.match raised ReException, and auxiliary functions dostuff &c were guaranteed not to propagate ReException themselves, then...: try: dostuff(re1.match(thestring)) except ReException: try: dootherstuff(re2.match(thestring)) except ReException: try: etcetcetc(re3.match(thestring)) except ReException: nomatchatall() still a bit too 'nestful' for comfort, but better than the current alternative IMHO. Alex From ngps at madcap.dyndns.org Mon Jul 9 11:39:23 2001 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 9 Jul 2001 15:39:23 GMT Subject: Integrating SimpleHTTPServer into asyncore References: <3B491961.12A83FE5@alcyone.com> Message-ID: <9icj7b$8df$1@dahlia.singnet.com.sg> According to Erik Max Francis <max at alcyone.com>: > Is there a standard way to integrate SimpleHTTPServer (and related > classes) into the asyncore poll loop, or is it just the rather obvious > process of creating a dispatcher that containers a SimpleHTTPServer and > delegates all the relevant asyncore methods to SimpleHTTPServer? Just use Medusa's http_server. Medusa does HTTP/1.1 with persistent connections; SimpleHTTPServer (really BaseHTTPRequestHandler) does HTTP/1.0 only. Some refactoring of Medusa and/or BaseHTTPRequestHandler to simplify writing HTTP method (GET, POST, etc.) handlers that are portable to both would be nice; e.g., send_header(), end_headers() versus Medusa's http_response object. -- Ng Pheng Siong <ngps at post1.com> * http://www.post1.com/home/ngps Quidquid latine dictum sit, altum viditur. From donn at u.washington.edu Thu Jul 5 18:31:44 2001 From: donn at u.washington.edu (Donn Cave) Date: 5 Jul 2001 22:31:44 GMT Subject: Question about scope References: <3B44D696.61A8B915@tundraware.com> <3B44D89A.1DF28AD9@tundraware.com> <3B44DBDF.41C4CF2F@snakefarm.org> Message-ID: <9i2psg$o14$1@nntp6.u.washington.edu> Quoth Carsten Gaebler <clpy at snakefarm.org>: | Tim Daneliuk wrote: |> I guess what I want to know is when globally declared objects are seen inside a function, class, or |> block, and when they must be explicitly declared as being global. | | You can always 'read' a global variable in a function, e.g. | | g = 0 | def func(): | print g | func() | | prints '0'. If you want to modify a global variable inside a function you | need to declare it as global: | | g = 0 | def func(): | global g | g = 1 | func() | print g | | prints '1'. | | Otherwise an assignment inside a function will create a new variable in | the local namespace: | | g = 0 | def func(): | g = 1 | print g | | prints '0' because g=1 only exists inside func(). As long as we're here - the queerest thing is when you combine the two in this order: g = 0 def func(): print g g = 1 That will raise an "UnboundLocalError", because (as I understand it) the interpreter already classified g as local at "compile" time, when it saw the assignment. Not at run time when it actually performs the assignment. Donn Cave, donn at u.washington.edu From treaves at silverfields.com Thu Jul 12 13:38:57 2001 From: treaves at silverfields.com (Timothy Reaves) Date: Thu, 12 Jul 2001 13:38:57 -0400 Subject: Compile 2.1 problem In-Reply-To: <Pine.LNX.4.30.0107122127300.3555-100000@rnd.onego.ru> References: <20010712125340.5baf980b.treaves@silverfields.com> <Pine.LNX.4.30.0107122127300.3555-100000@rnd.onego.ru> Message-ID: <20010712133857.6e90786a.treaves@silverfields.com> On Thu, 12 Jul 2001 21:27:59 +0400 (MSD) Roman Suzi <rnd at onego.ru> wrote: > On Thu, 12 Jul 2001, Timothy Reaves wrote: > > > Hello. I'm trying to compile python2-2.1-5.src.rpm on a SuSE 7.1 system. It gets along a ways and then: > >/usr/bin/install -c -m 644 ./LICENSE /var/tmp/python2-2.1-root/usr/lib/python2.1/LICENSE.txt > >PYTHONPATH=/var/tmp/python2-2.1-root/usr/lib/python2.1 \ > > ./python -tt /var/tmp/python2-2.1-root/usr/lib/python2.1/compileall.py /var/tmp/python2-2.1-root/usr/lib/python2.1 > >Listing /var/tmp/python2-2.1-root/usr/lib/python2.1 ... > >Compiling /var/tmp/python2-2.1-root/usr/lib/python2.1/BaseHTTPServer.py ... > >make: *** [libinstall] Segmentation fault > >Bad exit status from /var/tmp/rpm-tmp.83840 (%install) > > Does it occur at the same palce everytime? > > (I not so, you have hardware problems) > Yes, at the same place. From gustavo at ifour.com.br Fri Jul 20 13:03:30 2001 From: gustavo at ifour.com.br (Gustavo Vieira Goncalves Coelho Rios) Date: Fri, 20 Jul 2001 14:03:30 -0300 Subject: string random generator (Sorry if too stupid, but i am a beginner) Message-ID: <20010720140330.B39397@ifour.com.br> Hi folks! I am in need for a function that return a string of len x random generated, like strrnd(5) 'Df%d^' strrnd(2) '&@' I have the following code: The problem is that i don't known how to map a int to a char. import random def strrnd(n = 24) : result = [] while n : n = n - 1 result.append(random.randrange(1,255,1)) return result How may i get what i want. (Sorry if too basic, but i am a python beginner). Another problem: This functins will be called thousands of time a minute, so performance is a definitive requirement. -- Whatever became of eternal truth? From pinard at iro.umontreal.ca Fri Jul 20 18:09:22 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 20 Jul 2001 18:09:22 -0400 Subject: Case insensitivity In-Reply-To: <cpvgkofyru.fsf@cj20424-a.reston1.va.home.com> References: <mailman.995506711.21636.python-list@python.org> <cpvgkofyru.fsf@cj20424-a.reston1.va.home.com> Message-ID: <oq7kx38d7x.fsf@lin2.sram.qc.ca> [Guido van Rossum] > TeachScheme is an interesting case -- Scheme is a case-sensitive > language, but in "beginner mode", TeachScheme is case-insensitive. I Did it change recently? I thought Scheme was case-insensitive. An idiom I saw a few times in Scheme code, written by other people, is writing `lambda' or `cdr' when you mean what it means, and `LAMBDA' and `CDR' when you are quoting the same, for example when you write code which produces code. But DSSSL, which introduces a flavour of Scheme, is case-sensitive. (Please someone correct me if I'm wrong.) That is an improvement. > My own intuition and experience tells me that there seem to be two > kinds of people: some folks think case-sensitively, others think > case-insensitively. There are also people who like spelling correctly, and others who do not care. The later kind might ask that Python be forgiving about dyslexic errors on Python keywords or variables names, and might even argue that this would tremendously help beginners. > It's been argued that making string, String, STRING and StRiNg mean > the same thing makes for less readable programs. I agree. A good > programming environment should silently correct the case of > identifiers as you type to conform to the definition. Yes, quite agreed. It is the job of the editing environment to take care of dyslexic errors, case discrepancies, or case clashes. Python in itself, as a language, does not really have to be modified to take care of such things. Beginners, or children, should merely use a suitable environment: I do not understand the purpose of modifying the language itself for them. What or where is the gain? > To me, the only real important question is, how can we introduce > case-sensitivity for novices without breaking the millions of lines of > existing Python code. One option could be: forget it, it's too late. > Another: put the case-insensitivity in the tools. (I presume you meant "case-insensitivity" on the second line of the above paragraph). Would not it be convenient, before asking "how", to wonder "why"? The real prerequisite question might be to define quite precisely "What are we wanting to achieve, here?". Once this done, another question might be to ask ourselves? "Is modifying the language the proper answer to about how to reach the goals?", meaning the goals identified by the first question. I worry a bit that you state that the real important question is "how", as if you were trying to escape the prerequisite questions, or maybe trying to tell us that your mind got firm answers about them. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From moshez at zadka.site.co.il Mon Jul 23 00:13:26 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Mon, 23 Jul 2001 07:13:26 +0300 Subject: PEP0238 lament In-Reply-To: <3B5B7689.F37B991C@alcyone.com> References: <3B5B7689.F37B991C@alcyone.com>, <3B5B3676.40F39389@alcyone.com>, <mailman.995826216.11537.python-list@python.org> <eppstein-03540D.13070222072001@news.service.uci.edu> <mailman.995836120.7223.python-list@python.org> Message-ID: <E15OX5y-0005Rk-00@darjeeling> On Sun, 22 Jul 2001 17:57:45 -0700, Erik Max Francis <max at alcyone.com> wrote: > That's quite different from the current case, where we're talking about > an operation that will return different types depending on the inputs. > I don't see any good reason to change the current behavior; / means > division over the types that are passed in. It does? I fail to see why people assume that operations *have* to return the type of their operands. In this case, succumbing to this rule means that we violate much more important, IMHO, rules, like >>> a==b 1 >>> c==d 1 >>> a/c == b/d 0 (the part before that is: Python 2.1 (#1, Apr 27 2001, 01:24:08) [GCC 2.95.3 20010219 (prerelease)] on linux2 Type "copyright", "credits" or "license" for more information. >>> a,b,c,d=1,1.,2,2. Of course) > If you pass in ints, you want integer division. I do? > Sorry, lazily pasted something into my .sig database. It was meant to > be: > > http://www.alcyone.com/max/lang/esperanto/ Thanks! -- gpg --keyserver keyserver.pgp.com --recv-keys 46D01BD6 54C4E1FE Secure (inaccessible): 4BD1 7705 EEC0 260A 7F21 4817 C7FC A636 46D0 1BD6 Insecure (accessible): C5A5 A8FA CA39 AB03 10B8 F116 1713 1BCF 54C4 E1FE From hao-nghi.au at fr.thalesgroup.com Wed Jul 18 03:08:51 2001 From: hao-nghi.au at fr.thalesgroup.com (hao-nghi.au at fr.thalesgroup.com) Date: Wed, 18 Jul 2001 09:08:51 +0200 Subject: command substitution Message-ID: <33105F8B185CD51182E300306E06473E2701A8@hermes.isr.thomson-csf.com> Hi Rapha?l, I think you can define a function like : import os, string def GetStdOut(cmd): pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r') return string.split(string.strip(pipe.read()),'\n') then : OUT=GetStdOut('ls') Regards, Hao-Nghi Au -----Original Message----- From: Raphael Bauduin [mailto:rb at tiscali.be] Sent: Monday, July 16, 2001 10:35 AM To: python-list at python.org Subject: command substitution Hi! I was looking for a solution like in bash, which let you put the standard output of a command in a variable(in bash, you can do it like OUT=`ls` or OUT=$(ls) ). If you have another way to take the standard output of a command and put it in a variable, it would be helpfull too. Thanks. Raph -- Open Source and Free Software Developers Meeting See you at the 2002 edition. Check the 2001 sessions on www.opensource-tv.com Visit http://www.osdem.org and subscribe to the mailing list! -- http://mail.python.org/mailman/listinfo/python-list From Sugarpine.Sierra.West at greatbasin.net Sun Jul 22 04:22:00 2001 From: Sugarpine.Sierra.West at greatbasin.net (Sugarpine.Sierra.West at greatbasin.net) Date: Sun, 22 Jul 2001 02:22:00 -0600 Subject: Press Release Message-ID: <20017228520python-list@python.org> For Immediate Release Incline Village, Nevada Contact Corporate Communications www.sugarpinellc.com Sugarpine Sierra West, LLC is proud to announce 4 additional services, Sports Memorabilia, Hair Raisers, Financial Services and Worlds-Best-4 the worlds largest virtual shopping mall featuring over 2.2 million products! Save time! Save money! Make money!!! These services and products are now available to everyone. To view these tremendous opportunities, please visit our website. Sports Memorabilia may be viewed simply by clicking on its front-page banner. Hair Raisers may be viewed by visiting our web site, www.sugarpinellc.com, and select our associates? link. Our Financial Services is linked and bannered on our home page. As you all may already know, Sugarpine Sierra West, LLC is at its heart an asset hosting company. Please don?t forget to look at our Asset Gallery to see some outstanding business and investment opportunities, as well as collectables and real estate. Sugarpine Sierra West, LLC would like to extend its sincere thanks and appreciation to all! Please visit us at our web site at: www.sugarpinellc.com. Corporate Communications: Sugarpine Sierra West, LLC Mr. Charles J. Armstrong II or Ms. Denise Pavlo Phone: 775-832-2552 E-Mail: info at sugarpinellc.com To be removed from our e-mail list, reply to this e-mail with "REMOVE" in the subject line of your reply. From michael at stroeder.com Fri Jul 13 09:53:04 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Fri, 13 Jul 2001 15:53:04 +0200 Subject: PyDNS? References: <3B4ECBE0.96898063@stroeder.com> <bsrtktkhojr3osgha2npgoukhro5h0lfnt@4ax.com> Message-ID: <3B4EFD40.C0C075B6@stroeder.com> Wolfgang Strobl wrote: > > Michael Str?der <michael at stroeder.com> schrieb am Fri, 13 Jul 2001 > 12:22:24 +0200: > > >I wonder if there's interest to maintain the DNS module formerly > >written as demo by Guido van Rossum. Anthony Baxter has a modified > >version of it under http://www.interlink.com.au/anthony/dns.tar.gz. > >I've added support for SRV RRs and I'm thinking about adding caching > >support. > > Great. > > File "DNS\Lib.py", line 105, in addname > index.append(keys[j], offset + len(buf)) > TypeError: append() takes exactly 1 argument (2 given) > > This definitely needs an overhaul. :-) Already fixed this too. Not sure if I covered all cases though. For the impatient: My version of the module is shipped with http://web2ldap.de. Simply pull it out of pylib/ dir. If somebody is going to work on it let me know to avoid doubling efforts. Ciao, Michael. From gmcm at hypernet.com Sun Jul 15 10:11:50 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 15 Jul 2001 14:11:50 GMT Subject: Importing XML modules in py2exe or Installer? References: <Xns90DE9C2957BDgustaflalgonetse@194.213.69.152> <Xns90DE68B66343Agmcmhypernetcom@199.171.54.154> <Xns90DEC227B102Cgustaflalgonetse@194.213.69.148> <Xns90DE9C0C61AFAgmcmhypernetcom@199.171.54.155> <Xns90DF1E7FD2E35gustaflalgonetse@194.213.69.152> Message-ID: <Xns90DF67CD969E2gmcmhypernetcom@199.171.54.155> [posted and mailed] Gustaf Liljegren wrote: > Gordon McMillan <gmcm at hypernet.com> wrote: > >>So put the line >>packages=_xmlplus >>in the APPZLIB section. > > Okay, now I used Standalone first. Got a .cfg file and changed it > according to the above. Then I ran in again with Builder. Is this > really the normal operation? I had expected to first make a config file > and then make an exe, or that you would get an opportunity to save the > modified config file and run Standalone on it again. But I guess this > is a special case, and the second run is normally not needed. All Standalone, Simple and Freeze do is create config files for you, and then run Builder on them. If the code does not contain import hacks, that's all that's needs to be done. There are 2 general approaches to getting around import hacks (which, for some reason, many package authors seem to feel compelled to use, even when simpler solutions are possible). Both require figuring out what the hack does. The easiest is to do the import yourself in plain Python (using straight "import"s) before the hack gets executed. When the hack executes, it will find the module(s) already in sys.modules and complete successfully. The second is to use the config file. Depending on the hack, that may not always work. The config file is very handy for trimming the size of your executable, though. By using Analyze, you can strip out all unneeded modules. > When I run Builder, I get the following two warnings (among many others > that seem non-significant): > > W: __import__ hack detected at line 54 of xml.dom.domreg > W: __import__ hack detected at line 100 of xml.sax > > Does this mean that the import of the XML modules wasn't successful? No, it means you'd better look at that code and see what the author is doing with his import hacks. > My script needs a special config file, written in XML, in the same > directory as the script itself. I was happy to see that before I had > added the XML file to this directory, jane.exe complained in the right > way: > > E:\python\gustaf\dist_jane>jane > No profiles file found. > > However, when I add the XML file to the directory, it fails: > > E:\python\gustaf\dist_jane>jane [snip] > File "e:\python\_xmlplus\sax\saxexts.py", line 75, in make_parser > sys.modules[parser_name].create_parser = _create_parser > KeyError: xml.sax.drivers2.drv_pyexpat I'd guess one of those __import__s is responsible for importing xml.sax.drivers2.drv_pyexpat. If you do that yourself (before this code executes), you'll at least get past the KeyError. <editorial>It's not a good sign for Python's maturity that developers ignore (subvert!)[1] the distribution of packaged apps. Assuming that end users have a Python installation (of the correct version) is just silly. Python is not just for Python developers.</editorial> [1] One notable exception being Greg MacFarlane, who has included a bundlepmw script with his Pmw package for years. - Gordon From nhodgson at bigpond.net.au Sat Jul 21 19:50:10 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Sat, 21 Jul 2001 23:50:10 GMT Subject: Language change and code breaks References: <Pine.LNX.4.33.0107191316390.24983-100000@bms><mailman.995571273.18192.python-list@python.org><9j7gv8$9mg@dispatch.concentric.net><cppuawfqbm.fsf@cj20424-a.reston1.va.home.com> <mailman.995734717.26373.python-list@python.org> Message-ID: <Syo67.20628$Xr6.171242@news-server.bigpond.net.au> Justin Sheehy: > Guido van Rossum <guido at python.org> writes: > > > If you use this a lot (message = Message() etc.) your code is less > > readable than it should be. > > Really? People use capitalization semantically all the time, both in > programming and in the rest of life. I don't understand at all what > makes the above code unreadable. I find code like this harder to read and reason about. There are multiple entities with the same name so you have to remember to think about some extra details. While example code that looks like m=M() is at the low end of difficulty, stuff like: caterpillar = Caterpillar() # ... lots of code ... egglets = caterpillar() places more strain on my poor brain. _In_ written English, a change _in_ capitalisation is not always a change of meaning as it is most often done for sentence formation. Neil From tim.one at home.com Mon Jul 23 01:08:03 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 23 Jul 2001 01:08:03 -0400 Subject: PEP0238 lament In-Reply-To: <995862297.667165@yabetcha.drizzle.com> Message-ID: <LNBBLJKPBEHFEDALKOLCCEECLAAA.tim.one@home.com> [Tim] > Of course, but computer numerics is a massive exercise in picking the > general rules you want to preserve at the expense of others, > and trading all that off against pragmatics too. Not losing information > silently is also a Very Good General Rule, and even 745 binary fp > arithmetic is better at meeting that one than current "/". > [Donn Cave] > So would it make sense to also change the >> and << operators to > rotate shift? I mean, I sure wouldn't find that more useful, but > it does conserve information that the current shifts lose. First explain what bitstring operations have to do with computer numerics. You may as well as complain that, e.g., "del a[i]" loses information too. Well, of course it does -- that's its purpose. Same thing with >>. << does not lose info on longs, and it is indeed a source of bugs that it may lose info on ints (the result is platform-dependent in Python). From brian at sweetapp.com Fri Jul 13 04:06:20 2001 From: brian at sweetapp.com (Brian Quinlan) Date: Fri, 13 Jul 2001 01:06:20 -0700 Subject: sort->list In-Reply-To: <9im8jj$1b36$1@news.lf.net> Message-ID: <000301c10b72$b34ed5b0$445d4540@D1XYVL01> Domi wrote: > Does somebody know how to sort a numeric list in the right way? > The sort method sort a list in this way: > [1,10,11,12,13,14,15,16,17,18,19,2,20,21,...] > > but I need a list sort like this: > [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,...] It looks like you list is actually of strings rather than integers. That is why it is being sorted alphabetically rather than numerically. Try converting the list to integers first i.e. testList = ['1', '10', '2', '15'] testList = map(int, testList) testList.sort() From fredrik at pythonware.com Thu Jul 12 11:35:19 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 12 Jul 2001 15:35:19 GMT Subject: Pickle translation References: <jtr8vncn38.fsf@wazor.biostat.wisc.edu> <Bl237.4856$z21.493441@newsc.telia.net> <jtn16bchrx.fsf@wazor.biostat.wisc.edu> <mailman.994887559.21749.python-list@python.org> Message-ID: <Xsj37.9345$e5.1243922@newsb.telia.net> Skip Montanaro wrote: > Interpretation of \x escapes was tightened up in 2.0 I believe. In versions > earlier than 2.0 '\xyy' is interpreted as the four-character sequence: > > \ x y y not if yy is hexadecimal digits. the difference is that in 1.5.2, \x could consume more than 2 hex digits. > In 2.0 and 2.1 the ValueError you see is raised because "yy" can't be > interpreted as a hex number. shouldn't happen, though: pickle uses repr, and repr didn't ever create \x escapes in 1.5.2. you could get this problem if you move text pickles from 2.1 back to 1.5.2, though: "\x1234" is one character under 1.5.2, three under 2.0 and later. and 2.1's repr uses \xnn instead of \ddd on output... > I'm not sure what the solution is. Someone with more pickle/string/ > internals knowledge will probably have some ideas. one possible workaround could be to load the pickle under 1.5.2, and write it out as a binary pickle: infile = open("data") object = pickle.load(infile) outfile = open("outdata", "wb") pickle.dump(object, outfile, 1) outfile.close() </F> From guido at python.org Fri Jul 27 22:40:34 2001 From: guido at python.org (Guido van Rossum) Date: Sat, 28 Jul 2001 02:40:34 GMT Subject: Changing the Division Operator -- PEP 238, rev 1.12 References: <mailman.996263475.24304.python-list@python.org> <270720011702397113%mday@apple.com> Message-ID: <cpbsm522ul.fsf@cj20424-a.reston1.va.home.com> Mark Day <mday at apple.com> writes: > I think my original discomfort was due to using C for so long (and > damaging my brain along the way). But maybe C is like tobacco, and if > I quit, maybe my brain will eventually heal. One can hope. :-) There's also the phenomenon Tim calls "Extreme Fear of Floating Point". That used to be a rational fear (no pun intended :-) but that was long ago. --Guido van Rossum (home page: http://www.python.org/~guido/) From Gareth.McCaughan at pobox.com Fri Jul 27 18:18:12 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Fri, 27 Jul 2001 23:18:12 +0100 Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <eppstein-03540D.13070222072001@news.service.uci.edu> <LNBBLJKPBEHFEDALKOLCOECNLAAA.tim.one@home.com> <mailman.995899647.346.python-list@python.org> <tclolt053o18f8q0ntb7n4aggitdkmeg4h@4ax.com> <Io_67.23543$B7.3779351@ruti.visi.com> <slrn9lp2m5.vp.Gareth.McCaughan@g.local> <p56plt8q4rs3bgcqbepk61q2r3g0tr2vhe@4ax.com> <slrn9ls3ae.2fm.Gareth.McCaughan@g.local> <cpitghbq05.fsf@cj20424-a.reston1.va.home.com> <MWD77.27751$EP6.6983549@news1.rdc2.pa.home.com> <9jnt9p$qhe$1@newsy.ifm.liu.se> <SYV77.27286$B7.4239335@ruti.visi.com> <cpitgf7itx.fsf@cj20424-a.reston1.va.home.com> <WIY77.27607$B7.4257794@ruti.visi.com> <cp3d7j75jv.fsf@cj20424-a.reston1.va.home.com> <mailman.996192239.4930.python-list@python.org> <U_387.50579$Cy.6523947@news1.rdc1.az.home.com> <eppstein-4B8DDD.19163726072001@news.service.uci.edu> <cp1yn25wee.fsf@cj20424-a.reston1.va.home.com> Message-ID: <slrn9m3q54.1c5.Gareth.McCaughan@g.local> Guido van Rossum wrote: [Tim Hochberg:] > > Actually, I do dislike this. Much as I find floats generally useless, I > > think that 0.666667 should return a float, and that if I want to write a > > rational literal I should be able to write it as 2/3. > > I think you're right. An early version of ABC worked like this, and > at the time I though "hmm, but why shouldn't 0.98 be an exact number; > it could be intended as a price or something like that", and I > convinced the team to change it. But in practice it was more often > annoying. Now maybe that was because we (the biggest users) were CS > and math folks, and we tended to tackle typical math and CS problems > -- but my gut is to vote against this aspect of the PEP. I am a fan of rationals, but I strongly agree. Turning 0.98 into 49/50 is likely to cause much more confusion than it saves. -- Gareth McCaughan Gareth.McCaughan at pobox.com .sig under construc From nhodgson at bigpond.net.au Fri Jul 13 09:13:40 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Fri, 13 Jul 2001 23:13:40 +1000 Subject: [Python-Dev] PEP: Unicode Indexing Helper Module References: <3B4EE3C0.9875AB3D@lemburg.com> Message-ID: <072101c10b9d$a28068e0$0acc8490@neil> M.-A. Lemburg: > next_<indextype>(u, index) -> integer > > Returns the Unicode object index for the start of the next > <indextype> found after u[index] or -1 in case no next > element of this type exists. > > prev_<indextype>(u, index) -> integer > ... Its not clear to me from the description whether the term "object index" is used for a code unit index or an <indextype> index. Code unit index seems to make the most sense but this should be explicit. Neil From michael at stroeder.com Wed Jul 18 10:21:52 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Wed, 18 Jul 2001 16:21:52 +0200 Subject: SocketServer and broken ThreadingMixIn - patch for 2.1.1c1 References: <slrn9lb58c.885.stain@zoidberg.trd.linpro.no> Message-ID: <3B559B80.4C8EDBE3@stroeder.com> Stian Soiland wrote: > > As known, in Python 2.1 the SocketServer.ThreadingMixIn > does not work, and thereby SocketServer.ThreadingTCPServer > etc. are broken as well. I'm very glad that you took the discussion to the news group since the SourceForge bug tracking page is not a discussion forum. > However, the fix simply removes close_request() > for threaded servers, as the process_request() > is overridden. The overriden process_request() > simply starts final_request() (doing the actual > work), but does not call close_request() > afterwards. > > This means that there is a difference between > threaded servers and non-threading servers. I agree with Guido that it does not hurt to call close_request() method more than once. Therefore your handler thread can easily call close_request() without being incompatible to single-threaded (checked it myself) or forking mode (did not check myself yet). Ciao, Michael. From barry at zope.com Wed Jul 25 16:06:20 2001 From: barry at zope.com (Barry A. Warsaw) Date: Wed, 25 Jul 2001 16:06:20 -0400 Subject: ANNOUNCE Mailman 2.0.6 Message-ID: <15199.9916.286454.845536@anthem.wooz.org> I've just released version 2.0.6 of Mailman, the GNU Mailing List Manager. Mailman is released under the GNU General Public License (GPL). Version 2.0.6 fixes a potential security problem in Mailman 2.0.x, and includes a few other minor bug fixes. It is possible, although unlikely, that you could have an empty site password, or an empty list password. Because of peculiarities in the Unix crypt() function, such empty passwords could allow unauthorized access to the list administrative pages with an arbitrary password string. This situation does not occur normally, but it is possible to create it by accident (e.g. by touch'ing data/adm.pw). This patch ensures that such empty passwords do not allow unauthorized access, by first checking to make sure that the salt is at least 2 characters in length. Alternatively, you can make sure that either data/adm.pw does not exist or that it is not empty. For the extra paranoid, you'd need to be sure that none of your lists have empty passwords, but that's an even more difficult situation to create by accident. This patch guards against both situations. (Please note that Mailman 2.1alpha is not vulnerable to this problem because it does not use crypt().) A few other minor bugs have been fixed; see the NEWS excerpt below for details. Mailman 2.0.6 is being released as both a gzip'd source tarball and as a patch file. GNU Mailman is software to help manage electronic mail discussion lists. Mailman gives each mailing list a unique web page and allows users to subscribe, unsubscribe, and change their account options over the web. Even the list manager can administer his or her list entirely via the web. Mailman has most of the features that people want in a mailing list management system, including built-in archiving, mail-to-news gateways, spam filters, bounce detection, digest delivery, and so on. Mailman is compatible with most web servers, web browsers, and mail servers. It runs on GNU/Linux and should run on any other Unix-like operating system. Mailman 2.0.6 requires Python 1.5.2 or newer. To install Mailman from source, you will need a C compiler. For more information on Mailman, including links to file downloads, please see the Mailman WWW page: http://www.gnu.org/software/mailman And its mirrors at: http://mailman.sourceforge.net http://www.list.org Downloads are available at http://sourceforge.net/project/shownotes.php?release_id=45268 There are email lists (managed by Mailman, of course!) for both Mailman users and developers. See the web sites above for details. Enjoy, -Barry 2.0.6 (25-Jul-2001) Security fix: - Fixed a potential security hole which could allow access to list administrative features by unauthorized users. If there is an empty data/adm.pw file (the site password file), then any password will be accepted as the list administrative password. This exploit is caused by a common "bug" in the crypt() function suffered by several Unix distributions, including at least GNU/Linux and Solaris. Given a salt string of length zero, crypt() always returns the empty string. In lieu of applying this patch, sites can run bin/mmsitepass and ensure that data/adm.pw is of length 2 or greater. Bug fixes: - Ensure that even if DEFAULT_URL is misconfigured in mm_cfg.py (i.e. is missing a trailing slash), it is always fixed upon list creation. - Check for administrivia holds before any other tests. - SF bugs fixed: 407666, 227694 - Other miscellaneous buglets fixed. From quinn at yak.ugcs.caltech.edu Wed Jul 18 17:19:54 2001 From: quinn at yak.ugcs.caltech.edu (Quinn Dunkan) Date: 18 Jul 2001 21:19:54 GMT Subject: converting from perl: variable sized unpack References: <roy-B2459F.22112513072001@news1.panix.com> <mailman.995081424.8581.python-list@python.org> <slrn9l4esk.885.quinn@yak.ugcs.caltech.edu> <slrn9l5lc4.6ko.philh@comuno.freeserve.co.uk> <9j2dnn$ndm$0@216.39.144.220> <slrn9lavp6.v3.philh@comuno.freeserve.co.uk> Message-ID: <slrn9lbvbp.6o6.quinn@yak.ugcs.caltech.edu> On Wed, 18 Jul 2001 13:20:54 +0100, phil hunt <philh at comuno.freeserve.co.uk> wrote: >>> This goes for lots of things; IMO if you >>> access a list or dictionary with a non-existant index it should >>> return a value such as None, instead of raising an exception. >> >>Sometimes. It's convenient in CGI to have tags default to '' if missing. >>But you can't find a one-size-fits all solution. For some applications, >>None and '' are legitimate values, and must be distinguished from >>"key not found". Thus, why Python offers both dict.get('x', DEFAULT) >>as well as dict['better be there or KeyError']. > >No, because on the odd occasions that you want an exception you can >always throw one manually. > >Here, I'm assuming that usually you don't want one -- perhaps this >is jsut my idiosyncratic programming style and most people vare different >here. Comments? It's not just you, but I don't agree, and it's not just me either. NameErrors, KeyErrors, and IndexErrors have saved me many times. One of the things I didn't like about perl is how it magically created values on reference, and then I had to go hunt down the bad reference that created it. And I often store None in dicts and lists. It would be weird if d.has_key(x) could be true or false while d[x] always evaluated to None. That means that d[x] is implicitly creating a None when d.has_key(x) is false, but not when it's true (python's None is a normal value, not a magic "nothing" pseudo-value). I like all bad references to be errors, always, not "press on and hope for the best" or "depends on what declarations were made" or "depends on what kind of reference it is" (as in ruby). Perl has undef, and lua has nil, and in both those languages saying 'x = nil' is equavalent to unbinding `x' (I think that's true for perl, don't remember). If python's None were to be consistent we should remove NameError and del and have all unbound names evaluate to None. Then people would request perl-like 'use strict' hacks to turn it off. And lastly, and most importantly, that's the way the language works. Some languages may work differently, but many languages also work this way. Since obviously no one agrees, there is no "should". And there has to be a really clear "should" to justify breaking code for it. For the circumstances when it's handy to have a 'default value' dict or list that never raises, it's easy to subclass UserDict. From stefan.heimann at web.de Sun Jul 22 05:50:11 2001 From: stefan.heimann at web.de (Stefan Heimann) Date: 22 Jul 2001 09:50:11 GMT Subject: interactive mode, history Message-ID: <slrn9ll8ei.dh.stefan.heimann@kunz.ratzer> Hi! I have a problems with arrow keys in interactive mode. When I hit the up-arrow, I get ^[[A, the left-arrow produces ^[[D and so on. This problem occurs NOT with python 1.5 but with python 2.0 and 2.1. I have debian woody installed here and it doesn't matter if I invoke python on the console or in a xterm. I alsoe tried wterm, gnome-terminal and konsole from kde. With all I get the same results. Can anyone help Thanks stefan From jim at publishingresources.com Fri Jul 20 11:54:22 2001 From: jim at publishingresources.com (Jim) Date: Fri, 20 Jul 2001 15:54:22 -0000 Subject: ActivePython ASP comobject.getCOMObject() does not work References: <9j6tac$b96$00$1@news.t-online.com> <3B576D8C.9080705@ActiveState.com> Message-ID: <Xns90E478A656FFBjimpublishingresourc@207.126.101.100> Mark Hammond <MarkH at ActiveState.com> wrote in <3B576D8C.9080705 at ActiveState.com>: >Jochen Riekhof wrote: > >> >> rst = getRecordset() >> >> Now, I want to use the recordset: >> rst.MoveFirst() >> >> and get the following error: >> Python ActiveX Scripting Engine (0x80020009) >> Traceback (innermost last): File "<Script Block >", line 5, in ? >> rst.MoveFirst() AttributeError: 'tuple' object has no attribute >> 'MoveFirst' /OrboPCT/pytest.asp, Zeile 15 >> rst.MoveFirst() > > >This means that "getRecordset()" is actually returning _2_ values - the >recordset itself, and some other value (possibly a boolean or some >such). > >You will probably find that you need something like: > >ok, rst = getRecordset() > >or maybe the other way around: > >rst, ignored = getRecordset() > >Mark. > >From the Python-Win32 list: Jim Abrams wrote: >objCN = Server.CreateObject("ADODB.Connection") >objCN.open(dsn) >objRS = objCN.Execute("select * etc") >objRS now has a tuple of (<RecordSetObject>, int) >I have no idea what the int means, but you need to trim it away to get >at the RecordSet object. > Ok, well I obviously didn't know that Application wasn't just a simple Dispatch object in asps but this one I do know! The reason Execute returns a tuple is because Execute has an [out] parameter which returns the number of rows affected. Here's the clip from OLEVIEW: _Recordset* Execute( [in] BSTR CommandText, [out, optional] VARIANT* RecordsAffected, [in, optional, defaultvalue(-1)] long Options); Any COM [out] parameter will be returned from the method since in Python parameters are passed by value rather than by reference (we won't talk about object references). -- Jens B. Jorgensen jens.jorgensen at tallan.com From cliechti at mails.ch Thu Jul 26 22:39:36 2001 From: cliechti at mails.ch (chris liechti) Date: 27 Jul 2001 04:39:36 +0200 Subject: freeze.py (where is it?) References: <3B58494D.C82965AD@raqia.com> <dd144f8b.0107260325.6a0f21e4@posting.google.com> <3B6019CE.4070900@herts.ac.uk> Message-ID: <Xns90EB300C26454cliechtimailsch@62.2.32.50> freeze.py is in the source distribution. if you want to create standalone python apps on win32 "py2exe" could also be a solution for you (easier as it doesn't needs a c compiler... :-) chris Mark Robinson <m.1.robinson at herts.ac.uk> wrote in news:3B6019CE.4070900 at herts.ac.uk: > can anyone tell me where I might find the freeze utility. It doesn't > seem to be included in the windows installation of python 2.1. Am I just > being blind or has it perhaps been superceeded by something better, I am > only aware of it from a reference in 'programming python'. > > blobby > -- chris <cliechti at mails.ch> From peter at engcorp.com Fri Jul 20 07:47:27 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 20 Jul 2001 07:47:27 -0400 Subject: KeyboardInterrupt References: <3b57e9e8.1285896@news.newsguy.com> Message-ID: <3B581A4F.381F3072@engcorp.com> "Owen F. Ransen" wrote: > > The Quick Python Book says that KeyboardInterrupt is > tested regularly when the Python interpreter is running, > but I have a program which may run for several minutes > without printing anything, and I find I cannot break out of > it with control-C. > > How can I get my program to be more responsive to control-C? This could be a platform-dependent issue. Are you by any chance running on Win2K? From ed at ewilson.com Mon Jul 2 00:42:37 2001 From: ed at ewilson.com (Edward B. Wilson II) Date: Sun, 1 Jul 2001 21:42:37 -0700 Subject: Is Python Dead? Message-ID: <MNS%6.355$Xs4.225014@news.pacbell.net> I have been following Python for five years now, and I am still just as frustrated with it as I was in 1996. Python still doesn't have good database support, nor has it grown to be useful in the web space as mod_perl. PyApache has been around longer than mod_php, yet php has far surpassed it as a productivity tool in the web space. It would seem Python can do everything, yet nothing. Everyone wants to write the next killer application with Python, XML parsers, image manipulators, super computer steering modules, yet no one wants to work on making Python perform where it matters most. Python is the best language at eclectic stuff, however, poor at bread and butter tasks. Python needs better leadership in areas of its growth. Python is truly the best language in use today, except it still isn't very useful for the largest solution sector, database access, and information presentation (web, or otherwise). It seems that Python should strive to be great at the ABC's before it attempts poetry. --Ed From hamish_lawson at yahoo.co.uk Tue Jul 3 17:41:56 2001 From: hamish_lawson at yahoo.co.uk (Hamish Lawson) Date: 3 Jul 2001 14:41:56 -0700 Subject: Python Essential Reference 2d edn. References: <da5vhtcqa8tafr4edm2l5opnd65gva6osl@4ax.com> <zY5X6.137$fr.175944@news.uswest.net> Message-ID: <915a998f.0107031341.271e2ced@posting.google.com> Michael Prager wrote: > 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? Kevin Altis wrote: > 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. The text of the second edition is in a welcome larger font. However, if you were to go by the sample PDF, you'd think it was actually in a *smaller* font than the first edition - I'm guessing it must be a pre-production draft. Hamish Lawson From aleaxit at yahoo.com Mon Jul 9 03:30:45 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 9 Jul 2001 09:30:45 +0200 Subject: Help With map() *He says while pulling his hair out* References: <pM927.657463$166.13605776@news1.rdc1.bc.home.com> Message-ID: <9ibmi812a8n@enews2.newsguy.com> "EricIDLE" <grayson-wilson at home.com> wrote in message news:pM927.657463$166.13605776 at news1.rdc1.bc.home.com... > Ok first off I have a wee problem with one of the examples in my book it is > as follows: > > s="12.19.6.7.12" > ls = string.split(s, '.') > md = map(string.atoi, ls) > > Ok. well the problem is basically the whole thing. I know s="12.19.6.7.12" > is just defining the varible 's' with the numbers. But my first problem is Specifically, variable s is being bound to a string made up of several DIGITS and periods. "Number" is an ambiguous terms, while "digit" more precisely identifies one of the characters '0', '1', ... '9' (note the quotes). > after string.split in its argument I know what the S means but I dont know > what the '.' means does that mean to remove all the periods? No, it means to SPLIT where a period occurs. The result of string.split is then a list of strings, each a copy of the substring of s that occurs between two periods. > The second problem is that I dont quite grasp the map() function what > exactly does it do, In its argument it says in lamens terms "Turn the string > ls into intergers" my problems is wasent it always intergers? I mean the ls is a list of strings. string.split always returns a list of strings -- specifically, copies of substrings of s. > varible ls contains ['12', '19', '6', '7', '12'] arent those intergers they No, they are strings (which happen to be made up of digits, only, in this case). The quotes around each are a strong indication of their string nature. If you need to transform a string of digits into an integer number, you can pass the string of digits to function int (or, as here used, function string.atoi). map() calls its first argument (normally a function) over each item in its second argument (a sequence) and returns the list of results (map also has other uses, but this is one fundamental use for it). Alex From paulp at ActiveState.com Tue Jul 17 13:05:03 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Tue, 17 Jul 2001 10:05:03 -0700 Subject: PEP: Defining Python Source Code Encodings References: <Pine.LNX.4.21.BCL.0107171439080.704-100000@suzi.com.onego.ru> Message-ID: <3B54703F.DDB8C4B6@ActiveState.com> Roman Suzi wrote: > > .... > > If I understood correctly, Python will soon switch to "unicode-only" > strings, as Java and Tcl did. (This is of course disaster for some Python > usage areas such as fast text-processing, but...) No, this is not likely to happen "soon". Maybe before the death of Sol but not in the next year. >... > > I think non-literal data must be in ASCII. I agree. Allowing "funny characters" in names is not something we have much call for yet and it may break many tools that have ASCII-only assumptions. >... > > May be just put something like ''# <!DOCTYPE HTML PUBLIC'' > at the beginning... If you want an XML-style declaration, a more compact syntax could be: #?python encoding="..." > Or, even greater idea occured to me: allow some XML > with meta-information (not only encoding) somehow escaped. I think we should be wary of overcomplicating a relatively simple idea. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From bokr at accessone.com Thu Jul 12 18:59:05 2001 From: bokr at accessone.com (Bengt Richter) Date: Thu, 12 Jul 2001 22:59:05 GMT Subject: Light Speed Socket Connections References: <d01baf67.0107112132.34e70d03@posting.google.com> <3b4d6184.1698299906@wa.news.verio.net> <ku66cy58qp.fsf@lasipalatsi.fi> Message-ID: <3b4e2522.1748377423@wa.news.verio.net> On 12 Jul 2001 20:59:26 +0300, Erno Kuusela <erno-news at erno.iki.fi> wrote: >In article <3b4d6184.1698299906 at wa.news.verio.net>, bokr at accessone.com >(Bengt Richter) writes: > >| For accurate timing, time.clock() >| is recommended, I believe: > >[...] > >the docs recommend it, but on unix time.time() is far better > >time.clock() tries to measure "cpu time" instead of "real time" >there, which results in terrible resolution. time.time() maps >to gettimeofday(2). > > -- erno On my boxes, I know I have pentiums where it's ok, and I've been doing C/C++ so here is what I've used. It gives very good resolution ( 1 cpu clock at your CPU rate ): Executing the instructions and storing the numbers takes a few cycles, but I seem to remember 23 cycles minimum for something I did. At my 300mhz, that was about 77 nanoseconds. So you just substract that out when you time something ;-) // for linux typedef unsigned long long u64; inline u64 getTick64() { u64 ticks; asm volatile ("rdtsc" : "=A"(ticks)); return ticks; } This will get you an accurate tick count in a real hurry ;-) What I do is save them raw, and convert to seconds after computing the deltas. You can do the same on windows with //for win32 #include <basetsd.h> typedef UINT64 u64; inline u64 getTick64() { __asm { rdtsc ; puts counter in eax,edx } } Of course, this doesn't directly do you a lot of good in Python, but I could see a useful extension using it, building in proper checks for rdtsc availability. NOTE WELL: THE ABOVE CODE PRESUMES YOU HAVE A PENTIUM THAT SUPPORTS RDTSC !! You can check with a bit that comes back from the cpuid instruction. But this is the reason for using the windows QueryPerformanceCounter API instead of going to the hardware direct. Maybe there should be such an API on unix. I'll be someone has done it. For PC's it's the same hardware after all. From rnd at onego.ru Fri Jul 6 12:29:53 2001 From: rnd at onego.ru (Roman Suzi) Date: Fri, 6 Jul 2001 20:29:53 +0400 (MSD) Subject: Maintaining the Python FAQ In-Reply-To: <9i4neh$h1jne$1@ID-11957.news.dfncis.de> Message-ID: <Pine.LNX.4.30.0107062028470.12590-100000@rnd.onego.ru> On Fri, 6 Jul 2001, Emile van Sebille wrote: >The first reference to the faq on python.org does this. It's not so much a >question of why would you, more so how could you not the first time. Maybe >drop the complete reference on the front page, leaving the reference to it Oh, no. "FAQ" is one of the eye catches, like "Download" ;-) >on the faq wizard page so that you know when clicking it that you'll get a >bunch. > >http://python.org/doc/FAQ.html > >-- > >Emile van Sebille >emile at fenx.com > >--------- >"Guido van Rossum" <guido at python.org> wrote in message >news:cpvgl6jbyz.fsf at cj20424-a.reston1.va.home.com... >> Oleg Broytmann <phd at phd.fep.ru> writes: >> >> > On Fri, 6 Jul 2001, Guido van Rossum wrote: >> > > Hm. To what extent is the current FAQ wizard a problem for its >> > >> > For me the biggest problem is not the FAQ Wizard, but FAQ.html - it >is >> > too big. 270K is too big for the Net. Let us split it intopages. >> >> Huh? The FAQ wizard gives you plenty of ways to access individual >> items or sections. Why would you ever download the whole FAQ? >> >> --Guido van Rossum (home page: http://www.python.org/~guido/) > > Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Friday, July 06, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ ""Stupid" is a boundless concept." _/ From thomas at xs4all.net Mon Jul 16 04:22:55 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 16 Jul 2001 10:22:55 +0200 Subject: re Challenge: More Compact? In-Reply-To: <slrn9l4llv.p58.tim@vegeta.ath.cx> References: <mailman.995247446.16415.python-list@python.org> <slrn9l4llv.p58.tim@vegeta.ath.cx> Message-ID: <20010716102255.F5396@xs4all.nl> On Mon, Jul 16, 2001 at 02:39:50AM +0000, Tim Hammerquist wrote: > I'm in the habit (in Python as well) of return undef on > false because in some methods, 0 is ambiguous. So, in cases where 0 is > not ambiguous, 0 is idiomatically preferred to None? You wouldn't call those functions in a boolean context, now would you ? I prefer to return -1 if 0 is a valid return value, or just raise an exception if -1 is valid as well. We're talking an entirely different function though, one where an 'error return' really is exceptional. > Ok, so here's my version (I hate wasted line space and unnecessary temp > vars): Just wait until you revisit this code in 6 months ;) -- Thomas Wouters <thomas at xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From tim.one at home.com Sat Jul 21 17:30:07 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 21 Jul 2001 17:30:07 -0400 Subject: The windows python.exe interpreter hangs processing large files. In-Reply-To: <u7fcj9.uis.ln@127.0.0.1> Message-ID: <LNBBLJKPBEHFEDALKOLCIEAFLAAA.tim.one@home.com> [gradha at iname.com] > I have tried to use some Linux scripts I have under Windows, and the > python.exe ran in a dos Box under Win98 just hangs when it has to > process slightly big text files (over 20 KB). Could it be just because > I use the DOTALL option in regular expressions? No: the regexp engine is the same on both platforms. > Under Linux everything goes blazing fast, and since everything hangs > I don't know what to do or how to debug it, especially because Windows > is not my native work environment and don't master any tools there. Stick in print statements to determine *where* it hangs. Then whittle it down to a minimal case. The most frequent cause of Linux->Windows Python porting problems is neglecting to open binary files in binary mode. From craigmnet at cow.physics.wisc.edu Mon Jul 23 01:53:34 2001 From: craigmnet at cow.physics.wisc.edu (Craig Markwardt) Date: 23 Jul 2001 00:53:34 -0500 Subject: PEP0238 lament References: <mailman.995861918.11181.python-list@python.org> Message-ID: <onofqc5gyp.fsf@cow.physics.wisc.edu> "Tim Peters" <tim.one at home.com> writes: > [John W. Baxter] > > I see a fairly strong argument there for starting out with a language > > in which int / int --> float (or rational) and int // int --> int (or > > int div int --> int). > > I don't consider a vote an argument. At best, since it was a visible show > of hands, it let everyone know who wasn't worthy to live due to voting the > wrong way <wink>. > ... I'll decloak here for a moment. I'm an IDL user, as in Interactive Data Language by RSI, but I mostly admire Python from afar, and read the newsgroup. I can relate the community experience of the upgrade between IDL version 4 and version 5. In the new version, IDL gained an *optional* language change. IDL 5 allows users to subscript arrays with either the square brackets [] or the round parentheses (). IDL 4 only allowed the round parentheses. As a result of this, people began coding both styles. However, the new style was not backwards compatible, so there was some fragmentation. Some major standard libraries were, and are still, maintained in two forms. Overall, from introduction to acceptance, the change took about 2-3 years. This change was thankfully optional. I am very grateful that I can still pull up useful IDL archive code from ten or more years ago, written by someone long gone, and usually have it run successfully. Thus, I am dismayed to hear about a Python language change that will *not* be optional, and which will break the function of existing code. Doing so will eventually place people in the unenviable quandry of either upgrading their Python interpreter, or tossing out a tried and tested library module. Other language enhancements, like nested scopes, add features at the expense of resolving language ambiguities. The proposed integer division change is an outright language change, and impacts a core functionality: arithmetic. Quite frankly, I am baffled. Craig -- -------------------------------------------------------------------------- Craig B. Markwardt, Ph.D. EMAIL: craigmnet at cow.physics.wisc.edu Astrophysics, IDL, whatever else -------------------------------------------------------------------------- From mday at apple.com Tue Jul 17 16:59:54 2001 From: mday at apple.com (Mark Day) Date: Tue, 17 Jul 2001 13:59:54 -0700 Subject: Python 2 times slower than Perl References: <8f41cfd.0107171238.6ff33b9b@posting.google.com> Message-ID: <170720011359545210%mday@apple.com> In article <8f41cfd.0107171238.6ff33b9b at posting.google.com>, Xu, C.S. <xucs007 at yahoo.com> wrote: > #!/usr/bin/env python > i = 2.5; > while i < 1e7: > j = 2.5 * 2.5 > i += 1 > print i, j Notice that the assignment to j is a loop invariant. It could be moved outside the while loop without changing the result. I'll bet the C and Java compilers are in fact moving it outside of the loop for you, so you're only timing the increment of i. I think Perl may be precomputing 2.5 * 2.5, so it may just be repeating the assignment of j and not the multiplication. I don't think Python will evaluate the expression at "compile" time, nor move the assignment outside the loop. -Mark From XQ.Xia at ccsr.cam.ac.uk Thu Jul 19 10:13:20 2001 From: XQ.Xia at ccsr.cam.ac.uk (XiaoQin Xia) Date: Thu, 19 Jul 2001 15:13:20 +0100 Subject: Unable to produce Tkinter.Toplevel() in a Thread object Message-ID: <3B56EB00.EA378CB@ccsr.cam.ac.uk> Hi, everybody, I tried to display some information in a thread, but failed to produce Tkinter.Toplevel() in a Thread object. Is it possible to use such functions, eg. "showinfo, showerror, askokcancel" (import from tkMessageBox)? Cheers, XiaoQin Xia From sam at ddmweb.com Tue Jul 31 16:06:09 2001 From: sam at ddmweb.com (Sam Penrose) Date: Tue, 31 Jul 2001 13:06:09 -0700 Subject: www.python.org is down Message-ID: <01073113091406.01179@frock.ddmweb.com> Guido writes: >>We have a broken hard drive on the machine that is www.python.org. CNRI claims there is no spare drive. It may be a while before we resolve this. In the mean time, here's a mirror:<< Does www.python.org need funds for a drive or a new server? I'd be happy to contribute funds if it would help and someone will volunteer to collect the checks. From chrishbarker at home.net Mon Jul 23 19:50:19 2001 From: chrishbarker at home.net (Chris Barker) Date: Mon, 23 Jul 2001 16:50:19 -0700 Subject: A way to accommodate laguage changes Message-ID: <3B5CB83B.F3B7D51@home.net> Hi all, Having spent (wasted?) far too much time reading everyone's opinion of the new division proposal, I have come to the following conclusions: 1) Everyone seems to agree that having both kinds of division is a good idea 2) Without careful counting , it seems that most people think that having the "/" operator on two integers result in a float and another operator ("//", div, whatever) do integer division is a better syntax for A NEW LANGUAGE. 3) So, the big disagreement is over whether the improvement in the language resulting from the proposed change is worth the considerable pain it is likely to cause by: A) Breaking old code B) Making it very difficult to write code that can run on old and new version of the interpreter. It seems that since (3) is the big stumbling block, perhaps we need to focus our intentions on how to make not only this change, but other potential changes less painful. It's too late now, but ideally, Python might have had a required version header: UsesVersion 1.5.2 (#!/usr/bin/env python1.5.2) would do, but it's not useful on all systems. I'm not proposing a syntax here, just the concept. Once a given file has an indication in it as to what version of Python it was designed for, the interpreter could shift into an appropriate backward compatability mode. This would ensure that old code could run just fine on new interpreters. Since this doesn't currently exist, it would have to be added now, but it could be assumed that any *.py file without the header was version <= 2.1. This way no old code would break. Beyond this change, it would allow for far less painful changes in the future as well. I'm betting that this is not the last incompatable change that will be introduced. At worst, we will have some bloat by having essentially mutiple copies of the interpreter running, at best, it could be more cleverly implimented, and just a few changes added to the compiler. That would certainly be easy to do if a keyword was added, or something like case sensitivity was changed. Anyway, even if it is decided not to make a backward incompatable change to division, it is likely to happen some day, so it could be a useful addition to the language. This is how LaTeX changed from version 2.09 to 2e. If the header was "\documentstyle" it is 2.09, and if it is "\documentclass" it is a version 2e file. That way the LaTeX installation could be upgraded, without breaking any existing documents. Python, unfortunatly, doesn't have such a header, but if one were added now, it would be better poised for the future. I can't currently think of any major problem with this: many of us put he #! line on top of files anyway, and I've even seen people put it on files on Windows and Macintosh, because that's what was in the examples, so I don't think newbies will have any problem with 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 BBRANNIGAN at CYBERTOURS.COM Tue Jul 17 14:16:23 2001 From: BBRANNIGAN at CYBERTOURS.COM (BRYAN BRANNIGAN) Date: Tue, 17 Jul 2001 14:16:23 -0400 Subject: windows port access References: <3b520bcb@news.cybertours.com> <3B522E98.BAAA9E93@engcorp.com> <mailman.995288852.27369.python-list@python.org> <3B5390BC.C5FFCD2A@engcorp.com> <mailman.995346569.21423.python-list@python.org> Message-ID: <3b5480f5@news.cybertours.com> Thanks for the responses, This card is going to send small voltages to relays to control motors and is the only way I have found to accomplish this task. The address on the card is flexible. Bryan "Chris Gonnerman" <chris.gonnerman at newcenturycomputers.net> wrote in message news:mailman.995346569.21423.python-list at python.org... > ----- Original Message ----- > From: "Peter Hansen" <peter at engcorp.com> > > > > Chris Gonnerman wrote: > > > > > > Unfortunately what Bryan is asking is not what you are answering. He > wants > > > to access the I/O port 0x280, which he states is assigned to a "custom > ISA > > > card" which (I assume) is not using the standard parallel port > interface, > > > nor serial, etc. and for which he evidently has no driver. > > > > I admit I didn't actually look at the winioport stuff proposed in the > > "parallel port?!?" thread, but given that it was called winioport > > and not winparallelport, I assumed it was a way of providing generic > > access to IO ports under Windows. If I was wrong, then you are right > > to correct me! (Do you know winioport would not work or were you just > > tricked by the name of the thread?) > > Whups. Evidently the low-level package in use by winioport DOES support > generic > access. My mistake... I was going by the commentary on the main winioport > page, > where he says "I am now able do printer port IO." I assumed that was the > entire > scope of the package, but evidently not. > > > Of course, it's probably moot given Jon Nicoll's response which suggests > > a perfectly viable alternative. > > Indeed... to wit: > > ----- Original Message ----- > From: "Jon Nicoll" <jkn at nicorp.f9.co.uk> > > > This is exactly what my code can be used for - you can set it up to > > get access to arbitary IO ports (via the ioperm mechanism in Linux), > > and then read or write etc. as you like. Admittedly, it doesn't > > currently cater for interrupts. > > Which could be vitally significant or totally unimportant. > > > I originally started writing this to drive an ISA 8255/8253 card, and > > although this project-ette is currently in limbo, the basics are all > > there and working, if Bryan wants to do eg. polled access to an A/D > > card etc. > > > > You don't need a VxD (for W95 at least), although it's probably the > > 'better' way of doing things. My code is in C and turns into a little > > '.PYD' (= .DLL) file. In NT, you need a kernel mode driver, which I > > haven't yet got around to looking at. > > Here the winioport module (and the underlying DriverLYNX package) might > be better for Bryan. > > > I've just resurrected my code and am looking at using distutils to get > > it in a form more easily distributed. Email me if would be of use to > > you in the meantime. > > Bryan hasn't responded since he initially requested this information... > are you out there, Bryan? > > > From peter at engcorp.com Wed Jul 11 17:47:50 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 11 Jul 2001 17:47:50 -0400 Subject: Long Live Python! References: <E566B020833BD311B6610008C791A39705CA5230@il93exm04.css.mot.com> <mailman.994804336.23495.python-list@python.org> <slrn9kokj6.mjk.philh@comuno.freeserve.co.uk> Message-ID: <3B4CC986.A5C8E605@engcorp.com> phil hunt wrote: > > On Tue, 10 Jul 2001 15:31:11 -0700, Paul Prescod <paulp at ActiveState.com> wrote: > >Kemp Randy-W18971 wrote: > >> > >> So an interesting question is raised. If PHP and Ruby are gaining > >> acceptance because they address business needs, what needs to be done to > >> carry Python in that direction? And while Java may be slow, Sun pushing it > >> for business solutions also gives that language acceptance. How can Python > >> become as popular as Perl, Java, or PHP? > > > >Perl, Java and PHP all grew popular by solving a particular problem at a > >particular time, better than any other language. (I'm thinking of system > >administration/CGI, Applets and web page generation). Perl and Java grew > >into general purpose languages over time. The jury is still out on PHP. > > > >Python does not have a niche and is not obviously a niche-friendly > >language. > > Sure it does: python's niche is as a scripting language that's also good > for longer programs. I tend to think of Python more as an extremely effective and maintainable general-purpose programming language, which happens also to work very well when applied as a "scripting language" (whatever that means). (In a way I agree with Paul's conclusion that Python is too generally useful and overall nice to use to have drawn the attention of a tiny core of vocal fanatics (who then have to write 100 books explaining every subtle nuance of the language).) We've applied it so widely that I would certain question the term "niche language" when applied to Python (more so than almost any other language). Even Java has a more clearly defined "niche" (internet programming). -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From s713221 at student.gu.edu.au Sat Jul 14 02:50:50 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Sat, 14 Jul 2001 16:50:50 +1000 Subject: apply problems References: <3B4F3501.E1469159@bioeng.ucsd.edu> <mailman.995048304.8843.python-list@python.org> <3B4F8B57.7684D13A@bioeng.ucsd.edu> Message-ID: <3B4FEBCA.E3F256E2@student.gu.edu.au> Curtis Jensen wrote: > I thought about that. But in the test examples below, you can see that > you'll that you don't have to pass "self" with apply. In fact if you > do, you'll end up with too many parameters. Also, symanticly, I think > "apply( self.ren.Elements, (self, cmd[1]), additional_kwds )" will only > pass two arguments "self" and "cmd[1]" as apposed to sending "self" and > all the items in "cmd[1]" as individual argument. You'd need to put > "self" at the beginning of cmd[1], or make a new tuple to pass in. But > I know what you mean. If you need to add a self argument to a list of arguments, (Usually if you're calling an unbound class method) the typical method is as follows: apply( self.ren.Elements, (self,)+cmd, additional_kwds ) Of course this is assuming that cmd is a tuple. If it's a list you need to do the following: apply( self.ren.Elements, (self,)+tuple(cmd), additional_kwds > In any case, my problem went away. I'm not exactly sure why. It > probably had to do with unsafe dynamic binding or something like that. > :) Would you be able to show us what cmd and additional_kwds typically look like? -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From sh at ttsoftware.co.uk Mon Jul 23 14:15:35 2001 From: sh at ttsoftware.co.uk (Steve Horne) Date: Mon, 23 Jul 2001 19:15:35 +0100 Subject: PEP0238 lament References: <mailman.995898939.27893.python-list@python.org> Message-ID: <6unolt4kg5pjav1k0c7qjv8mg4qe0fdbaj@4ax.com> On Mon, 23 Jul 2001 09:34:36 -0500, <mcherm at destiny.com> wrote: >Guido writes: >> [...] >> Because all Arthur does is tick me off, I'll leave it at this -- >> maybe someone else can explain it all to him. > >Well, I'll see what I can do. In the language there are (at least) >two distinct things we might want to do when "dividing" A and B: > > (1) split A up into B parts > (2) find how many B's fit in an A > >A good example of (1) is float division, and the cannonical example >of (2) is "int division", aka "div". These are DIFFERENT THINGS. Nope - float division is simply a logical extension of int division, the same as float addition compared with int addition. The fact that some people *see* them as different things is irrelevant given that others don't. >So I'm hoping that everyone reading this can agree, BOTH (1) and >(2) are USEFUL things, and a good language should allow BOTH. If >not, then please stop reading: there's no way I can convince you. Here I agree - division that implicitly coerces integers to floats is likely to be useful, at least for some. It's *not* the only solution for the stated problems, but it is a reasonable idea. >Given that you want both (1) and (2), there is just one problem: >the syntax "A / B" is the ideal syntax for BOTH of these purposes. >It's ideal for (1) because the mathematical operation of division >is traditionally represented with a "/", and it's ideal for (2) The mathematical operation of division is traditionally represented as ? in general - or as a horizontal line between the numerator and denominator. Only rationals merit the / in mathematics - it's simply the best compromise. But mathematics uses the same set of symbols equally for both integer and real division - it's rarely made explicit which is in use as it is normally blatantly obvious. So I don't believe (1) is valid. >because C and other languages have historically used "/" between >integers for (2). In my opinion (and those of quite a few others), >this is pretty lopsided: (1) is probably used more often, so it Most programs make heavy use of integer subscripts and indices. Integer division is heavily used in many applications - including numerics (even numeric algorithms have to partition their data sets for some tasks). The first form of division is rarely done outside of noddy teaching exercises and some specialist fields. *THAT* is the rare case. >should get priority, PLUS just imitating C isn't very convincing >since other languages (eg: Pascal) use other syntax, PLUS the use Pascal is half dead - only Delphi is realistically keeping it alive, and that is a single vendor non-standard implementation which has never been a major language in the way C, C++ or Java have - why do you think they made C++ Builder? Lets see - on the 1/2 gives 0.5 front we have... Perl Completely untyped, so it only has one 'numeric type' anyway. Only popular as a scripting language - ie it is a competitor, not something lots of people will use concurrently with Python so confusion on changeover will be relatively limited. LISP Lots-Of-Infuriatingly-Stupid-Parentheses? - A very important language academically, but *not* a model of clarity or simplicity. To my knowledge, the biggest user base is the non-standard version used for scripting EMACS. Pascal Again a very *important* language, but mainly historical. Ada - a language very heavily influenced by Pascal and by Wirth in general - *REVERSED* this decision ON THE GROUNDS OF CLARITY, SIMPLICITY AND RELIABILITY - and believe me, Ada was *not* designed using guesswork and personal ideologies. Modula 2/3 etc Better than Pascal, but sadly not kept around to the same extent. Definitely minority languages. JavaScript Hardly a model of cleanliness or simplicity - my experience is that half the time the interpreter is trying to guess what you mean and getting it wrong - just like HTML, I suppose. It's dumbed down to the point that you have to figure out just how stupid it's assuming you are to have any chance of getting it to work at all. On the other side... Visual BASIC The most used language for at least three years running. C What need I say? Not a great model for clarity in general, but at least a *lot* of people are used to it. C++ Ditto Java Ditto Ada See 'Pascal' above VBA The most used language by non-programmers who just want a quick script in a spreadsheet or whatever. Has anyone noticed a pattern here ;-) Sorry for arguing against something that's only a minor part of the issue - especially when you clearly understand my main worry - but I want people to appreciate that even in twenty years when every Python script in use has been fixed and no-one remembers the argument - it will *still* be a matter of opinion which is better. -- Steve Horne Home : steve at lurking.demon.co.uk Work : sh at ttsoftware.co.uk From max at alcyone.com Sun Jul 22 15:18:17 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 22 Jul 2001 12:18:17 -0700 Subject: subclassing Exceptions References: <9ihklt8u0vvh1aa0mg6tadbmjo9mot47e0@4ax.com> <mailman.995773776.14791.python-list@python.org> <v3mklt0fcn31un5en9pr90lvnh44935qi4@4ax.com> <3B5B137E.3606B75D@alcyone.com> <9t6mltc0nhqt4enj7dq0n0c9s3u9ens4eb@4ax.com> Message-ID: <3B5B26F9.A2C71182@alcyone.com> Sheila King wrote: > I'm trying to see the "big picture". I'm a "big picture" kind of gal. > I > don't feel comfortable working with just bits and pieces...just enough > information (in the information-giver's opinion) for me to get by. ... > Does this mean there is something wrong with me? Should I be satisfied > with the docs only? Not necessarily, but I'm still not sure what you're asking for. You say you want the "big picture," but your queries seem too general to pin down exactly what part of the "big picture" (if any) you're missing, particularly since you have access to and have read the library reference section on exceptions.Exception. Why not try asking some very specific questions, with code if necessary, and see where that takes you? -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Humor is emotional chaos remembered in tranquility. \__/ James Thurber Rules for Buh / http://www.alcyone.com/max/projects/cards/buh.html The official rules to the betting card game, Buh. From machin_john_888 at hotmail.com Sat Jul 7 22:20:07 2001 From: machin_john_888 at hotmail.com (John Machin) Date: 7 Jul 2001 19:20:07 -0700 Subject: Comment on PEP-0238 References: <3B3BE855.A6223E70@3-cities.com> <cp7kxvlake.fsf@cj20424-a.reston1.va.home.com> <Y4J%6.4084$Z6.2010194@news1.rdc2.pa.home.com> <mailman.994016102.30019.python-list@python.org> Message-ID: <92ae279c.0107071820.7ebb77f8@posting.google.com> Paul Prescod <paulp at ActiveState.com> wrote in message news:<mailman.994016102.30019.python-list at python.org>... > I really don't want to go through this whole argument again (after all, > that's the point of PEPs) but when you were a child, you "just knew" > whether you meant truncating or float division. Python guesses based on > the types of the operands which is a poor choice in a dynamically typed > language that otherwise treats "5.0" as a more verbose alternate syntax > for "5": > > for i in range(5.0): > print i > > If Python were to always disallow integer/float coercion then users > would learn that and life would go on. Instead, it coerces in some > places and not others. Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 >>> range(5.0) [0, 1, 2, 3, 4] -- as advertised by Paul. However doc says args are "plain integers". >>> range(5.9999) [0, 1, 2, 3, 4] -- should maybe have a last value of 5 (see doc). >>> range(5.99999999999999999) [0, 1, 2, 3, 4, 5] -- Tim seems to need to spend a lot more time explaining this sort of thing to newbies than why 1/3 produces 0 >>> range(5+0j) Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: can't convert complex to int; use e.g. int(abs(z)) -- Not consistent with the theory espoused elsewhere in the PEP-0208 thread that ints are a subset of floats. Floats are a subset of complex numbers. IMO, narrowing coercions, ones that can silently lose information, like the far-too-helpful automatic conversion from character to numeric that's found in awk and Perl, are dangerous and are against what I thought was the Python way. Certainly range(5.9999) is a dark corner that I suspect most people had never ventured into. From jpb at ApesSeekingKnowledge.net Thu Jul 12 20:23:07 2001 From: jpb at ApesSeekingKnowledge.net (Joe Block) Date: Fri, 13 Jul 2001 00:23:07 GMT Subject: Maintaining the Python FAQ References: <mailman.994428256.27172.python-list@python.org> <cpvgl6jbyz.fsf@cj20424-a.reston1.va.home.com> Message-ID: <jpb-BA1E76.20231012072001@news-server.cfl.rr.com> In article <cpvgl6jbyz.fsf at cj20424-a.reston1.va.home.com>, Guido van Rossum <guido at python.org> wrote: > Oleg Broytmann <phd at phd.fep.ru> writes: > > > On Fri, 6 Jul 2001, Guido van Rossum wrote: > > > Hm. To what extent is the current FAQ wizard a problem for its > > > > For me the biggest problem is not the FAQ Wizard, but FAQ.html - it is > > too big. 270K is too big for the Net. Let us split it intopages. > > Huh? The FAQ wizard gives you plenty of ways to access individual > items or sections. Why would you ever download the whole FAQ? To print it, so it can be read while I'm away from the net? From alf at leo.logilab.fr Thu Jul 12 13:28:46 2001 From: alf at leo.logilab.fr (Alexandre Fayolle) Date: Thu, 12 Jul 2001 17:28:46 +0000 (UTC) Subject: asyncore.dispatch_with_send bug Message-ID: <slrn9krnq0.fm0.alf@leo.logilab.fr> Hello, I think there's a bug in asyncore.dispatcher_with_send. The accesses to self.out_buffer in this class cause errors because of the __getattr__ method inherited from dispatcher, causing tracebacks such as File "/home/alf/Narval/narval/services/SocketManager.py", line 118, in _run loop(timeout=60,use_poll=0) File "/usr/lib/python2.1/asyncore.py", line 193, in loop poll_fun (timeout, map) File "/usr/lib/python2.1/asyncore.py", line 84, in poll if obj.writable(): File "/usr/lib/python2.1/asyncore.py", line 452, in writable return (not self.connected) or len(self.out_buffer) File "/usr/lib/python2.1/asyncore.py", line 357, in __getattr__ return getattr (self.socket, attr) AttributeError: out_buffer Am I right, or am I misunderstanding the code ? Alexandre Fayolle -- LOGILAB, Paris (France). http://www.logilab.com http://www.logilab.fr http://www.logilab.org Narval, the first software agent available as free software (GPL). From fellowsd at cs.man.ac.uk Thu Jul 12 05:24:46 2001 From: fellowsd at cs.man.ac.uk (Donal K. Fellows) Date: Thu, 12 Jul 2001 10:24:46 +0100 Subject: shortest match regexp operator anyone? References: <yv266cz4aom.fsf@lionsp093.lion-ag.de> Message-ID: <3B4D6CDE.FE8B08F0@cs.man.ac.uk> Harald Kirsch wrote: > 2) TASK: Find the first '<A>' and match, if it is followed by a 'B' > SOLUTION: ??? > > An approximation for (2) is '^[^<>A]+<A>B', but it does not match > 'A<A>B', which it should. This isn't purely a regexp, but it is a one-liner: if {[regexp -indices {<A>(B)?} $string matched gotB]&&[lindex $gotB 0]+1} { #.... } Donal. -- Donal K. Fellows http://www.cs.man.ac.uk/~fellowsd/ fellowsd at cs.man.ac.uk -- Actually, come to think of it, I don't think your opponent, your audience, or the metropolitan Tokyo area would be in much better shape. -- Jeff Huo <jeff at starfall.com.nospam> From barry at zope.com Wed Jul 25 10:39:33 2001 From: barry at zope.com (Barry A. Warsaw) Date: Wed, 25 Jul 2001 10:39:33 -0400 Subject: Language change and code breaks References: <Pine.LNX.4.33.0107191316390.24983-100000@bms> <mailman.995571273.18192.python-list@python.org> <9j7gv8$9mg@dispatch.concentric.net> <cppuawfqbm.fsf@cj20424-a.reston1.va.home.com> <mailman.995734717.26373.python-list@python.org> <3B5DF101.9B2E4631@earthlink.net> <cpofq9a858.fsf@cj20424-a.reston1.va.home.com> Message-ID: <15198.55845.931191.151572@anthem.wooz.org> >>>>> "GvR" == Guido van Rossum <guido at python.org> writes: GvR> You would be very surprised if email to JKnapka at EarthLink.Net GvR> was sent to a different user than email to GvR> jknapka at earthlink.net. Interestingly enough (or maybe not ;), those might be consider two different addresses. E.g. Mailman case-preserves the localpart for delivery purposes, but is case-insensitive for membership purposes. The domainpart of course is case insensitive. -Barry From oliphant at ee.byu.edu Thu Jul 19 15:06:17 2001 From: oliphant at ee.byu.edu (Travis Oliphant) Date: Thu, 19 Jul 2001 13:06:17 -0600 Subject: Statistics tool box. In-Reply-To: <Pine.LNX.4.21.0107131826180.32753-100000@seahawk.ecc.engr.uky.edu> References: <Pine.LNX.4.21.0107131826180.32753-100000@seahawk.ecc.engr.uky.edu> Message-ID: <Pine.LNX.4.33.0107191304540.10340-100000@oliphant.ee.byu.edu> > Hi, > I am trying to convert my matlab scripts into Python. But I see that > there are no equivalent stat. tools in Python. If there are any, could you > please let me know. I am looking for the functions similar to: > > normrnd() > unifrnd() > hist() > The equivalent functionality is available but you need to install Numeric, Scientifc Python (Konrad Hinsen), and the stats package. Alternatively, wait a couple of weeks for the alpha release of SciPy. -Travis Oliphant From skip at pobox.com Tue Jul 31 13:20:48 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 31 Jul 2001 12:20:48 -0500 Subject: case sensitivity redux (was Re: Language change and code breaks) In-Reply-To: <3b66c4ce.904451372@wa.news.verio.net> References: <Pine.LNX.4.33.0107191316390.24983-100000@bms> <mailman.995571273.18192.python-list@python.org> <9j7gv8$9mg@dispatch.concentric.net> <cppuawfqbm.fsf@cj20424-a.reston1.va.home.com> <Pine.LNX.4.33.0107231434170.15565-100000@oliphant.ee.byu.edu> <532qlt453irrepptskcvp213d44r3so2e2@4ax.com> <cp4rs2qf6p.fsf@cj20424-a.reston1.va.home.com> <3B5DF282.87266DA2@earthlink.net> <cpr8v5a8h5.fsf@cj20424-a.reston1.va.home.com> <9k5tg301mn9@enews4.newsguy.com> <3b66c4ce.904451372@wa.news.verio.net> Message-ID: <15206.59632.530210.78316@beluga.mojam.com> Bengt> Most of us have lots to be thankful for, clearly. Shifting case Bengt> is also an extra finger dexterity exercise, which is difficult Bengt> for some with good sight but other impairments. Let's assume you have a desterity problem that makes it hard to press the shift key while hitting other keys on the keyboard. No problem, all your identifiers will be lower case. You'll probably want to separate words in identifiers with underscores, however, and on American keyboards at least, that requires you to use the shift key. Someone with an impairment such as you suggest would have to either have a special keyboard (perhaps special enough to be a voice recognition system) or work on a system that allows them to remap their keyboards as you can do with X/xmodmap, so they could move the underscore into an unshifted position. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From peter at engcorp.com Tue Jul 24 20:20:09 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 24 Jul 2001 20:20:09 -0400 Subject: Python 2.0.1 bug? References: <20010720095330.19318.00000287@ng-fn1.aol.com> <Xns90E4B1153C485gmcmhypernetcom@199.171.54.154> Message-ID: <3B5E10B9.A7402CB5@engcorp.com> Gordon McMillan wrote: > TheDustbustr) wrote: [snip] > > When you run this program then point your webbrowser to localhost:8080, > > you SHOULD see your GET / HTTP/1.1 request echoed to the screen (the > > "webpage"), as well as echoed to the console. Well, under Python 1.5.2 > > running under Linux, it does. Running 2.0.1 under Windows 95, it > > doesn't, *nothing* is printed to the webbrowser. [snip] > Or it could be that your Windows browser is waiting to see a proper > HTTP response, but your Linux browser is being "forgiving". > > Browsers are notoriously difficult beasts, so I would definitely > look there first. Or at least use 'telnet' first, to view the actual response in a tool more suited to debugging basic socket problems like this, rather than assuming the browser is really showing everything it has received. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From andymac at bullseye.apana.org.au Fri Jul 27 21:33:11 2001 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Sat, 28 Jul 2001 11:33:11 +1000 (EST) Subject: Python 2.1 _sockets error In-Reply-To: <u9r0mtkbja3hbichui2ki1vqniqd0051b0@4ax.com> Message-ID: <Pine.OS2.4.32.0107281124570.27429-100000@central> {posted and mailed} On Thu, 26 Jul 2001, Zen wrote: > When I start Zope, I get this error: > Traceback (most recent call last): > File "/usr/www/heavenga/Zope-2.4.0-src/z2.py", line 540, in ? > import ZServer > File "/usr/www/heavenga/Zope-2.4.0-src/ZServer/__init__.py", line > 87, in ? > from medusa.test import max_sockets > File > "/usr/www/heavenga/Zope-2.4.0-src/ZServer/medusa/test/max_sockets.py", > line 2, in ? > import socket > File "/usr/local/lib/python2.1/socket.py", line 41, in ? > from _socket import * > ImportError: /usr/local/lib/libcrypto.so.1: Undefined symbol > "ERR_load_RSAREF_strings" {...} > The system is running FreeBSD 3.4, and the installed version is Python > 2.1. This happened with the install from the ports collection, as > well as installing from the source package with the basic configure. For some reason, your base system doesn't have some RSA related entrypoints in its libcrypto, but your build from the Python port expected it. This may be related to the ports system now not specifically supporting FreeBSD < v4.0. It might be worth trying to build Python 2.1 (better yet, use 2.1.1) from the configure script and see whether you get the same result. For many reasons, you should at the very least upgrade the system to FreeBSD 3.5.1-STABLE, or even better the 4.3 security updates only branch (RELENG_4_3 I think). -- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andymac at bullseye.apana.org.au | Snail: PO Box 370 andymac at pcug.org.au | Belconnen ACT 2616 Web: http://www.andymac.org/ | Australia From wesc at deirdre.org Sun Jul 15 03:07:43 2001 From: wesc at deirdre.org (Wesley Chun) Date: Sun, 15 Jul 2001 00:07:43 -0700 (PDT) Subject: Maintaining the Python FAQ Message-ID: <Pine.LNX.4.31.0107142358330.20249-100000@emperor.deirdre.org> On Fri, 13 Jul 2001 02:27:56 GMT, grante at visi.com (Grant Edwards) wrote: > On Fri, 13 Jul 2001 00:23:07 GMT, Joe Block <jpb at ApesSeekingKnowledge.net> wrote: >> On Fri, 6 Jul 2001, Guido van Rossum wrote: >>> Huh? The FAQ wizard gives you plenty of ways to access individual >>> items or sections. Why would you ever download the whole FAQ? >> >> To print it, so it can be read while I'm away from the net? > Away from the net? > Huh? Why would you ever be away from the net? ;) what a cute discussion. ;-) actually, i *like* to periodically print an entire FAQ for reference purposes. although i have an 802.11 setup at home, it seems more awkward to take my laptop to the restroom when i can bring my trusty printout -- double-sided, double-columned to save whatever tree i can -- along with a highlighter. as i was working on a certain manuscript (name withheld to prevent a shameless plug), the FAQ proved very useful when i could flip back and forth and make annotations in the margins. plus, i *wanted* to be off the net so that i could get some *real* work done! :) -wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Silicon Valley-SF Bay Area Python users group: http://baypiggies.org "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 cribeiro at mail.inet.com.br Sun Jul 1 23:30:31 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Mon, 02 Jul 2001 00:30:31 -0300 Subject: New PEP: Quality Guidelines For Standard Modules In-Reply-To: <20010702105039.A23408@Vetinari.home> References: <5.0.2.1.0.20010701213736.0277d700@mail.inet.com.br> <5.0.2.1.0.20010701213736.0277d700@mail.inet.com.br> Message-ID: <5.0.2.1.0.20010702001802.02764c60@mail.inet.com.br> Now it's a little over midnight, a bad time to give a meaningful reply after a busy Sunday :-) You raised several interesting points. I believe that some problems are caused by my limited knowledge of english. Sometimes I'm not able to make myself clear. I'll try to reply only one of your comments; I'll leave the rest of them for tomorrow. At 10:50 02/07/01 +0800, Malcolm Tredinnick wrote: >The OS-LIMITED concept was a bit confusing to me the first couple of >times I read this. Basically, you are saying "write portable code", as >far as I can tell. If there were other obstacles, wouldn't that make the >module OS-DEPENDENT? If I'm missing something here, perhaps you can give >an example of something that is portable code, but OS-LIMITED and not >OS-DEPENDENT. Let me try to explain what I meant: some modules are not as portable as they should. There is nothing inherently non portable on the module code, but the author may have used (maybe inadvertently) some non portable feature of some particular platform. This is the what I meant as OS-LIMITED. It was my way to define modules that deserve to be "fixed". By removing unneeded dependency these modules may become portable, and so OS-INDEPENDENT. Many modules that are available on the net suffer from this problem. Let us talk about something simple: some advanced data structure, for example a tree. Some implementations available on the net compile only for some particular platforms, sometimes because the author used particular features of that platform's compiler. In such case, it should be relatively easy to remove the dependency in order to make the code OS-INDEPENDENT, as by my definition. As for the rest of your comments, they were all very helpful. I'll try to think on them a little bit harder Monday morning after a good sleep <wink-and-snore> Carlos Ribeiro From tim.one at home.com Fri Jul 27 18:18:32 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 27 Jul 2001 18:18:32 -0400 Subject: defining classes within loops? In-Reply-To: <roy-10E6A4.08233827072001@news1.panix.com> Message-ID: <LNBBLJKPBEHFEDALKOLCGEMPLBAA.tim.one@home.com> [Roy Smith] > Just out of curiosity, how many people have ever written a function or > class definition nested inside a loop? Seems like sort of a > strange thing to do, although I suppose it might be useful in some > situations. Never a class, but sometimes a function. This can be (marginally!) handy when abusing the default-argument mechanism to build a family of functions that differ in some regular way. For a non-trivial example (it's simply fresh on my mind), the 2.2 test_generators.py contains a generator-based N-Queens solver, which uses a different column-number generator for each row of the board. The column generators are created in a loop, using the default-argument trick to give each row's column-number generator its own pre-initialized local list containing info about the diagonals reachable from each square in that row. So that's the problem: examples are either too complex to explain both clearly and briefly, or so trivial that if I included one here I'd be subject to another rash of "but that's so useless only an academic propeller-head could think it was valuable!" rants <0.9 wink>. not-a-*common*-practice-regardless-ly y'rs - tim From michael at stroeder.com Fri Jul 13 04:41:58 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Fri, 13 Jul 2001 10:41:58 +0200 Subject: Encryption and python? References: <m27kxdy543.fsf@mouse.copelandconsulting.net> Message-ID: <3B4EB456.5A315CF9@stroeder.com> Greg Copeland wrote: > > I've been browsing around for a while now trying to come up with > "the" python encryption library that I can make use of. This is a very general question. What are you looking for? - Low-level algorithms (hashes and encryption) - Crypto Protocols (e.g SSL or S/MIME) - Key stores ... There's also a mailing list (currently very low volume): http://listserv.surfnet.nl/archives/python-crypto.html Ciao, Michael. From peter at engcorp.com Fri Jul 27 02:01:24 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 27 Jul 2001 02:01:24 -0400 Subject: File Reading , Reverse Direction References: <3B60F7EC.5275E026@lsu.edu> Message-ID: <3B6103B4.AF7AE15B@engcorp.com> Ratnakar Malla wrote: > > Hi, > I need to read from a very long file. But the only information I am > interested is > 2 lines at the bottom of the file. > 1) Can i read the file in the reverse direction , so that I dont lose > time? Do you really want to read in "reverse"? To me that implies getting each byte in reverse order, which would require reversing the lines again after finding the "first" two... Or do you just want to read line-by-line, in reverse? > 2) If so how?? How about this? lastTwoLinesAsList = open('somefile').readlines()[-2:] > 3) I tried the normal way, but looks like, it is taking lot of time. What is "normal"? Maybe your code is not the most efficient implementation... You could also use "seek" to find the end of the file, then go backwards a few dozen bytes at a time, grabbing blobs of data until you found the third-last newline (or the second last, if the file did not end with a newline), then return everything after that point. This would be awkward, largely unreadable, bug-prone, and might take a while to develop. Or how about calling out to "tail"? import os lastTwoLinesAsString = os.popen('tail -2 somefile').read() You might also want to post a sample of your code, and mention which platform you are on, so feedback might be a little more relevant to your situation... -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From rnd at onego.ru Tue Jul 17 09:37:50 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 17 Jul 2001 17:37:50 +0400 (MSD) Subject: PEP: Defining Python Source Code Encodings In-Reply-To: <3B542B69.8C092964@lemburg.com> Message-ID: <Pine.LNX.4.21.BCL.0107171620190.704-100000@suzi.com.onego.ru> On Tue, 17 Jul 2001, M.-A. Lemburg wrote: > > I think, that if encoding is not given, it must sillently assume "UNKNOWN" > > encoding and do nothing, that is be 8-bit clean (as it is now). > > To be 8-bit clean it will have to use Latin-1 as fallback encoding > since this encoding assures the roundtrip safety (decode to Unicode, > then reencode). Nope. There must be no encode-decode back. Or it will slow down starting Python _scripts_ unnecessary. That is why I suggested "unknown" encoding - a safe default for those who do not want any back-and-force recodings. > > Otherwise, it will slow down parser considerably. > > Yes, that could be an issue (I don't think it matters much though, > since parsing usually only done during byte-code compilation and > the results are buffered in .pyc files). No! Scripts are compiled each time they run. If this will be implemented, developers will need to do the trick of making each script a module and so on. This is not good idea. There clearly must be the way to prevent encode-decode. And it would be better if only EXPLICITLY given encoding will trigger encode-decode mechanism. > > I also think that if encoding is choosen, there is no need to reencode it > > back to literal strings: let them be in Unicode. > > That would be nice, but is not feasable at the moment (just try > to run Python with -U option and see what happens...). Then indeed --encoding= is needed with -U ;-) > > Or am I missing something? > > It won't switch any time soon... there's still too much work > ahead and I'm also pretty sure that the 8-bit string type won't > go away for backward compatibility reasons. ...and efficiency reasons too. re was slowed down significantly by adding Unicode support. > > > To make this backwards compatible, the implementation would have to > > > assume Latin-1 as the original file encoding if not given (otherwise, > > > binary data currently stored in 8-bit strings wouldn't make the > > > roundtrip). > > > > ...as I said, there must be no assumed charset. Things must > > be left as is now when no explicit encoding given. > > This is what the Latin-1 encoding assures. I still think something like "raw" is needed... > > > 4. The encoding used in a Python source file should be easily > > > parseable for en editor; a magic comment at the top of the > > > file seems to be what people want to see, so I'll drop the > > > directive (PEP 244) requirement in the PEP. > > > > > > Issues that still need to be resolved: > > > > > > - how to enable embedding of differently encoded data in Python > > > source code (e.g. UTF-8 encoded XML data in a Latin-1 > > > source file) > > > > Probably, adding explicit conversions. > > Yes, but there are cases where the source file having the embedded > data will not decode into Unicode (I got the example backwards: > think of a UTF-8 encoded source file with a Latin-1 string literal). utf-7 bit for embedded things ;-) > Perhaps we should simply rule out this case and have the > programmer stick to the source file encoding + some escaping > or a run-time recoding of the literal data into the preferred > encoding. This is probably wise. Python program need not be a while Zoo of encodings... > > No variant is ideal. The 2nd is worse/best than all > > (it depends on how to look at it!) > > > > Python has no macro directives. In this situation > > they could help greatly! > > We've been discussing these on python-dev, but Guido is not > too keen on having them. And this is right. I even think encoding information could be EXTERNAL. For example, directory will need to have "__encodings__.py" file where encodings are listed. Then, Python if started with some key could check for such file and compile modules accordingly. If there is not __encodings__.py, then Python proceed as it does now, WITHOUT any conversions to and from. This will make script-writer happy (no conversion overhead) and those who want to write encoding-enabled programs (they could specify __encodings__.py) I think, this solves most problems. > > That "#!encoding" is special case of macro directive. > > > > May be just put something like ''# <!DOCTYPE HTML PUBLIC'' > > at the beginning... > > > > Or, even greater idea occured to me: allow some XML > > with meta-information (not only encoding) somehow escaped. > > > > I think, GvR could come with some advice here... > > > > > Comments are welcome ! > > Thanks for your comments, I just hope the realisation of your PEP will not make Python scripts running slower ;-) while allowing truly useful i18n functionality. * I have a feeling that PEP is solving non-problem. Or have I lost the thread? For example, I usually write scripts where I assume "koi8-r" or "windows-1251" encodings. And the only problems I have is when I use "koi8-r" strings from modules when I need "1251" ones. (In this case I explicitely recode). Aren't encodings better confined in documents (in XML for examples), than programs? If programs need to be written in unicode, then isn't the next step o allow embedding sound, graphics and video? (I imagine video docstring ;-) I can admit that using utf-8 in writing programs could be justified, but Unicode... It will bring nightmare... Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From cribeiro at mail.inet.com.br Mon Jul 2 07:20:57 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Mon, 02 Jul 2001 08:20:57 -0300 Subject: New PEP: Quality Guidelines For Standard Modules In-Reply-To: <t250ktcev8fp615ab7uanin3cq1rj9ga5j@4ax.com> References: <mailman.994034642.25601.python-list@python.org> Message-ID: <5.0.2.1.0.20010702081012.02776e10@mail.inet.com.br> At 06:25 02/07/01 +0000, Courageous wrote: >When writing language requirements, one MUST not use the >term "MUST" in conjunction with an "except". And in any case, >I disagree. Emphatically. Point taken. >The use of a singleton pattern changes nothing unless every >call to the module has the singleton as its first argument. And >if you're envisioning storing the singleton as a global, nothing >has been accomplished. There's a global. > >Perhaps you could make a better case for why you think this >is even important. One example that comes to mind is the fileinput standard module. It stores global state: input([files[, inplace[, backup]]]) Create an instance of the FileInput class. The instance will be used as global state for the functions of this module, and is also returned to use during iteration. Let us say that you are iterating over the lines in the main loop of a filter, and then, depending on the line read, have to iterate over several other files. The global state prevents you from using the same instance of the fileinput module. The workaround is to import the module a second time, binding it by a different name. Please note that I haven't done any *real* test on this myself. Also, if the state variable is declared as a global, even reimporting the module will fail. Carlos Ribeiro From avv at quasar.ipa.nw.ru Thu Jul 26 17:50:54 2001 From: avv at quasar.ipa.nw.ru (Alexander V. Voinov) Date: Thu, 26 Jul 2001 14:50:54 -0700 Subject: Problem with Python-2.1.1 and Numeric-20.1.0 Message-ID: <3B6090BD.F2B81140@quasar.ipa.nw.ru> Hi, It says: data = Numeric.transpose(data) File "/.../site-packages/Numeric/Numeric.py", line 280, in transpose axes = arange(len(array(a).shape))[::-1] File "/.../site-packages/Numeric/Numeric.py", line 159, in arrayrange m = (add.accumulate(ones((n,), Int))-1)*step +(start+(stop-stop)) NameError: global name 'add' is not defined The program worked OK with Python-2.0 and Numeric-17.1. Thank you in advance Alexander From aahz at panix.com Tue Jul 3 21:29:57 2001 From: aahz at panix.com (Aahz Maruch) Date: 3 Jul 2001 18:29:57 -0700 Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <X4l07.7611$B7.1402508@ruti.visi.com> <9hsu54$t38$1@panix3.panix.com> <9htjhb$ck4@news1.gtech.com> Message-ID: <9htril$5ml$1@panix6.panix.com> [BTW, would you please attribute the quotes. It makes conversation difficult if we can't keep track of who said what.] In article <9htjhb$ck4 at news1.gtech.com>, Peter Milliken <peter.milliken at gtech.com> wrote: >>>Aahz: >>>> >>>> >>>>Suppose that the only language choices are between C/C++ and >>>>Python, and that the real-time resolution requirement is on the >>>>order of one second. Which would you choose and why? > >Sorry, won't answer because it is not a realistic situation i.e. the choice >wouldn't be between C/C++ and Python :-). We already have the information that applications in this domain are written in C/C++, so your claim that it's an unrealistic situation strikes me as specious at best. -- --- 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'm not tense, i'm just terribly, terribly alert" --unknown From vvainio at karhu.tp.spt.fi Tue Jul 17 05:19:52 2001 From: vvainio at karhu.tp.spt.fi (Ville Vainio) Date: 17 Jul 2001 12:19:52 +0300 Subject: Is Python Dead? Long Live Python! References: <mailman.994803257.19598.python-list@python.org> <3b53fda0$0$151$9b622d9e@news.freenet.de> Message-ID: <yoxr8vfhpzb.fsf@karhu.tp.spt.fi> Guido Stepken <stepken at little-idiot.de> writes: > I have been teaching python to kids ...12 years old .... they really had > fun ... that's the (only) reason for the extreme growing acceptance for > python over java or perl or php .... python will be #1 in 2 years > .....expecially for huge projects .... I don't really think this learn-as-child thing is too important. Generation of people (20-somethings) who were doing basic at age 12 have already abandoned the language, while people who are actually using basic these days probably didn't use it at age 12. OTOH, Unlike basic, Python doesn't suck. -- 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 wyatts at onr.com Sat Jul 21 05:54:15 2001 From: wyatts at onr.com (wyatt stafford) Date: Sat, 21 Jul 2001 09:54:15 GMT Subject: Case insensitivity References: <mailman.995506711.21636.python-list@python.org> <cpvgkofyru.fsf@cj20424-a.reston1.va.home.com> <mailman.995634453.9136.python-list@python.org> <hlgglt4hrnnb8a7dmocntkns5bkm4b6jmm@4ax.com> Message-ID: <bjc67.73$5W4.2036582442@news.onr.com> > :Indeed, I don't think case-sensitiveness is something that will help > :non-programmers to get used to the language. I am new to Python and programming, in general. It is much more important to me that the syntax be consistent, rather than specifically easy. In my newbie opinion, case sensitivity gives me the ability to make finer distinctions in the names of things, though possibly I will also screw myself by being too clever. wyatt stafford From bsass at freenet.edmonton.ab.ca Thu Jul 26 14:50:52 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Thu, 26 Jul 2001 12:50:52 -0600 (MDT) Subject: Language change and code breaks In-Reply-To: <08k0mtc2lftoon7eii2jo43qj1tt76256c@4ax.com> Message-ID: <Pine.LNX.4.33.0107261216140.11619-100000@bms> On Thu, 26 Jul 2001 maxx at easynews.com wrote: > On Wed, 25 Jul 2001 05:29:41 GMT, Guido van Rossum <guido at python.org> wrote: <...> > >The number of symbols available is so much larger than the number of > >distinct names you need that the reduction is irrelevant. > > Plus, the day that symbols become so numerous in code that the usage of case is > necessary to differentiate them, then software development will have become > truly too complex for mortals such as myseld. Sure, and we can generate as many identifiers as we need with only 2 symbols, "0" and "1". Obviously there can be both too many symbols and too few symbols... the question is, `how many is too many, and how few is too few'. Furthermore, case-sensitive vs. case-insensitive can be handled as a convention (if you don't like 52+<numbers> symbols then only use 26+), no need to change the language and force 26+ on everyone. > >> Everyone knows that in normal usage, case carries meaning (bob > >> vs Bob). How could it possibly benefit the beginner to violate > >> that naive expectation? > > Because writing code is a completely different function than "normal every day > writing." Learning to write code means beginners must learn to structure their > thoughts, and organize tasks, so that their code is not a potential jumble of > ideas, as normal every day writing can be. What does that have to do with case sensitivity... code, thoughts and tasks can be organized just as well with case sensitivity as without, and can be just as jumbled without case sensitivity as they can be with it. This is a function of the language's semantics and how well the users have `wrapped their head' around the language. > Creative writing and code writing are like apples and oranges. To expect that > beginners do not need this distinction is to doom them to failure. In fact, some > of the restrictions that Python places on users, forcing them to indent code for > example, is what makes the language a great training tool. Indentation is not a restriction, it is part of the language. It would be a restriction if the semantics were clear without indentation (e.g., we had block identifiers) but indentation was forced anyways. > Most every piece of problematic code I have dealt with in my career has been > difficult to work with primarily because it is poorly formatted and structured. > More often than not, I find code that does not work because novices just put > commands down in the order that they think of them, not bothering to design the > proper process flow first. Then they wind up with a malfunctioning mess that > even they cannot decipher. If they learned on languages like Python first > (instead of the popular stream of conciousness messes like VB), then they would > develop "good habits", and be more successful. That may be true, but "format" and "structure" have nothing to do with case sensitivity. Case sensitivity may affect readability, for those who do not realize that "a" and "A" are different... a simple >>> ord("a"), ord("A") (97, 65) should fix that problem though. - Bruce From joonas.paalasmaa at nokia.com Fri Jul 13 03:31:34 2001 From: joonas.paalasmaa at nokia.com (Joonas Paalasmaa) Date: Fri, 13 Jul 2001 07:31:34 GMT Subject: Regural expression puzzle for gurus References: <3B4EA0C8.9F697D06@vip.fi> Message-ID: <3B4EA470.AA7B0D12@nokia.com> Pekka Niiranen wrote: > > I have a string in the middle of a text starting with #-sign and ending > to \W. > I can find it with re.compile('#\w+') and would like to replace it by > adding a > # -sign also to the end of it. > > Example: > > original string: xx:yy:#AAA.!:-#BBB:2324:#CCC:!"?% > > after replacement: xx:yy:#AAA#.!:-#BBB#:2324:#CCC#:!"?% > > How can I do replacement with a single regural expression line ? > > I have found a solution like: > text = 'xx:yy:#AAA:-#BBB:aa' > line = re.compile('#\w+') > list = line.findall(text) > for i in range(len(list)): > text = text.replace(list[i],list[i]+'#') > > >>> text > 'xx:yy:#AAA#:-#BBB#:aa' > > I would like to do this without the for -loop (unless somebody can > convince > me the found solution is the fastest available) Try this. import re text = """xx:yy:#AAA.!:-#BBB:2324:#CCC:!"?%""" print re.sub(r"(#\w+)(\W)", r"\1#\2", text) - Joonas From twofingersalute at atl.mediaone.net Sun Jul 1 19:14:15 2001 From: twofingersalute at atl.mediaone.net (myself) Date: Sun, 01 Jul 2001 19:14:15 -0400 Subject: any books for python for downloading? References: <993939668.727430@athnrd02.forthnet.gr> Message-ID: <9hoat4$euo90$1@ID-87965.news.dfncis.de> In article <993939668.727430 at athnrd02.forthnet.gr>, "whats_really_hot" <whats_really_hot at hotmail.com> wrote: > so, are there..........give me a feedback and some help(how about some > URL's with books for downloading) for learning Python...... > how about: http://www.ibiblio.org/obp/thinkCSpy/index.htm ?? From skip at pobox.com Tue Jul 31 13:42:32 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 31 Jul 2001 12:42:32 -0500 Subject: Arg decoding with a template? In-Reply-To: <55ndmt4e43rpoi7at0pikc4a50qp90jh4b@4ax.com> References: <ljidmtouqj6som2t9ecagbkj95c53kjaeh@4ax.com> <4oA97.5883$9i1.519137@e420r-atl1.usenetserver.com> <55ndmt4e43rpoi7at0pikc4a50qp90jh4b@4ax.com> Message-ID: <15206.60936.334175.227484@beluga.mojam.com> Dale> It looks a bit unfriendly with all the - and -- but I'll see if I Dale> can make some sense of it. It's actually pretty easy to use once you learn the pattern. I commonly use it like so: alternate = "" binary = quiet = verbose = 0 # split arg list up into pieces try: # colon after "a" says it needs an argument - others are boolean # flags opts, args = getopt.getopt(sys.argv[1:], "a:bqv") except getopt.error: usage() # process the flags for opt, arg in opts: if opt == "-a": alternate = arg elif opt == "-b: binary = 1 elif opt == "-q": quiet = 1 elif opt == "-v": verbose = 1 # process the rest of the args if not args: infile = sys.stdin outfile = sys.stdout if len(args) == 1: infile = open(args[0]) outfile = sys.stdout elif len(args) == 2: infile = open(args[0]) outfile = open(args[1], "w") else: usage() You can expand your getopt call to accept long args by adding a third argument and adding the necessary tests to your for loop, but for internal stuff I rarely do. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From bit_bucket5 at hotmail.com Wed Jul 25 11:42:44 2001 From: bit_bucket5 at hotmail.com (Chris) Date: 25 Jul 2001 08:42:44 -0700 Subject: How to telnet to other unix machines and grep log files etc? Message-ID: <fa7108b0.0107250742.7b38c678@posting.google.com> Relative unix newbie. Would like to write a python script to do what I do manually--telnet to two different unix machines from a third unix machine. Grep through some log files, gather the grep results from the different machines and spit them out. I think I need to do something with popen, or popen2, or ??? I don't know where to start. Any pointers much appreciated. Thanks, Chris From tim.one at home.com Wed Jul 4 19:25:18 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 4 Jul 2001 19:25:18 -0400 Subject: Eiffel better than Python ? In-Reply-To: <9huj6g01er2@enews1.newsguy.com> Message-ID: <LNBBLJKPBEHFEDALKOLCEEHDKMAA.tim.one@home.com> [Tomasz Stochmal] > Should I stop using Python and jump on Eiffel wagon ? [Tim] > You didn't say what you want to accomplish. If the idea of "provably > correct" programs appeals to you, Eiffel will give you more help than > any other practical language I know of. [Alex Martelli] > I still think Haskell would be of higher help. Immutable data > make proving program properties easier (while not _easy_). (If > you're implying Haskell isn't "practical", I'll unchain the > slavering hordes of FP groupies against you... scary threat, > innit?). Consider the questioner. Eiffel is an embodiment of a formal theory of software construction, and has many language features specifically designed to make application of that theory straightforward. Thomasz likely doesn't know either what to prove or how to go about it, in a vacuum; most programmers wouldn't; Eiffel helps them by providing a well-documented theory and executable framework; doing it in Haskell instead requires sucking the theory of functional programming out of scattered papers, building the proof support machinery by hand, and then persistent commitment to use it. Immutability isn't really much help when the *interesting* questions are about how dozens of subsystems interact with each other; documented and automagically enforced preconditions, postconditions, and class invariants do help, and in large part by forcing the programmer to *think* about them. If you try to do something similar in Haskell, you have to bring the motivation and support tools with you. DBC never catches on in Python for much the same reasons, I fear. too-clumsy-==-won't-be-used-except-by-motivated-experts-and-those-are- the-ones-who-need-it-least-ly y'rs - tim From markus at kepler.ibp.de Thu Jul 19 09:59:38 2001 From: markus at kepler.ibp.de (markus at kepler.ibp.de) Date: 19 Jul 2001 15:59:38 +0200 Subject: Problems with self as default parameter References: <3B56D025.508F40AD@olen.to> Message-ID: <m3y9plt3xx.fsf@kepler.ibp.de> Joonas Paalasmaa <joonas at olen.to> writes: > How can I use class members as default values. > The code above raises an error. > > class Test: > def __init__(self,s): > self.default = s > def printer(self, string = self.default): > print string [...] > NameError: name 'self' is not defined That's it: the default values are evaluated only once, at the time when the function is defined. And then the value of self.default (which belongs to the instance, not to the class) is not defined. A common idiom to overcome this problem is: def printer(self, string = None): if string is None: string = self.default print string - Markus From sholden at holdenweb.com Mon Jul 23 14:34:57 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 23 Jul 2001 14:34:57 -0400 Subject: direct (not DNS) database connection References: <74cc9702.0107190115.18ce07aa@posting.google.com> Message-ID: <05_67.12906$YK4.1093571@e420r-atl1.usenetserver.com> "phillip" <phillip at transwitch.co.za> wrote in message news:74cc9702.0107190115.18ce07aa at posting.google.com... > Hi, > > I am able to connect to a database, but I must first create a data > source name(DSN) in windows and the connect through the DSN. > > I would like to connect directly like : servername:port/databasename > > What module will enable me to do this ( connection pooling would be > good as well)? > > currently I am using odbc for windows and dcoracle for linux. > Take a look at cx_Oracle on www.computronix.com (?): I believe that will allow you to use the equivalent of Oracle connect strings, and I suspect ir will run on both your platforms. regards Steve -- http://www.holdenweb.com/ From skip at pobox.com Fri Jul 6 14:16:53 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 6 Jul 2001 13:16:53 -0500 Subject: Short form of file names In-Reply-To: <39916145.20010707010418@tomsk.net> References: <39916145.20010707010418@tomsk.net> Message-ID: <15174.149.10005.190801@beluga.mojam.com> Mikhail> Is there some Python module for converting Windows long paths Mikhail> to short form, i.e. 8.3? os.path.normpath() does not do this.. Try importing dospath directly: >>> import dospath >>> dospath.normpath("/supercalifragilisticexpealidocious.py") '\\supercal.py' -- Skip Montanaro (skip at pobox.com) (847)971-7098 From duncan at NOSPAMrcp.co.uk Thu Jul 19 04:14:52 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Thu, 19 Jul 2001 08:14:52 +0000 (UTC) Subject: Exceptions' Behaviour References: <mailman.995459309.19355.python-list@python.org> Message-ID: <Xns90E2B04A54C14duncanrcpcouk@127.0.0.1> Martin Sj?gren <martin at strakt.com> wrote in news:mailman.995459309.19355.python-list at python.org: > What's going on here? If (A, B) is raised like A, B, why don't I get > anything in my 'var' variable? If not, how come (A, B) is matched against > A? raise takes 0 to 3 expressions. (A, B) is a single expression yielding a tuple. You could have written 'raise (A, B), "Hello"' and then var would have been set to "Hello". However, a tuple isn't a valid type for an exception which must be a string class or instance object so I think that probably this should have thrown a TypeError as it does if you try to 'raise 3'. Why it didn't escapes me, but a quick play with the interpreter seems to indicate that raising any tuple is equivalent to raising the first element of the tuple and the remaining elements are lost. I just looked at the source and in fact it is recursive, as long as the first argument is a tuple, it replaces it with its first element. -- 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 nospam at nospam Wed Jul 11 17:32:31 2001 From: nospam at nospam (Rufus V. Smith) Date: Wed, 11 Jul 2001 17:32:31 -0400 Subject: ActivePython word wrap in Shell or PythonWin during list printout Message-ID: <3b4cc843$0$172@wodc7nh6.news.uu.net> I am running the latest Python from ActiveState and I have a problem that when I print a long list (Like dir()), the entire list prints out on one line and I have to scroll over to read it. Is there an environment setting to force word wrap at a certain line length? Or is there a list function that can take a list and pretty print it with word wrap. (Not having one gave me an opportunity to learn some Python scripting as I wrote my own, but if there was a library standard, that might be better. ) def marginprint(L,margin=80): b="" for a in L: if len(str(a)+b)+3 >= margin : print b b = "'"+str(a)+"'" else: if b: b+="," b += "'"+str(a)+"'" if b: print b b="" With this function, I just type marginprint(dir()) and it will respect the margins. Only I have to load this into my environment every time I bring it up. From aleaxit at yahoo.com Mon Jul 2 11:49:53 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 2 Jul 2001 17:49:53 +0200 Subject: Augmented Assignement (was: Re: PEP scepticism) References: <mailman.993952381.32699.python-list@python.org> <zbN%6.415855$oc7.58414702@news2.rdc2.tx.home.com> <q0avjto87p59hn7gv28r5cf1c84j2fb8c7@4ax.com> <naO%6.416271$oc7.58537852@news2.rdc2.tx.home.com> <vm40kt8knq3pplpv1rarjubl73vnl12ure@4ax.com> <20010702145211.M8098@xs4all.nl> <mailman.994083124.18397.python-list@python.org> Message-ID: <9hq57a0jnd@enews4.newsguy.com> "Paul Prescod" <paulp at ActiveState.com> wrote in message news:mailman.994083124.18397.python-list at python.org... ... > I'd like to see some real-world code that takes advantage of the fact > that this single operator behaves differently with mutable and immutable > types. Then I will believe that it isn't just a squishing together of > two unrelated features. Depending on how you define "real world", I have some use of that with my still-unreleased "in-house" (literally:-) "gmpy 1.0", where I have mutable numbers. My application code is doing combinatorial arithmetic (computing bridge-related stuff) -- iterating over a zillion different possible cases (exhaustively covering all possible distribution of cards over suits in a given situation), and for each given case X that occurs n times finding out how case X is to be classified (e.g., number of tricks that in case X are taken with playstrategies a/b/c, being compared). When it's found the classification index of case X is Y, it just does countof[Y] += n If container countof has been initialized with plain longs (or standard GMPY mpz's), that's like countof[Y] = countof[Y] + n. Sometimes these are LONG longs (combinatorial arithmetic does have a knack for producing *big* numbers... unless you do very clever analysis indeed to ensure against double- and triple- counting, and part of this application is exactly eschewing all the usual clever analysis, that one often gets subtly wrong, and using brute-force counting from first principles instead). So, I think releasing the old long (or gmpy.mpz) and allocating a new incremented one may sometimes be costly. But anyway this is what I get to have with good-old-Python, and with the gmpy that is released (because I accepted the unanimous advice from all Pythonistas who deigned to comment -- numbers must stay immutable). With the "new and improved" gmpy, I have an mpz variant that is mutable. So if I initialize countof with such numbers, I'll get inplace incrementing and save the deallocation and reallocation cost at each and every increment. Nothing huge I guess, these ARE scalars after all albeit big ones at times, but over a few million increments it builds up a bit. Having this polymorphism here lets me write an application that can run in plain Python, or with released-gmpy (a bit faster, because I get to use GMP's enhanced algorithms for long int [mpz] multiplication, the fast builtin 'comb' function, &c), or with experimental-gmpy (a bit faster yet). I like this. I do want to keep the flexibility because one day this might be running in Jython (e.g. as part of some JSP setup on the net) or under a Python installation I don't fully control (e.g. at some ISP's) so I may or may not be able to install gmpy on the side, or I may only be able to install the fully stable, released version. Of course, except for performance, I couldn't care less whether the increment is inplace or not -- I never have other outstanding references to the 'bins' of countof as I run this nested loop, so the identity of the object that the bin references is of no interest here. I guess that's pretty much a limit case for += &c on *scalars*. Most scalars probably won't have significant costs in freeing and allocation -- huge integer or rational numbers would seem to be atypical this way; surely vectors/matrices will be involved most of the time that +='s inplace version does matter performance-wise. But I doubt I'm the only weirdo doing combinatorial arithmetic, though most may be currently suffering from the 'numbers must be immutable' taboo and not considering 'mutable numbers' as a possible source of speedup:-). Alex From bckfnn at worldonline.dk Sun Jul 29 17:22:44 2001 From: bckfnn at worldonline.dk (Finn Bock) Date: Sun, 29 Jul 2001 21:22:44 GMT Subject: ANN: Third alpha release of Jython-2.1 Message-ID: <3b647cc5.30690039@mail.wanadoo.dk> I am happy to announce the third alpha release of Jython 2.1. Jython is a Java implementation of the Python programming language. It allows users to compile Python source code to Java byte codes, and run the resulting bytecodes on any Java Virtual Machine. It is a very seamless and smooth integration with Java: from Python you have complete access to all Java libraries, can build applets, can integrate with Java beans, and can subclass Java classes in Python and vice versa. Like Python, and unlike Java, Jython can also be used interactively: just type some Jython code at the prompt and see the results immediately. A java installer is available for download at the Jython website: http://www.jython.org/ Installation on version 2.1a3 is similar to version 2.0. Further information and tips on installation is available at: http://www.jython.org/install.html Jython 2.1 aims to be feature compatible with Python 2.1.1 and among the new feature are: - A settable console encoding will allow windows users to enter national characters at the command prompt. - The names of zip- and jarfiles can be added to sys.path. A complete list of changes and differences are available here: http://www.jython.org/NEWS.html A list of fixed bugs can be found here: http://sourceforge.net/tracker/?group_id=12867&atid=112867 Change the Status input box to "Closed" and the Group input box to "Fixed in 2.1a3" and press the "Browse" button. Bugs can be reported to the bug manager on SourceForge: http://sourceforge.net/bugs/?group_id=12867 Cheers, the jython-developers From JamesL at Lugoj.Com Tue Jul 10 01:19:44 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Mon, 09 Jul 2001 22:19:44 -0700 Subject: Newbie asks: How to translate this line of C to Py References: <tkl15g5on0mla8@news.supernews.com> Message-ID: <3B4A9070.A394537C@Lugoj.Com> "Steve S.L. Wong" wrote: > > while (command = strtok(line_ptr,";"),line_ptr=0,command) { > } I've been coding C for 20 years and I can therefore say authoritatively that that is one ugly line of code good sir. You've really abused the comma operator. Oh well, no animals were harmed I assume. Anyway, assuming you are doing something with the tokens inside the while loop, one equivalent appears to be: import string for command in filter(None, string.split(line_ptr, ";")): print command The string.split() tokenizes line_ptr, but includes zero length tokens, so I am applying the filter() function with the "identity" function None, which will remove the non-true list elements (in this case the zero-length strings) from the list of tokens. Hope this helps. From Randy.L.Kemp at motorola.com Tue Jul 10 09:20:35 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Tue, 10 Jul 2001 08:20:35 -0500 Subject: Is Python Dead? Long Live Python! Message-ID: <E566B020833BD311B6610008C791A39705CA5223@il93exm04.css.mot.com> Let's give Java its due respect, and Python its due respect. J2EE does have a considerable amount of emphasize in the business world, along with creating some open source efforts (www.jboss.org and www.enhydra.org). But Python should be used more in the business world. Unfortunately, it is not. -----Original Message----- From: James Logajan [mailto:JamesL at Lugoj.Com] Sent: Monday, July 09, 2001 4:24 PM To: python-list at python.org Subject: Re: Is Python Dead? Long Live Python! James_Althoff at i2.com wrote: > > Edward Wilson wrote: > <snip> > >Java is WAY too slow for serious development of any kind. > <snip> > > Might we be over-generalizing just a wee bit, perhaps? My company is > generating hundreds of millions of dollars of revenue with products written > in Java (with major pieces implemented in Jython :-). > > (I suppose *serious development* is relative <wink>). "A few billion here, a few billion there, and pretty soon you're talking real money." A few hundred million? A mere pittance! Obviously no one who wants to make real money develops in Java! (Do I really need to add a wink or smiley??) From cjensen at bioeng.ucsd.edu Tue Jul 3 13:59:32 2001 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Tue, 03 Jul 2001 10:59:32 -0700 Subject: accessing class data members Message-ID: <3B420804.9882D166@bioeng.ucsd.edu> In many OO languages, and theory, it is often the case that when you want to know the value of some data member, that a function is written to return that value. However, in Python it seems that people just access the data member directly. for example: if there were a class that represented a physical object. In the class there were data members that held the objects temperature and location. If I wanted to know the temperature of an object, I could just use obj.temperature. Though in other languages, the convention seems to call a function that returns the value, like: obj.get_temperature. Which is better? -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From sholden at holdenweb.com Wed Jul 18 15:03:53 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 18 Jul 2001 15:03:53 -0400 Subject: bug in python's scope handling? References: <slrn9lbkhg.1at.philipprw@chello213047126184.14.univie.teleweb.at> <Fok57.21911$PF1.1081086@e420r-atl2.usenetserver.com> <slrn9lbmfi.1at.philipprw@chello213047126184.14.univie.teleweb.at> Message-ID: <52l57.22260$PF1.1093557@e420r-atl2.usenetserver.com> ----- Original Message ----- From: "Philipp Weinfurter" <philipprw at gmx.at> Newsgroups: comp.lang.python Sent: Wednesday, July 18, 2001 2:48 PM Subject: Re: bug in python's scope handling? > On Wed, 18 Jul 2001 14:20:49 -0400, Steve Holden <sholden at holdenweb.com> wrote: > > When your Python is compiled into bytecode, the assignment to a is detected > > during compilation of your function func2(). The name a is therefore assumed > > to refer to a local variable, hence the ruin-time exception you observe. > > yes, this is what i thought. but is it correct? > i don't mean to be pedantic, but the rules are that if a variable > is not found in local scope, then the compiler looks up the global > scope and python doesn't follow this rule here. > it doesn't really hurt, since in 99% of all cases the programmer > probably _thinks_ he is referring to a local variable, but still... The rules are correct, but you are making the mistake of assuming that Python determines the locality of local names by searching the namespace. This is where you are wrong. The compiler performs a static program analysis of each function, and if it sees assignments to a particular name (or indeed various other bindings, as described below) then it optimizes ALL references to that name to be local. I know it's a little difficult to get your head around, but that's the way it is! From section 4.1 of the 2.0 reference manual: """Whether a name is local or global in a code block is determined by static inspection of the source text for the code block: in the absence of global statements, a name that is bound anywhere in the code block is local in the entire code block; all other names are considered global. The global statement forces global interpretation of selected names throughout the code block. The following constructs bind names: formal parameters to functions, import statements, class and function definitions (these bind the class or function name in the defining block), and targets that are identifiers if occurring in an assignment, for loop header, or in the second position of an except clause header. Local names are searched only on the local namespace; global names are searched only in the global and built-in namespace.""" regards Steve -- http://www.holdenweb.com/ From sholden at holdenweb.com Sun Jul 8 15:42:55 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sun, 8 Jul 2001 15:42:55 -0400 Subject: Comment on PEP-0238 References: <3B3BE855.A6223E70@3-cities.com> <cp7kxvlake.fsf@cj20424-a.reston1.va.home.com> <Y4J%6.4084$Z6.2010194@news1.rdc2.pa.home.com> <mailman.994016102.30019.python-list@python.org> <92ae279c.0107071820.7ebb77f8@posting.google.com> Message-ID: <fH227.14742$i8.1300639@e420r-atl3.usenetserver.com> <tongue_in_cheek> How about instead of the current proposal we provide a division operator, say "/.", that always produces a floating-point (or at least non-integer) result? Then we could call the people who need to use that one the "slash-dotters". </tongue_in_cheek> At least it wouldn't break existing code... regards Steve -- http://www.holdenweb.com/ From sill at optonline.net Sat Jul 14 21:05:12 2001 From: sill at optonline.net (Rainy) Date: Sun, 15 Jul 2001 01:05:12 GMT Subject: How popular is Python, anyway? (was: Long Live Python!) References: <E566B020833BD311B6610008C791A39705CA5230@il93exm04.css.mot.com> <mailman.994804336.23495.python-list@python.org> <slrn9koofo.mjk.philh@comuno.freeserve.co.uk> <slrn9kpr3e.527.sill@sill.silmarill.org> <Gzj37.13006$B7.2564502@ruti.visi.com> <slrn9ks0mh.9oi.sill@sill.silmarill.org> <yox4rsh6w82.fsf@karhu.tp.spt.fi> <slrn9kutbc.36s.sill@sill.silmarill.org> <3B4F9D27.CF8DC351@engcorp.com> Message-ID: <slrn9l1r0a.ai.sill@sill.silmarill.org> On Fri, 13 Jul 2001 21:15:19 -0400, Peter Hansen <peter at engcorp.com> wrote: > Rainy wrote: >> >> On 13 Jul 2001 11:59:09 +0300, Ville Vainio <vvainio at karhu.tp.spt.fi> wrote: >> > sill at optonline.net (Rainy) writes: >> > >> >> this and that, and getting hired. I actually did use some python at my >> >> previous job (some cgi/image manipulation). I was then asked to redo it >> >> in perl :-/." >> > >> > And that's when you reached for your revolver? >> >> No, the script was fairly short, maybe a hundred lines. It was also the kind of >> script that you write once and never have to extend, so doing it in perl wasn't >> a problem. > > I understand what you mean here, but I'm not sure I believe in the > idea that there really are scripts you write once and never have to extend. Well, there *are* such scripts, but the problem is, you don't know if the one you're writing is going to be one of these or not. I made an educated guess that the one in question will be write-once and was right, and so wasn't too annoyed to rewrite it in perl :P. > > That's why I value Python's maintainability so much: effectively > every program or script we write has to be extended, even if just > in the first few months of use. > > With Python, we regular hand off 100 line programs from one person > to another for completion and maintenance, as people are available. > I think there's even one each of us has contributed to over the > last year. Contrary to what you might imagine, it has become > progressively cleaner and easier to understand, rather than growing > into its own little tar pit of a program. I totally agree. -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: http://silmarill.org/cymbaline From new_name at mit.edu Tue Jul 3 14:29:17 2001 From: new_name at mit.edu (Alex) Date: 03 Jul 2001 14:29:17 -0400 Subject: Calling a user-defined Exception from within a function. Need Help. References: <9hsmbn+781@eGroups.com> <mailman.994180745.3880.python-list@python.org> Message-ID: <etd7kxp3lz6.fsf@lola-granola.mit.edu> > | raise other > > I think this line is wrong, but I could be wrong. No, you can raise a subclass of Exception. I do it all the time. Alex. From jwbaxter at spamcop.com Wed Jul 18 20:05:00 2001 From: jwbaxter at spamcop.com (John W. Baxter) Date: Wed, 18 Jul 2001 17:05:00 -0700 Subject: Language change and code breaks References: <mailman.995378792.16515.python-list@python.org> <cpvgkq1f2b.fsf@cj20424-a.reston1.va.home.com> Message-ID: <180720011705003205%jwbaxter@spamcop.com> In article <cpvgkq1f2b.fsf at cj20424-a.reston1.va.home.com>, Guido van Rossum <guido at python.org> wrote: > Roman Suzi <rnd at onego.ru> writes: > > > Windows is case-insensitive and thus "easy to use" only before one needs > > to put web-pages on the real (UNIX) web-server. Then they understand all > > the troubles with mised case, national-charset filenames, abbr~ted > > filenames, local file references "C:\Mydocs\lalala", bmp-images etc. > > But it's still open for debate whether the problem here is Windows or > Unix! All programming languages and file systems used to be > case-insensitive, until the designers of Unix and C decided that it > was too much work to write and use a case-insensitive comparison > routine. It wasn't necessarily intended to be better, just easier to > implement. But times have changed, and that's a lousy excuse. Well, let's see. The first machines I used didn't have a case problem: they only had upper case. Is that case sensitive or case insensitive? [They also had identifiers of 3 or fewer characters.] Then I used some machines with upper and lower case, which were case sensitive in the language processors I used (favoring lower case). For that matter, they didn't have a file naming problem...they didn't use file names. Times do change. I happen to prefer case-sensitive languages (that could be the only aspect of C that I prefer to the related aspect of the Pascals I used...which had reacted to the advent of readily available lower case in mid-life by being case insensitive). So I think Python is currently right in this area, but it isn't important enough to me to cause me to stop upgrading Python versions when it changes. Or argue about. [The direction the Unicode source threads are taking might well, but we still have the BDFL (or bdfl, or bDFL, or bDFl ...) to conrol that...I hope.] I also hope that after the change to case-insensitive Python, we don't also go through a change to diacriticals-don't-matter Python. --John From JamesL at Lugoj.Com Thu Jul 26 18:59:57 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Thu, 26 Jul 2001 15:59:57 -0700 Subject: Language change and code breaks References: <mailman.995378792.16515.python-list@python.org> <cpvgkq1f2b.fsf@cj20424-a.reston1.va.home.com> <ud76rn4p8.fsf@cs.uu.nl> <3B5D88B1.774A4D70@Bibliothek.Uni-Augsburg.de> <wzhew2gm27.fsf@sunshine.cs.uu.nl> <3B601CBE.627D3D22@Bibliothek.Uni-Augsburg.de> <9jpbi8$32v$1@samos.cs.uu.nl> <9jpj4j$182a$1@nntp4.u.washington.edu> <cplmlb5q2t.fsf@cj20424-a.reston1.va.home.com> <Vk087.27863$B7.4280302@ruti.visi.com> Message-ID: <3B60A0ED.BAAFE3A9@Lugoj.Com> Grant Edwards wrote: > And (at least in the Pascal compiler) identifiers were limited > to 6 characters so that an entire identifier would fit into a > single word -- so two identifiers could be compared in a single > instruction. I too fondly remember the CDC Cyber series. They didn't have a traditional stack. As I recall, a blank memory space was left at the beginning of each subroutine where a single return address could be stored. This meant you couldn't do recursion using the standard assembly language subroutine call mechanism. I forget how Pascal got around this. I do recall them switching from 6 bit characters to an optional 12 bit characters to support lowercase a few years after I encountered Kronos. > Yikes. It was an interesting architecture. One of my > assignments in a class once upon a time was to write a 6600 > instruction set simulator in 6600 assembly language. It had a > small, regular instruction set and it was surprisingly easy... It has been soooo long that I may misremember, but wasn't it pretty much automatic to set the r1 register to 1 at the top of an assembly language program? And to clear r0? Or was it the other way around? > Doing the same thing for a Pentium would be pretty horrific. While I am one of the grunting barbarians who doesn't wish to see progress roll over a lot of legacy code, I suspect any ugliness of the Pentium is due to the attempts by Intel to retain some form of backward compatibility at least as far back as the 8008. But it has been so long since I did any assembly language programming that that may no longer hold true. From peter at engcorp.com Sat Jul 14 21:40:13 2001 From: peter at engcorp.com (Peter Hansen) Date: Sat, 14 Jul 2001 21:40:13 -0400 Subject: How popular is Python, anyway? (was: Long Live Python!) References: <E566B020833BD311B6610008C791A39705CA5230@il93exm04.css.mot.com> <mailman.994804336.23495.python-list@python.org> <slrn9koofo.mjk.philh@comuno.freeserve.co.uk> <slrn9kpr3e.527.sill@sill.silmarill.org> <Gzj37.13006$B7.2564502@ruti.visi.com> <slrn9ks0mh.9oi.sill@sill.silmarill.org> <yox4rsh6w82.fsf@karhu.tp.spt.fi> <slrn9kutbc.36s.sill@sill.silmarill.org> <3B4F9D27.CF8DC351@engcorp.com> <slrn9l1r0a.ai.sill@sill.silmarill.org> Message-ID: <3B50F47D.BD251C00@engcorp.com> Rainy wrote: > > On Fri, 13 Jul 2001 21:15:19 -0400, Peter Hansen <peter at engcorp.com> wrote: > > I understand what you mean here, but I'm not sure I believe in the > > idea that there really are scripts you write once and never have to extend. > > Well, there *are* such scripts, but the problem is, you don't know if the one > you're writing is going to be one of these or not. I made an educated guess > that the one in question will be write-once and was right, ^^^^^^^^^^^^^ So far. :-) > and so wasn't too annoyed to rewrite it in perl :P. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From guido at digicool.com Thu Jul 19 15:33:35 2001 From: guido at digicool.com (Guido van Rossum) Date: Thu, 19 Jul 2001 15:33:35 -0400 Subject: Language change and code breaks In-Reply-To: Your message of "Thu, 19 Jul 2001 13:27:56 MDT." <Pine.LNX.4.33.0107191316390.24983-100000@bms> References: <Pine.LNX.4.33.0107191316390.24983-100000@bms> Message-ID: <200107191933.f6JJXZF17263@odiug.digicool.com> > I'm still wondering what advantage there is to crippling the > expressivity of a language for the sake of a small group of > non-programmers. IMO there are two non-truths in this statement. (1) The expressivity of the language is not crippled. (2) Potentially, the group of non-programmers is much larger than the group of programmers (and it's easier to teach programmers an arbitrary rule than non-programmers). --Guido van Rossum (home page: http://www.python.org/~guido/) From andreas at andreas-jung.com Fri Jul 20 22:21:34 2001 From: andreas at andreas-jung.com (Andreas Jung) Date: Fri, 20 Jul 2001 21:21:34 -0500 Subject: Help with PDF References: <000801c11181$3145dcc0$2cde3dd8@glindshome> Message-ID: <00cc01c1118b$dd96f9f0$9865fea9@SUXLAP> Take a look at Reportlab (www.reportlab.com) ========================================================================== Andreas Jung andreas at digicool.com Digital Creations "Zope Dealers" http://www.zope.org ----- Original Message ----- From: Greg & Janet LINDSTROM To: python-list at python.org Sent: Freitag, 20. Juli 2001 20:05 Subject: Help with PDF Greetings- What is available in Python to produce Portable Document Format (PDF) files? I have read through the "Python Programming on Win32" book and searched the web-site, with little result (the book is good, but eluded that new tools might be available by the time the book had been published). What is the state-of-the-python on pdf? Is it considered "the method of choice" for "pretty" documents? Thanks, Greg Lindstrom Vilonia, Arkansas From steve at lurking.demon.co.uk Wed Jul 25 03:26:59 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Wed, 25 Jul 2001 08:26:59 +0100 Subject: PEP0238 lament References: <mailman.995898939.27893.python-list@python.org> <6unolt4kg5pjav1k0c7qjv8mg4qe0fdbaj@4ax.com> <cpzo9uoz9k.fsf@cj20424-a.reston1.va.home.com> Message-ID: <4rrslt8tpvf1fe7de8tph82c88goq18lss@4ax.com> On Tue, 24 Jul 2001 20:20:14 GMT, Guido van Rossum <guido at python.org> wrote: >Steve Horne <sh at ttsoftware.co.uk> writes: > >> The mathematical operation of division is traditionally represented as >> ? in general - or as a horizontal line between the numerator and >> denominator. Only rationals merit the / in mathematics - it's simply >> the best compromise. >> >> But mathematics uses the same set of symbols equally for both integer >> and real division - it's rarely made explicit which is in use as it is >> normally blatantly obvious. So I don't believe (1) is valid. > >I believe you are wrong here on both counts. Knuth, a mathematician >if there ever was one, uses / for division when written in-line and a >horizontal line in "display" formulas. He also uses an explicit floor >notation to indicate integer division, and without that his divisions >are real divisions. (Knuth's floor notation acts like a pair of >brackets around an expression; the left bracket looks like an L, the >right bracket looks like a reverse L. He has a similar ceiling >notation where the L's are upside down.) Being more explicit is essential when you are defining and proving algorithms. Everyday application of those algorithms is a completely different thing. Most mathematics I've seen uses a mixture of '/' (or, rarely, '?') and horizontal lines even in the same expression - the issue is convenience and clarity due to the length of the numerator and denominator expressions, not the semantics of the notation. In discrete mathematics, of course adding the additional explicit floor/ceiling notations is the norm - for the same reason as when defining and proving algorithms. However, it isn't always so - it's just that in any currently *interesting* discrete mathematics, it *is* necessary. Cases where it is not necessary are generally considered to be done-and-dusted and boring, but that doesn't make them wrong - they are the cases that happen in every day life, and which most frequently occur in programming. From steve at lurking.demon.co.uk Sun Jul 22 00:43:56 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Sun, 22 Jul 2001 05:43:56 +0100 Subject: Can I copy a generators state and then backtrack to it if necessary? References: <sdigltkmqv58ujun2b55jrgvbd5oec4okb@4ax.com> <mailman.995751757.31814.python-list@python.org> Message-ID: <rt8klto9303h65rth71cfsmikgptpdqdt0@4ax.com> On Sat, 21 Jul 2001 17:41:54 -0400, "Tim Peters" <tim.one at home.com> wrote: >It's not at all clear what p.copy() "should" do, though-- even for simple >iterators --and that's why we're leaving it out, at least at the start. For >example, the bindings of local variables are part of a generator's state. >What should p.copy() do about *them*? If a local vrbl is also a generator, >should it (recursively) apply the .copy() method to it too? Just make >another reference to the current bindings of the locals? Systematically do >shallow copies of values? Systematically do deep copies? It's all *very* clear to me - only a full deep copy would do. The only reason it should generate a different sequence to the original copy would be due to external state. I can see that a generator following exactly the same sequence again is not much use, and that re-running the sequence should mean getting a different result, but that should result from external state in my mind - if only *some* internal state was copied, it would be far too confusing. However, although it would be an interesting capability, I'm not actually sure my original thought was valid... >> A major use I could think of for this is in applications that need to >> balance searching by depth and by breadth according to some heuristic. >> In addition to the search tree so far, it would be easy to record >> generator states that have only identified some of the branches from a >> particular state - so you could explore this area of the tree >> depth-wise for a bit then nip-back to expand the breadth later. An >> obvious application would be for board games such as chess. Chess doesn't need to rederive from the same generator state more than once - the tree building/searching heuristic I mentioned merely needs to store a partially evaluated generator for each node that is capable of working out the remaining possible moves from its state. Evaluating the same position and move more than once would be pointless. Given that, I'm not sure I can think of another use. Backtracking in the Icon sense can be handled quite effectively without it. >Needs a PEP, and won't go in for 2.2 because I can pretty much guarantee >"one size fits all" won't. Python generators aren't quite like any other >language's, and so we need more real-life experience with them before >deciding what (if anything) more is truly needed. I can accept that. >in-the-meantime-python-chess-apps-aren't-really-a-major-use<wink>-ly Of course you're right - noughts and crosses is *much* more important ;-) From greg at cosc.canterbury.ac.nz Mon Jul 9 23:32:43 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Tue, 10 Jul 2001 15:32:43 +1200 Subject: Comment on PEP-0238 References: <LNBBLJKPBEHFEDALKOLCEEPDKMAA.tim.one@home.com> <mailman.994548913.18171.python-list@python.org> <cppubbipxg.fsf@cj20424-a.reston1.va.home.com> Message-ID: <3B4A775B.1212684C@cosc.canterbury.ac.nz> Guido van Rossum wrote: > > I just discovered that we don't need to add a new operator overloading > name for the div and mod operations: classes already look for a > __divmod__ method to overload divmod(), and we should naturally define > div(x, y) (or x div y) as divmod(x, y)[0]. That sounds suspiciously similar to the argument that we don't need __eq__, __le__ etc. because we can just as well funnel them all through __cmp__... -- 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 Jul 8 05:53:45 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 8 Jul 2001 11:53:45 +0200 Subject: [OT] Eternal programming References: <mailman.994576272.19695.python-list@python.org> Message-ID: <9i9afg0385@enews3.newsguy.com> "Roman Suzi" <rnd at onego.ru> wrote in message news:mailman.994576272.19695.python-list at python.org... ... > to include to the core. For example, if one want to do logic, > there is only one operation needed (i do not know how to call it in > English: > > X Y X/Y > 0 0 1 > 1 0 1 > 0 1 1 > 1 1 0 It's usually called "nand" (short for Not-AND, I guess). > I believe, that there is some set of operations which is as general as > Turing machine BUT is easily evolutionable into something practical. Sure, there must be plenty (infinitely many, I'd bet, offhand). But I think the most practical one must be some subset of Scheme -- no effort wasted on syntax... and quite practical as often demonstrated. Alex From dsh8290 at rit.edu Tue Jul 3 13:00:31 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 3 Jul 2001 13:00:31 -0400 Subject: Is this a true statement: Part III In-Reply-To: <fnt3ktkphaut5q2ohbpage1n1advhdt109@4ax.com>; from jkraska1@san.rr.com on Tue, Jul 03, 2001 at 04:40:31PM +0000 References: <9hsckg$4rt$1@taliesin.netcom.net.uk> <fnt3ktkphaut5q2ohbpage1n1advhdt109@4ax.com> Message-ID: <20010703130031.C22543@arizona.cs.rit.edu> On Tue, Jul 03, 2001 at 04:40:31PM +0000, Courageous wrote: | | >The thing that I found interesting about the Part II posts were the positive | >things said about the C language. Is C that much different than C++? Why | >the leaning towards C over C++? | | The explosion of forms available and commonly in use in C++ gives me | a headache. I really just want "C with classes and virtual functions," pretty Isn't that called "Objective C"? I read an overview and the beginning of a tutorial once. -D From greg at electricrain.com Tue Jul 17 21:19:40 2001 From: greg at electricrain.com (Gregory P. Smith) Date: Tue, 17 Jul 2001 18:19:40 -0700 Subject: Importing XML modules in py2exe or Installer? In-Reply-To: <Xns90DEC227B102Cgustaflalgonetse@194.213.69.148>; from gustafl@algonet.se on Sat, Jul 14, 2001 at 05:04:38PM +0000 References: <Xns90DE9C2957BDgustaflalgonetse@194.213.69.152> <Xns90DE68B66343Agmcmhypernetcom@199.171.54.154> <Xns90DEC227B102Cgustaflalgonetse@194.213.69.148> Message-ID: <20010717181940.E28612@zot.electricrain.com> On Sat, Jul 14, 2001 at 05:04:38PM +0000, Gustaf Liljegren wrote: > Gordon McMillan <gmcm at hypernet.com> wrote: > > >Doesn't help to use py2exe args with Installer! > > Sorry, misunderstood this first. Haven't used ConfigParser before. > > >Edit myscript.cfg and put > >packages=_xmlplus > >in the PYZ section. > > It don't work. Here's what I have done: ... I hack that I don't really recommend, but that does work: rename the _xmlplus subdirectory from the pyxml installation to xml. (move any old tiny xml directory that python came with out of the way). We've been doing this to package mojo nation successfully with both gordons and py2exe. [we did that for other historical reasons unrelated to packaging but it worked for packaging as a side effect] -G From donn at u.washington.edu Tue Jul 24 13:06:54 2001 From: donn at u.washington.edu (Donn Cave) Date: 24 Jul 2001 17:06:54 GMT Subject: Advice wanted: asynch I/O on unix References: <owen-66B4BF.09573623072001@nntp4.u.washington.edu> <ku4rs3yueb.fsf@lasipalatsi.fi> <9jk65h$dto$1@nntp6.u.washington.edu> Message-ID: <9jk9ve$m94$1@nntp6.u.washington.edu> Quoth "Russell E. Owen" <owen at astrono.junkwashington.emu>: ... | The main problem is going to be how to buffer data until it can be read. | the parallel port card has no buffering of its own. Hence the complex | process outlined above. | | I was hoping unix and/or Python had some nice way to "magically" connect | an unbuffered input device to a FIFO buffer and make it look like a | socket, so I could use select and/or aynchcore. Yes and no, I guess. I would expect the file descriptor to be selectable, at least in principle though subject to implementation details, but the point is you probably want a more leisurely select schedule, which would require a kernel I/O buffer. I can't say there is no way to get the kernel to buffer a normally unbuffered device, but it would have to be a Solaris dependent feature. If Solaris supports some kind of loadable kernel module, it might be a fun project to see if it could be done generically. Far from simplifying life though. | P.S. Any advice regarding using "aioread", etc. vs "aio_read", etc.? | This is on Solaris 8. "aio_read", etc. seems to be the standard Posix | way of doing asynch I/O. I have no idea where "aioread", etc. come from, | but it's what the existing C code uses. At first glance, the interface | to aio_read looks a bit better, but I'd hate to pick something that was | buggy or deprecated. I bet aio_read is not any kind of POSIX, but I do find it documented on Digital UNIX, and not aioread. So that's one vote for aio_read being the more standard non-standard function. Neither is documented on NetBSD. Buggy or not is up to Sun. For the Python module, I think Modules/cStringIO.c would be a good reference for C type that presents a file interface. Donn Cave, donn at u.washington.edu From bokr at accessone.com Mon Jul 2 19:53:28 2001 From: bokr at accessone.com (Bengt Richter) Date: Mon, 02 Jul 2001 23:53:28 GMT Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> <bebbba07.0107021206.70a22aa8@posting.google.com> Message-ID: <3b4102f4.887720905@wa.news.verio.net> On 2 Jul 2001 13:06:57 -0700, 18k11tm001 at sneakemail.com (Russ) wrote: >I agree that the quality of the design is paramount. BTW, I would like >to thank everyone who responded to my query. I should probably point >out that I am an aerospace engineer with some experience in C++ and >Tcl/Tk, but I am a Python beginner. > >As for function prototyping, it seems to me that argument passing by >keyword in Python can be used to advantage. If all procedure arguments >are passed by keyword, there is much less chance that a procedure will >be called incorrectly, particularly when a procedure interface is >changed. Contrast that with C++. The C++ compiler will catch only some >of those kinds of errors. If I change the order of two ints in a >function interface, for example, the C++ compiler won't have a clue >that the interface has changed. > >What would be very desirable for Python is some kind of static checker >that can guarantee BEFORE run time that all procedures are called >correctly. Does anyone know of anything that does that? > >Also, can anyone give specific examples of Python being used in >safety-critical applications? Thanks. > I am wondering if using non-deterministic[1] memory allocation is permissible in a safety-critical system. What kind of testing could you specify to guarantee that code would continue to run? Or does memory allocation/garbage collection have provable behavior under conditions that you could implement within? Also, do you have any hard-real-time requirements? Actually, I would be surprised if you have the freedom to choose to use anything in your final product that doesn't formally meet stringent requirements, if it is really safety-critical. Better read the requirements docs with a lawyer at your elbow, I would think ;-/ [1] Obviously I don't mean that a computer proceeds randomly, any more than it does when generating pseudo-random numbers. From JamesL at Lugoj.Com Sat Jul 14 01:06:34 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Fri, 13 Jul 2001 22:06:34 -0700 Subject: converting from perl: variable sized unpack References: <roy-B2459F.22112513072001@news1.panix.com> Message-ID: <3B4FD35A.26B4568E@Lugoj.Com> Roy Smith wrote: > > What's the best way to translate this perl snippet into python: > > ($f1, $f2, $f3, $f4, $f5, $f6) = split ('\s+', $line); > > The obvious translation would be: > > [f1, f2, f3, f4, f5, f6] = string.split (line) > > but the problem is that line may have fewer than 6 fields on it. Perl > handles this smoothly by leaving the "extra" variables undefined, whereas > python raises a ValueError exception. What I'd like to do is have the > extra field variables left as null strings. This may not be the most elegant or efficient, but how about this: [f1, f2, f3, f4, f5, f6] = (string.split (line) + 6*[None])[:6] From phd at phd.fep.ru Fri Jul 6 13:17:00 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Fri, 6 Jul 2001 21:17:00 +0400 (MSD) Subject: Maintaining the Python FAQ In-Reply-To: <3B460CCF.2924.33315027@localhost> Message-ID: <Pine.LNX.4.33.0107062116260.2536-100000@phd.fep.ru> On Fri, 6 Jul 2001, Garry Steedman wrote: > maybe this would be a good time for someone to think about writing a > nifty FAQ product for Zope? The only problem with FlexFAQ2 is its funny URLs. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From johann at physics.berkeley.edu Wed Jul 18 12:36:15 2001 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 18 Jul 2001 09:36:15 -0700 Subject: Python CGI speed on MacOS X References: <johnca-1707011356260001@nop009.transbay.net> Message-ID: <mty9pm9ou8.fsf@astron.berkeley.edu> John Abbe writes: > I'm running MacOS X on a PowerBook G3 400MHz, and have Python 2.1 > installed (from http://tony.lownds.com/macosx/). I've got the same computer, and I do notice Python being a bit more pokey than it should be. I suspect some weird intereaction between the Apple-patched gcc compiler and the Python source. I'm afraid I can't help, though. :-( -- Johann Hibschman johann at physics.berkeley.edu From aleaxit at yahoo.com Thu Jul 5 06:27:59 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 5 Jul 2001 12:27:59 +0200 Subject: system exec ? References: <9i1er4$mth$1@news.businessobjects.com> Message-ID: <9i1ffe029cm@enews1.newsguy.com> "alphaZeta" <NOSPAM.hnguyen421 at NOSPAM.hotmail.com> wrote in message news:9i1er4$mth$1 at news.businessobjects.com... > Hi, > > I didn't find any documentation (lib and tut) about how to execute a program > in a python script. os.system('theprogram') just executes it. What you desire is different: > Does anybody know ? > > For example : I would like to store in a variable the result of a call to > the system. > alike : >>> a = sys.exe("ls -l") a = os.popen("ls -l").read() may be what you want (but you may also prefer to call .readlines() instead for example, getting the result as a list of strings, one per line, rather than as one big string). Alex From aleaxit at yahoo.com Wed Jul 4 04:06:34 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 4 Jul 2001 10:06:34 +0200 Subject: Access all classes in a directory, put into an array, and print them out References: <mailman.994168205.8845.python-list@python.org> <9hsql302ghk@enews1.newsguy.com> <slrn9k4s5u.v3.tim@vegeta.ath.cx> <tk54ovf2o14ede@corp.supernews.com> Message-ID: <9huiqb01eih@enews1.newsguy.com> "Stephen Boulet" <spboulet at speakeasy.net> wrote in message news:tk54ovf2o14ede at corp.supernews.com... ... > Ok, how would you write this if you actually needed the index of array in > your for loop? > > My (ugly looking) solution; I hope there's something better: > > i = 0 > for item in array: > process(item) > someFunction(i) > i = i + 1 # somewhere "up above", e.g. placed in __builtin__ by # your siteconfigure.py or whatever: indices = xrange(sys.maxint) for index, item in zip(indices, array): process(item) someFunction(index) See http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52233 for a bit more discussion &c (ratings and/or comments always welcome, of course:-). Alex From guido at python.org Thu Jul 19 19:28:01 2001 From: guido at python.org (Guido van Rossum) Date: Thu, 19 Jul 2001 23:28:01 GMT Subject: Language change and code breaks References: <mailman.995580633.1267.python-list@python.org> Message-ID: <cpsnfsfqjk.fsf@cj20424-a.reston1.va.home.com> Bruce Sass <bsass at freenet.edmonton.ab.ca> writes: > The short of it is... ya got less symbols to work with, therefore it > is less <something>... why is that good for programmers? You flunked math, right? The number of available identifiers is still infinite... --Guido van Rossum (home page: http://www.python.org/~guido/) From sholden at holdenweb.com Mon Jul 23 14:47:28 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 23 Jul 2001 14:47:28 -0400 Subject: BURNING EARTHSHAKING Tuple Question References: <mailman.995840325.21528.python-list@python.org> Message-ID: <ch_67.13062$4v6.1090294@e420r-atl3.usenetserver.com> "Tim Peters" <tim.one at home.com> wrote in message news:mailman.995840325.21528.python-list at python.org... > [Erik Max Francis] > > so perhaps when mathematicians are isolated with other mathematicians > > they tend to pronounce it that way. I really don't know. > > [Tom Bryan] > > In both my undergraduate and graduate studies in mathematics in the > > U.S., I only remember hearing tuple pronounced so that it rhymes with > > goop. > > Now *that's* an affectation. Where I went to school, it rhymed with goople > <wink>. > > > If anyone pronounced it to rhyme with couple, it was rare enough > > that I don't remember it. But we also said "pie" for pi and "fee" for > > phi. > > Perfectly sensible. At PythonLabs, I think Fred Drake says > tuple-like-couple. I'm a tuple-like-goople guy (i.e., normal). Jeremy > hasn't existed for months, and everyone runs away when Barry speaks, so who > knows what they say. Guido only barks orders in Dutch, so I'm not sure how > he pronounces it either. > > but-pretty-sure-he-prounounces-"dict"-like-"luxury-yacht"-ly y'rs - tim > Of course in a civilised society, tuple rhymes with goople, and also has a "y" sound after the t, so it's "tyoople", if you don't mind, thank you very much. OK? no-nooze-is-good-nooze-ly y'rs - steve -- http://www.holdenweb.com/ From rjh at 3-cities.com Wed Jul 4 19:39:19 2001 From: rjh at 3-cities.com (Robert J. Harrison) Date: Wed, 04 Jul 2001 23:39:19 GMT Subject: Comment on PEP-0238 References: <3B3BE855.A6223E70@3-cities.com> <cp7kxvlake.fsf@cj20424-a.reston1.va.home.com> <Y4J%6.4084$Z6.2010194@news1.rdc2.pa.home.com> <mailman.994016102.30019.python-list@python.org> <7ef50c46.0107020554.31cc948b@posting.google.com> <mailman.994084684.19932.python-list@python.org> <7ef50c46.0107030657.2e0fc92b@posting.google.com> <mailman.994177387.31239.python-list@python.org> <3B42B152.5EC4F056@3-cities.com> <mailman.994276569.27572.python-list@python.org> Message-ID: <3B43AE03.F58B72C7@3-cities.com> Paul Prescod wrote: > "Robert J. Harrison" wrote: > > Python does not undermine the distinction between integers and floats. > >>> 5 + 10 > 15 > >>> 5 + "10" > Traceback (most recent call last): > File "<stdin>", line 1, in ? > TypeError: number coercion failed You seem to want to have the string "10" automatically converted to be an integer. PEP-0238 will have no impact on this. Python extensively distinguishes between numeric types and other types. Consider all of the special class methods devoted to this end (.e.g, __add__). It would not be too hard to creat a numeric string that could behave to your satisfaction. > > Arithmetic expressions that > > involve only integers currently always result in an integer. > >>> import math > >>> math.cos(5) > 0.28366218546322625 Cosine is not an arithmetic operation; it is a trigonometric function. Again, PEP-0238 would not change this behaviour and would not increase consistency with it since in this instance it is a property of the function (give it a real number and it gives you float) not of the type of the argument (other than requiring the real number property). > ... Only people with a history in statically > typed languages seem to expect operations to be type-consistent. One of the great virtues of Python is indeed dynamic typing, and I am not struggling to preserve type consistency. I do think that the current behaviour is more consistent with the properties of mathematical integers, and for this reason I have had no trouble in communicating to students the expected behaviour. My comments have been directed at - the assumption that the change will help beginners. I believe this to be incorrect - the PEP merely moves the point at which they must appreciate the difference between integer and floating point arithmetic. - the amount of code that is broken Hinsen and others have noted that functions written to expect a floating point argument will behave more consistently if they are mistakenly given an integer argument. The PEP will indeed accomplish this. But so would other far less drastic mechanisms. You cite an example above. cos(5) does the "right" thing. It is a property of the function itself, not the argument passed to it. But cos("5") also (correctly in my view) gives a type error. > > Who expects? You are already seeing in this discussion that many > > people think that the current behaviour is not only what they expect > > but is actually very justifiable. > > Sure, people with a bunch of programming language experience. > > http://www.python.org/doc/essays/cp4e.html This issue is only mentioned in passing in this article and no reference is given to an actual survey. Can U please post a better link to the reference? All I can find on Prof. Pausch's home page or with a Google search are either third party notes from a Python conference or papers on Alice that again only touch on this issue in passing. I'm a big fan of Alice, so I know he knows about usability, but I'd like to see his description of how the survey was conducted and his conclusions. The audience for Python is very large. A survey that captures only just a small part of that audience (e.g., novices focussing not on programming but on 3-D graphics) is not necessarily a basis for change. My experience with scientifically literate programming novices is also not representative of the entire Python user community. Hence the debate. > > All programmers must very soon appreciate the different nature of > > integer and floating point (or rational) arithmetic in order to > > address discretized quantities such as lists, files, strings, etc. > > If you are consistent about this I might support you. Let's ban > expressions like this: > > >>> 1/2.0 > 0.5 > > Then Python will be consistent about the fact that integers and floats > are as different as strings and integers. Integers and floats are both numbers - hence 1/2.0 makes sense and the Python coercion rules handle the choice of the type of the result. Integers are a subset of floats - so the Python choice of coercing integers to floats in mixed integer-float expression makes sense. Integers have properties that most floats do not - so forcing the coercion of integers to floats in *some* pure integer expressions is a matter of choice. It is only this choice that PEP-0238 is addressing. ------------------------------------------------------------------- "A foolish consistency is the hobgoblin of little minds, adored by little statesmen and philosophers and divines. With consistency a great soul has simply nothing to do. He may as well concern himself with his shadow on the wall. Speak what you think now in hard words, and to-morrow speak what to-morrow thinks in hard words again, though it contradict every thing you said to-day." Ralph Waldo Emerson ------------------------------------------------------------------- -- Robert J. Harrison (rjh at 3-cities.com) From michael at rcp.co.uk Tue Jul 31 08:29:26 2001 From: michael at rcp.co.uk (Michael Abbott) Date: Tue, 31 Jul 2001 12:29:26 +0000 (UTC) Subject: 2.2 features References: <mailman.996258542.15795.python-list@python.org> <cpwv4u16rx.fsf@cj20424-a.reston1.va.home.com> <mailman.996270412.11895.python-list@python.org> <cpofq524lr.fsf@cj20424-a.reston1.va.home.com> <slrn9m61bs.atb.quinn@retch.ugcs.caltech.edu> <slrn.pl.9m6a5m.kmu.qrczak@qrnik.zagroda> <cpae1lzio7.fsf@cj20424-a.reston1.va.home.com> <mailman.996578158.8220.python-list@python.org> Message-ID: <Xns90EF896FA6DF1michaelrcpcouk@194.238.50.13> "Ken Seehof" <kseehof at neuralintegrator.com> wrote in news:mailman.996578158.8220.python-list at python.org: > I hereby revoke the title ".*[dD]ictator". I dub thee "Fearless Leader". > Nice one; I agree it's earned! From peter at engcorp.com Tue Jul 17 00:12:51 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 17 Jul 2001 00:12:51 -0400 Subject: web interface to c program running on different server References: <3B53B116.86535A3@usa.net> Message-ID: <3B53BB43.986D70AE@engcorp.com> Lee wrote: > > I wonder if anyone reading this could be kind enough to offer me some > advice. [...] > Of course, there may be hundreds(?) of > ways to arrive at the desired results - using e.g. ASP, PHP, perl. If > anyone out there has worked on similar projects, or simply has some > recommendations, I should very much appreciate their thoughts. > > Ideally, I'd like to have maybe 5 or 6 different implementation > suggestions with an associated set of pros and cons for each, so I'd > love to hear lots of suggestions! You haven't really provided much in the way of information to allow anyone to suggest pros and cons *in the context of your application*. Can you provide background on the platforms the various servers you describe have to run? (Linux, Windows, undefined?) Can you discuss the requirements in terms of performance (required throughput, volume, number of hits, latency, whatever)? Is this commercial (implying money to pay for certain kinds of development) or a freebie (implying you are willing to trade off cost savings against perhaps reduced sophistication)? I could probably think of a dozen other such questions. If you provide more detail, maybe you'll get responses more closely tailored to your application and needs, rather than just a bunch of random suggestions. In other words, do you really want everyone to play pin-the-tail-on-the-donkey, or could you take off the blindfold and point us in the right direction? -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From peter at engcorp.com Fri Jul 13 02:15:31 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 13 Jul 2001 02:15:31 -0400 Subject: ANNOUNCE: SCons (Python build tool) development under way References: <mailman.994953807.6320.python-list@python.org> <3B4E702B.8070008@webone.com.au> Message-ID: <3B4E9203.FBF84764@engcorp.com> Oops, accidentally sent before done editing... simonb at webone.com.au wrote: > > Steven Knight wrote: > > >This is to announce that active development of SCons is now underway at: > > > > http://scons.sourceforge.net/ > So this is not just for a python project (i can't see why > you would need any "make" utility for a (purely) python project), > but as a real replacement for make? > ie. reads makefiles and such? > Well, im rather confused about this... Well, if it will help, since maybe you didn't click on the conveniently included link: """ SCons is ... an improved substitute for the classic Make utility... What makes SCons better? * Configuration files are Python scripts--no new syntax to learn. * Global view of all dependencies--no more multiple build passes or reordering targets to build everything. * Reliable detection of build changes using MD5 signatures, not timestamps. * Reliable, automatic dependency analysis--no more "make depend" / "make clean" to get all of the dependencies. * Easily extensible through user-defined builders. * Building from central repositories of source code and/or pre-built targets. """ This all sounds DAMN fine to me. What was it that confused you? As it says above, the configuration files are Python scripts, so no, it will not read makefiles. This is a substitute for make, an improved way of doing what make has been doing, gradually more and more awkwardly as programmers' needs became more sophisticated, for years. (I've been anxiously awaiting the release of this in some releasable form, so "alpha" or not I'm happy to see it reach this stage. Thanks, Steven!) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From piet at cs.uu.nl Tue Jul 24 15:32:32 2001 From: piet at cs.uu.nl (Piet van Oostrum) Date: 24 Jul 2001 21:32:32 +0200 Subject: Language change and code breaks References: <mailman.995378792.16515.python-list@python.org> <cpvgkq1f2b.fsf@cj20424-a.reston1.va.home.com> <ud76rn4p8.fsf@cs.uu.nl> <3B5D88B1.774A4D70@Bibliothek.Uni-Augsburg.de> Message-ID: <wzhew2gm27.fsf@sunshine.cs.uu.nl> >>>>> Sibylle Koczian <Sibylle.Koczian at Bibliothek.Uni-Augsburg.de> (SK) writes: SK> piet at cs.uu.nl wrote: >> >> >>>>> Guido van Rossum <guido at python.org> (GvR) writes: >> GvR> But it's still open for debate whether the problem here is Windows or GvR> Unix! All programming languages and file systems used to be GvR> case-insensitive, until the designers of Unix and C decided that it GvR> was too much work to write and use a case-insensitive comparison GvR> routine. >> >> This is not true. Algol 60 was case-insensitive from the beginning. By >> design, as Algol 60 was designed the way it is in spite of the difficulties >> it would give its implementors. >> -- SK> But that's exactly what he says! Algol 60 was before C, as far as I SK> know, and case-insensitive as was normal at the time. Sorry, I meant to say that Algol 60 was case sensitive. -- Piet van Oostrum <piet at cs.uu.nl> URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From guido at python.org Thu Jul 26 12:43:28 2001 From: guido at python.org (Guido van Rossum) Date: Thu, 26 Jul 2001 16:43:28 GMT Subject: Toppling the numeric tower References: <DLW77.49367$Cy.6275542@news1.rdc1.az.home.com> <eppstein-749F84.08434526072001@news.service.uci.edu> Message-ID: <cp7kwv7iag.fsf@cj20424-a.reston1.va.home.com> David Eppstein <eppstein at ics.uci.edu> writes: > (2) should isintegral() return true for algebraic integers that are not > rational integers? Sorry, you lost me there. What are these? --Guido van Rossum (home page: http://www.python.org/~guido/) From rnd at onego.ru Thu Jul 12 16:10:53 2001 From: rnd at onego.ru (Roman Suzi) Date: Fri, 13 Jul 2001 00:10:53 +0400 (MSD) Subject: Long Live Python! In-Reply-To: <slrn9krv7p.9oi.sill@sill.silmarill.org> Message-ID: <Pine.LNX.4.30.0107130007060.9325-100000@rnd.onego.ru> On Thu, 12 Jul 2001, Rainy wrote: >On Thu, 12 Jul 2001 02:29:21 +0100, phil hunt <philh at comuno.freeserve.co.uk> wrote: >> On Wed, 11 Jul 2001 17:47:50 -0400, Peter Hansen <peter at engcorp.com> wrote: >>>I tend to think of Python more as an extremely effective and maintainable >>>general-purpose programming language, which happens also to work >>>very well when applied as a "scripting language" (whatever that means). >> >> To me it means "good for short programs <100 lines". Bear in mind >> that 100 lines of Python is equivalent to 300 lines of Java or 400 >> lines of C++. >> >> > >I meant more like sending somewhere my resume saying I know python and did >this and that, and getting hired. I actually did use some python at my >previous job (some cgi/image manipulation). I was then asked to redo it >in perl :-/. ...and you wrote automated Python->Perl routine in Python? * I've redone cgiforum in Python and that saved as from REAL intrusion: Python code was immune for "../../../etc/passwd\0"-path exploit while Perl was not! he-he. That was before I learned to check every CGI-input. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Thursday, July 12, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Misfortune: The kind of fortune that never misses." _/ From BrianQ at ActiveState.com Tue Jul 10 19:37:04 2001 From: BrianQ at ActiveState.com (Brian Quinlan) Date: Tue, 10 Jul 2001 16:37:04 -0700 Subject: compiling c app in MSVC In-Reply-To: <3b4b8bc7$0$26110$6e365a64@newsreader02.highway.telekom.at> Message-ID: <002501c10999$3a4521e0$b503a8c0@activestate.ca> ThaFacka wrote: > MSVC5 complains when compiling a program with <python.h>, > that the lib file python20.lib is either invalid or my > disk is corrupted (cant set file pointer to 0xblabla). > and no my disk is not corrupted. anybody compiled ' > succesfully with MSVC5? Python is compiled with MSVC6, which does not produce libraries that are compatible with MSVC5. 1. You can try to rebuild Python with MSVC5 (probably won't work though) and then build your project (but the binary will not be compatible with everyone's Python). 2. You could pay Microsoft some cash and get MSVC6 3. You could start developing with Cygwin Python and use GCC From eppstein at ics.uci.edu Tue Jul 24 16:24:05 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Tue, 24 Jul 2001 13:24:05 -0700 Subject: size of a file References: <3b5dd418_8@news.newsgroups.com> Message-ID: <eppstein-223C39.13240524072001@news.service.uci.edu> In article <3b5dd418_8 at news.newsgroups.com>, "Janos Blazi" <jblazi at hotmail.com> wrote: > How can I find out the length of a file. I have a descriptor fd of the file > (I am using the os module). When I wanted to do this recently, I used f = open(fn) # open file, fn is a string containing the filename f.seek(0,2) # go to end of file fsize = f.tell() f.close() I guess if you already have an fd you could skip the call to open() and seek back to the start in place of the close(). No doubt someone will tell me a better way to do this... -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From clpy at snakefarm.org Tue Jul 3 12:19:15 2001 From: clpy at snakefarm.org (Carsten Gaebler) Date: Tue, 03 Jul 2001 18:19:15 +0200 Subject: Strange os.popen() behavior Message-ID: <3B41F083.55F65C46@snakefarm.org> Hi there! I have a problem with a script that reads the contents of /etc/passwd from a remote host. It doesn't always seem to read all lines: <test.py> #!/usr/bin/python import os for i in range(5): pipe = os.popen("ssh -q root at remotehost cat /etc/passwd") passwd = pipe.readlines() pipe.close() print len(passwd) </test.py> Here's the output: 969 72 969 325 969 If I enter the SSH command in a shell I always get all 969 lines of /etc/passwd (the file does not change over time). Any clues? I am using Python 2.1, OpenSSH 2.9p1 (client), OpenSSH 2.5.2p2 (server). Regards Carsten. From mertz at gnosis.cx Wed Jul 25 15:53:31 2001 From: mertz at gnosis.cx (Lulu of the Lotus-Eaters) Date: Wed, 25 Jul 2001 15:53:31 -0400 Subject: Some Python (Monty) Perspective Message-ID: <7OyX7kKkXgeB092yn@bellatlantic.net> "Tim Randolph" <timothyrandolph at NoSpamPleaseyahoo.com> wrote: |I, for one, would like to thank him for all the work he has done for the |language and its community. I really do feel gratitude (almost) every time |I first see the >>>. Oh... for a moment there I misread this. I thought you wrote that you felt gratitude every time you see ">>" :-). good-at-heart-but-still-prone-to-misjudgemently yours, Lulu... From bktoa23 at hotmail.com Sun Jul 22 10:50:28 2001 From: bktoa23 at hotmail.com (Tom Baker) Date: Sun, 22 Jul 2001 14:50:28 GMT Subject: capturing multiple groups? Message-ID: <UKB67.166784$mG4.79726347@news1.mntp1.il.home.com> What is the required syntax to match and save repeating groups? ie. Have: @12X12Y12Z@ Want: ['12X' '12Y' '12Z'] My re of re.compile("@(12.)*@") matches but only saves '12Z', and that is exactly what the manual says it should do!!! I'm sure I did this sort of thing in Perl before but I've not been able to come across the correct python syntax. Thanks in advance, Jim From max at alcyone.com Tue Jul 10 02:32:37 2001 From: max at alcyone.com (Erik Max Francis) Date: Mon, 09 Jul 2001 23:32:37 -0700 Subject: Newbie asks: How to translate this line of C to Py References: <tkl15g5on0mla8@news.supernews.com> <slrn.pl.9kl837.1c4.qrczak@qrnik.zagroda> Message-ID: <3B4AA185.9F9DC509@alcyone.com> Marcin 'Qrczak' Kowalczyk wrote: > for command in ';'.split(line_ptr): No, you mean for command in line_ptr.split(';'): ... The pattern you used is for the join method, not the split method. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Women are equal because they are not different any more. \__/ Erich Fromm Product's Quake III Arena Tips / http://www.bosskey.net/ Tips and tricks from the absolute beginner to the Arena Master. From barewy at edefod.net Sun Jul 29 14:25:53 2001 From: barewy at edefod.net (Timothy Gibson) Date: Sun, 29 Jul 2001 18:25:53 GMT Subject: Try floating the Back Orifice's dumb PGP and Willy will recycle you! Message-ID: <FDC34627.2CE8C0C7@edefod.net> If you'll recycle Gilbert's printer with keypads, it'll biweekly interface the thought. Sometimes Alexandra will get the robot, and if Samantha wistfully meets it too, the programmer will collaborate outside the fast cybercafe. My extreme PERL won't disconnect before I push it. He will engulf halfheartedly if William's plotter isn't bizarre. Go cry a protocol! When will you save the chaotic retarded zipdisks before Pilar does? Jeff wants to know seemingly, unless Chester infects machines within Evan's administrator. Until Jeff defiles the RAMs stupidly, Ann won't moan any solid cafes. Where Frederick's discarded LAN outwits, Robette facilitates in back of loud, plastic CIAs. Otherwise the terminal in Jonnie's librarian might prepare. Try typeing the Back Orifice's dry admin and Sherry will close you! Who shoots undoubtably, when Martin dreams the disgusting firewall in the mail server? Don't try to exclude the stacks wanly, eliminate them deeply. As badly as Robette reloads, you can negotiate the operator much more strongly. From tjreedy at home.com Mon Jul 16 13:20:04 2001 From: tjreedy at home.com (Terry Reedy) Date: Mon, 16 Jul 2001 17:20:04 GMT Subject: Most efficient solution? References: <31575A892FF6D1118F5800600846864D78BE8E@intrepid> <mailman.995298207.17374.python-list@python.org> Message-ID: <8nF47.11964$p7.3575146@news1.rdc2.pa.home.com> > map(A.remove, bb) Removing items from a list one at a time is O(len(list)) for each item removal. Filter() seems the better way to remove several items since it scans the list only once instead of len(bb) times. From robin at jessikat.fsnet.co.uk Wed Jul 18 04:12:38 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Wed, 18 Jul 2001 09:12:38 +0100 Subject: freeBSD 4.2 + Python2.1 Message-ID: <BAlhHJA2TUV7EwdX@jessikat.fsnet.co.uk> I'm trying to install Python2.1 and the package seems to install fine, but it seems that _socket.pyd is linked against libssl.so.2 which I don't have. Attempts to upgrade openssl are refused as openssl is part of the 'base' system. Am I really forced to upgrade the whole operating system? -- Robin Becker From jparlar at home.com Fri Jul 20 18:17:55 2001 From: jparlar at home.com (Jay Parlar) Date: Fri, 20 Jul 2001 18:17:55 -0400 Subject: py2exe problem Message-ID: <20010720222025.PXJA15886.femail4.rdc1.on.home.com@jparlar> My colleague and I are working on an application, coded mostly in Python, that must be distributed to people who don't have Python installed on their machines. Anyway, py2exe seemed the natural way to do this. However, it doesn't seem to be working correctly (although as is usually the case, I believe it has more to do with me than with py2exe). The first step in using py2exe is giving it an install script. Because of the nature of the program, we have all the components broken down into about 10 or 11 files, with one main file that coordinates everything. Using the suggestion from the py2exe page, my install script is simply the following: #install.py from distutils.core import setup import py2exe setup(name="webpass", scripts=["window1.py"], ) Now, this is my first time using Distutils, so maybe my install script isn't done correctly. It seems to compile all the modules we created ourselves when I run py2exe (I see their filenames going by on the screen during compilation). Because the app is for Windows, I compile the exe with the following command line: python install.py py2exe -w When run, the final product is supposed to present a GUI written in wxPython, which accesses an Access database using ADODB. When we run the file without py2exe, everything works (well, mostly works, we have some small bugs here and there, but we at least have an alpha version running). However, when I run the py2exe created .exe file, I have problems. If I run the .exe on my development machine, where Python is present, the GUI comes onto the screen properly, but the ADODB doesn't work perfectly. For some reason, it doesn't access one field of the database. However, if I run the .exe on a machine without Python, the GUI doesn't come up at all. I can tell that the backround operations are doing something, because the .ldb file for the database is generated after I try running the .exe, but the GUI never comes on screen. In addition, there is a command line option which would do nothing but print one line to a standard DOS prompt, but it won't even print that line. Again, the backround operations work (this command line creates registry entries, and they are present afterwards), but there is no screen output. One note: This program is intended to run as a COM local server (controlled by an IE comm band). Could that possibly be the problem? Does py2exe not take kindly to folks trying to use COM in their Python code? We're not even trying to run it with IE yet, there is a way to start it independently, but neither way will produce screen output on a machine that doesn't have Python installed. So to sum up: The py2exe version mostly works on my development machine that has Python installed, but when tried on a test machine without Python, there is no screen output, but the backround activities perform properly. The development machine is running Win95b, and the test machine is running Win98. I am running Python2.1 to create the code, and py2exe 0.2.6 to create the .exe. Any help would be GREATLY appreciated. (Bill, if I've made any mistakes in my explanation of the program, feel free to jump in and correct me) Jay Parlar ---------------------------------------------------------------- Software Engineering III McMaster University Hamilton, Ontario, Canada "Though there are many paths At the foot of the mountain All those who reach the top See the same moon." From Matthew.Alton at Anheuser-Busch.COM Fri Jul 13 12:43:08 2001 From: Matthew.Alton at Anheuser-Busch.COM (Matthew Alton) Date: 13 Jul 2001 09:43:08 -0700 Subject: Newbie list question Message-ID: <13c69f60.0107130843.5cd7dc38@posting.google.com> I am a UNIX/C programmer w/15y experience. Forgive me if my neural pathways are all about following pointers. The adjustment to Python-think is bumpy but I'll get by with a little help from my friends, eh? Here's the crux of the biscuit: >>> foo = ['a', 'b', 'c'] # We have a list named 'foo.' Excellent. >>> bar = foo # bar points to foo. Or does it? >>> baz = foo[:] # baz is a copy of foo. >>> foo ['a', 'b', 'c'] >>> bar ['a', 'b', 'c'] >>> baz ['a', 'b', 'c'] # So far, so good. >>> del foo[2] # Get rid of 'c' in foo and, therefore in bar (?) >>> foo ['a', 'b'] # 'c' is gone from foo... >>> bar ['a', 'b'] # ... and also from bar, as expected. >>> baz ['a', 'b', 'c'] # baz, the copy, is unaffected. Also as expected. >>> foo = foo + ['c'] # Add 'c' back to foo. >>> foo ['a', 'b', 'c'] # 'c' is back. Good. >>> bar ['a', 'b'] # ??? What the... ??? Where is 'c'? >>> baz ['a', 'b', 'c'] # baz still unaffected, of course. >>> I have verified this behavior on Python 1.5.1 (AIX 4.3.3) and on Python 2.1 (Solaris Sparc 2.8). From my arcane perspective, this behavior is utterly inconsistent and confusing. I strongly suspect that I simply do not correctly grok the list structure, but so far I am unable to turn up an explanation in the literature. Any help is appreciated. From grante at visi.com Tue Jul 10 11:11:07 2001 From: grante at visi.com (Grant Edwards) Date: Tue, 10 Jul 2001 15:11:07 GMT Subject: Python: Database to Web Part II (and "teaching language") References: <5174eed0.0107060820.ff90805@posting.google.com> <yox66d25zkd.fsf@karhu.tp.spt.fi> <23891c90.0107090815.3685a9@posting.google.com> <14m27.2182$z21.428719@newsc.telia.net> <23891c90.0107100440.2eb444af@posting.google.com> <3B4AFE8D.DE1F6563@stroeder.com> <mailman.994772496.27685.python-list@python.org> Message-ID: <fWE27.12057$B7.2309367@ruti.visi.com> In article <mailman.994772496.27685.python-list at python.org>, Thomas Wouters wrote: >On Tue, Jul 10, 2001 at 03:09:33PM +0200, Michael Str?der wrote: >> Paul Boddie wrote: > >> > Can the open source >> > movement include everyone, or is it inherently elitist? > >> Since you asked: The latter. > >Well, meritocracies are *very* likely to be elitist, but contrary to most >elitist systems, there is a clear and open doorway to the meritocrically >elite: contribute ;) But that doesn't mean you have to write code. You can: Help maintain a web site. Write a tutorial on something. Maintian a manual. Hang around a newsgroup and answer questions. etc. -- Grant Edwards grante Yow! I OWN six pink at HIPPOS!! visi.com From slinkp23 at yahoo.com Tue Jul 10 15:05:26 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Tue, 10 Jul 2001 19:05:26 GMT Subject: File processing References: <9id5p9$8r62@interserv.etn.com> <01b001c1091f$c9c74340$0e4ab43f@kens> <mailman.994758022.15575.python-list@python.org> <9ifima$8r69@interserv.etn.com> Message-ID: <3B4B507D.95897534@yahoo.com> Chris McMillan wrote: > > When I run my script, below, it complains after the line f = open(fname, > 'r') saying that it expected string, list found. I believe this happens > because of what the glob command returns, but I'm not sure how to fix it. > FYI - I'm running Python 2.0 on Windows NT. Thanks in advance for your > help! > Chris (snip) > for fname in glob.glob('M:\\python\\*.dat'): > fname = glob.glob('M:\\python\\*.dat') The first line assigns fname to each item from the list returned by glob.glob(), one at a time until it runs out of filenames. The second line then assigns fname to the list itself. Take this line out and you should get what you want. -- ................... paul winkler .................... custom calendars & printing: http://www.calendargalaxy.com A member of ARMS: http://www.reacharms.com home page: http://www.slinkp.com From tdelaney at avaya.com Sun Jul 22 21:21:11 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Mon, 23 Jul 2001 11:21:11 +1000 Subject: Pedants R us (was RE: Language change and code breaks) Message-ID: <B43D149A9AB2D411971300B0D03D7E8B0FC2C8@natasha.auslabs.avaya.com> > >Guido van Rossum wrote: > >> In my usage, a "programmer" is someone who is a > >> professional code-slinger, 8-12 hours a day. > > > >Eek - I hope you don't really mean that last subclause! > > A *real* programmer gets in a good six hours code-slinging in their > sleep - that period when all the hard problems find their neat > original solutions. Apart from the ones that get scribbled on a > beer-mat, that is ;-) Nah - all the best solutions are worked out in the shower. I am currently campaigning for all programmer's cubicles at my place of work to have showers installed. I predict that productivity will increase 5-fold. Tim Delaney From rnd at onego.ru Tue Jul 3 06:11:36 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 3 Jul 2001 14:11:36 +0400 (MSD) Subject: Python and DB support (was: Re: Is Python Dead?) In-Reply-To: <9hrv5k016q4@enews1.newsguy.com> Message-ID: <Pine.LNX.4.30.0107031407420.20048-100000@rnd.onego.ru> On Tue, 3 Jul 2001, Alex Martelli wrote: >"Roman Suzi" <rnd at onego.ru> wrote in message >news:mailman.994135925.11224.python-list at python.org... >> On 2 Jul 2001, David Bolen wrote: >> >> >Roman Suzi <rnd at onego.ru> writes: >> > >> >> However, my collegues were not satisfied with it. One somplain was that >in >> >> ASP/IIS it is "very easy" to receive a "recordset" from database and >then >> >> apply it in different situations in the ASP-page, because recordset is >an >> >> object and even subqueries could be made without quering DB again. >> > >> >Just curious, but did your colleagues try using Python's COM interface >> >to ADO to retrieve an actual recordset object that they could >> >manipulate the same in Python as in other ASP languages? >> >> Aha! Now I could understand what is the brake of Python library >> development. Most of Python users are Windows users. And they >> have COM for whatever is in their system. > >I strongly doubt that "most Python users are Windows users", but >it's certainly true that most Python users *WHO CONSIDER ASP/IIS >AN ALTERNATIVE* are Windows users (and pretty-clueless ones, if >they don't know Python can work perfectly well WITHIN ASP/IIS!-). Ok, I've not pushed the issue because people wanted to learn ASP. >> We mostly have Linux servers, so COM+ADO is no option. The point was not >> to choose between Windows and Linux, ASP was choosen to serve particular >> purpose, for the database already implemented in Microsoft land. > >If COM+ADO is not an option then neither is ASP/IIS! I am sorry that I gave inaccurate description. There were no point in installing Python just to serve 3-4 pages from IIS. * Anyway, I wanted to say that some generic (!=Windows only) ADO could help for those who consider Python for tasks usually done with PHP or ASP. Probably it could be coupled with gadfly to make subqueries possible. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Tuesday, July 03, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Paranoia is nothing to be afraid of!!" _/ From graham_guttocks at yahoo.co.nz Wed Jul 18 15:53:48 2001 From: graham_guttocks at yahoo.co.nz (Graham Guttocks) Date: Wed, 18 Jul 2001 12:53:48 -0700 (PDT) Subject: software documentation system? Message-ID: <20010718195348.75599.qmail@web10306.mail.yahoo.com> Greetings, A Python application of mine is now large enough that I need to get more serious about writing a real manual for it. I'm looking for a documentation system that uses a single source file to produce both online information and printed output. (PS, HTML, etc.) Any recommendations? I work in a UNIX environment and would prefer an opensource alternative. So far I've found GNU texinfo and also SGMLtools which is written in Python, but am open to other suggestions. Regards, Graham __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/ From rnd at onego.ru Tue Jul 3 03:05:17 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 3 Jul 2001 11:05:17 +0400 (MSD) Subject: How to call a method with variing arguments In-Reply-To: <e956b5f1.0107022240.776c1734@posting.google.com> Message-ID: <Pine.LNX.4.21.BCL.0107031100460.720-100000@suzi.com.onego.ru> On 2 Jul 2001, Heiko wrote: > Hello, > I want to do this: > > ClassObject = Class() > ClassObject.Method(Arg1, Arg2, Arg3) > ... > ClassObject.Method(Arg1, Arg2, Arg3, Arg4, Arg5 ....) > ... > ClassObject.Method() > ... > and so on. > > Means that I want to call a method with a variing number of arguments > and the method decides what to do. > If possible, it would be nice, if the sequence of the arguments > doesn?t matter, and the method realizes which argument is on which > position (but that is a "nice to have"). So, how do I have to declare > the method, that this works? example: class Class: def Method(self, Arg1="default", Arg2="def2", Arg3=None): Arg3 = Arg3 or [] print Arg1, Arg2, Arg3 class_object = Class() class_object.Method(Arg3=[1,2,3]) class_object.Method("a", "b", [2,3,4]) ... Works like this: >>> class Class: ... def Method(self, Arg1="default", Arg2="def2", Arg3=None): ... Arg3 = Arg3 or [] ... print Arg1, Arg2, Arg3 ... >>> class_object = Class() >>> class_object.Method(Arg3=[1,2,3]) default def2 [1, 2, 3] >>> class_object.Method("a", "b", [2,3,4]) a b [2, 3, 4] >>> > Thanks > Heiko > Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From peter at engcorp.com Sat Jul 7 11:06:23 2001 From: peter at engcorp.com (Peter Hansen) Date: Sat, 07 Jul 2001 11:06:23 -0400 Subject: PEP scepticism References: <mailman.993747643.21070.python-list@python.org> <9hfqb5$dsllb$3@ID-89274.news.dfncis.de> <3dhex01n1m.fsf@ute.cnri.reston.va.us> <cphewzlbis.fsf@cj20424-a.reston1.va.home.com> <9hlcp4$eiphi$2@ID-89274.news.dfncis.de> <cppubkkbhf.fsf@cj20424-a.reston1.va.home.com> <9hqc3i$f1dia$2@ID-89274.news.dfncis.de> <cpith6l3ip.fsf@cj20424-a.reston1.va.home.com> <iZR5BIA3wdR7EwJx@jessikat.fsnet.co.uk> <mailman.994456001.2112.python-list@python.org> <6Jd$FLAFotR7EwLP@jessikat.fsnet.co.uk> <3B471314.8B179A92@engcorp.com> <5lh$OIA2rxR7Ewou@jessikat.fsnet.co.uk> Message-ID: <3B47256F.72FE6CD0@engcorp.com> Robin Becker wrote: > > In article <3B471314.8B179A92 at engcorp.com>, Peter Hansen > <peter at engcorp.com> writes > >Robin Becker wrote: > >> > >> The language is evolving as all languages do because of the needs of its > >> users. Five years ago the leadership said integer division was good, > >> today it's bad; the audience changed is all. > > > >Actually, maybe it's just which audience members are vocal which > >has changed recently. ... [snip] > >But until now my voice was silent on the matter. Perhaps the > >reason you think the needs of the users has changed is because > >Python suits the needs of some users so well that they don't > >feel the need to constantly whine about the fact. Maybe only > >those who have a problem with it are going to make their voice > >heard. (As someone said a few messages back: Well, duh! :-) > > You infer too much as I prefer to keep the / operator as it is. I can't see anything in my message which infers your preference on this issue one way or the other. What I _did_ comment on was your expressed belief that the needs of the users was changing (this being the reason, you said, for the evolution of the language). > I believe that the python developers have an interest in promoting the > language to a wider audience and so they keep changing the language to > enhance its popularity. Guido said as much in other messages. I don't see this as a particularly bad thing (actually not bad in any way at all). I am a little concerned at the rate of change though, or, perhaps more accurately, at the desired rate of change. It appears the developers are working hard towards an environment in which language change can occur _very_ quickly. I believe they want to do this to make change go more smoothly, efficiently, and with greater consensus. The problem, I believe, is that not enough time is being given to the discussion of the change prior to agreeing to do it. As an example, the discussion on div() appears already to have progressed to the point where a decision is forming on a plan to do it over the next couple of years. I applaud the slow (proposed) pace of implementing the change, but I think the discussion itself should be taking many months before a decision is made, to give more people the opportunity to voice their concerns. That is to a large extent the purpose and effect of the PEP process, I suppose, and yet it feels like in the last few months there have been literally dozens of significant changes to the language. Perhaps the issue, then, is not the speed of discussion and implementation of individual changes, but the sheer volume of proposed changes. Taken one at a time they all seem reasonable and harmless, maybe even useful, but as a whole they feel like an onslaught that could lead to a loss of "focus" as to the nature of Python. They may dilute the language's (until now) clarify of purpose and style. Frankly I'm worried. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From guido at python.org Fri Jul 6 12:30:34 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 06 Jul 2001 16:30:34 GMT Subject: Comment on PEP-0238 References: <mailman.994427714.26169.python-list@python.org> Message-ID: <cpsngaja4g.fsf@cj20424-a.reston1.va.home.com> Roman Suzi <rnd at onego.ru> writes: > This is reasonable. However, IMHO, solution need to be different > than redefining established "/" behaviour? > > Could "right" division be given some other symbol than "/" and old "/" be > left intact as a "low-level" C-conformant division every Python programmer > is accustomed to? Unfortunately, the number of potential Python programmers who will be frustrated by the current integer division is much larger than the number of established Python programmers. The sooner we fix this the better! Another thing. Division of integers is a pretty uncommon operation (less common than shifting or bitwise masking, in my experience). As an experiment, I added a warning to int and long division, and ran the test suite. The result: 44 distinct warning locations, of which 38 were part of the test suite (more than half of which had to do with the testing of division or binary operators, or used 1/0 to raise an arbitrary exception). In the library itself, only three modules engaged in integer division during execution of the test suite: bisect, dumbdbm, and inspect. Of these, bisect and dumbdbm will need to be converted to using div(); inspect uses 1/0 to raise an exception. The warning framework and the future statement are there to make the transition easier. Here's my plan, "new division in four phases": 1. First we introduce a new function div() and a future statement that makes integer division return a float result for a specific module. 2. In a following revision, we add a warning when / is used on two int or long arguments, recommending to use div() instead. (It is important not to start warning in phase 1, so folks have time to switch to div() voluntarily first; maybe phase 1 could have a command line option to warn about integer division.) 3. A revision later, we change all plain integer divisions to be an error, *forcing* folks to use div() or use the future statement to specify floating point division. 4. Finally we can implement the "future" behavior by default. I haven't picked dates yet; if folks agree, I would like to add div() and a future statement to 2.2 and space the other steps a single revision apart, so phase 4 would be at Python 2.5 (April 2003, if we keep the current release schedule up). Is that too aggressive? I currently favor div(x, y) over x//y and x div y. Maybe also add mod(x, y) for symmetry (that would also explain divmod() as a messenger from the future :-). I'm not sure how to spell the future statement. Here are some choices: from __future__ import float_division from __future__ import real_division from __future__ import new_division from __future__ import division --Guido van Rossum (home page: http://www.python.org/~guido/) From aleaxit at yahoo.com Tue Jul 31 12:33:13 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 31 Jul 2001 18:33:13 +0200 Subject: Typing system vs. Java References: <mailman.996592198.30711.python-list@python.org> Message-ID: <9k6mkc02poc@enews4.newsguy.com> "Christian Tanzer" <tanzer at swing.co.at> wrote in message news:mailman.996592198.30711.python-list at python.org... """ > poor programming on my part, but I can't even think how one would type a > function like say: > > def f(zs): return reduce( lambda x, y: x + y, zs ) Genericity (templates in C++) this is not a problem -- you get one instance of `f` for each type `zs` you happen to apply `f` to. Disclaimer: C++ templates don't allow different return types for such functions, but that's a restriction of C++, not of genericity. IIRC, """ Beg pardon? template<class A, class B> A myfunction(const B& b) { return b; } Maybe you mean that C++ doesn't *automatically INFER* A when you just call myfunction(something)? But, you CAN partially specify myfunction<int>(something) [or, of course, totally specify myfunction<int,double>(something)], if you have a standard-compliant C++ compiler. Back to Python -- programming in Python has always felt to me a *LOT* like generic programming (e.g. with C++ templates) in so many ways... of course, I was "steeped" in C++ generics well before I met Python, so that may help explain this:-). But, really, the only significant difference seems to me to be that C++ instantiates its generics at compile-time (less flexibility, some more syntax cruft, better runtime speed) while Python works in a fully dynamic way, at runtime (some errors are diagnosed a bit later, speed is not so great, syntax is very lightweight and flexibility is nonpareil). They're still very subjectively similar programming mindsets... *signature-based polymorphism* dominates in either case! Alex (Brainbench MVP for C++) From James_Althoff at i2.com Fri Jul 13 16:13:08 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Fri, 13 Jul 2001 13:13:08 -0700 Subject: Long Live Python! Message-ID: <OF4AF701E5.07D90C51-ON88256A88.006D2F83@i2.com> Dennis Roark wrote: >James_Althoff at i2.com wrote: > >> >> >>What is it about Python that would, in your experience, make it only "good >>for short programs <100 lines". >> >>Jim >> > >Lack of type safety; lack of forcing variable names to be >declared before use. (In a long program, how hard it is to >find a bug that is simply the misspelling of a variable!) Have you actually found either of these *really* to be a problem in writing longer programs -- in *actual* practice, I mean? I ask because I haven't found either to be a show-stopper. Specifically, I *do* misspell variable names. And in my experience, misspelled variable names are pretty easy to find. One case where this is less so is when you misspell something in an exception handler (for example) and then *never* exercise that exception case. On the other hand, I consider such a thing to be a very bad practice anyway (the "never exercising part" ;-) My experience has been that the *hard* problems in big programs are *way* beyond anything that a compile can detect. Again, we are shipping production code with > 100,000 lines of Jython and neither "Lack of type safety" (by this I assume you mean "compile-time, static, type checking") nor "lack of forcing variable names to be declared before use" were problems for us. So, though I am not against the general notion of making it possible to detect errors as early as possible (e.g., at compile time) I don't see today's Python as being unsuitable for large program. In fact, I see Python as being *very* suitable for large programs. And I say this from the perspective of having already written large program using Python. :-) Jim > >I really like Python, but for at least the reasons above, I >can't see it for long programs. > >--------------------------------- >Dennis Roark >Dept. of Computer Science >University of Sioux Falls From BPettersen at NAREX.com Tue Jul 24 16:10:09 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Tue, 24 Jul 2001 14:10:09 -0600 Subject: cost of change Message-ID: <6957F6A694B49A4096F7CFD0D900042F27D57C@admin56.narex.com> > From: Galen Swint [mailto:hcsgss at texlife.com] > > Has anyone tried to figure out how much changes to Python > cost? The way I > figure it, it goes something like this: > 500,000 Python programmers > $20/hr > 3 hrs to port *all* needed code > Thats $30 *million*, and all those numbers are surely low -- > especially the > time to port. I can't imagine if you're using third party > packages and have to > wrangle with all their code yourself. > I've been programming with Python only two months, and I've > already gone > through part of the 1.5 to 2.1 upgrade, and it cost several > hundred dollars in > salary simply because pickling doesn't port up versions. (I > know that's > documented, but it's still crazy not to have a pickly that > works across > versions). > There are other hidden costs to breaking a language with > every upgrade. Two > come to mind - first, people like me, who thought they liked > it, now don't want > to do anything long term in it, and second, no one can afford > to spend time on > optimizations because the structure and code they are trying > to optimize keeps > shape shifting. > If you're going to change it, fine. *BUT*, do the world a > favor and be sure > that *any* change which breaks existing code carries a new > major version number > (PEP0238 clearly warrants a Python 3.0 designation) . > Galen $20/hr? I think it's time to renegotiate <wink> -- bjorn From tundra at tundraware.com Sun Jul 8 20:10:01 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 09 Jul 2001 00:10:01 GMT Subject: I'm Sure There's A Better Way References: <3B465858.CB7F38E8@tundraware.com> <9i6e5502d9g@enews4.newsguy.com> <3b478576.1314346961@wa.news.verio.net> <9i92mb02pnp@enews3.newsguy.com> <3b48d5b9.1400429941@wa.news.verio.net> Message-ID: <3B48F5BB.E93EF377@tundraware.com> Bengt Richter wrote: > Thanks to all who answered! A fertitle bunch of minds 'round here.... The response that gets it all (despite my fuzzy definition) was mailed to me privately. I deconstructed it (well really, reinvented it from scratch myself) to make sure I understood what was going on. And the winner is... ^-?((\d+(\.\d{2})?)|(\.\d{2}))$ To be really fussy, the \. should really be a string constant which is conatenated into the remainder substrings so that other delimiters could be used when I18Ning the code. Just for the record - I knew when I started that a re was a better way to do this. Although I've programmed a lot in other languages, I am still in the process of absorbing python, and I had not yet attacked its re capabilities so I decided to hand code it. Now that I look at the re implementation, I realize I should have started there because it is so much more compact and elegant. In any case, it was a nice tutorial exercise which made me learn an essential piece of python. I'm writing a complete (small) application which does keyboard I/O, saves state to disk, does meaningful arithmetic and so on. My intention is to put it up on the web when done so others can use it to see something a bit less trivial than the examples which are common in tutorials. Once again, many thanks to all who kindly took the time to respond. ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From gustin at pcpm.ucl.ac.be Tue Jul 3 02:06:48 2001 From: gustin at pcpm.ucl.ac.be (Cédric Gustin) Date: Tue, 3 Jul 2001 08:06:48 +0200 Subject: GUI Builder for Python ? References: <aknrjt8j3cm3qcnpu6qsgvu313rlmi8emg@4ax.com> <9hn12v$p0r$1@slb7.atl.mindspring.net> <Xns90D2622C0266C89065hrerehxvb@139.88.112.200> <9hqshs$k9m$1@nntp6.u.washington.edu> Message-ID: <9hrnhl$60k$1@estragon.sri.ucl.ac.be> "Frank Miles" <fpm at u.washington.edu> wrote: > >Has anyone made this work under Windows? I tried it a few months ago, and > >it worked great under Linux, but there seemed to be some piece (Python > >bindings for libGlade?) missing under Windows. > libglade stuff was graciously sent by Cedric Gustin, but he's working on > Python 2.1. Yesterday I patched pygtk-0.6.8, the latest stable version and recompiled _gtk.pyd and _libglade.pyd for python 2.1 on win32. I have also a working version of glade running on win32 (although it's also available on various sites, at http://libre.act-europe.fr/GtkAda/ among others). This means that you can write and port to win32 any pygtk application with libglade support. If anybody is interested, simply email me directly and I'll send you the binaries. I can also recompile everything for python 2.0 if necessary. If Hans Breuer is reading this newsgroup, I think it would be nice to provide a standard windows installer (I think I have a copy of installer vise somewhere) for both python 2.0 and python 2.1. If I remember correctly somebody posted a message about this a few weeks ago but maybe it was on the pygtk mailinglist... Cedric From pkalliok at cc.helsinki.fi Sun Jul 8 15:41:53 2001 From: pkalliok at cc.helsinki.fi (Panu A Kalliokoski) Date: 8 Jul 2001 19:41:53 GMT Subject: Adding a package to the standard distribution Message-ID: <9iad21$btd$1@oravannahka.helsinki.fi> Hello all, I've got a package (called Selecting) that I'd like to subject to consideration for being added to the standard python distribution. The package implements a better (in my opinion) scheme of abstraction over select.select() than does asyncore and asynchat. However, I don't know what mailing list / person I should write to to get the package included in the standard distribution. Whom should I contact? Panu Kalliokoski From peter at engcorp.com Wed Jul 25 00:26:15 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 25 Jul 2001 00:26:15 -0400 Subject: newbie projects References: <mailman.996028966.8516.python-list@python.org> Message-ID: <3B5E4A67.FD4BE81A@engcorp.com> fett at tradersdata.com wrote: > > Uh I know this sounds knda dumb but anyoone have a job that they want > done cheap or for free that doesnt have to be done by a professional, > because im not one by any stretch of the immagination. But i need some > type of project to do to help me hone my skills. Why not contribute your efforts to a worthy open-source project, like maybe one of the ones on SourceForge? Giving your time away to a commercial enterprise would be silly, unless you are specifically hoping to turn that into future work for the same company. And even then working on the open-source project might end up providing you more lasting value. And fun. (Just a thought.) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From tjreedy at home.com Fri Jul 20 19:26:28 2001 From: tjreedy at home.com (Terry Reedy) Date: Fri, 20 Jul 2001 23:26:28 GMT Subject: Most efficient solution? References: <mailman.995289809.28477.python-list@python.org><slrn9l5urp.nto.alf@leo.logilab.fr><OeF47.11959$p7.3571067@news1.rdc2.pa.home.com><wkk813nz6e.fsf@mail.connact.com> <mailman.995662297.13101.python-list@python.org> Message-ID: <E6367.7541$EP6.2460187@news1.rdc2.pa.home.com> > > def dict(a,c): > > start = time.clock() > > for item in a: > > d = filter(c.has_key, a) > > this is an error. You are creating a list containing items in 'a' and > 'c' for each item in a. You only need to make the list once. > > with the correction dict runs in .04 seconds while comp runs in 58.09 > > I would say that you still need to use dictionaries (note that this > doesn't actually solve the problem, which is to get items in 'a' but > not in 'b', but the following > > def dict2(a, c): > start = time.time() > d = [ i for i in a if not c.has_key(i)] > end = time.time() > print `end-start` > > does in in .14 seconds (still 400x faster than comp) To compare program running times, they should compute the same thing. How long does dict2 take if you remove the not, so it makes the list of 1500 elements that revised dict does, instead of the 'not' list of 6000? How long does dict take if you feed filter with 'lambda x, f=c.has_key: f(x)', so it make the 'not' list of 6000 elements? Terry J. Reedy From peter at engcorp.com Fri Jul 13 23:57:51 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 13 Jul 2001 23:57:51 -0400 Subject: Book count test References: <mailman.995037802.14375.python-list@python.org> Message-ID: <3B4FC33F.AA8C6095@engcorp.com> Kemp Randy-W18971 wrote: > > I went to www.amazon.com and counted the number of books in these categories > Python - 136 (including snake books) > Java - 1621 > Perl - 430 > C++ - 1341 > PHP - 38 > ASP - 172 > Oracle - 682 A little more useful are the following numbers: Python - 33 (not including snake books) Java - 1041 (not including volcanic rocks or coffee) Perl - 257 (not including readable languages) C++ - 1265 (not including reliable languages) PHP - 34 (not including the other four books you found) ASP - 80 (not including snake books either) Oracle - 356 (not including ancient Greece books) Amazon, being booksellers, know a little about cataloguing books. Just append the word "computer" after any of the above. It may not be 100% accurate yet, but it's more accurate than using just the language names alone... The only real outlier there might be Oracle. If that really is books about "the" Oracle from Oracle, that is at least one language where the difficulty of learning or applying it must be contributing to the volume of available books. (Note, roughly 33% of the Python books are not readily available (or even published yet) and only slightly fewer of the PHP books don't exist yet either.) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From k5r2a at chollian.net Mon Jul 23 22:54:30 2001 From: k5r2a at chollian.net (±èÇö±¹) Date: Tue, 24 Jul 2001 02:54:30 GMT Subject: user level can't bind socket address & port Message-ID: <Gr577.7519$2k2.398288@news.bora.net> hi, all as the title user level can't bind socket address & port for example, sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.bind((iface, port)) if i login user level, python interpreter generate error message like that " sock.bind((iface, port)) socket.error: (13, 'Permission denied') " How can I bind socket user level. please send comment...... From bokr at accessone.com Thu Jul 26 20:30:12 2001 From: bokr at accessone.com (Bengt Richter) Date: Fri, 27 Jul 2001 00:30:12 GMT Subject: Number tree (was: Re: proposed language change to int/int==float (was: PEP0238 lament)) References: <eppstein-03540D.13070222072001@news.service.uci.edu> <LNBBLJKPBEHFEDALKOLCOECNLAAA.tim.one@home.com> <mailman.995899647.346.python-list@python.org> <tclolt053o18f8q0ntb7n4aggitdkmeg4h@4ax.com> <Io_67.23543$B7.3779351@ruti.visi.com> <slrn9lp2m5.vp.Gareth.McCaughan@g.local> <p56plt8q4rs3bgcqbepk61q2r3g0tr2vhe@4ax.com> <slrn9ls3ae.2fm.Gareth.McCaughan@g.local> <cpitghbq05.fsf@cj20424-a.reston1.va.home.com> <m2wv4xdxlf.fsf@mycroft.actrix.gen.nz> <slrn.pl.9ltfv2.241.qrczak@qrnik.zagroda> Message-ID: <3b608138.493932958@wa.news.verio.net> On 25 Jul 2001 12:47:30 GMT, Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl> wrote: >26 Jul 2001 00:03:56 +1200, Paul Foley <see at below> pisze: > >>> int < long < rational < float < complex >> >> Well, it could, I suppose, but that would be a good reason to avoid >> Python :-) >> >> What it *should* look like is this: >> >> int < long < rational >> \ >> + < [real] < complex >> / >> float > >There are no real reals in programming. And Python's complex is as >inexact as float. > >I don't understand you. What practical difference do these diagrams >yield? What is wrong in *consequences* of Guido's and mine model >which your model puts differently? > >What happens if you int to float in your model? Rational to float? > The trouble with these discussions is that common usage creates an overloading of meanings for the words. Some of these things can be talked about sensibly even if computers don't exist. Some can't. >From the above, Can: rational, real, complex (integer belongs here too) Can't: int, long, float Separating the abstract (A) world from the world of (R)representations, you get a different diagram, with as many variations below the line as you can imagine (I'm mixing in C types and common typedefs to illustrate the idea) A[integer] < A[rational] < A[real] < A[complex] v v v v -------v------------v------------------------v----------------v----------- v v v v R[integer] R[rational] R[real] R[real],R[real] v~ ~[5] +---------v~ ~[6] +~ ~[7] long R[i]/R[i] float[3] R[rational] v v v v int64 R[i] fsingle[4] R[integer] v fdouble[1] v int32 v fsingle[2] v int16,short v int8,char v (single bit) R[i] is short for R[integer] above. Specifics re fp below relate to IEEE754: [1] as 53-bit integer [2] as 24-bit integer [3] as 53-bit integer * 2^n where -1022<=n<=1023 (interpret -n as /2^n ) [4] as 24-bit integer * 2^n where -126<=n<=127 (ditto) [5] I show a wiggly side branch, because there's a zillion possible other ways to represent integers. Python's long internally makes use of 15-bit integers, I think I read in a post of Tim's, so it's really off to the side if you like to think in terms of more traditional C representation types. I included the floats at [1] and [2] just to illustrate possible variety. [6] I added this to point out that you can/must interpret floating point numerical states as representations of particular exact A[rational] numbers, and these exact A[rationals] also serve as approximations to A[reals] (which can be right on or not) represented as R[rational] under R[real]. BTW, "A[float]" is a way of referring to the peculiar subset of A[rational] representable by concrete float states. [7] On this branch, you could imagine various schemes for representing irrational numbers, such as rationals with stored rational exponents, and special representations for e and pi etc., etc. By R[integer] etc., I mean representation in the widest sense that can have a concrete realization. E.g., we could imagine representing really big integers by combining the distributed resources on the internet. The point is, what's below the line has no significance mathematically until you translate it back to something above the line using some mapping you have in mind. Computers have been designed to transform stuff below the line. They can't touch stuff above the line. They can only produce stuff that may have a relationship to what's above. It's pretty obvious if you think about it, but it's easy to lose sight of in daily shortcut habits of thought. Maybe our discussions would become clearer if we adopted a convention to indicate which aspect of a number we were talking about, e.g., A[x] for the abstraction behind our mention of x, and R[x] for some corresponding representation. If you want to indicate a specific type of representation, it could be R[type:x], e.g., R[float:x] Saying that "there are no real reals in programming" is really saying A[real] != R[real], but that doesn't mean that we can't deal with A[problems] with A[real] functions by using R[real] approximations. Without [7] we can do no better than R[rational] under R[real], which is why I didn't elaborate the tree. Note that R[rational] includes float at [3]. Decimal floats or any other monster float you can come up with will ultimatlely also attach at [6]. Anyway, this is the way I look at it ;-) Maybe with Guido and Tim's help, and that of lurking mathematicians, something like the above could become a useful part of Python docs. It would be nice to work in exact vs inexact also. Obviously, any R[] is exactly something, because it has a particular distinct state, so there is an A[x] for every R[x]. Thus every R[x] has the possibility of serving as an exact representation (i.e., of A[x]). But I think I'll stop here, because exactness and all that is too big a discussion. HTH make discussions more meaningful ;-) From alf at leo.logilab.fr Mon Jul 16 10:59:27 2001 From: alf at leo.logilab.fr (Alexandre Fayolle) Date: Mon, 16 Jul 2001 14:59:27 +0000 (UTC) Subject: Most efficient solution? References: <mailman.995289809.28477.python-list@python.org> <slrn9l5urp.nto.alf@leo.logilab.fr> <6qae252b15.fsf@abnoba.intevation.de> Message-ID: <slrn9l60i2.o0p.alf@leo.logilab.fr> On 16 Jul 2001 16:39:34 +0200, Bernhard Herzog <bh at intevation.de> wrote: >A bit more elegant, perhaps, and a little faster still would be to use 1 >as the value in C and directly use C.get in filter: > >C = {} >for item in B: > C[item] = 1 > >A = filter(C.get, A) Much more elegant, of course. This is a good example of iterative refactoring ;o) I suppose that the first loop could also be rewritten using map, in order to squeeze some more juice out of the beast: C={} map(lambda item,dic = C: dic[item]=1, B) Alexandre Fayolle -- LOGILAB, Paris (France). http://www.logilab.com http://www.logilab.fr http://www.logilab.org Narval, the first software agent available as free software (GPL). From bokr at accessone.com Tue Jul 24 14:11:30 2001 From: bokr at accessone.com (Bengt Richter) Date: Tue, 24 Jul 2001 18:11:30 GMT Subject: A use for integer quotients References: <mailman.995941542.7888.python-list@python.org> Message-ID: <3b5db927.311644451@wa.news.verio.net> On Mon, 23 Jul 2001 22:24:08 -0400, "Tim Peters" <tim.one at home.com> wrote: >[Bengt Richter] >> I wonder if the implementation is factored to where not using >> floating point would let you substitute small exception-raising >> stubs for otherwise large (?? usually, floating point carries a >> lot of baggage along in the C/C++ world) chunks concerned with >? floating point. > >No, it is not. > >> Then that could be a make option. I was wondering if someone's >> been there done that. > >These folks have: > > http://www.abo.fi/~iporres/python/ > >Their patch is against 1.5.1, but I bet the principle still applies <wink>. > Thanks. Interesting. Though "patch" may be a bit of an understatement ;-) From grahamd at dscpl.com.au Thu Jul 26 22:25:57 2001 From: grahamd at dscpl.com.au (Graham Dumpleton) Date: 26 Jul 2001 19:25:57 -0700 Subject: Distributed computing using SOAP. What about speed ? References: <LBA77.58$bXi.175168000@news.telia.no> <dc6f5c99.0107251655.f3c625b@posting.google.com> <3B5FC733.5186D588@tundraware.com> Message-ID: <dc6f5c99.0107261825.7e74fa89@posting.google.com> Tim Daneliuk <tundra at tundraware.com> wrote in message news:<3B5FC733.5186D588 at tundraware.com>... > > OSE is implemented using an event driven system model. This includes the HTTP > > servlet framework, such that multiple requests can be handled at a time etc. > > It includes mechanisms for knowing when connections block due to slow HTTP > > clients so you can stop sending data back etc. > > > > OSE at its core is actually C++, with Python wrappers. Thus, you are getting > > the efficiency of C++ but the simpler interfaces possible with Python. > > I have a related question. I come from a very high-scale, high-arrival > rate transactional computing background. In this world, connection-oriented > solutions like RPCs across wide-area networks are a big "no no" for > a variety of reasons. (If you care more about why, I wrote a paper, years > ago, in grad school on this topic. The specifics of the paper are quite > out of date, but the general critique' of RPCs is still very much relevant, > perhaps even moreso today with the proliferation of the internet. You can > find it at: http://www.tundraware.com/RPCpaper/rpcpaper.pdf) The short > reason for this is that connection-oriented solutions like RPCs create > very "brittle" applications in highly distributed, high-performance > environments. I am thus less than enthusiastic about SOAP as a solution. > > One really good alternative is transactional queuing with asynchronous > read/write interfaces to the queues. I'm wondering if anyone is doing > anything in this area with Python. I have saved your document and will look at it, but be aware that OSE actually supports publish/subscribe and request/reply modules of communication using an asynchronous model. OSE uses messaging concepts in its implementation as opposed to connection oriented RPCs. It does however take a simple approach to this in that it isn't underlayed by persistent message queues. This is still useful for many applications and certainly makes the implementation easier. It hasn't been the intention with OSE to target transactional environments so it would more than likely not be useful for that sort of application, but there are lots of other things it would be quite adequate for. I will look at your paper. You may want to look further at the Python manual for OSE and you might see it ain't quite what you first had in mind. From mirko.liss at web.de Sun Jul 15 04:58:01 2001 From: mirko.liss at web.de (Mirko Liss) Date: Sun, 15 Jul 2001 10:58:01 +0200 Subject: do .. while loops ? In-Reply-To: <3B51256D.E6266B50@alcyone.com> References: <mailman.995169745.15095.python-list@python.org> <3B51256D.E6266B50@alcyone.com> Message-ID: <20010715085808.1176385C.NOFFLE@niccolo.ke4.de> On Sat, 14 Jul 2001, Erik Max Francis wrote: > do...while loops are a language feature that tend to be fairly > controversial in some languages, for some reason -- probably because it > seems more on the "fluff" side to many people. They're easy enough to > simulate with other control structures. On the other hand, if you write do..while - loops, you can get rid of one jump per iteration. Rewriting while - loops into do ... while - loops is a common optimization. Lets take a look at it: Python 1.5.2 (#1, Jul 29 2000, 14:28:37) [GCC 2.95.2 19991024 (release)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import dis >>> def testme(a): ... while a > 0: ... a = a -1 ... >>> dis.dis(testme) 0 SET_LINENO 1 3 SET_LINENO 2 6 SETUP_LOOP 34 (to 43) >> 9 SET_LINENO 2 12 LOAD_FAST 0 (a) 15 LOAD_CONST 1 (0) 18 COMPARE_OP 4 (>) 21 JUMP_IF_FALSE 17 (to 41) 24 POP_TOP 25 SET_LINENO 3 28 LOAD_FAST 0 (a) 31 LOAD_CONST 2 (1) 34 BINARY_SUBTRACT 35 STORE_FAST 0 (a) 38 JUMP_ABSOLUTE 9 >> 41 POP_TOP 42 POP_BLOCK >> 43 LOAD_CONST 0 (None) 46 RETURN_VALUE >>> Rewriting this to >>> def testme2(a): ... while 1: ... a = a - 1 ... if a < 0 : break ... yields something like: ... 35 LOAD_FAST 0 (a) 38 LOAD_CONST 2 (0) 41 COMPARE_OP 0 (<) 44 JUMP_IF_FALSE 8 (to 55) 47 POP_TOP 48 SET_LINENO 4 51 BREAK_LOOP 52 JUMP_FORWARD 1 (to 56) >> 55 POP_TOP >> 56 JUMP_ABSOLUTE 9 >> 59 POP_TOP 60 POP_BLOCK ... Using a do..while - loop, you'd have one jump less per iteration, but because of the if..break you get one additional jump. regards, Mirko PS: Sorry, if this has been discussed before. From orlov at diasoft.ru Thu Jul 5 06:58:28 2001 From: orlov at diasoft.ru (Oleg Orlov) Date: Thu, 5 Jul 2001 14:58:28 +0400 Subject: Weird problem on WIN platform.. any ideas? References: <ecfce343.0107042329.54bcd07a@posting.google.com> Message-ID: <9i1h03$20p5$1@gavrilo.mtu.ru> > > However, when I schedule SQL Server Agent to run the script, the Agent > reports the following error: > > File "C:\scripts\dailygif.py", line 26, in ? > urlretrieve(gif_url,gif_filename) > File "c:\python20\lib\urllib.py", line 68, in urlretrieve return > _urlopener.retrieve(url, filename, reporthook, data) > File "c:\python20\lib\urllib.py", line 212, in retrieve tfp = > open(filename, 'wb') IOError: [Errno 2] No such file or directory: > 'v:\\images\\dailygif\\dailygif.gif' Hint: LocalSystem account can not access resources outside local computer. > > As I said, I'm unable to repeat this error when I run the same script > from command line. The double slashes in the error-causing file path > are not of my doing (gif_filename = > 'v:\images\dailygif\dailygif.gif'). > > Any help would be greatly appreciated! Thanks. From djc at object-craft.com.au Thu Jul 12 10:15:49 2001 From: djc at object-craft.com.au (Dave Cole) Date: 13 Jul 2001 00:15:49 +1000 Subject: csv-0.4 (John Machin release) released Message-ID: <m3r8vmp71m.fsf@vole.object-craft.com.au> The CSV module provides a fast CSV parser which can split and join CSV records which have been produced by Microsoft products such as Access and Excel. For some reason on Python 2.0, it now outperforms string.split(). Of course the CSV parser can handle much more complex records than string.split()... This is a bugfix release. My thanks to Skip Montanaro for providing most of the following example: 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 The fields returned by this example are: ['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. In Microsoft created CSV files this is done by doubling them: 1,2,3,"""I see,"" said the blind man","as he picked up his hammer and saw" Excel and Access quite reasonably allow you to place newlines in cell and column data. When this is exported as CSV data the output file contains fields with embedded newlines. 1,2,3,"""I see,"" said the blind man","as he picked up his hammer and saw" A single record is 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. The changes in this release are: 1- Exception raising was leaking the error message. Thanks to John Machin for fixing this. 2- When a parsing exception is raised during parse(), the parser will automatically call clear() discard accumulated fields and state the next time you call parse(). The old behaviour can be restored either by passing zero as the auto_clear constructor keyword argument, or by setting the auto_clear parser attribute to zero. As well as raising an exception, a parsing error will also set the readonly parser attribute had_parse_error to 1. This is reset next time you call parse() or clear(). Thanks again to John Machin for suggesting this. 3- An obscure parsing bug has been fixed. The old behaviour: >>> p.parse('12,12,1",') ['12', '12', '1",'] >>> The new behaviour: >>> p.parse('12,12,1",') ['12', '12', '1"', ''] >>> I am still of two minds about whether I should raise an exception when I encounter text like that... The module homepage: http://www.object-craft.com.au/projects/csv/ For people who do not have a C compiler on Windows I have put a Python 2.1 binary up here: http://www.object-craft.com.au/projects/csv/csv.pyd - Dave -- http://www.object-craft.com.au From dave at klatu.worldonline.co.uk Wed Jul 4 14:39:45 2001 From: dave at klatu.worldonline.co.uk (Dave Stanton) Date: Wed, 04 Jul 2001 19:39:45 +0100 Subject: beginners books Message-ID: <20010704.193914.1943327684.1100@klatu.worldonline.co.uk> Hi What book (s) would people recommend for a beginner to python ?. I did some basic programming years ago and have done a lot of pic microcontroller assembler programming. Cheers Dave From thomas at xs4all.net Tue Jul 3 05:51:54 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 3 Jul 2001 11:51:54 +0200 Subject: Python for air traffic control? In-Reply-To: <20010703020254.B5005@node0.opengeometry.ca> References: <134704696.994123281122.JavaMail.root@boots> <mailman.994128604.28588.python-list@python.org> <bebbba07.0107022044.106d9da8@posting.google.com> <20010703020254.B5005@node0.opengeometry.ca> Message-ID: <20010703115154.N8098@xs4all.nl> On Tue, Jul 03, 2001 at 02:02:54AM -0400, William Park wrote: > On your original post, you came across as a high-schooler with homework. > Now, it's becoming clear... a propaganda by fucking trolls. [ snip rant ] > So, go way. You know, this is really the first time I even considered the benifits of a moderated c.l.py. And all because of one person... that scares me. I'd have thought the cynical old bastard in me would have given up its hope and belief in humanity by now. -- Thomas Wouters <thomas at xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From mwh at python.net Sun Jul 1 17:06:38 2001 From: mwh at python.net (Michael Hudson) Date: 01 Jul 2001 22:06:38 +0100 Subject: [Python-iterators] While we're at it... References: <mailman.993954541.982.python-list@python.org> Message-ID: <m34rsw1hr5.fsf@atrus.jesus.cam.ac.uk> "Tim Peters" <tim.one at home.com> writes: > [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. Quite. It's probably not going to be done by me though (I'm not going to have decent internet access over the summer, and if 2.2a1 is really going to be within ... checks ... three weeks (!?) we'd better move fast on this one). > Like, who said slice should be a generator? Maybe they want an > explicit list. Well, I was thinking that generally the iterators module would contain functions that took iterators or iteratable objects as arguments and return iterators (like the "outer" and "zip" thingies that got chucked around on python-iterators a couple of months back - and could probably now be trivially implemented as generators!). > 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. Well, if we can drum into people that iterators.blah(...) returns an iterator then these all more or less go away, don't they? Also turning an iterator into a list is a piece of piss (list(it)) whereas turning a list into an iterator is impossible. So if there's no need to materialise the list, one probably shouldn't. > 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() That can go in, then! I might have time to whip up a strawman proposal (pre-PEP?) in the next couple of days. [...] > 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. Well, it should have a few more methods I'd think. > 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. I very much agree here! Cheers, M. -- Remember - if all you have is an axe, every problem looks like hours of fun. -- Frossie -- http://home.xnet.com/~raven/Sysadmin/ASR.Quotes.html From skip at pobox.com Thu Jul 12 10:59:16 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 12 Jul 2001 09:59:16 -0500 Subject: 'import' error in csh In-Reply-To: <3B4DABBE.D176B14F@nokia.com> References: <c8fd1ef9.0107120544.20e2bec@posting.google.com> <3B4DABBE.D176B14F@nokia.com> Message-ID: <15181.47940.138512.594822@beluga.mojam.com> Joonas> That code hasn't gone thru Python interpreter, because the error message Joonas> comes from csh. Joonas> Try to fix the first line from '# !/usr/bin/local/python' to Joonas> '#!/usr/bin/local/python' or more likely: #!/usr/local/bin/python -- Skip Montanaro (skip at pobox.com) (847)971-7098 From tim at vegeta.ath.cx Mon Jul 16 00:38:01 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Mon, 16 Jul 2001 04:38:01 GMT Subject: re Challenge: More Compact? References: <3B51E6B1.47E25214@tundraware.com> <92ae279c.0107151429.398e6e9e@posting.google.com> <slrn9l4fob.p58.tim@vegeta.ath.cx> <slrn9l4rck.rlt.quinn@regurgitate.ugcs.caltech.edu> Message-ID: <slrn9l4sjj.pv9.tim@vegeta.ath.cx> Me parece que Quinn Dunkan <quinn at regurgitate.ugcs.caltech.edu> dijo: > On Mon, 16 Jul 2001 00:58:46 GMT, Tim Hammerquist <tim at vegeta.ath.cx> wrote: > >from 'Mastering Regular Expressions', p.124: > > > >'^([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.\ > >([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])$' > > How about: > > for o in '.'.split(ip_addr): > assert 0 <= int(o) <= 255, 'ip octet not a byte in "%s"' % ip_addr > > Re's can be handy, but their usefulness can trick you into trying to use them > for things for which they're not suitable. That was the point the author was making when he said "Was it worth the trouble?" (which was snipped). Also, Perler's can be as over-zealous with re's as Pythonista can be with the string module. Sometimes re's are faster, though maybe not in this case. Depends on number of function calls and so many other things. I don't think I'll benchmark it, tho. BTW: your solution allows '10.20.30.40.50'. Is this a valid IP? ;) -- 640K ought to be enough for anybody. -- Bill Gates (circa 1981) From aleaxit at yahoo.com Wed Jul 4 10:21:54 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 4 Jul 2001 16:21:54 +0200 Subject: Two problems with backslashes References: <Xns90D4A141E71CDgustaflalgonetse@194.213.69.148> Message-ID: <9hv8q4022kn@enews1.newsguy.com> "Gustaf Liljegren" <gustafl at algonet.se> wrote in message news:Xns90D4A141E71CDgustaflalgonetse at 194.213.69.148... > I have two problems with backslashes in DOS path strings: > > >>> path = 'e:\test\test.txt' That's e, colon, tab, e, s, tab, e ... each \t is an escape sequence representing a tab. You'll need to double the backslashes or use a rawstring... > >>> paths = 'e:\test\file1.txt e:\test\file2.txt' The \f's are form-feeds, I believe. As above... Alex From new_name at mit.edu Mon Jul 23 14:08:16 2001 From: new_name at mit.edu (Alex) Date: 23 Jul 2001 14:08:16 -0400 Subject: interating letters References: <9jhojp$t7h$1@solaria.cc.gatech.edu> Message-ID: <etdlmlfplgv.fsf@m2-225-11.mit.edu> You could use this: >>> chr(65) 'A' Alex. From vvainio at karhu.tp.spt.fi Mon Jul 23 01:45:01 2001 From: vvainio at karhu.tp.spt.fi (Ville Vainio) Date: 23 Jul 2001 08:45:01 +0300 Subject: Any Suggestions for an Editor with MS-Windows ? References: <92757716C8BFF476.D432477A795DB759.E2FB05E062137965@lp.airnews.net> Message-ID: <yox1yn819nm.fsf@karhu.tp.spt.fi> zeke <Zeke at xyz.net> writes: > job of bringing over some basic files (yea, right). Currently using > Ultra Edit but having doubts about it. http://www.xemacs.org/Download/win32/ Version 21.4.3 of xemacs, at least, ships with python mode as standard. With GNU Emacs, you would have to get and install the python mode yourself. Xemacs also has tons of other great stuff when compared to the gnu emacs. -- 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 tjreedy at home.com Wed Jul 25 01:43:48 2001 From: tjreedy at home.com (Terry Reedy) Date: Wed, 25 Jul 2001 05:43:48 GMT Subject: PEP0238 lament References: <5sdnlt072hm6hp17nluu6f0fqq4bvr6mj8@4ax.com> <mailman.995873261.11975.python-list@python.org> <916olt0p3kciv0evmotdg6jev9bl29l57i@4ax.com> <Xns90E77C7A1776Cjimpublishingresourc@207.126.101.100> <3B5C52EA.9430255E@alcyone.com> <cpofqaova7.fsf@cj20424-a.reston1.va.home.com> <u7kwxki4i.fsf@ctwd0143.fitlinxx.com> Message-ID: <o0t77.26820$EP6.6648839@news1.rdc2.pa.home.com> > Could we also at least keep in the fray a slightly alternate question > of "what can we do about the PEP"? I mean, as has been suggested > elsewhere at times, one solution to the old code is not to break it - > using "//" (or some other sequence) as the float division is backwards > compatible (no current code using it) and can be introduced at any > time for new code to use. It wouldn't even need a lengthy period, but > could show up right in 2.2. > > It seems to me that the only real argument against that is aesthetics, > or am I missing something. Perhaps. 1. PEP238 introduces *two* new meanings to replace the current meaning, so the alternative some have asked for is not merely a matter of switching. 2. This change is the one arithmetic change Guido needs, and in the core and in the form proposed, for his dream project -- CP4E. This proposal is the first change of its type. I hope and expect it will be the last for years to come. Terry J. Reedy From peter at engcorp.com Fri Jul 27 02:27:47 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 27 Jul 2001 02:27:47 -0400 Subject: Ints and performance (was Re: PEP0238 lament) References: <mailman.996211014.7234.python-list@python.org> Message-ID: <3B6109E3.624BE2B0@engcorp.com> Tim Peters wrote: > > [Peter Hansen] > > The interpreter currently has direct support for the most-used > > integer operations, thus ensuring that this type has performance > > reasonably close to the maximum feasible given the nature of > > virtual machines. > > Actually not close at all. In, e.g., > > k = i + j > > we spend a lot more time fiddling with reference counts and memory > management than doing the arithmetic! But we'll ignore that since you're > already happy <wink>. Well, I knew all that of course, which is what I meant with "given the nature of virtual machines" (which have to do all those extra goodies which make them so worthwhile). I meant there is a spot reasonably close to the identification of the bytecode operation where the integer operation is actually performed. So close, in fact, that it is right in the interpreter core itself very much like you might inline critical code with C macros. This is in contrast to all other types (actually, I don't have the source in front of me, but do I recall floats being optimized in the same way?) which end up executing the actual operation (in C for builtins) way, way down the chain after a horrendous series of indirections, virtual methods, dictionary lookups, and so on (implemented in wonderfully elegant and rather efficient-looking code I readily agree). > > Would the number system unification imply that this integer > > optimization would be eliminated? > > BTW, Python got along fine for years without any integer optimizations at > all, but I agree that specialing-casing int + - and compares in the eval > loop was a clear net win (for which you can, IIRC, thank Fredrik Lundh). Thank you, Fredrik! :-) That is my point, though. These integer optimizations are, as we agree, a clear win. Are these optimizations in danger of being impacted as a result of this unification, or will we still be able to count on integer performance being significantly better than that of less frequently used types. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From michael at stroeder.com Tue Jul 10 09:09:33 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Tue, 10 Jul 2001 15:09:33 +0200 Subject: Python: Database to Web Part II (and "teaching language") References: <5174eed0.0107060820.ff90805@posting.google.com> <yox66d25zkd.fsf@karhu.tp.spt.fi> <23891c90.0107090815.3685a9@posting.google.com> <14m27.2182$z21.428719@newsc.telia.net> <23891c90.0107100440.2eb444af@posting.google.com> Message-ID: <3B4AFE8D.DE1F6563@stroeder.com> Paul Boddie wrote: > > Can the open source > movement include everyone, or is it inherently elitist? Since you asked: The latter. Ciao, Michael. From new_name at mit.edu Fri Jul 27 01:20:53 2001 From: new_name at mit.edu (Alex) Date: 27 Jul 2001 01:20:53 -0400 Subject: Language change and code breaks References: <mailman.996208009.24941.python-list@python.org> <Xns90EB99AB31ADBatodddexterpinioncom@203.2.194.51> Message-ID: <etditgf0wy2.fsf@lola-granola.mit.edu> I just did a search for 'government' and got the same message, so it may be referring to the search service, rather than the python service. or-maybe-the-libertarians-get-to-see-their-ideas-in-action-ly yr's Alex. From claird at starbase.neosoft.com Mon Jul 30 09:21:45 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 30 Jul 2001 08:21:45 -0500 Subject: Large-scale Python (was: Language Niches (long)) References: <8beb91f5.0107280407.5a30341d@posting.google.com> <mailman.996429234.13926.python-list@python.org> <Ej5QPKA1WHZ7EwvP@jessikat.fsnet.co.uk> <mailman.996442753.17197.python-list@python.org> Message-ID: <C2D62BF6D2E4F577.D8696582805EEB21.2093367A0D5F09C4@lp.airnews.net> In article <mailman.996442753.17197.python-list at python.org>, Paul Prescod <paulp at ActiveState.com> wrote: . . . >Python are certainly not mature. In particular, many people use Python >today in radically different ways than they would have five years ago >(in particular much bigger projects). They make certain demands on . . . This illustration interests me. Without contesting any of Paul's larger points, what are the facts here? I believe: * Python is good for team-work and big projects; and * There is increasing recogni- tion and use of Python in this role. What role has "language change" played in this, though? I don't think Python's syntax or semantics support modularization and packaging significantly better than in '96 (Paul, do you have a Jython point in mind?). Does performance improvement in hardware which makes raw speed less frequently a constraint constitute a "language change"? -- Cameron Laird <claird at NeoSoft.com> Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From sholden at holdenweb.com Tue Jul 31 07:54:55 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 31 Jul 2001 07:54:55 -0400 Subject: Non-Programmers (was: Changing the Division Operator) References: <mailman.996556736.30160.python-list@python.org> <m3k80piax2.fsf@kepler.ibp.de> Message-ID: <XZw97.5001$9i1.471725@e420r-atl1.usenetserver.com> <markus at kepler.ibp.de> wrote in message news:m3k80piax2.fsf at kepler.ibp.de... > Bruce Sass <bsass at freenet.edmonton.ab.ca> writes: > > > In this context, it comes from the CP4E motivation that people may be > > called upon to script operations or interactions between their > > `toys'... calling them "non-programmers" is shorter than saying, > > `people who may need to program without knowing they are doing it' > > (imo). > > We obviously need a good name. > > Maybe 'non-professional programmers'? Doesn't sound right. It should > mean someone whose profession is something else and who has to write > some code to get the work done. Something like the work of system > administrators, who may have to write some code but whose programs > probably will never run on other machines than those which they > administrate. > > Perl is called a 'glue language', so should we call the work of system > administrators and other 'non-programmers' as 'glue programming'? > Sounds strange, but at least it is new. > > Any ideas? > > How about "incidental programmers", since the programming is largely incidental to the real goals of their activities? regards Steve -- http://www.holdenweb.com/ From niemeyer at conectiva.com Tue Jul 31 19:24:41 2001 From: niemeyer at conectiva.com (Gustavo Niemeyer) Date: Tue, 31 Jul 2001 20:24:41 -0300 Subject: 2.2 features In-Reply-To: <200107312309.TAA17435@cj20424-a.reston1.va.home.com>; from guido@zope.com on Tue, Jul 31, 2001 at 07:09:43PM -0400 References: <cpofq524lr.fsf@cj20424-a.reston1.va.home.com> <slrn9m61bs.atb.quinn@retch.ugcs.caltech.edu> <slrn.pl.9m6a5m.kmu.qrczak@qrnik.zagroda> <cpae1lzio7.fsf@cj20424-a.reston1.va.home.com> <15206.48884.18637.676324@beluga.mojam.com> <200107311705.NAA16444@cj20424-a.reston1.va.home.com> <15206.61485.360973.566871@beluga.mojam.com> <200107311904.PAA17115@cj20424-a.reston1.va.home.com> <15207.1733.965818.91745@beluga.mojam.com> <200107312309.TAA17435@cj20424-a.reston1.va.home.com> Message-ID: <20010731202441.M19610@tux.distro.conectiva> > Ah, but there you're wrong. Classes are also instances (of the > metaclass), and when we don't know anything about an object X, after > knowing that "X in Foo" is true, we would still not know whether X was > a Foo subclass or a Foo instance. Very different beasts. I'm starting to like the is{subclass,instance}() version. It's probably quicker for one to understand code written by others, and for non-fulltime-python-programmers to remember what "in" means in each context. -- Gustavo Niemeyer [ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ] From brakedon at hotmail.com Mon Jul 9 11:40:58 2001 From: brakedon at hotmail.com (eric_brake) Date: 9 Jul 2001 08:40:58 -0700 Subject: Make an *.EXE Using Python. References: <oAI17.647550$166.13393459@news1.rdc1.bc.home.com> <7b515e0f.0107081724.56b2a434@posting.google.com> <OT927.657477$166.13612439@news1.rdc1.bc.home.com> Message-ID: <7b515e0f.0107090740.6d7fb9f0@posting.google.com> "EricIDLE" <grayson-wilson at home.com> wrote in message news:<OT927.657477$166.13612439 at news1.rdc1.bc.home.com>... > I just used the one off the py2exe website it is as follows. > > # setup.py > from distutils.core import setup > import py2exe > > setup(name="test", > scripts=["test.py"], > ) > > Is that bad or whats the story? No, if it works then use it, but there won't be any meta info (if you even care about that) From BMichielsen at compuserve.com Sat Jul 21 09:15:05 2001 From: BMichielsen at compuserve.com (Bas Michielsen) Date: Sat, 21 Jul 2001 15:15:05 +0200 Subject: Don't understand this "method mapping" Message-ID: <3B598059.42027565@compuserve.com> ## Hello, ## I am a beginner with Python and I don't understand why in the code below ## the attribute `map' first represents Curve.linear which also ## points to the external function linear and then, after calling set_map, ## is simply the external function linear for a Curve object. ## I had expected that calling Curve.linear would be signalled as an ## attribute error because there is no method linear in class Curve or ## otherwise that the two ways to initialise the map attribute would be ## equivalent??? ## ## Is somebody able and willing to explain this to me, def linear( x_in, a=0): # a=0 is a stub to get past an error condition print "linear called, a =", a return x_in class Curve: map = linear def use_map( self, x): print "Using self.map = ", self.map self.y = self.map( x) def set_map( self): self.map = linear # Test code (I am running Python 1.5.2) c = Curve() print c.map c.use_map( 1.0) print c.y c.set_map() c.use_map( 1.0) print c.y ## # Output produced by the above ## <method Curve.linear of Curve instance at 80c7380> ## Using self.map = <method Curve.linear of Curve instance at 80c7380> ## linear called, a = 1.0 ## <__main__.Curve instance at 80c7380> ## Using self.map = <function linear at 80b6dd0> ## linear called, a = 0 ## 1.0 -- Bas Michielsen 14, avenue du Corail 31650 St. Orens de Gameville France From bokr at accessone.com Sun Jul 29 18:20:09 2001 From: bokr at accessone.com (Bengt Richter) Date: Sun, 29 Jul 2001 22:20:09 GMT Subject: [OT] Number theory [Was: A use for integer quotients] References: <yCK67.17615$EP6.4467503@news1.rdc2.pa.home.com> <mailman.995860718.9550.python-list@python.org> <mailman.995862939.15013.python-list@python.org> <mailman.995883879.12071.python-list@python.org> <3B5C5665.8D41D1F1@tundraware.com> <slrn.pl.9los0f.jh4.qrczak@qrnik.zagroda> <3B5C749A.59F97320@tundraware.com> <JDa77.97061$Rr4.549007@ozemail.com.au> <Xns90E97C9849AD5robindotgarneratinam@172.18.25.3> <IjA77.97824$Rr4.589251@ozemail.com.au> <3b602afa.930850@nntp.sprynet.com> <slrn9m121m.e6f.Gareth.McCaughan@g.local> <3b617133.1013412@nntp.sprynet.com> <slrn9m3ssq.1c5.Gareth.McCaughan@g.local> <3b62c8c4.2448381@nntp.sprynet.com> <slrn9m61e6.1jof.Gareth.McCaughan@g.local> <3b6409e0.2079581@nntp.sprynet.com> Message-ID: <3b645f76.747435355@wa.news.verio.net> On Sun, 29 Jul 2001 13:14:12 GMT, ullrich at math.okstate.edu (David C. Ullrich) wrote: >On Sat, 28 Jul 2001 19:34:46 +0100, Gareth.McCaughan at pobox.com (Gareth >McCaughan) wrote: > and >>David Ullrich wrote: >> [...lots of set stuff...]> >>This has long ceased to have anything to do with Python. >>I suggest that we take it to e-mail or drop it entirely. > >Simply dropping it seems the sensible option, since >neither of us is actually saying anything the other >doesn't know - my original butting in was a just for >the record thing. > >(Did they change the rules recently? Don't recall >relevance to Python being a criterion here...) > >>(But if you prefer continuing in c.l.py, I don't mind.) > Something that might be relevant to Python: I have been using bit twiddling operators and arithmetic operators for decades, mostly putatively on things referred to as two's complement integers, represented by an ordered sequence of bits, but also other entities. ISTM that thinking of bit twiddling as operating on integers is not clean conceptually. I.e., I think there is an implicit coercion to a set type for the twiddle operation and then implicitly back to integer again when supposedly twiddling two integers with a binary twiddling operation (same for unary, of course). ISTM if i an j were taken as integers per se, 'i | j' would create a set of two integers. Obviously the '|' operation is not referring to the integers as integer-set members. I think that ought to be made clear, but I am not sure about the best way to talk about what's really happening. I'm grasping after something about ordered-binary-coefficient-set-ordinal sets, or something like that, I think. More below ;-) PEP 218 introduces sets to the language. I think it would be good to say something there too about integers-as-sets (and maybe have explicit conversions to/from integers, and ordered sequences of integers such as convert nicely to strings) (I am sending a Bcc to the author gvwilson at ddj.com, in case he's interested in this). If some paragraphs on this belonged in the docs (by URL link ;-) where bit twiddle operations are explained, it sounds like you guys would be the ones to get it officially right. (Or immediately know an existing reference ;-) BTW, I got to thinking about this because of a post mentioning the '<<' operator as being uniquely bit twiddling in nature. Yet ISTM it really does have an aritmetic meaning as well, i.e., '*2**' and '<<' are often interchangeable in code, and both senses are used (even if sometimes intended in the alternate sense ;-). So what is the best way to talk about a binary-represented integer in the abstract? A vector of coefficients for radix powers doesn't evoke the usages that ignore the radix powers, i.e., treating 1-or-0 coefficients as existence booleans for set elements identified by position number (or *being* position number). BTW, note the usefulness of boolean-as-integer returned from comparison operators, if you want to be picky about plurals: print "There %s %d error%s." % ( ['were','was'][n==1], n, 's'*(n!=1) ) Sets seem a lot like dictionaries with values restricted to true/false. Less generally, don't-care/no-key is sometimes useful. You could convert an integer into a dictionary of bitposition:bitvalue pairs and back pretty reliably, so an integer could have a standard conversion to a dictionary. Of course, you would probably hide the implementation for efficiency ;-) You could do a dictionary for numbers with non-binary radix, revealing that you really have radixPower:coefficient pairs, and in the binary case are using the pairs in an elementId:existence sense. Side thought: You could write a Python program for addition etc. that would operate on integers represented as sets. I wonder if this sort of thing could help students understand what is going on in the hardware. Serial adder as set comprehension? Time flies when you're having fun ('cause timing flies is a real nuisance if you aren't having fun ;-) From ransen_spam_me_not at nemo.it Fri Jul 20 23:35:29 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Sat, 21 Jul 2001 03:35:29 GMT Subject: KeyboardInterrupt References: <3b57e9e8.1285896@news.newsguy.com> <3B581A4F.381F3072@engcorp.com> Message-ID: <3b5a8e2f.323275@news.newsguy.com> >> How can I get my program to be more responsive to control-C? > >This could be a platform-dependent issue. > >Are you by any chance running on Win2K? No Windows 98. It really does not seem to respond at all unless I am print() ing something... -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From peter at engcorp.com Thu Jul 12 21:26:00 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 12 Jul 2001 21:26:00 -0400 Subject: How popular is Python, anyway? (was: Long Live Python!) References: <E566B020833BD311B6610008C791A39705CA5230@il93exm04.css.mot.com> <mailman.994804336.23495.python-list@python.org> <slrn9koofo.mjk.philh@comuno.freeserve.co.uk> <slrn9kpr3e.527.sill@sill.silmarill.org> <Gzj37.13006$B7.2564502@ruti.visi.com> Message-ID: <3B4E4E28.719ACE57@engcorp.com> Grant Edwards wrote: > > In article <slrn9kpr3e.527.sill at sill.silmarill.org>, Rainy wrote: > > >I doubt I'll find a job using python any time soon. :/ > > Probably not if you wait around for management to tell you to > start using it. > > I use Python on my job because I decided to. I'm probably > luckier than most when it comes to being able to choose my > tools. Even if one is not officially "allowed" to use Python on a project, there's nothing stopping one from following the recommendation often seen here, of using Python to prototype a solution and debug an algorithm, and then to port the result to the mandated target language. After one's productivity and morale goes up significantly for no apparent reason, it might not be quite as hard to advocate a more official role for Python... There's also always the slight more devious ("guerrilla") approach of writing useful utilities in your own time (you know, the extra ten to twenty unpaid hours a week you spend at work) which then are surreptitiously integrated into the work environment (maybe using py2exe to disguise them :), at which point it becomes difficult for management to justify rewriting them all and poof, Python is an official part of the scenery. (This latter is difficult to do if you have a manager like me, who rigorously controls the languages used for all development and has periodically demanded that certain newly developed small tools be rewritten in the official languages. Of course, if you have a manager like me, I'm asking you to rewrite Perl code in Python anyway, so maybe it's not a problem. :) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From quinn at yak.ugcs.caltech.edu Tue Jul 3 20:04:48 2001 From: quinn at yak.ugcs.caltech.edu (Quinn Dunkan) Date: 4 Jul 2001 00:04:48 GMT Subject: PyArg_Parse Message-ID: <slrn9k4ncv.f00.quinn@yak.ugcs.caltech.edu> This is a bit of a silly question, but where is PyArg_Parse documented? I've checked the source, the faq, and the C api manual, and no luck. Reading module source is sort of risky because there seems to have been several different versions and syntaxes for PyArg_* over the years. Also, the intro to the "utilities" chapter for the api manual should probably be altered to be less misleading. It currently says: The functions in this chapter perform various utility tasks, such as parsing function arguments and constructing Python values from C values. In fact, the functions in that chapter do neither of those things. thanks From vAbazarov at dAnai.com Fri Jul 27 11:30:59 2001 From: vAbazarov at dAnai.com (Victor Bazarov) Date: Fri, 27 Jul 2001 15:30:59 GMT Subject: Unusual minidom behaviour: Part Deux References: <vKJ77.12050$Up.355596@sea-read.news.verio.net> <j4lmlcglpm.fsf@informatik.hu-berlin.de> <cpu1zz7pve.fsf@cj20424-a.reston1.va.home.com> <%_W77.12073$Up.356411@sea-read.news.verio.net> <j48zhah4ib.fsf@informatik.hu-berlin.de> Message-ID: <TOf87.5470$Kd7.2901996@news1.rdc1.sfba.home.com> "Martin von Loewis" <loewis at informatik.hu-berlin.de> wrote... > "Victor Bazarov" <vAbazarov at dAnai.com> writes: > > > The system that tries to use some XML files is written in Python > > and is being run from under a Java application. In the system > > something (that looks like a deadlock) happens when two threads > > both need to parse (each its own) XML file. > > When you say "thread" here, do you mean "Java thread" or "Python > thread"? I assume you mean "Java thread", since you did not indicate > at all that you are using threads in your Python application. Don't assume. I don't mean Java thread, otherwise I would be asking in a Java forum. > Note that when you call Java's Runtime.exec, you create a new > operating system process. So when two Java threads simultaneously > invoke Runtime.exec, you end up with two operating system processes, > each running a separate Python interpreter - not with a single Python > interpreter running two threads. > > Can you please confirm that this is the situation you are confronted > with? No, sorry, I can't confirm. It's one Python interpreter running multi-threaded Python application. I do believe the problem to be with Python multithreading code (and not even with our Python code). Why it shows up when run under Java, I don't know. But symptoms are very similar to what was talked about in another thread (no pun intended) here. See "Threads in Python version 1.5, thread doesn't start until calling process dies". > > Both call 'parse' from 'minidom' package, which leads to an attempt > > to __import__ the xml.sax.expatreader. > > Assuming that [...] Thanks. Wrong assumption, though. Victor -- Please remove capital A's from my address when replying by mail From thomas at xs4all.net Mon Jul 2 03:22:39 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 2 Jul 2001 09:22:39 +0200 Subject: [Python-iterators] While we're at it... In-Reply-To: <B43D149A9AB2D411971300B0D03D7E8B0FC21D@natasha.auslabs.avaya.com> References: <B43D149A9AB2D411971300B0D03D7E8B0FC21D@natasha.auslabs.avaya.com> Message-ID: <20010702092239.L8098@xs4all.nl> On Mon, Jul 02, 2001 at 11:03:18AM +1000, Delaney, Timothy 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. > def iter_map (f, seq): > > def iter_map_generator (f=f, seq=seq): > for o in seq: > yield f(o) > return iter_map_generator() While this makes a technical difference, the result is exactly the same. It's just slower :-) The first example (iter_map, the generator) shows exactly why 'yield' isn't magic and a generator should be defined using 'def': all you need is 'yield' instead of 'result.append()' and you magically do the right thing :-) -- Thomas Wouters <thomas at xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From peter at engcorp.com Sat Jul 14 08:59:10 2001 From: peter at engcorp.com (Peter Hansen) Date: Sat, 14 Jul 2001 08:59:10 -0400 Subject: How to run codeobjects in Python? References: <mailman.995024902.7812.python-list@python.org> <9imphr015u5@enews1.newsguy.com> <3B4FBBD8.45F56742@engcorp.com> <9iorv60pj2@enews4.newsguy.com> Message-ID: <3B50421E.F00DBFD@engcorp.com> Alex Martelli wrote: > > "Peter Hansen" <peter at engcorp.com> wrote [...]: > > Alex, please consider moving closer to the Eastern Standard timezone > > so that you may answer my questions more quickly. What's so special > > about Italy anyway? > > Pasta, of course. You guys can claim your pizza is as good as Italy's > (I'd disagree, but there IS space for debate), but our pasta is still > nonpareil -- people who decry spaghetti coding don't know what > they're blabbering about! Ah, but where I live we have maple syrup and, not to far down the road (hi Montreal), poutine. Now _there's_ a fine cuisine... ;) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From fcnpereira at home.com Sat Jul 14 15:09:33 2001 From: fcnpereira at home.com (Fernando Pereira) Date: Sat, 14 Jul 2001 19:09:33 GMT Subject: How to run codeobjects in Python? References: <mailman.995024902.7812.python-list@python.org> <9imphr015u5@enews1.newsguy.com> <3B4FBBD8.45F56742@engcorp.com> <9iorv60pj2@enews4.newsguy.com> <3B50421E.F00DBFD@engcorp.com> <9ipkp501mop@enews4.newsguy.com> Message-ID: <140720011509328399%fcnpereira@home.com> In article <9ipkp501mop at enews4.newsguy.com>, Alex Martelli <aleaxit at yahoo.com> wrote: > The latest issue of the Economist magazine has an in-depth survey > of Italy, and, to balance out the fact that it's mostly about the > woes and challenges of our economics & politics, it starts out > with a Paean titled "What a lovely off place!" "Off place" intimates some kind of putrefaction (of the political system?). "Odd place" as in the original is less scary <wink> -- F From peter at engcorp.com Mon Jul 16 21:27:18 2001 From: peter at engcorp.com (Peter Hansen) Date: Mon, 16 Jul 2001 21:27:18 -0400 Subject: Most efficient solution? References: <mailman.995289809.28477.python-list@python.org> <9iv38i0ppd@enews2.newsguy.com> <mailman.995305828.11815.python-list@python.org> Message-ID: <3B539476.B31A639E@engcorp.com> William Park wrote: > On Mon, Jul 16, 2001 at 06:03:27PM +0200, Alex Martelli wrote: > > "Jay Parlar" <jparlar at home.com> wrote: > > ... > > > for eachItem in A: > > > if eachItem in B: > > > A.remove(eachItem) > > > > > > Now, this will work fine, > > > > Are you sure about that? Normally, modifying the list > > you're iterating on does NOT work fine. > > Good point. Most of us knew what he meant, though. (Yeah, but only Alex knew that what he meant was wrong...) I find humour (and humor) in these discussions, on several fronts. 1. Python appears to be a language with an incredibly wide range of potential optimizations. The generic "vanilla" idiom (is that triply redundant?) posted by many people often appears to be very similar, in comparison to other languages (the likely source of the "one way to write it" mantra). As refactoring goes on, the performance probably improves several orders of magnitude. 2. These are wonderful examples of just how many excellent programmers can post incorrect code. Sure, relatively little time was spent developing it or, obviously, testing it before posting. Still it should serve to spread a little humility on us all. 3. We certainly talk a lot about "one way to write it", but obviously Python does allow several ways in most cases. It seems to split roughly between the "most obvious" (probably only for us newcomers) and the map/filter/lambda/list comprehension style which is obviously second nature for some and entirely outside of the experience of others. This ties back to (1), suggesting that learning more about these builtins is one of the best ways to optimize (working) Python code. 4. Pythonistas spend too much time writing working code, so they obviously need an "optimization fix" from this newsgroup from time to time! :-) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From zawy at oxiqi.net Sun Jul 29 15:16:14 2001 From: zawy at oxiqi.net (Walter Dupuis) Date: Sun, 29 Jul 2001 19:16:14 GMT Subject: Let's exclude behind the usable printers, but don't burst the lost opinions. Message-ID: <E71BD296.CE8FA110@oxiqi.net> When will you authenticate the clear slow emails before Grover does? I'd rather kick compleatly than close with Jimmie's sly warning. My minor Java won't defile before I dig it. The bug unbelievably builds the idle IRC server. One more hard spool or room, and she'll inadvertently defeat everybody. The flat messy advertisement shoots over Walter's sticky firewall. What did James transport to all the librarians? We can't learn robots unless Eddie will regularly load afterwards. Go persevere a FORTRAN! The insecure modem rarely disconnects Pamela, it questions Terrance instead. From sholden at holdenweb.com Mon Jul 9 20:29:20 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 9 Jul 2001 20:29:20 -0400 Subject: Python Idiom Question References: <3B4A4126.7AD3CDD0@tundraware.com> Message-ID: <8Zr27.2394$vA6.115437@e420r-atl1.usenetserver.com> "Tim Daneliuk" <tundra at tundraware.com> wrote in ... > What is the equivalent python idiom to the following 'C' code: > > while (x=getchar() != 'N') > { > Do something} > > In other words, is there a convenient way to simultaneously get > input, from say, raw_input() or f.read(), and check the return > value agains some logical construct, re pattern match, or whatever? > > I'm sure this is possible, I just cannot seem to find the magic > combination that gets me there. Nothing seems to turn up when I > look in the Usual Places, but then again, I may not be Lookin' Right. > > At the moment, I'm doing things like: > > x=raw_input() > while x: > Do Something Interesting > x = get_input("Prompt: ") > The approved idiom is x = raw_input() while 1: if not x: break DoSomethingInteresting() However, you may be aware that iterators and generators will shortly make their appearance in a programming language near you, and this might allow some other technique. You might want to look at FAQ 6.30, "Why can't I use an assignment in an expression" for the rationale. regards Steve -- http://www.holdenweb.com/ From rnd at onego.ru Wed Jul 4 00:16:44 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 4 Jul 2001 08:16:44 +0400 (MSD) Subject: Newbie Radiobutton question In-Reply-To: <a5d3ff08.0107031901.33157db9@posting.google.com> Message-ID: <Pine.LNX.4.30.0107040803400.6839-100000@rnd.onego.ru> On 3 Jul 2001, Rick Olson wrote: >Hi-- > >I'm trying to run the following from IDLE: > from Tkinter import * root=Tk() x=IntVar() x.set(2) Radiobutton(root, text='a',value=1,variable=x).pack(anchor=W) Radiobutton(root, text='b',value=2,variable=x).pack(anchor=W) # What about adding root.mainloop() saving this program as something.py and trying this as a program _not from IDLE_? (IDLE is made in TK and probably there is not enough isolation between it and programs it runs) >With Red Hat Linux (Python 1.5.2, IDLE .4) it runs fine the first >time. I get the window and the second radio button is selected. If I >close the window and try to run it again by immediately clicking on F5 >the window and buttons appear, but nothing is selected. If I click on >the buttons they work properly. Even closing the window with the >program, reopening the file and running won't cause the buttons to be >selected. I need to close IDLE, and restart it. > > > >With Win2K (Python 1.6.1, IDLE .6) it runs every time. > > > >I'm a linux neophyte, but will figure out how to upgrade whatever is >necessary. Is this a Python problem, and IDLE problem, a Red Hat >problem or a user problem? Is there anything else that I am likely >to need to change (e.g. tcl installation)? > > >Thanks in advance-- > >Rick Olson > Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Wednesday, July 04, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Mediocrity requires aloofness to preserve it's dignity" _/ From aleaxit at yahoo.com Fri Jul 13 06:28:12 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 13 Jul 2001 12:28:12 +0200 Subject: Regural expression puzzle for gurus References: <3B4EA0C8.9F697D06@vip.fi> Message-ID: <9imift0qqr@enews1.newsguy.com> "Pekka Niiranen" <krissepu at vip.fi> wrote in message news:3B4EA0C8.9F697D06 at vip.fi... > I have a string in the middle of a text starting with #-sign and ending > to \W. > I can find it with re.compile('#\w+') and would like to replace it by > adding a > # -sign also to the end of it. > > Example: > > original string: xx:yy:#AAA.!:-#BBB:2324:#CCC:!"?% > > after replacement: xx:yy:#AAA#.!:-#BBB#:2324:#CCC#:!"?% > > How can I do replacement with a single regural expression line ? > > I have found a solution like: > text = 'xx:yy:#AAA:-#BBB:aa' > line = re.compile('#\w+') line = re.compile('(#\w+)') text = line.sub(r'\1#', text) should do what you want. The parentheses around the re's pattern define a group, the \1 in sub backreferences to the group (in many contexts "group 0" can be used to mean the whole substring matched, but, I believe, not here, so I don't think you can avoid the parentheses in the pattern). Alex From duncan at NOSPAMrcp.co.uk Thu Jul 26 06:44:05 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Thu, 26 Jul 2001 10:44:05 +0000 (UTC) Subject: 2.2 features References: <mailman.996098094.16930.python-list@python.org> <l_P77.559300$eK2.117135519@news4.rdc1.on.home.com> Message-ID: <Xns90EA74D4A27F2duncanrcpcouk@127.0.0.1> "Nick Perkins" <nperkins7 at home.com> wrote in news:l_P77.559300$eK2.117135519 at news4.rdc1.on.home.com: > assert type(num) is int > assert type(msg) is str > > ( I assume the use of 'is', rather than '==', is acceptable here ) > > ..much prettier. > Prettier, but now you can subclass builtin types you may want isinstance instead: assert isinstance(collection, dictionary) -- 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 sholden at holdenweb.com Sun Jul 8 16:29:59 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sun, 8 Jul 2001 16:29:59 -0400 Subject: Q: Duplicating Objects ... HOW ??? References: <9ia0ru$80k$1@sun.rhrk.uni-kl.de> <etd7kxjcp8x.fsf@pickled-herring.mit.edu> <Uh327.14798$i8.1312190@e420r-atl3.usenetserver.com> Message-ID: <Nl327.20471$F%5.1437375@e420r-atl2.usenetserver.com> "Steve Holden" <sholden at holdenweb.com> wrote in message news:Uh327.14798$i8.1312190 at e420r-atl3.usenetserver.com... > "Alex" <new_name at mit.edu> wrote in message > news:etd7kxjcp8x.fsf at pickled-herring.mit.edu... > > > > You may be happier in the long run keeping the sequence of test objects > > in a sequence, like a list. You could do something like this: > > > > import copy > > test_list = [copy.copy(obj) for obj in 20*[test]] > > > Or, possibly, in a dictionary: > > dict = {} > for i in range(1,21): > dict[test+str(i)] = copy.copy(obj) > Sorry, read that last as dict["test"+str(i)] = copy.copy.(obj) From dsavitsk at e-coli.net Thu Jul 12 15:00:25 2001 From: dsavitsk at e-coli.net (doug s.) Date: 12 Jul 2001 12:00:25 -0700 Subject: dictionary speed Message-ID: <41899b99.0107121100.7b2c2cdc@posting.google.com> hi all, is there any speed differential to be aware or with nested dictionaries? that is, does the position of data matter. for example, if i need to access certain data quickly and often, is it best to structure things so that it is all near the top level? thanks, doug From jkraska1 at san.rr.com Wed Jul 4 11:50:25 2001 From: jkraska1 at san.rr.com (Courageous) Date: Wed, 04 Jul 2001 15:50:25 GMT Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <9htgsb$ck3@news1.gtech.com> <9huo4n01jfl@enews1.newsguy.com> <slrn9k605n.esf.jajvirta@sirppi.helsinki.fi> <9hv9pl$5c7$1@panix6.panix.com> Message-ID: <56f6kt4goieognhbpi8i8kh4v79egmtaa2@4ax.com> >>b) Very good professional programmers are ten times as productive as >> poor ones, at same training and two-year experience level. >> (Sackman, Grant and Erickson) I agree with this wholeheartedly, with the exception that I would change it to "Highly motivated and very good professional...". Motivation and a willingness to really throw oneself into programming is an essential element of a real programming maverick. C// From othello at javanet.com Fri Jul 20 15:31:44 2001 From: othello at javanet.com (Raymond Hettinger) Date: Fri, 20 Jul 2001 15:31:44 -0400 Subject: The unPEP: List-Tuple Unification References: <3B586A1E.B037349D@javanet.com> <aTZ57.5911$qh7.379822@e420r-atl2.usenetserver.com> <3B587279.A225AC51@javanet.com> <%3%57.7717$m11.427739@e420r-atl1.usenetserver.com> Message-ID: <3B588720.83400FB5@javanet.com> Steve Holden wrote: > "I don't > see why immutability has to be a one-way attribute when converiosn between > list and tuple is so easy. > > regards > Steve Dictionary's rely on immutability of keys. If the list is used as a key, then it cannot be subsequently assigned to without breaking the key reference. Also, immutability can be an important internal optimization. Once made immutable, the list can be fixed length, stored as an array, and hashed once and for all. tuples-who-needs-them-ly, yours Raymond From vvainio at karhu.tp.spt.fi Thu Jul 26 01:17:12 2001 From: vvainio at karhu.tp.spt.fi (Ville Vainio) Date: 26 Jul 2001 08:17:12 +0300 Subject: control-C not responding, short example program References: <3b5d7220.664033@news.newsguy.com> <yoxhew1zejh.fsf@karhu.tp.spt.fi> <3b5f0932.2397984@news.newsguy.com> Message-ID: <yoxsnfkw9pj.fsf@karhu.tp.spt.fi> ransen_spam_me_not at nemo.it (Owen F. Ransen) writes: > >What about the good old control-break? > > Nope don't work. :( Yep, I noticed the same thing yesterday when I had to test a script on win95. Control-break is usually (almost always) stronger than control-C, so I assumed it might work. -- 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 Henning at 3s-hanusa.de Sat Jul 7 06:28:28 2001 From: Henning at 3s-hanusa.de (Henning Hanusa) Date: Sat, 7 Jul 2001 12:28:28 +0200 Subject: Newbie Help -- Python 2.1 - MySQL-python-0.9.0 Message-ID: <9i6oce$tbe$1@news.online.de> i'm a newbie to installing Python packages: using ActiveState Python 2.1.0.211 and want to inistall MySQL-python-0.9.9-win32-2. cannot do with the descritption (sorry) - any hints please thx Henning From dale at riverhall.NOSPAMco.uk Mon Jul 30 08:53:41 2001 From: dale at riverhall.NOSPAMco.uk (Dale Strickland-Clark) Date: Mon, 30 Jul 2001 13:53:41 +0100 Subject: Loaded module list and attributes Message-ID: <o2mamt4qtis8r77maqnsmjg7h193aa80t4@4ax.com> How do I itterate through all the loaded modules and find the name of the module and a value of a local attribute (__version__ in this case)? I'm writing a small debugging routine and Python internals are still a bit of a black box to me. Thanks. -- Dale Strickland-Clark Riverhall Systems Ltd From donn at drizzle.com Mon Jul 23 00:06:30 2001 From: donn at drizzle.com (Donn Cave) Date: Mon, 23 Jul 2001 04:06:30 -0000 Subject: PEP0238 lament References: <3B5B3676.40F39389@alcyone.com> <mailman.995826216.11537.python-list@python.org> <eppstein-03540D.13070222072001@news.service.uci.edu> <mailman.995836120.7223.python-list@python.org> <220720011959361323%jwbaxter@spamcop.com> Message-ID: <995861189.362184@yabetcha.drizzle.com> Quoth "John W. Baxter" <jwbaxter at spamcop.com>: ... | By the way, in .../lib/module-math.html (I keep my own copy on my end | of my 56K frame connection), it is not stated whether the input to | sin() (and the others where it applies) is degrees or radians. An | experiment is necessary, or a reference to my rapidly waning C | knowledge or a visit to the C standard (which I'd rather not do, for | reasons of marginal sanity). | | >>> math.sin(1) | 0.8414709848078965 | | is a conclusive experiment...which I had to run before making the "also | unlikely" claim. Right! and I don't think it's what the common folk expect either. Someone should write up a PEP to change these functions to take degrees (not on my account, but it would seem to be a potential stumbling block for the uninitiated, wouldn't it?) Donn Cave, donn at drizzle.com From rnd at onego.ru Thu Jul 5 05:47:37 2001 From: rnd at onego.ru (Roman Suzi) Date: Thu, 5 Jul 2001 13:47:37 +0400 (MSD) Subject: Python for air traffic control? In-Reply-To: <bebbba07.0107042341.4283ca43@posting.google.com> Message-ID: <Pine.LNX.4.30.0107051339400.17954-100000@rnd.onego.ru> On 5 Jul 2001, Russ wrote: >> There are studies that indicate that productivity in strongly typed >> languages is higher (2:1 in one study I read - unfortunately, they are >> "thin" on the ground because you need two identical ability teams doing the >> same application in two different languages to get meaningful comparisions - >> but it has been done and that was the result) than loosely typed languages. > >Let's cut right to the chase here. I like strong typing almost as much >as you do, but I don't understand why I can't get it in Python, >perhaps by specialized code-analysis tools. Is the problem just that >the development tools are underdeveloped, or is there a fundamental >technical reason that type-checking cannot be done? If it's the >former, then I suggest that the tools be given a very high priority. What for? Python has dynamic type-checking and making yet another Pascal from it is probably stupid idea. >If it's the latter, then perhaps type checking can be done under >certain reasonable restrictions. Whatever the case, I want to have my >cake and eat it too. :-) You can add asserts to whatever places to check types: from types import * def add_int(x, y): assert type(x) is IntType and type(y) is IntType return x+y I can't see how static type-checking could eliminate more problems than create, though. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Thursday, July 05, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ ">From the Department of Redundancy Dept." _/ From fredrik at pythonware.com Tue Jul 3 03:17:53 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 03 Jul 2001 07:17:53 GMT Subject: newbie apply() question References: <C_b07.778$ei5.255138@typhoon2.gnilink.net> Message-ID: <Bke07.7480$e5.975477@newsb.telia.net> Aaron Edsinger wrote: > hi. i'm stumped on something that seems easy. why doesn't this work: > > x=4 > apply(sys.stdout.write,x) #fails TypeError: apply() 2nd argument must be a sequence as the exception implies, the second argument to apply must be a sequence. an integer is not a sequence. > apply(sys.stdout.write,(x,)) #fails TypeError: argument must be string or read-only character buffer, not int as the exception implies, the argument (to sys.stdout.write) must be a string, not an int(eger). > is there a way to make this work? if you really need to use apply, you can do something like: apply(sys.stdout.write,(str(x),)) or even: sys.stdout.write(*(str(x),)) but since write doesn't take a variable number of arguments, I see no reason why you cannot simply write: sys.stdout.write(str(x)) hope this helps! </F> From emile at fenx.com Sun Jul 8 22:43:31 2001 From: emile at fenx.com (Emile van Sebille) Date: Sun, 8 Jul 2001 19:43:31 -0700 Subject: calling a variable from a separate function References: <7b515e0f.0107081752.5dc1680d@posting.google.com> Message-ID: <9ib60g$hph69$1@ID-11957.news.dfncis.de> Well, I'm going to guess you mean to be working in a class. Then what you'd say is: class Test: #--untested-- def func1(self): self.var1 = 22 def func2(self): print self.var1 HTH, -- Emile van Sebille emile at fenx.com --------- "eric_brake" <brakedon at hotmail.com> wrote in message news:7b515e0f.0107081752.5dc1680d at posting.google.com... > Let's say > > def function1: > self.variable1 = 22 > def function2: > print variable1 > > Would function2 look like "print function1.variable1" or some other > way? By the way I already know that the "function1.variable1" format > doesn't work. thanks for any help. From bokr at accessone.com Thu Jul 26 00:27:06 2001 From: bokr at accessone.com (Bengt Richter) Date: Thu, 26 Jul 2001 04:27:06 GMT Subject: A modest PEP0238 suggestion References: <mailman.996054346.18950.python-list@python.org> Message-ID: <3b5f90cb.432383654@wa.news.verio.net> On Wed, 25 Jul 2001 05:43:24 -0400, "Tim Peters" <tim.one at home.com> wrote: [...] > >Dead serious apps don't take chances, and there are no restrictions in the >Python license on redistributing it with your apps. If you don't isolate >your app from user whims, there's no guarantee it will continue to work even >if they install a single bugfix to a shared Python. I don't know which OS >you're targeting, but it doesn't sound like you've thought about the big >picture here, be it Linux or Windows. The more important the app, the more >important to cover your butt, and even pure bugfixes can break code that >relied on accidents. > >test-what-you-ship-and-ship-what-you-test-ly y'rs - tim > > IOW, only ship bootable CDROMS. No, wait, better ship the whole box, with 110/220 adapter ;-) (Actually, I wouldn't be surprised to see this approach happen. First-time cost of a major commercial application suite is often considerably more than the bare-bones box part of the system it gets bought for. The opportunities for patent/UCITA control will be too much to resist. Your system will become a stack of app bricks. Of course this general idea is obvious, but hereby put in the public domain just in case ;-) From andreas at andreas-jung.com Thu Jul 19 17:24:35 2001 From: andreas at andreas-jung.com (Andreas Jung) Date: Thu, 19 Jul 2001 16:24:35 -0500 Subject: Distributing a Python app References: <20010719195840.BHJ2711.femail24.sdc1.sfba.home.com@jparlar> Message-ID: <07d201c11099$36abe440$9865fea9@SUXLAP> The standard way to distribute Python modules or applications is *usually* with DistUtils (see Python documentation for further informations). DistUtils supports to build and install a Python package and allows you to build archives for distribution like .tar.gz or rpms. Andreas ----- Original Message ----- From: "Jay Parlar" <jparlar at home.com> To: <python-list at python.org> Sent: Donnerstag, 19. Juli 2001 14:56 Subject: Distributing a Python app > I'm just wondering if anyone has any suggestions as to the best way to distribute an application written in Python, intended for > people who don't have Python installed on their machines? Even possibly a commercial distrubtion program, if it's the best. I've > been playing around with py2exe, with not much success (although that's a topic for a different day). Assuming I do get py2exe > working properly, how would everyone suggest we distribute our application? (By the way, this application is for Windows > machines). > > Jay Parlar > ---------------------------------------------------------------- > Software Engineering III > McMaster University > Hamilton, Ontario, Canada > > "Though there are many paths > At the foot of the mountain > All those who reach the top > See the same moon." > > > > -- > http://mail.python.org/mailman/listinfo/python-list From steve at lurking.demon.co.uk Tue Jul 24 00:22:53 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Tue, 24 Jul 2001 05:22:53 +0100 Subject: PEP0238 lament References: <mailman.995926001.4339.python-list@python.org> <vmcpltkoo6137ko4hnivtl5a01b9dtq2e1@4ax.com> <3B5CE049.8F274BD@geocities.com> <hW577.26451$Xr6.212776@news-server.bigpond.net.au> Message-ID: <ilrpltg0nls6p8gs46k57kar6q2a5u4cqf@4ax.com> On Tue, 24 Jul 2001 03:27:09 GMT, "Neil Hodgson" <nhodgson at bigpond.net.au> wrote: >Myles: > >> Ermm, fact correction : >> not on the VB and VBA I have available to me. >> >> VB (admittedly v.4): >> x = 1 \ 2 >> MsgBox (x) >> gives 0.5 > > Also in VBScript (on W2K): >WScript.echo(1/2) > displays "0.5". > > And QBasic >PRINT 1/2 > displays ".5" > > Neil <fx: slowly descending whistle> <fx: ***BOOM***> Thats one big hole blown in one of my major arguments - dammit. Teach me for assuming BASIC would work the same way for five minutes, I suppose. The next ***BOOM*** is still going to be a huge hole blown in my credibility after advocating Python though - so I'm still not a happy bunny :-< From skip at pobox.com Mon Jul 9 10:43:39 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 9 Jul 2001 09:43:39 -0500 Subject: socket module In-Reply-To: <20010709091943.A18359@strakt.com> References: <20010709091943.A18359@strakt.com> Message-ID: <15177.49947.594373.154573@beluga.mojam.com> Martin> Is there ANY way to use the socket module from a Python module Martin> written in C? Sure. Check the C API manual: http://www.python.org/doc/api/api.html especially the sections on importing modules and the object protocol section (for calling callable objects). Basically, you'll do just what you'd do from Python: import socket sock = socket.socket(...) sock.connect(...) Something vaguely like: PyObject *sockmodule, *sockfunc, *socket; sockmodule = PyImport_Import("socket"); sockfunc = PyDict_GetItemString(PyModule_GetDict(sockmodule), "socket"); PyCall_Object(sockfunc, ...); -- Skip Montanaro (skip at pobox.com) (847)971-7098 From max at alcyone.com Mon Jul 23 02:36:51 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 22 Jul 2001 23:36:51 -0700 Subject: PEP0238 lament References: <3B5B7689.F37B991C@alcyone.com>, <3B5B3676.40F39389@alcyone.com>, <mailman.995826216.11537.python-list@python.org> <eppstein-03540D.13070222072001@news.service.uci.edu> <mailman.995836120.7223.python-list@python.org> <mailman.995861977.11576.python-list@python.org> Message-ID: <3B5BC603.692036B0@alcyone.com> Moshe Zadka wrote: > It does? I fail to see why people assume that operations *have* to > return > the type of their operands. It's not a requirement, but integer division is very frequently used. An operation that's closed on the types of its arguments is always easy to understand, consistent with many other programming languages that do such integer division, and is already the way things work. -- 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 stronger in the world than gentleness. \__/ Han Suyin Erik Max Francis' bookmarks / http://www.alcyone.com/max/links/ A highly categorized list of Web links. From skip at pobox.com Fri Jul 6 18:47:27 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 6 Jul 2001 17:47:27 -0500 Subject: Postgres support In-Reply-To: <o5acktc6ot7upcu01eh3hul6e8mtu9qqnn@4ax.com> References: <gul1kts5l6aolk55o7vguk97uorjd08j9f@4ax.com> <5174eed0.0107061058.5446dac9@posting.google.com> <mailman.994448787.15987.python-list@python.org> <o5acktc6ot7upcu01eh3hul6e8mtu9qqnn@4ax.com> Message-ID: <15174.16383.881430.115111@beluga.mojam.com> Rene> Oracle is almost free [$200] for development purposes. ... Rene> Just put your production data in PostgreSQL and Oracle is quite Rene> affordable. Huh? Why would I plunk down $200 for an Oracle development license, then field my application using Postgres? -- Skip Montanaro (skip at pobox.com) (847)971-7098 From ajs at ix.netcom.com Thu Jul 19 21:08:16 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Thu, 19 Jul 2001 21:08:16 -0400 Subject: Case insensitivity Message-ID: <002501c110b8$758a2860$a9e1fea9@carol> Guido writes - >I apologize for my poor English -- I don't know what you mean by "an >affection" or "an affect". Consulting a dictionary didn't help, but >I'm guessing that you mean something that gets in your way when >programming. The poor English is all mine, for which I apologize. The correct word is affectation, which I used in the sense of: "manner of speech or behavior not natural to one's actual personality or behavior" Implies artificial. >To me, the only real important question is, how can we introduce >case-sensitivity for novices without breaking the millions of lines of >existing Python code. One option could be: forget it, it's too late. >Another: put the case-insensitivity in the tools. But I have also been trying to ask you to define a term - "novice". Seems to me it is clear that the needs of someone with an interest in learning programming is a novice in a whole different sense than someone with no such interest. That seems obvious, but you do seem to point time and again to circumstances in which the goal is for the subject to accomplish something specific - and the set-up is specifically to insulate them from an understanding of programming. *Not* to motivate them to achieve it. Anything you might *continue* to do to make an understanding of programming accessible to those interested in such an understanding, I would certainly support. I happen not to believe focusing on case-sensitivity is at all a core issue for that audience. But that, as they say, is me. To spend any significant energy to cater to the novice in the other sense - the novice who combines a lack of experience with a lack of interest in the subject matter of programming... well if I were you, I'd let myself off that hook. ART From emmanuel.astier at winwise.fr Fri Jul 6 09:24:11 2001 From: emmanuel.astier at winwise.fr (Emmanuel Astier) Date: Fri, 06 Jul 2001 13:24:11 GMT Subject: embedding pythonwin ? Message-ID: <3b45ba6c.17617021@news.iway.fr> Hi all, I would like to embed python, to use its debugging facilities. My application that embed python let me enter python commands. Here's what happens : ----------------------------------------------------------------------- import pywin.debugger pywin.debugger.GetDebugger() Could not create the debugger! Traceback (most recent call last): File "d:\python\python_2_1\pythonwin\pywin\debugger\__init__.py", line 46, in GetDebugger rc = _GetCurrentDebugger() File "d:\python\python_2_1\pythonwin\pywin\debugger\__init__.py", line 35, in _GetCurrentDebugger _CheckNeedGUI() File "d:\python\python_2_1\pythonwin\pywin\debugger\__init__.py", line 21, in _CheckNeedGUI pywin.framework.app.CreateDefaultGUI(dbgpyapp.DebuggerPythonApp) File "d:\python\python_2_1\pythonwin\pywin\framework\app.py", line 386, in CreateDefaultGUI appClass().InitInstance() File "d:\python\python_2_1\pythonwin\pywin\debugger\dbgpyapp.py", line 38, in InitInstance from pywin.framework import interact File "d:\python\python_2_1\pythonwin\pywin\framework\interact.py", line 21, in ? import pywin.scintilla.IDLEenvironment File "d:\python\python_2_1\pythonwin\pywin\scintilla\IDLEenvironment.py", line 56, in ? GetIDLEModule("AutoIndent").IndentSearcher.readline = fast_readline File "d:\python\python_2_1\pythonwin\pywin\scintilla\IDLEenvironment.py", line 24, in GetIDLEModule __import__(modname) File "d:\python\python_2_1\pythonwin\pywin\idle\AutoIndent.py", line 38, in ? import PyParse File "d:\python\python_2_1\pythonwin\pywin\idle\PyParse.py", line 2, in ? import re File "d:\python\python_2_1\lib\re.py", line 28, in ? from sre import * File "d:\python\python_2_1\lib\sre.py", line 218, in ? import copy_reg ValueError: bad marshal data ----------------------------------------------------------------------- All is release compile, so I don't have issues with "*_d.pyd". Anyone has any clue ? Thanks by advance, Emmanuel From robin at stop.spam.alldunn.com Tue Jul 3 22:07:44 2001 From: robin at stop.spam.alldunn.com (Robin Dunn) Date: Wed, 04 Jul 2001 02:07:44 GMT Subject: py2exe & wxWin References: <m2lmm6m1tg.fsf@mouse.copelandconsulting.net> Message-ID: <PTu07.61$7981.44630199@news.randori.com> "Greg Copeland" <gtcopeland at earthlink.net> wrote in message news:m2lmm6m1tg.fsf at mouse.copelandconsulting.net... > > Is it possible to use py2exe to package up a wxPython application? > Yep. Works quite nicely too. -- Robin Dunn Software Craftsman robin at AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython! From jkraska1 at san.rr.com Tue Jul 31 13:28:32 2001 From: jkraska1 at san.rr.com (Courageous) Date: Tue, 31 Jul 2001 17:28:32 GMT Subject: Python Threads on Linux References: <d396b814.0107302239.6341a93@posting.google.com> <3dsnfdjg1w.fsf@ute.cnri.reston.va.us> <akuchlin@mems-exchange.org> <mailman.996596704.6347.python-list@python.org> Message-ID: <ojqdmtguukc4ju3d8k7gvivqdfksd8e6dg@4ax.com> >Didn't IBM just release a new (optional) threads package for Linux that >implements true lightweight threads? This would require a kernel-patch, yes? C// From tjreedy at home.com Mon Jul 23 10:06:30 2001 From: tjreedy at home.com (Terry Reedy) Date: Mon, 23 Jul 2001 14:06:30 GMT Subject: A use for integer quotients References: <mailman.995866298.23496.python-list@python.org> <eppstein-E19F08.00451323072001@news.service.uci.edu> <3B5BDCB4.A2010560@letterror.com> Message-ID: <GbW67.19921$EP6.4914854@news1.rdc2.pa.home.com> "Just van Rossum" <just at letterror.com> wrote in message news:3B5BDCB4.A2010560 at letterror.com... > David Eppstein wrote: > > > Ok, you convinced me to look more carefully at all the divisions in my > > recent small project, a program to generate web pages from collections of > > JPEGs. I found: > > > > 3 instances of simplifying numbers prior to output (e.g. I want file size > > in kbytes rather than bytes). > > [ ... ] > > Do you really want 2047 bytes to be shown as 1 kbyte? > Integer division is a lousy tool in this particular example... Just, this is stupid, wrong, and gratuitously insulting, and therefore, in my opinion, ugly and nasty. As for the first line: unless you have seen Eppstein's code, which I assume not, you do not know what divisor he uses (both k = 1000 and 1024 have been by various people, as have both m = 1000000 and 1024*1024). You do no know whether he truncates down, rounds [(bytes + k/2)/k], or truncates up. You do not know that a difference of +-1 matters a bit to him and his audience, or that his program ever encounters 2K microjpegs. Given the care he described in choosing his focal length formula and the care he exhibited in examining his code and reporting the results, it is reasonable to assume that he made what he considers to be sensible choices for reporting file sizes. Who are you to assume otherwise? As for the second line: do you really think int(float(bytes)/float(k)+.5) is signigicantly better for rounding? If so, that is a statement of anti-integer float-religion preference, not fact. I am beginning to think that there is something wrong with a proposal that apparently has to be promoted by bulldozing away reasonable skepticism. Terry J. Reedy From rupe at metro.yak.net Fri Jul 6 15:44:46 2001 From: rupe at metro.yak.net (Rupert Scammell) Date: 6 Jul 2001 12:44:46 -0700 Subject: Best method for updating pickled data objects? References: <79179cf5.0107051214.19990222@posting.google.com> <mailman.994365490.28604.python-list@python.org> Message-ID: <79179cf5.0107061144.5e1d627d@posting.google.com> Neil Schemenauer <nas at python.ca> wrote in message news:<mailman.994365490.28604.python-list at python.org>... > Rupert Scammell wrote: > > Deleting and recreating the pickle file, then writing out the data > > object from memory each time seems horribly inefficient to me > > (especially for large data objects). There's got to be a better way to > > do this. Any suggestions would be appreciated. > > You want ZODB: > > http://www.amk.ca/zodb/ > > Its sounds complicated and scary but its really easy to use. > > Neil Thanks for your help Neil. ZODB looks like an elegant solution to this problem, and appears to have some nice extra features to boot. The semi-intelligent caching of dirty objects back to disk is especially useful. Once again, Andrew saves the day! --- Rupert From visionary25 at _nospam_hotmail.com Tue Jul 3 17:52:35 2001 From: visionary25 at _nospam_hotmail.com (Vis Mike) Date: Tue, 3 Jul 2001 14:52:35 -0700 Subject: accessing class data members References: <3B420804.9882D166@bioeng.ucsd.edu> <3B421822.572A5CDD@recombinant.demon.co.uk> Message-ID: <d8r07.169$T57.104869@news.pacbell.net> I've been toying with the idea of a new language, and I thought of this to aid in the getter/setter dilemma: Methods take precedence over variables of the same name, so you can simply use direct access at first, and implement a getter/setter method when the time comes. Incremental development. :) Mike "Stephen D Evans" <stevee at recombinant.demon.co.uk> wrote in message news:3B421822.572A5CDD at recombinant.demon.co.uk... Curtis, It's a question of style/performance. Neither obj.temperature nor obj.get_temperature() are necessarily better. Accessing a class variable directly or indirectly via a function are both valid and have advantages/disadvantages depending on the language/task. For indirect variable access via a function: In a compiled language the indirect access via a function call can be optimised away by the compiler, so there may be no loss of runtime speed. In Python there is the overhead of a function call, therefore potentially slower. If the function does not exist, the code crashes. Debugging is easier as all accesses to the variable can be trapped/traced. For direct variable access: In Python this is quicker. It is possible to set a 'typo', e.g. obj.temperature_oops = t without any complaint, but not (always) retrieve one e.g. t = obj.temperature_oops may or may not work. Possibly harder to debug the code. For quick and dirty debugging in Python it is possible to override the __getattr__ and __setattr__ class methods and thus provide the equivalent of obj.get_temperature() and obj.set_temperature(t) while using obj.temperature in the code. Use has to be made of the __getattr__/__setattr__ asymmetry. class UpperClassTwitOfTheYear: """An example for debugging only""" def __setattr__(self, name, value): if name == 'temperature': name = 'hidden_temperature' # rename, place debugging code here self.__dict__[name] = value def __getattr__(self, name): assert name=='temperature' # should only be called for this return self.__dict__['hidden_temperature'] Having looked at a lot of Python code and programmed in Python regularly for over a year, I generally use direct access to the class variable in Python i.e. obj.temperature Stephen D Evans Curtis Jensen wrote: In many OO languages, and theory, it is often the case that when you want to know the value of some data member, that a function is written to return that value. However, in Python it seems that people just access the data member directly. for example: if there were a class that represented a physical object. In the class there were data members that held the objects temperature and location. If I wanted to know the temperature of an object, I could just use obj.temperature. Though in other languages, the convention seems to call a function that returns the value, like: obj.get_temperature. Which is better? -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From BPettersen at NAREX.com Tue Jul 3 19:47:58 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Tue, 3 Jul 2001 17:47:58 -0600 Subject: No float limits Message-ID: <6957F6A694B49A4096F7CFD0D900042F27D4E0@admin56.narex.com> > From: D-Man [mailto:dsh8290 at rit.edu] > > On Tue, Jul 03, 2001 at 11:37:51PM +0200, J?rgen Hermann wrote: > | Hi! > | > | I just stumbled over the fact that there is sys.maxint, but > no sys.maxfloat > | and sys.epsfloat. In case anyone thinks this is a valid > addition, I'll come > | up with a patch. > > What value would sys.maxfloat have? > > IIRC IEEE754 states that all ones (ie 0xFFFFFFFF for a single > precision float) means infinity, so there really isn't a "max" value > for a float. Perhaps not, but there is a maximum representable number, a.k.a. DBL_MAX in your C library (same argument for DBL_EPSILON of course ;-) -- bjorn From tim.one at home.com Mon Jul 23 20:41:12 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 23 Jul 2001 20:41:12 -0400 Subject: intersection and union idea In-Reply-To: <3b5cb9d4$0$325$8eec23a@newsreader.tycho.net> Message-ID: <LNBBLJKPBEHFEDALKOLCCEIALAAA.tim.one@home.com> [Neil Macneale] > I was day dreaming about python today, and I realized that it would be > very python-ish to have intersection and union operators for lists and > tuples. Eg: > > >>> (1,2,3,4) | (1,3,6,8) > (1,2,3,4,6,8) > >>> (1,2,3,4) & (1,3,6,8) > (1,3) > > Does such an operator exist? I am sure someone else has thought of this > before. No and yes. A feeble subset of set operations isn't worth the bother of adding ("gratuitous bloat"), so the best hope for this kind of thing is in PEP 218: http://python.sourceforge.net/peps/pep-0218.html a-lot-of-bloat-is-always-better-than-a-little<wink>-ly y'rs - tim From peter at engcorp.com Thu Jul 12 22:17:40 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 12 Jul 2001 22:17:40 -0400 Subject: list and implicit continuation may cause bugs in Python programs References: <Pine.LNX.4.21.BCL.0107121756210.14873-100000@suzi.com.onego.ru> <07cb01c10ae4$64a3c440$9865fea9@SUXLAP> <oqvgkyrxhw.fsf@lin2.sram.qc.ca> <086c01c10aec$8ebe4b80$9865fea9@SUXLAP> <mailman.994959323.21264.python-list@python.org> Message-ID: <3B4E5A44.7100F507@engcorp.com> Fran?ois Pinard wrote: > > ... My mother often said to me: > > "Des go?ts et des couleurs, on ne discute pas. > Mais il y en a de meilleurs que d'autres..." > > (roughly translated: "People should never discuss about what is good taste. > Yet, some people have better taste than others."). Fran?ois, are you sure your translation is accurate? I think it should read "Yet, some people taste better than others." -cannibalistic-ly yr's, Peter H From philh at comuno.freeserve.co.uk Thu Jul 19 20:01:16 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Fri, 20 Jul 2001 01:01:16 +0100 Subject: Language change and code breaks References: <mailman.995572293.19088.python-list@python.org> Message-ID: <slrn9let6c.65h.philh@comuno.freeserve.co.uk> On Thu, 19 Jul 2001 13:49:57 -0600, Bjorn Pettersen <BPettersen at NAREX.com> wrote: >> From: Guido van Rossum [mailto:guido at digicool.com] >> >> > I'm still wondering what advantage there is to crippling the >> > expressivity of a language for the sake of a small group of >> > non-programmers. >> >> IMO there are two non-truths in this statement. >> >> (1) The expressivity of the language is not crippled. >> >> (2) Potentially, the group of non-programmers is much larger than the >> group of programmers (and it's easier to teach programmers an >> arbitrary rule than non-programmers). > >TRuE, tHe ExPRESsiVity oF ThE lANGuaGE is ProBAbLY nOt cRipPled, >hOWEvEr, tHere ARe SigNIficantLy FeweR ideNtIFIeRs AVaILABlE whICh mEAns >iT is LESs eXPRessIvE. IN pArTicULar, cOMmON Idioms liKE naMiNg CLASseS >stArTiNg WiTh UppER cASE lETtERS, AND instaNCeS OF THose cLAsSes >begINNiNG with A lOwER caSE LettER CaN NO LongeR Be usED. Rubbish. The only thing you can't do is give them the same name, eg: message = Message() but this is bad practise anyway, IMO. -- #===== Philip Hunt == philh at comuno.freeserve.co.uk ======# Herbivore: effort-free public key encryption. See: <http://www.vision25.demon.co.uk/oss/herbivore/intro.html> ** First software release coming soon! ** From skip at pobox.com Wed Jul 25 15:48:40 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 25 Jul 2001 14:48:40 -0500 Subject: Redirecting broswers in Py In-Reply-To: <3B5F0AC8.BF54029C@telocity.com> References: <3B5F0AC8.BF54029C@telocity.com> Message-ID: <15199.8856.97177.810376@beluga.mojam.com> Adonis> the script accepts the connection then processes information Adonis> once that is done i want to be able to send the broswer to X Adonis> page. That's the job of the Location: header in the HTTP response. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From greg at cosc.canterbury.ac.nz Mon Jul 30 00:35:31 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Mon, 30 Jul 2001 16:35:31 +1200 Subject: [OT] Number theory [Was: A use for integer quotients] References: <yCK67.17615$EP6.4467503@news1.rdc2.pa.home.com> <mailman.995860718.9550.python-list@python.org> <mailman.995862939.15013.python-list@python.org> <mailman.995883879.12071.python-list@python.org> <3B5C5665.8D41D1F1@tundraware.com> <slrn.pl.9los0f.jh4.qrczak@qrnik.zagroda> <3B5C749A.59F97320@tundraware.com> <JDa77.97061$Rr4.549007@ozemail.com.au> <Xns90E97C9849AD5robindotgarneratinam@172.18.25.3> <IjA77.97824$Rr4.589251@ozemail.com.au> <3b602afa.930850@nntp.sprynet.com> <Xns90EB76175FA2Brobindotgarneratinam@172.18.25.3> Message-ID: <3B64E413.B9086368@cosc.canterbury.ac.nz> Robin Garner wrote: > > As sets (and from the p.o.v. of analysis), Z is a subset of R, but as > algebraic entities there is a distinction. In other words, it all depends on the purpose you have in mind! -- 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 michael at stroeder.com Mon Jul 16 19:15:32 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Tue, 17 Jul 2001 01:15:32 +0200 Subject: CGI-Problem with Refresh Header References: <9ivnss$csl$01$1@news.t-online.com> Message-ID: <3B537594.35F2CA08@stroeder.com> Heiko Wundram wrote: > > I have a small problem with my CGI-script; I need to do a refresh (to some > other page) after a certain amount of time, but I can't remember the exact > syntax of the "Refresh:"-HTTP-Header... > > Anybody out there who can help me? :) RFC2616: Hypertext Transfer Protocol -- HTTP/1.1 Ciao, Michael. From jrbjr at digitalexp.com Fri Jul 6 03:04:11 2001 From: jrbjr at digitalexp.com (jrbjr) Date: Fri, 06 Jul 2001 07:04:11 GMT Subject: What do you think? I want to know!!! Message-ID: <Lpd17.566615$ho6.36516038@news5.aus1.giganews.com> This message posted with trial version of Express News Poster _____________________________________________________________ Want to voice your opinion or belief? Visit my new site Called "Alternatives To Popular Beliefs" (www.jrbjr.freeservers.com) I have a chatroom, messageboard and poll. I am looking for new topics, so please send me ideas for topics you would like to see on my site. From fdrake at beowolf.digicool.com Wed Jul 18 16:10:31 2001 From: fdrake at beowolf.digicool.com (Fred Drake) Date: Wed, 18 Jul 2001 16:10:31 -0400 (EDT) Subject: [maintenance doc updates] Message-ID: <20010718201031.F34352892C@beowolf.digicool.com> The development version of the documentation has been updated: http://python.sourceforge.net/maint-docs/ Current status of the 2.1.1 documentation -- very few changes since the 2.1.1c1 release. From -$Paul$- at verence.demon.co.uk Sun Jul 8 11:04:20 2001 From: -$Paul$- at verence.demon.co.uk (Paul Wright) Date: 8 Jul 2001 15:04:20 -0000 Subject: Limiting thread intruction count References: <3b46ddb2$0$332$8eec23a@newsreader.tycho.net> Message-ID: <9i9spk$1hr$1@verence.demon.co.uk> In article <3b46ddb2$0$332$8eec23a at newsreader.tycho.net>, Neil Macneale <mac4-devnull at theory.org> wrote: >Is there a way to limit the number of instructions executed by a thread >to a certain number? I want to start several threads and give them all >the same number of instructions to work, then have them all stop after >they have reached that point. Then I would like to resume all of those >threads again for another 'round' of instruction batches. > >The idea is that I have a game where people play there code against >others, and I would like to have some granularity in the number of >intructions each thread executes in a given time frame. > >I think this may be impossible, but any suggestions would be great! Greg Stein has a Robot Wars implementation which does what you want by playing with thread locks in a function which is a sys.settrace hook. sys.settrace lets you specify a function to run after every line of code (it's intended for people writing debuggers). http://www.pythonpros.com/gstein/war/ (Unfortunately it's not a complete implementation: it'd be a cool way to help beginners learn Python, especially those with a limited attention span :-) -- ----- Paul Wright ------| Oh, how horrible our sins look when they are -paul.wright at pobox.com--| committed by someone else! -- Chuck Smith http://pobox.com/~pw201 | From emile at fenx.com Wed Jul 25 13:28:50 2001 From: emile at fenx.com (Emile van Sebille) Date: Wed, 25 Jul 2001 10:28:50 -0700 Subject: Deposing Dictators References: <mailman.996076486.582.python-list@python.org> Message-ID: <9jmvru$6afv$1@ID-11957.news.dfncis.de> I ordered the Zope book on-line at Barnes & Noble this morning, and when searching for Python, the first entry displayed is a Perl book!?? -- Emile van Sebille emile at fenx.com --------- "Kemp Randy-W18971" <Randy.L.Kemp at motorola.com> wrote in message news:mailman.996076486.582.python-list at python.org... > I agree that Python is fun and exciting. In fact, I ran into this guy in the alley, who sold me a bunch of Python tee shirts, with a picture of a guy named Larry Wall on them. Can anyone tell me if these are "official Python tee shirts?" I hate to think that I got ripped off. > From opengeometry at yahoo.ca Fri Jul 13 19:02:38 2001 From: opengeometry at yahoo.ca (William Park) Date: Fri, 13 Jul 2001 19:02:38 -0400 Subject: Statistics tool box. In-Reply-To: <Pine.LNX.4.21.0107131826180.32753-100000@seahawk.ecc.engr.uky.edu>; from prem@engr.uky.edu on Fri, Jul 13, 2001 at 06:29:19PM -0400 References: <Pine.LNX.4.21.0107131826180.32753-100000@seahawk.ecc.engr.uky.edu> Message-ID: <20010713190238.A230@node0.opengeometry.ca> On Fri, Jul 13, 2001 at 06:29:19PM -0400, Prem Rachakonda wrote: > Hi, > I am trying to convert my matlab scripts into Python. But I see that > there are no equivalent stat. tools in Python. If there are any, could you > please let me know. I am looking for the functions similar to: You probably have to write your own. I remember - an old post in comp.lang.python about C math library wrapper... "cephes" or something. - an old post in <freshmeat.com> about C math library -- William Park, Open Geometry Consulting, <opengeometry at yahoo.ca> 8 CPUs cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc. From jochen at riekhof.de Fri Jul 20 05:21:38 2001 From: jochen at riekhof.de (Jochen Riekhof) Date: Fri, 20 Jul 2001 11:21:38 +0200 Subject: ActivePython ASP comobject.getCOMObject() does not work References: <9j6tac$b96$00$1@news.t-online.com> <3B576D8C.9080705@ActiveState.com> Message-ID: <9j8t73$d5g$00$1@news.t-online.com> ah, and FYI, hte second TUPLE-Value is the connection DSN string! DSN=<somedsn>;UID=<someuid>;PWD=<somepwd> Ciao Jochen From michael at stroeder.com Tue Jul 10 16:16:08 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Tue, 10 Jul 2001 22:16:08 +0200 Subject: Unicode -> String problem References: <mailman.994625054.7131.python-list@python.org> <92ae279c.0107092059.8b56186@posting.google.com> <1103_994765524@jparlar> <3B4B0141.580437D2@stroeder.com> <1103_994771037@jparlar> Message-ID: <3B4B6288.C4854E73@stroeder.com> Jay Parlar wrote: > > > > Now, whenever I'm given HTML from IE's cache, it is unicode. There is > > > no doubt about that. > > > > Are you sure? Which encoding of Unicode? UTF-16, UTF-8, ... > > Well, I know that it's Unicode for two reasons: > 1) The developer > of the module that generates the HTML from the cache told me so, Frankly this is not a real reason... > and 2) I do a check for > UnicodeType in my own code. I don't think I could tell you > which encoding it is though (not without knowing how to check > for that within my code). I wonder how you want to properly initialize an Unicode object without knowing the encoding. You should have a closer look at the cached data and not trust was anybody said. Especially you should watch out for the HTTP header and <meta> tags. Then you should get familiar with Unicode handling in Python and the distinction of strings and Unicode objects by reading the fine Python docs. Ciao, Michael. From JamesL at Lugoj.Com Fri Jul 20 12:27:44 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Fri, 20 Jul 2001 09:27:44 -0700 Subject: Language change and code breaks References: <mailman.995572293.19088.python-list@python.org> <slrn9let6c.65h.philh@comuno.freeserve.co.uk> Message-ID: <3B585C00.93162A1@Lugoj.Com> phil hunt wrote: [ Elided. ] > message = Message() > > but this is bad practise anyway, IMO. Why is that bad practice? What problems do you think this causes? I never used that convention much until after I had been exposed to ASN.1, where it is a common convention to have identifiers differ from type names only by a change of case in the first letter. In ASN.1 type names start with upper case and instance names start with lower case. Obviously the ITU didn't see any problems with that convention. I have never run into any problems at all with that convention and actually find it quite useful. From robin at jessikat.fsnet.co.uk Tue Jul 17 09:20:32 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Tue, 17 Jul 2001 14:20:32 +0100 Subject: python2.1 pythonw.exe base address Message-ID: <83weaIAguDV7EwJm@jessikat.demon.co.uk> I don't know how much this is of real interest, but using the latest proc explorer from http://www.sysinternals.com/ I notice that pythonw.exe has a base address of 0x1e190000, but that python21.dll wants to reside at 0x1e100000 and has a length of 0xAF000, the result is that python21.dll gets relocated. Redefining the base address of pythonw to be something non-controversial that didn't overlap would be a zero cost win for tk apps. as an aside it seems that tcl83.dll and _tkinter.pyd are also relocated, but I don't know the desired base address. -- Robin Becker From Randy.L.Kemp at motorola.com Tue Jul 3 17:19:47 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Tue, 3 Jul 2001 17:19:47 -0400 Subject: What's wrong with this program Message-ID: <E566B020833BD311B6610008C791A39705CA51FC@il93exm04.css.mot.com> Does anyone have an example of how to set filename to access files in a directory list, so I can implement this? My Python is limited, as I don't use it every day, and in limited ways. Thanks. -----Original Message----- From: Oleg Broytmann [mailto:phd at phd.fep.ru] Sent: Tuesday, July 03, 2001 3:05 PM To: Kemp Randy-W18971 Cc: 'python-list at python.org' Subject: RE: What's wrong with this program On Tue, 3 Jul 2001, Kemp Randy-W18971 wrote: > Thanks for the correction. Actually I think you don't need ftp.connect() at all - it is called in ftp.__init__... > Anyone know the correct format to transfer files > from one server directory to another server directory? I don't know - I've never used ftplib, but the idea is obvious: put it one by one. Something like this: for filename in somelist: ftp.storbinary("STOR " + filename, open(filename, 'rb')) Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From paulp at ActiveState.com Tue Jul 24 08:22:56 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Tue, 24 Jul 2001 05:22:56 -0700 Subject: PEP0238 lament References: <mailman.995814276.15005.python-list@python.org> <cp66clexxt.fsf@cj20424-a.reston1.va.home.com> <9jhbfj$79s$1@pea.uk.research.att.com> <mailman.995930743.17137.python-list@python.org> <9jjfts$9k2$1@pea.uk.research.att.com> Message-ID: <3B5D68A0.5E48C13@ActiveState.com> Duncan Grisby wrote: > >... > > I return to my question. Suppose Python 2.2 is released with this > __future__ division. Now suppose I must maintain some code which can > run on Python 2.0, 2.1 and 2.2, which needs integer division. What am > I to do? I think divmod()[0]. (or maybe I've missed something there) Another option would be for Guido to add a declaration that wouldn't break old versions of Python (i.e. a comment) that you could add to your module. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From johnroth at ameritech.net Fri Jul 27 11:46:30 2001 From: johnroth at ameritech.net (John Roth) Date: Fri, 27 Jul 2001 08:46:30 -0700 Subject: Eliminating upgrade risk References: <tlu596rosgngd9@news.supernews.com> <3B5FAD11.FB9D737E@engcorp.com> Message-ID: <tm336a7vjqjq5f@news.supernews.com> "Peter Hansen" <peter at engcorp.com> wrote in message news:3B5FAD11.FB9D737E at engcorp.com... > John Roth wrote: > > > > After enduring the PEP 238 threads for far too long, as well as other > > threads, I've come to the conclusion that Python is simply too unstable > > for real use. > > Do you really mean "is" too unstable, or you mean it looks like it > "might be" unstable, solely because of the proposals about changing the > way the / operator works? I mean is. Notice that I said "among others," therefore PEP 238 was **NOT** the sole proposal involved. > I've used Python for about a year and a half in dozens of practical > areas in industry. I consider it *bar none* the most stable language > I've ever used. Not only with respect to the stability of the > applications I write, but also the runtime (I can hardly recall a crash, > although I'm sure I've had a few when using calldll around third-party > DLLs) and definitely *even the language definition*. Runtime stability was not the issue. That's a given before I even start evaluating. And I don't consider the existing problem with Win 9x console mode and Tkinter to be a point in Python's favor. > Changing from 1.5.2 to 2.1 required us to do, let me see: nothing! > I reviewed the list of changes, predicted we would not be impacted, > and so far (after several months of ongoing development and continued > use of our many utilities and applications) I've been proven correct. Many shops want something a little more concrete than a statement by the top technical expert. A compatibility scan tool would be appreciated. > So I'm guessing you really just mean that this PEP 238 proposal > is scarey. I agree, to the extent that code breakage is never nice > to contemplate, but with the ongoing consideration being given to the > issue by the developers, I'm reasonably satisfied that even this > drastic change will end up having relatively little effect on my > opinion of Python's stability. Planning over two years in > advance and guaranteeing the breakage will only occur when > a major upgrade (Python 3.0) is released is pretty much the > best you could hope for from any language. After all, by convention > major upgrades are where you are supposed to *expect* code > breakage. That last sentence is what is scarey, not PEP238 or any of the other specific proposals. There's an endemic mindset in the xNIX community that simply doesn't understand the risk aversive behavior of many of the large shops. If compatability isn't guaranteed, then an upgrade is a project - which has to be scoped, justified, planned, and then prioritized with all the rest of the projects. > > Hopefully, this is going to provide more food for thought than fuel for the > > flames. > > I hope you don't consider this a flame. But I'm not responding to > the suggestion of "required" other than to say I don't think it's > really necessary (because I don't think it's really necessary... > as should be evident from the above). I think we're going to disagree on this one... John Roth > > -- > ---------------------- > Peter Hansen, P.Eng. > peter at engcorp.com From thomas at xs4all.net Mon Jul 9 04:16:50 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 9 Jul 2001 10:16:50 +0200 Subject: Comment on PEP-0238 In-Reply-To: <5.0.2.1.1.20010708185646.023c9640@mail.accessone.com> References: <cpsngaja4g.fsf@cj20424-a.reston1.va.home.com> <FFv17.1178$Y6.656565@news1.rdc2.pa.home.com> <cpelrskgrr.fsf@cj20424-a.reston1.va.home.com> <9i7a7k$h9ks6$1@ID-11957.news.dfncis.de> <cp4rsok3i7.fsf@cj20424-a.reston1.va.home.com> <mailman.994531918.7040.python-list@python.org> <9i8512$haelg$1@ID-11957.news.dfncis.de> <cpk81jip74.fsf@cj20424-a.reston1.va.home.com> <3b48de4e.1402626870@wa.news.verio.net> <5.0.2.1.1.20010708185646.023c9640@mail.accessone.com> Message-ID: <20010709101650.B32419@xs4all.nl> On Sun, Jul 08, 2001 at 08:02:27PM -0700, Bengt Richter wrote: > >Doesn't fix the problems. What about this: > > > >semantics PRECISION, 0: > > x = 2/7 > > > >semantics PRECISION, 100: > > print x > I'm thinking that's trying to peek from one nested scope into another, > and would be either illegal, trigger a special exception, or get you > a NameError. I haven't thought this through, but that was > part of the reason for a block rather than just setting global control > parameters. I think only new bindings would be affected. Rebinding > global names to stuff created within a semantic scope might have to carry > environment along. I haven't thought that through either ;-) Note that currently, only functions and classes introduce a new scope, not other blocks like if, for, try, etc. And this still is no solution: if you can't carry values from your 'precision scopes' to upper scopes, they are useless black bloxes that eat everything that goes in :) And an explicit 'return x' is not going to change anything about the problem. And what about this, for that matter: def printme(x): semantics PRECISION, 100: print x semantics PRECISION, 0: x = 2/7 printme(x) (or even with printme defined as semantics PRECISION, 100: def printme(x): print x :-) -- Thomas Wouters <thomas at xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From XQ.Xia at ccsr.cam.ac.uk Wed Jul 11 07:16:00 2001 From: XQ.Xia at ccsr.cam.ac.uk (XiaoQin Xia) Date: Wed, 11 Jul 2001 12:16:00 +0100 Subject: Can not use jTkinter Message-ID: <3B4C3570.218395D4@ccsr.cam.ac.uk> Hi everybody, The JPython1.1 was installed in c:\winnt\java\JPython-1.1, a copy is in c:\winnt\java\JPython11 according to guidance, modification was made in c:\winnt\java\JPython11: 1. The replacement jpython.jar must be copied to the JPython directory. -- in c:\winnt\java\jpython11 2. The jTkinter.jar must be placed somehere on your classpath. -- copies of jpython.jar can be found in c:\winnt\java\classes; c:\winnt\java\jpython11; c:\winnt\java\jpython11\lib 3. The tcl82.dll, tk82.dll and tkinter.dll must be placed somewhere on your path. -- in c:\winnt\java\jpython\lib 4. The Lib\_tkinter.py, Lib\code.py, Lib\imp.py and Lib\javaos.py must be copied to the JPython Lib directory. -- in c:\winnt\java\jpython\lib 5. The folders Lib\tcl8.2, Lib\tk8.2 and Lib\lib-tk directories must be copied to the JPython Lib directory. -- in c:\winnt\java\jpython\lib 6. The full path to lib-tk must be added to python.path in JPython's registry. Remember to use double backslashes in the windows path, e.g: c:\\java\\jpython-1.1\\lib\\lib-tk -- done after enter JPython. But I still got the following error information: C:\WINNT\java\JPYTHO~1>jpython JPython 1.1+jTkinter on java1.1.4 (JIT: null) Copyright (C) 1997-1999 Corporation for National Research Initiatives >>> import sys >>> sys.path.append("c:\\winnt\\java\\jpython11\\lib\\lib-tk") >>> import Tkinter Traceback (innermost last): File "<console>", line 1, in ? File "D:\java\jpython\jTkinter\lib-tk\Tkinter.py", line 8, in ? File "C:\WINNT\java\JPython11\Lib\_tkinter.py", line 4, in ? ImportError: no module named jTkinter >>> import Tkinter >>> dir(Tkinter) ['__file__', '__name__', '__version__', 'sys'] >>> r=3DTkinter.Tk() Traceback (innermost last): File "<console>", line 1, in ? AttributeError: module 'Tkinter' has no attribute 'Tk' >>> Cheers, Xiao-Qin Xia From sholden at holdenweb.com Mon Jul 2 20:56:35 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 2 Jul 2001 20:56:35 -0400 Subject: amkCrypto/mxCrypto on Win32 with Visual C++ References: <HS507.15883$Lk6.1149673@e420r-atl2.usenetserver.com> Message-ID: <II807.21844$he.1176748@e420r-atl1.usenetserver.com> Itamar Shtull-Trauring was kind enough to send me the following, which is good news for all Windows Python would-be cryptographers: > I've got this (compiled for 2.0 and the source needed to compile for > non-2.0 versions of Python) at http://itamarst.org/downloads/. Could you > forward this on to the list without my email? (don't want to get spam :). His email is ... [only joking]. Itamar's web site says: """amkCrypto-0.1.3-win32.zip - the amkCrypto package compiled for Windows. Includes the necessary OpenSSL DLLs (v.0.9.6a) and updated source code so you can compile it yourself.""" You will, of course, require the OpenSSL and the Python source headers in order to do this, and the setup.py requires source. Just dropping the Crypto directory from the distribution in uner my Python root appeared to do the trick for a binary installation, however. regards Steve -- http://www.holdenweb.com/ "Steve Holden" <sholden at holdenweb.com> wrote in message news:HS507.15883$Lk6.1149673 at e420r-atl2.usenetserver.com... > I'm trying to get the amkCrypto (modified mxCrypto) package working under > Win32, but Visual C++ is barfing about the declaration (and concurrent > initialization) of public member variables. > > For example, mxCrypto.h includes the following declaration: > > class StreamCipher > { > protected: > int mode; > > public: > static int const blocksize = 1; > static int const keysize = 0; > > StreamCipher(PyStringObject *v, int cipher_mode); > ~StreamCipher(); > PyObject *encrypt(PyStringObject *v); > PyObject *decrypt(PyStringObject *v); > int getmode(void) { return mode; }; > }; > > The compiler says that the public member variables (blocksize and keysize) > cannot be intialized in the header file. But clearly this code works under > some compilers... > > Has anyone sucessfully installed this code on Windows? Nothing on Google to > suggest previous problems. > > Thanks in advance > Steve > -- > http://www.holdenweb.com/ > > > > From ak42 at altavista.com Thu Jul 19 01:24:55 2001 From: ak42 at altavista.com (Alex K) Date: Thu, 19 Jul 2001 07:24:55 +0200 Subject: Retreiving a single number from a list of numbers ? References: <3b565953@news.iprimus.com.au> Message-ID: <3B566F26.24C4F807@altavista.com> Peter Moscatt wrote: > > I am trying to extract a value from a variable that contains more than one > value. > > For example: > If I assigned the result of wxGetClientDisplayRect() to the var 'a' > like: > a = wxGetClientDisplayRect() > > the 'a' would return something like (0, 0, 800. 540) > > How then would I assign the 800 from 'a' and give it to a var called 'b' ?? > > Regards > Pete >>> a=(0, 0, 800, 540) >>> a (0, 0, 800, 540) >>> a[2] <-- slicing 800 >>> (0, 0, 800, 540)[0] 0 >>> (0, 0, 800, 540)[3] 540 >>> From grey at despair.dmiyu.org Mon Jul 16 18:30:09 2001 From: grey at despair.dmiyu.org (Steve Lamb) Date: Mon, 16 Jul 2001 22:30:09 -0000 Subject: do .. while loops ? References: <mailman.995169745.15095.python-list@python.org> Message-ID: <slrn9l6qnh.rkf.grey@teleute.dmiyu.org> On Sun, 15 Jul 2001 14:00:31 +1000, Paul Andreassen <paul at andreassen.com.au> wrote: >Could someone please tell me why "do .. while" loops are not part of the >python language? I realise they are rarely used but the implementation >should be easy. http://groups.google.com/groups?as_q=do%20while%20&as_ugroup=comp.lang.python&num=100 -- 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 aahz at panix.com Fri Jul 13 00:54:26 2001 From: aahz at panix.com (Aahz Maruch) Date: 12 Jul 2001 21:54:26 -0700 Subject: Python speed References: <roG27.666914$166.13798179@news1.rdc1.bc.home.com> <9ik9kd$nch$1@news.mathworks.com> <9ikc0m$bmg$1@panix2.panix.com> <9ikee9$rpv$1@news.mathworks.com> Message-ID: <9iluu2$bmb$1@panix2.panix.com> In article <9ikee9$rpv$1 at news.mathworks.com>, jcm <grumble at usa.net> wrote: >Aahz Maruch <aahz at panix.com> wrote: >> In article <9ik9kd$nch$1 at news.mathworks.com>, jcm <grumble at usa.net> wrote: >>> >>>If you'd like, reread my point as "muds are likely to be CPU-bound >>>programs". >> >> Fine, but in that case, what *is* your point? > >Muds are likely to be CPU-bound programs. If that is the entirety of your point, why are you posting? -- --- 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 "How come we choose from just two people for President but more than 50 for Miss America?" --AEN From sassman at nucentrix.net Sat Jul 14 18:24:20 2001 From: sassman at nucentrix.net (Mark Sass) Date: Sat, 14 Jul 2001 17:24:20 -0500 Subject: Performance data Message-ID: <Gy347.1380$QX5.6266@eagle.america.net> Hello, I am trying to get the current CPU load of a system using the win32 modules, but when I pull the data I get some very small number which seems to be the CPU load for the machine over a long time (even if I max out the CPU, I only get small increases in this value). Anyone have a way to get the current CPU usage that includes both priveleged and user? counter = '\Processor(_Total)\% Processor Time' #This returns the percent IDLE time, so my result is 100 - value def queryperfdata(counter): machine, object, instance, parentInstance, index, counterName = win32pdh.ParseCounterPath(counter) path = win32pdh.MakeCounterPath( ( machine, object, instance, None, index, counterName) ) # if ValidatePath(path) != 0: # return None hq = win32pdh.OpenQuery() try: hc = win32pdh.AddCounter(hq, path) try: win32pdh.CollectQueryData(hq) type, result = win32pdh.GetFormattedCounterValue(hc, win32pdh.PDH_FMT_DOUBLE) return result finally: win32pdh.RemoveCounter(hc) finally: win32pdh.CloseQuery(hq) Any help would be greatly appreciated. Thanks, Mark Sass, sassman at nucentrix.net From skip at pobox.com Sat Jul 21 21:43:01 2001 From: skip at pobox.com (Skip Montanaro) Date: Sat, 21 Jul 2001 20:43:01 -0500 Subject: Language change and code breaks (fwd) In-Reply-To: <3b5a1d11.74651563@wa.news.verio.net> References: <mailman.995574754.22146.python-list@python.org> <3b5873ba.2423857703@wa.news.verio.net> <9jbp9l$90f$1@apollo.csd.net> <mailman.995756077.11446.python-list@python.org> <3b5a1d11.74651563@wa.news.verio.net> Message-ID: <15194.12197.735895.185029@beluga.mojam.com> >> date = 1 >> DATE += 1 >> print Date Bengt> Ok, after the above, what would locals() give you? Which will Bengt> give the value 2, locals()['date'] or locals()['DATE'] or both? My guess is that case issues aside, locals() will be deprecated in the relatively near future, so your question may be moot. I'm not sure what the correct answer is. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From whisper at oz.nospamnet Tue Jul 3 08:53:27 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 3 Jul 2001 12:53:27 GMT Subject: Python for air traffic control? References: <etdofr32d4f.fsf@lola-granola.mit.edu> <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> <bebbba07.0107021206.70a22aa8@posting.google.com> <mailman.994111084.403.python-list@python.org> <etdofr32d4f.fsf@lola-granola.mit.edu> <mailman.994132144.528.python-list@python.org> Message-ID: <9hsf87$oqv$0@216.39.170.247> In article <mailman.994132144.528.python-list at python.org>, cribeiro at mail.inet.com.br says... > As for the flight path planning, please note that airplanes can't travel in > any place in space. You can't see it but there are several "lanes" in air > space, defined by the authorities. The use of the radio frequencies must > also be managed by the tower to make sure that there are not any undesired > interference between different airplanes. The system must also balance a > high degree of automation and the need for human decision. This is not the > place for dumb decisions. > > Carlos Ribeiro > A minor point: with the advent of GPS and enhanced avionics, the airlines are moving towards point to point flights and away from the charted airways (at least in the US). Since they totally screwed up with excessive reliance on the hub/spoke system, they are trying to undo some of the damage and realize some fuel savings too. Dave LeBlanc From SBrunning at trisystems.co.uk Wed Jul 11 10:03:43 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Wed, 11 Jul 2001 15:03:43 +0100 Subject: Newbie problem with user input Message-ID: <31575A892FF6D1118F5800600846864D78BE58@intrepid> > From: Chris McMillan [SMTP:christopherjmcmillan at eaton.com] > Hello all! The partial code below prompts a user to enter a path. I then > want it to find (and later do something with) all the files in that > directory matching the specified string. The problem is that when I run > the > script, and enter, for example D:\test it does not find any of the files. > I > believe it is because the glob command is searching for > ''D:\\test'\\*.dat' > With the extra single quotes. How can I get it to search for > 'D:\\test\\*.dat' ? Thanks! > Chris > > print 'Enter the path:' # prompt user for directory path > path = raw_input() > for fname in glob.glob('path\\*.dat'): # finds files matching string Try this (untested): import os, glob path = raw_input('Enter the Path') for fname in glob.glob(os.path.join(path, '*.txt')): pass # do whatever... 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 phr-n2001 at nightsong.com Wed Jul 4 17:15:42 2001 From: phr-n2001 at nightsong.com (Paul Rubin) Date: 04 Jul 2001 14:15:42 -0700 Subject: batch generation of keypairs by GnuPG References: <slrn9k71fq.707.philh@comuno.freeserve.co.uk> Message-ID: <7xelrwl7k1.fsf@ruckus.brouhaha.com> philh at comuno.freeserve.co.uk (phil hunt) writes: > (2) Should I be using GnuPG at all? I don't need its key management > facilities -- I can use a serialised Python data structure for that -- > and I find it overcomplex to use programmatically. Is there a better > solution? What I need is software that can generate keypairs > (using an unencumbered algorithm such as ElGamal), and can encrypt > and decrypt using those keys, and make/test signatures using > the keys. Is there anything which does this (either a Python > program, or something accessible from the command line)? I think there's Python bindings for OpenSSL, which can do all that stuff. Or you could just code the algorithms yourself using one of the bignum libraries. I'm pretty sure Python has those, but I'm not a Python user and don't know specifics. From chrishbarker at home.net Mon Jul 30 13:50:59 2001 From: chrishbarker at home.net (Chris Barker) Date: Mon, 30 Jul 2001 10:50:59 -0700 Subject: PEP 238 (revised) References: <mailman.996263093.23412.python-list@python.org> <3B61F08A.1A4C6069@Lugoj.Com> Message-ID: <3B659E83.FEF6B9E4@home.net> James Logajan wrote: > Is the intent to do > IEEE-754 FP arithmetic on all platforms when FP is involved? What if the > underlying hardware isn't conformant? Sorry, since this seems to be going > through the python-list mailing list, the "References:" header isn't being > included for some reason, so I missed the introduction of IEEE-754 into the > discussion. Can't find it mentioned in that PEP (unless it is in another PEP > or is documented elsewhere). There is no mention of it in the PEP. I think IEEE-754 was brought up because: a) it is a standard for floating point computation b) it is a very good standard. HTe only piece of it that I have heard serious objection to is the number of bits in the exponent for doubles. c) it is implimented (most of it anyway) on the vast majority of hardware sold today. Because of these points, it is a good context in which to test possible computation schemes. IF you can't comply with IEEE-754 with a given proposal, it probably has an important flaw. By the way, I think a number of us on this list would love to see Python be IEEE-754 compliant. Unfortunately, that is very difficult given that not all hardware and C libraries support 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 max at alcyone.com Sat Jul 14 01:03:40 2001 From: max at alcyone.com (Erik Max Francis) Date: Fri, 13 Jul 2001 22:03:40 -0700 Subject: More on "with" statement References: <mailman.995086406.23419.python-list@python.org> Message-ID: <3B4FD2AC.BF2F9AD6@alcyone.com> Roman Suzi wrote: > Programmers must be lazy to some degree. So, they tend to write > > a*(b+c+d+e) > > instead of > > a*b+a*c+a*d+a*e That's just plain more efficient. Four additions and one multiply instead of three additions and four multiplies. -- 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 no dull subjects. There are only dull writers. \__/ H.L. Mencken Physics reference / http://www.alcyone.com/max/reference/physics/ A physics reference. From jkraska1 at san.rr.com Tue Jul 31 13:27:29 2001 From: jkraska1 at san.rr.com (Courageous) Date: Tue, 31 Jul 2001 17:27:29 GMT Subject: Typing system vs. Java References: <mailman.996524288.7635.python-list@python.org> <jonathan-D4822F.08343331072001@news.easynet.co.uk> <Xns90EF65598E954michaelrcpcouk@194.238.50.13> <3B66B3A2.F47BA3E2@engcorp.com> <3B66E4FA.158E7DDA@home.net> Message-ID: <u4qdmtcsd0uj65qgl9itrejaipq1mr36ut@4ax.com> >I would probably only use it in small computational functions that I >could efficiently compile. By and large this is nothing a good optimizing JIT can't handle without static typing information. QKS is getting a 10-100X improvement in Python execution speeds without modifying the Python language. http:\\www.smallscript.com. Execution times within 1-2X of C. >For performances, sake another nice addition would be the introduction >of the "homogenous" sequence. This I can agree with. >Does anyone else think this could be a good idea??? Sure. Pretty easy to implement yourself, of course, saving the first-class language support. Although one can imagine something like: var = []! C// From xtian at hyperactive.co.nz Tue Jul 3 02:09:41 2001 From: xtian at hyperactive.co.nz (xtian at hyperactive.co.nz) Date: Tue, 03 Jul 2001 06:09:41 GMT Subject: newbie apply() question References: <C_b07.778$ei5.255138@typhoon2.gnilink.net> Message-ID: <3b415332.96563631@news.supernews.com> On Tue, 03 Jul 2001 04:37:54 GMT, "Aaron Edsinger" <edsinger at ai.mit.edu> wrote: >hi. i'm stumped on something that seems easy. why doesn't this work: > >x=4 >apply(sys.stdout.write,x) #fails >apply(sys.stdout.write,(x,)) #fails > >is there a way to make this work? > >thanks, > aaron If you try to run this by itself (without doing anything else), it fails with the traceback Traceback (most recent call last): File "<pyshell#1>", line 1, in ? apply(sys.stdout.write,(x,)) NameError: name 'sys' is not defined What this means is that Python has tried to look at the object referred to by 'sys' to find out what it's 'stdout' attribute is, and discovered that the name 'sys' hasn't been set (or 'bound') yet. Names can be bound in quite a few ways, the main one being assignment. In this case, you want the binding 'sys' to refer to the sys module - to bind the name 'sys' to the sys module, you need to import the module with... import sys ...at the start of your script (or at least before the first use of sys). Incidentally, when importing a module, you can pick the name you want to bind it to; if you'd had (I'm assuming Python 2.0 or up here)... import sys as fish ...at the start, you could then use... apply(fish.stdout.write,(x,)) # this is the form that works, by the way. ...just as well. (I'm assuming that your confusion was caused by not understanding what was meant by NameError. If I sounded patronising - sorry! Also, as a general hint, if you're asking people for help working out what's causing an error, post the traceback (long error message) - they're very useful in diagnosing the problem.) The best explanation of name binding of which I know is the effbot guide to Python objects: http://effbot.org/guides/python-objects.htm Any others around? So, to wrap up, you need an 'import sys' at the start. (Good choice trying Python - it's so cool!) Hey - I feel like the Martellibot - that was long. xtian Question 6: I'm trying to implement a Content Management System. Should I use Scissors, XML, or dirt? From johann at physics.berkeley.edu Mon Jul 23 19:54:43 2001 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 23 Jul 2001 16:54:43 -0700 Subject: A use for integer quotients References: <mailman.995866298.23496.python-list@python.org> <cpzo9veuml.fsf@cj20424-a.reston1.va.home.com> <8rdoltsi3fcph86pnkgckmiqich6d9qqng@4ax.com> <mtn15v2wiw.fsf@astron.berkeley.edu> <2b6plts93l46r4aip12u0veqfab01sfsau@4ax.com> Message-ID: <mtvgkj19rw.fsf@astron.berkeley.edu> Stephen Horne writes: >> Anyway, there are two camps. The proposed new behavior would make my >> life easier, so I like it. It's also "the right thing" from a >> mathematical point of view. Others clearly disagree. > They are *NOT* the right thing from a mathematical point of view - > integer division in mathematics gives an integer quotient and integer > remainder as any five-year-old knows. Well, most mathematicians I know would disagree. Division is not well-defined on integers, unless you want "5 / 2" to return "(2, 1)". It's just not a property integers have. Or, well, you can define the operation, but they'll stop being a group under it, so all hell breaks loose. :-) Five year olds don't know much maths. > If you are so keen on int <op> int -> float, why is it *ME* that has > to change operators and not *YOU*. Is it really just that it makes > *YOUR* life easier so sod everyone else? Well, that, and the improved purity of the language now that the false idol called "integer division" has been banished back to whatever dank hell from which it sprang. :-) It's not that big a deal for me; I'd be almost as happy with a special "float division operator" like "/." or such. However, if people are thinking about getting rid of what I perceive as a wart, then I'm not about to argue against it, am I? -- Johann Hibschman johann at physics.berkeley.edu From cliechti at mails.ch Tue Jul 31 20:23:19 2001 From: cliechti at mails.ch (chris liechti) Date: 1 Aug 2001 02:23:19 +0200 Subject: C/Cygwin/Python References: <slrn9mdold.1snq.m-turk@dhcp101054.res-hall.nwu.edu> Message-ID: <Xns90F018F3860E1cliechtimailsch@62.2.32.50> m-turk at nwu.edu (Matthew Turk) wrote in news:slrn9mdold.1snq.m- turk at dhcp101054.res-hall.nwu.edu: > Hi there. I'm working on some 'back-end' stuff that I'm doing in C - > and I'm struggling through compiling it properly, which is an entirely > different question. i can try my makefile that's a example on using DDE: http://www.geocities.com/chrisliechti/en/python/spam2.0.zip > > Essentially, I want to be able to use it on computers that don't run > Cygwin. Is this going to work? I certainly *don't* want to resort to its needing cygwin1.dll not the entire cygwin installation - i think. > Visual C, since I have no idea how to operate in that environment, nor > do I own a copy. I know that cygwin has the -Wno_cygwin or something > flag that'll compile without CYGWIN.DLL, but will that be sufficient > for compiling a python extension? the extension should work either way. its just more convenient for distribution if you dont need to suply the cygwin stuff. -- chris <cliechti at mails.ch> From db3l at fitlinxx.com Mon Jul 30 16:56:36 2001 From: db3l at fitlinxx.com (David Bolen) Date: 30 Jul 2001 16:56:36 -0400 Subject: Best practices with import? References: <9jvnoe$om2$1@slb5.atl.mindspring.net> <etdy9p81q8t.fsf@lola-granola.mit.edu> <9jvsio$j4r$1@slb6.atl.mindspring.net> <3B639A2D.83B00CD5@engcorp.com> Message-ID: <usnfe5e63.fsf@ctwd0143.fitlinxx.com> Peter Hansen <peter at engcorp.com> writes: > Possible reasons to import in a function: > > 1. Readability: if the import is needed in only one > function and that's very unlikely ever to change, > it might be clearer and cleaner to put it there only. > > 2. Startup time: if you don't have the import outside > of the function definitions, it will not execute > when your module is first imported by another, but > only when one of the functions is called. This > delays the overhead of the import (or avoids it > if the functions might never be called). One thing to point out is that the "might never be called" part may be more than just convenience, if the import that is being done is platform-specific. In such a case, putting the import at the top of the screen could prevent it from loading at all (without a dedicated try/except block around it), while placing it inline in the platform specific code is a bit more straight-forward. -- -- 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 timothyrandolph at NoSpamPleaseyahoo.com Sat Jul 21 13:50:03 2001 From: timothyrandolph at NoSpamPleaseyahoo.com (Tim Randolph) Date: 21 Jul 2001 17:50:03 GMT Subject: Language change and code breaks References: <Pine.LNX.4.33.0107191316390.24983-100000@bms> <mailman.995571273.18192.python-list@python.org> <9j7gv8$9mg@dispatch.concentric.net> <slrn9ljdq4.9ur.grante@tuxtop.visi.com> Message-ID: <9jcfcb$9n1@dispatch.concentric.net> "Grant Edwards" <grante at visi.com> wrote in message news:slrn9ljdq4.9ur.grante at tuxtop.visi.com... > >Nobody wants to see fOo and FOO and foo with the same meaning, but nobody > >wants to see foo and FOO and foo at all in the same program with distinct > >meanings. > > That is simply not true. Do you really ever want "fOo" and "FOO" and "foo" in the same program? (Notice the typo in my original? fOo --> foo. No wonder I want a case insensitive language. ;-) I would bet a $100 bucks that you are a better coder than I am, but I really can't imagine why you would want that. > >I also don't think the cutesy c=C() makes for readable code -- at > >least for this sometime programmer. > > I've been using foo and Foo to mean two different things for > many years (and I know of lots of others do also). Perhaps it's > not to your taste, but that doesn't make all of us "nobody". > I wasn't trying to lump the foo=Foo() case with the "fOo", "FOO", "foo" case. The latter is used as the pat example on what a case insenstive Python would look like, which is not the way I see it. I really have not seen any one suggesting that they use more than a leading character difference in case intentionally. foo=Foo() is a matter of taste, which, as I said in my original message, doesn't work for me. I have no idea how representative of sometime programmers I might be. My apologies for any offense. None was intended. ---Tim Randolph From JamesL at Lugoj.Com Wed Jul 11 23:16:52 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Wed, 11 Jul 2001 20:16:52 -0700 Subject: Help With filter(). References: <XA537.678643$166.13965187@news1.rdc1.bc.home.com> <3B4CEF3C.D664D82A@Lugoj.Com> <I%737.679443$166.13999728@news1.rdc1.bc.home.com> Message-ID: <3B4D16A4.E8941F20@Lugoj.Com> EricIDLE wrote: > > I Still Dont Get It. Could you explain it in simpiler terms? How good is your Python? Do you know about lists and how to manipulate them and how to use "for" loops? Do you understand that variables can be assigned references to functions and that a function can take a function reference as an argument? If you are unclear on any of that, then that may be why my explanation is unclear. Or more likely I did not explain very well, so I'll try again: How about: "filter" takes a reference to a filtering function and a list, and returns a subset of the supplied list. Try some examples: # This function returns true if given a number larger # than 23 and false for all other numbers. def MyFunc(listItem): return listItem > 23 So the following call: filter(MyFunc, [10, 22, 23, 24, 5, 30, 45]) would return another list containing only those elements for which MyFunc returns true: [24, 30, 45] Now if you don't supply a function, the items themselves are tested for "truthness" as Python defines it. Try the following: filter(None, [10, 0, None, 23, -3, "", "hi", [], "the end"]) Since Python considers 0, None, "", and empty lists [] as having "false" truth values when used in boolean expressions, they are filtered out and you would get everything else, which Python considers has a "true" value in boolean expressions: [10, 23, -3, 'hi', 'the end'] You need to run the Python interpreter and use the interactive mode and start playing around with it. Experimenting more may answer a lot of your questions. From ullrich at math.okstate.edu Thu Jul 26 10:57:00 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Thu, 26 Jul 2001 14:57:00 GMT Subject: Deposing Dictators References: <9jmjne$q54$1@wisteria.csv.warwick.ac.uk> Message-ID: <3b602daf.1623450@nntp.sprynet.com> On Wed, 25 Jul 2001 14:05:34 +0000 (UTC), <margg at ux-ma160-18.csv.warwick.ac.uk> wrote: [...] >2) The level of dissent required to change the opinion of the BDFL >perhaps calls into question the 'B'. Nonsense. Without saying anything about who's right and who's wrong, or about whether the D is B or not: To be "benevolent" towards someone is to act in a way consistent with that person's best interests. This is not the same thing as giving the person what he asks for, not by a long shot. (My opinion is if he wants to keep his position he should give _everyone_ exactly what they want. Of course this would require several thousand different versions of Python...) Why in the world should "level of dissent" have any bearing on anything? Deciding moral issues by taking a vote is one thing - deciding what's best on a technical issue by taking a vote is silly. David C. Ullrich From mikle at tomsk.net Fri Jul 6 22:40:43 2001 From: mikle at tomsk.net (Mikhail Astafiev) Date: Sat, 7 Jul 2001 09:40:43 +0700 Subject: Short form of file names In-Reply-To: <cpn16hkft1.fsf@cj20424-a.reston1.va.home.com> References: <39916145.20010707010418@tomsk.net> <mailman.994443389.735.python-list@python.org> <cpn16hkft1.fsf@cj20424-a.reston1.va.home.com> Message-ID: <1816249903.20010707094043@tomsk.net> Hi! Saturday, July 07, 2001, 2:42:25 AM, you wrote: > Skip Montanaro <skip at pobox.com> writes: >> Mikhail> Is there some Python module for converting Windows long paths >> Mikhail> to short form, i.e. 8.3? os.path.normpath() does not do this.. >> >> Try importing dospath directly: >> >> >>> import dospath >> >>> dospath.normpath("/supercalifragilisticexpealidocious.py") >> '\\supercal.py' > Yeah, but shouldn't it return '\\superca~1.py' ? I believe the > algorithm to produce the ~1 part is dependent on what else is in the > same directory. I guess the ActiveState win32 modules hide an API > somewhere that gets this information directly from the filesystem. Yes, I think so too. I just wanted to know if someone already wrote such pyd calling appropriate Win32 API function. Actually my problem is the bug in os.chdir() function - it does not work with long filenames under Win9x. :( I'll create pyd myself. Well, thanks to all for responses! Mikhail. From grante at visi.com Tue Jul 3 20:30:58 2001 From: grante at visi.com (Grant Edwards) Date: Wed, 04 Jul 2001 00:30:58 GMT Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> <9hrj3q$cj1@news1.gtech.com> <bebbba07.0107031040.593143f8@posting.google.com> <9htgsb$ck3@news1.gtech.com> Message-ID: <slrn9k4out.ms.grante@tuxtop.visi.com> On Wed, 4 Jul 2001 08:25:50 +1000, Peter Milliken <peter.milliken at gtech.com> wrote: >This assumes that your coding standing inforces passing >arguments by name - just try staffing an ATC project and >enforcing a coding standard. There will be many programmers who >"don't like the standard" and will do anything to get around >it. You generally catch these people through code review only >and often too late! :-). Python doesn't enforce this, [without looking at the source code] I think it would probably be farily trivial to hack Python to require all arguements be passed by keyword. >personally I believe it is a good feature and I use it >frequently - but not all of the time :-) > >> In C++, the function calls all get checked automatically at >> compile time, but Python doesn't check them until run time. >> That is a valid concern, but hardly a show-stopper. I >> understand that PyChecker can be used for static checking. I >> actually think the core Python language should have an option >> to do static checking, but as long as some product is >> available to do it, the issue is not major. > >PyChecker is still very imature and some things it will never >(poor word to use, since if someone wants to put in the effort, >nothing is impossible :-)) be checked by it. It will only ever >be an aid. The ability of Python to dynamically "change its >behaviour on the fly" is one of its strengths but also a >weakness from the point of view of ensuring correctness and >reliability in such an application domain. On a project as large as an ATC program there will probably be (or at least _should_ be) some support staff whose job is nothing other than specify/acquire/develop/tweak/test development tools. -- Grant Edwards grante Yow! I wish I was a at sex-starved manicurist visi.com found dead in the Bronx!! From guido at python.org Wed Jul 18 10:30:27 2001 From: guido at python.org (Guido van Rossum) Date: Wed, 18 Jul 2001 14:30:27 GMT Subject: Language change and code breaks References: <mailman.995378792.16515.python-list@python.org> Message-ID: <cpvgkq1f2b.fsf@cj20424-a.reston1.va.home.com> Roman Suzi <rnd at onego.ru> writes: > Windows is case-insensitive and thus "easy to use" only before one needs > to put web-pages on the real (UNIX) web-server. Then they understand all > the troubles with mised case, national-charset filenames, abbr~ted > filenames, local file references "C:\Mydocs\lalala", bmp-images etc. But it's still open for debate whether the problem here is Windows or Unix! All programming languages and file systems used to be case-insensitive, until the designers of Unix and C decided that it was too much work to write and use a case-insensitive comparison routine. It wasn't necessarily intended to be better, just easier to implement. But times have changed, and that's a lousy excuse. --Guido van Rossum (home page: http://www.python.org/~guido/) From mday at apple.com Thu Jul 26 21:09:21 2001 From: mday at apple.com (Mark Day) Date: Thu, 26 Jul 2001 18:09:21 -0700 Subject: Suggestion for impriving list comprehensions References: <gER67.534750$eK2.111982758@news4.rdc1.on.home.com> <ac677656.0107231024.3ab3e6f1@posting.google.com> <3B5F0867.7447E5FB@ccvcorp.com> <ac677656.0107251340.15e848fb@posting.google.com> <9jphkk$rhc$1@newsy.ifm.liu.se> <cpofq75qax.fsf@cj20424-a.reston1.va.home.com> Message-ID: <260720011809216278%mday@apple.com> In article <cpofq75qax.fsf at cj20424-a.reston1.va.home.com>, Guido van Rossum <guido at python.org> wrote: > paul at svensson.org (Paul Svensson) writes: > > > I would like to suggest that we add a "while condition" clause > > to list comprehensions, similar to the "if condition" clause, > > but terminating the list comprehension on the first false condition. > > The above example could then be written as > > > > [x for x in fib() while x < 50] > > Neat, but maybe not general enough. How do you request the first N? [x[0] for x in zip(fib(),xrange(N))] or [x for x in fib()][:N] assuming it's smart enough to stop iterating when the slice has been produced. I guess the list comprehension would have to be a form of iterator/generator, and slices would have to stop iterating when they get all the elements they need. Would this work in 2.2a1? > And fuzzy: does this include or exclude the first x >= 50? I would have assumed it would exclude the first x >= 50. But then I tend to think in C and prefer while(){} over do{}while(). Consider: >>> [3*i for i in xrange(10) if (i%2)==0] [0, 6, 12, 18, 24] When I see that list comprehension, I think of it as something like: for i in xrange(10): if (i%2)==0: yield 3*i or temp = iterator(xrange(10)) while 1: i = temp.next() if i%2==0: yield 3*i where the while loop terminates when temp returns an exception. So, [x for x in fib() while x < 50] would be something like: while (x=fib.next()) < 50: yield x I'm using C notation to express combined assignment and condition test. But that's because that concept is a little more cumbersome to express in Python (and why it would be great in list comprehensions). I suppose the Pythonic way would be something like: x = fib.next() while x<50: yield x x = fib.next() -Mark From ngps at madcap.dyndns.org Fri Jul 13 13:42:02 2001 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 13 Jul 2001 17:42:02 GMT Subject: Q: HTTP through multiple NICs References: <mailman.995022383.31577.python-list@python.org> Message-ID: <9inbta$rqb$1@dahlia.singnet.com.sg> According to Gardiner, Geoff <ggardiner at accelrys.com>: > I need to send HTTP traffic through multiple NICs (multihoming with > different IP addresses AND different MAC addresses) on a single PC. The > traffic doesn't need to be simultaneous (I think I'll try to walk before I > run). The archetypal TCP client socket example goes like this: from socket import * 1 s = socket(AF_INET, SOCK_STREAM) 2 s.connect((addr, port)) s.send('blah blah blah') <etc.> To do what you want, insert "s.bind((local_addr, local_port))" between lines 1 and 2. Yes, bind() works for client sockets, too. For this to work, your host's networking, routing, etc. must be configured correctly, of course. (A while ago, I used M2Crypto.SSL sockets with the bind() thingy above to test so-called server load balancers' SSL session-id persistence when the SSL session resumption requests come from different IP addresses, which happens because certain ISPs were implementing transparent HTTP/HTTPS proxying thru their cache farms, fronted by _their_ load balancers.) A quick glance thru httplib shows no mechanism to pass your own socket objects in - httplib's HTTP and HTTPConnection classes want to create their own sockets. You can subclass either of those (use HTTPConnection, it's newer ;-) to pass in your own sockets that bind to your choice of local address. -- Ng Pheng Siong <ngps at post1.com> * http://www.post1.com/home/ngps Quidquid latine dictum sit, altum viditur. From bokr at accessone.com Thu Jul 12 03:58:39 2001 From: bokr at accessone.com (Bengt Richter) Date: Thu, 12 Jul 2001 07:58:39 GMT Subject: Language Shootout References: <mailman.994910001.4712.python-list@python.org> Message-ID: <3b4d4913.1692043049@wa.news.verio.net> On Wed, 11 Jul 2001 23:52:59 -0400, "Tim Peters" <tim.one at home.com> wrote: [...] > >The rub is that while this kind of thing is fun and easy to program in >Python, it's a total pain in the ass to program in C, and indeed leads to >code bloat. Since Python longs use base 2**15 internally, converting to >power-of-2 bases is both simple and fast in C, so we settled for that. > That's interesting. Are you in effect saying there can't be compiled python bytecode in python, even if there could be both speed and space advantage for a given function? So long as you weren't trying to lift yourself by not-yet-existent boot straps, why not? That sounds a little funny, but ITYKWIM ;-) BTW, looking at the way you can call the interpreter from C for embedding, I would think you could write a translator for a useful subset of python that would output a mix of plain C and Py_whatever calls to create C source that could be compiled and linked into CPython. This would bypass the PITA part and leave the fun part, ISTM ;-) Could you alter the byte code compiler to emit this? Done that way, strL wouldn't amount to that much C (or would it?), and you could have 100% C code that way (i.e., not even byte codes as C constants to feed the python interpreter). From johnca at DIESPAMmac.com Tue Jul 17 16:56:26 2001 From: johnca at DIESPAMmac.com (John Abbe) Date: Tue, 17 Jul 2001 13:56:26 -0700 Subject: Python CGI speed on MacOS X Message-ID: <johnca-1707011356260001@nop009.transbay.net> I'm running MacOS X on a PowerBook G3 400MHz, and have Python 2.1 installed (from http://tony.lownds.com/macosx/). Running some python stuff for CGI (PikiePikie -- see pikie.darktech.org -- it's a cgi script and a bunch of modules; .pyc files have been generated). It's very slow (about 6-7 seconds every time i click). Serving regular pages is plenty fast, and PikiePikie at the above address is pretty fast (a Linux box). Is there any obvious (or inobvious) advice for speeding this up? Appreciatively, John -- We've been waiting seven years for real Mac on Unix. Get the most out of it! Links & tips for learning, and to get OS X up and running: http://www.ourpla.net/guiunix/GettingXGoing.html From dale at riverhall.NOSPAMco.uk Tue Jul 31 19:25:26 2001 From: dale at riverhall.NOSPAMco.uk (Dale Strickland-Clark) Date: Wed, 01 Aug 2001 00:25:26 +0100 Subject: Arg decoding with a template? References: <ljidmtouqj6som2t9ecagbkj95c53kjaeh@4ax.com> <4oA97.5883$9i1.519137@e420r-atl1.usenetserver.com> <duodmt0itqq9t1kq6bs5dhpnk9io64p2sj@4ax.com> <ulml5sz7m.fsf@ctwd0143.fitlinxx.com> Message-ID: <rdeemts4mrarb8b5ghqieio68n1jv32tl1@4ax.com> David Bolen <db3l at fitlinxx.com> wrote: >I suppose that's a matter of taste. Certainly in the Unix domain, >from whence this arose, where virtually everything was traditionally >done via the command line, all command line utilities parse their >command lines in exactly this way, it's extremely consistent and >trying to do other manual approaches actually makes the non-conformant >application stand out as such. > >In effect, such command line parsing is a standard interface, much as >under Windows, there's standard UI elements in its GUI. It's also >(unlike a GUI) designed as much for efficiency and flexibility as >looks. > >You'll find that it's a flexible interface for something that has to >deal with a textual command line. Try designing a CLI parser that has >optional arguments, arguments with and without values even with >multi-character options, spacing and order insensitive, and so on, and >you'll find yourself replicating much of the getopt behavior. > >Personally, since DOS/Windows command line applications never really >formed such consistency (IMO), and at least for me I find "-" less >glaring on the command line than "/", I find the use of a getopt >conformant command line to be nice as well as consistency >cross-platform. > >I don't know what particular user interface you are looking to serve, >so if you're comparing this to some GUI interface to obtain >parameters, that's not apples to apples. But if you're working >strictly with a command line, I wouldn't necessarily jettison getopt >summarily. > >-- >-- David I guess what I had in mind was a simple but effective equivelent that I used to use with BCPL. A function called rdargs, which I think also became part of AmigaDOS I've just had a quick hunt with Google and I can't find a definition for it anywhere. I'll probably end up using getopt just because I don't have time to do a proper job right now. -- Dale Strickland-Clark Riverhall Systems Ltd From grante at visi.com Sun Jul 1 21:07:43 2001 From: grante at visi.com (Grant Edwards) Date: Mon, 02 Jul 2001 01:07:43 GMT Subject: Is this a true statement: Part II References: <9hiifr$sjs$1@taliesin.netcom.net.uk> <mailman.993843346.4433.python-list@python.org> <fFD%6.19908$zT1.1099537@e420r-atl3.usenetserver.com> Message-ID: <slrn9jvibr.is.grante@tuxtop.visi.com> On Sun, 01 Jul 2001 11:17:31 GMT, Kragen Sitaker <kragen at dnaco.net> wrote: >>You could write an operating system that could only be directly >>programmed in Python. > >I'm not sure how. Nobody has yet come up with an operating system that >could only be directly programmed in C, or Lisp, or Algol, or Java, >despite implementing operating systems in all four. Weren't Symbolics machines circa 1980 directly programmable in Lisp? -- Grant Edwards grante Yow! I'm RELIGIOUS!! I at love a man with a visi.com HAIRPIECE!! Equip me with MISSILES!! From mnenadov at stclairc.on.ca Tue Jul 24 08:29:22 2001 From: mnenadov at stclairc.on.ca (Mark Nenadov) Date: Tue, 24 Jul 2001 12:29:22 GMT Subject: Pinecones multiply like rabbits around here... References: <mailman.995975742.21691.python-list@python.org> <20010724.084018.1789376348.1751@d150-169-166.home.cgocable.net> Message-ID: <20010724.084156.1238433452.1751@d150-169-166.home.cgocable.net> In article <20010724.084018.1789376348.1751 at d150-169-166.home.cgocable.net>, "Mark Nenadov" <mnenadov at stclairc.on.ca> wrote: > sys.mathtype = "break those dark pinecones" answer = 5/2 oopps.. "darn" that is, not "dark" -- ~Mark Nenadov (author/editor for http://www.coffeecode.com) From insanc at cc.gatech.edu Mon Jul 23 13:58:17 2001 From: insanc at cc.gatech.edu (Holland King) Date: 23 Jul 2001 17:58:17 GMT Subject: interating letters Message-ID: <9jhojp$t7h$1@solaria.cc.gatech.edu> how do you interate a letter or string? for instance: a + 1 = b or aa + 1 = ab etc. in c it is similar to above and i am guessing there is an equally simple way to do it in python, i just can't figure it out. thank you for your time and help. -- --- 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 martin at strakt.com Wed Jul 4 02:45:29 2001 From: martin at strakt.com (Martin Sjögren) Date: Wed, 4 Jul 2001 08:45:29 +0200 Subject: Problems with thread state In-Reply-To: <3B422857.F1050215@q-survey.be> References: <mailman.994152665.10869.python-list@python.org> <3B422857.F1050215@q-survey.be> Message-ID: <20010704084529.B595@strakt.com> On Tue, Jul 03, 2001 at 10:17:27PM +0200, Laurent Szyster wrote: > "Martin Sj?gren" wrote: > > > > I'm trying to write an OpenSSL module for Python (purely in C) and > > I've run into a big problem. > > There's allready a Python binding for OpenSSL: M2Crypto. Combining > Medusa and M2Crypto is the fastest I can think of to develop an SSL > network client or server. I know of M2Crypto, and I've been looking at it long and seriously and come to the conclusion that it doesn't fulfill my needs. I'm not bashing the author, I've exchanged several mails with him, but I've got a few issues with M2Crypto: * It's not written entirely in C - while this might not be an issue, I'm not sure if the communications protocol I'm working on will be written in C or Python * The exception handling is somewhat weird, and at several times (because of SWIG I guess) exceptions aren't raised where they should be. * The objects sent with the exceptions are strings all the way, which is not very nice to compare over. Oh, except for when SetFromErrno is used, and I think that's used on a few places where it shouldn't too. I guess I could patch most of this if I knew something about SWIG, but the first issue - not being written in C - weighs heavily on my shoulders here :) > > Seeing as a call to SSL_connect() might block, I surrounded the call to it > > by Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS. (...) > > OpenSSL has non-blocking IO API calls. Yes it's got non-blocking IO API calls, but I'm trying to develop a general module here, one that supports blocking IO too, eventhough I may not use it at all. After all, I want to do a good job, right? -- Martin Sj?gren martin at strakt.com ICQ : 41245059 Phone: +46 (0)31 405242 Cell: +46 (0)739 169191 GPG key: http://www.strakt.com/~martin/gpg.html -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 248 bytes Desc: not available URL: <http://mail.python.org/pipermail/python-list/attachments/20010704/84353c06/attachment.sig> From robin at jessikat.fsnet.co.uk Fri Jul 27 04:14:25 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 27 Jul 2001 09:14:25 +0100 Subject: Nasty typo in PEP 238 (revised) References: <eppstein-7014B5.21120826072001@news.service.uci.edu> <mailman.996209989.30329.python-list@python.org> Message-ID: <Q29FKvAhLSY7EwU8@jessikat.fsnet.co.uk> In article <mailman.996209989.30329.python-list at python.org>, Tim Peters <tim.one at home.com> writes >[David Eppstein] .... >Virtually all the functions in the math module wrap C library functions of >the same names. floor() is a required double->double function in standard >C, and Python's math.floor() exposes the platform C's floor() function. > ... when/if the grand unification happens what will math.cos do with 1+3j? What will floor do with 1.3+0j etc etc etc. Presumably a Timbot thread is even now busily extending all math functions to the complex domain. I eagerly await the arrival of quaternions. -- Robin Becker From tjreedy at home.com Mon Jul 23 13:56:25 2001 From: tjreedy at home.com (Terry Reedy) Date: Mon, 23 Jul 2001 17:56:25 GMT Subject: PEP0238 lament References: <mailman.995839419.19134.python-list@python.org> <cEN67.17775$EP6.4652917@news1.rdc2.pa.home.com> <cp3d7ngazy.fsf@cj20424-a.reston1.va.home.com> Message-ID: <dzZ67.20235$EP6.5031096@news1.rdc2.pa.home.com> http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/nondist/p eps/ "Guido van Rossum" <guido at python.org> wrote in message news:cp3d7ngazy.fsf at cj20424-a.reston1.va.home.com... > "Terry Reedy" <tjreedy at home.com> writes: > > > >and nobody has ever proposed taking away the ability to get an > > >integer result; the issue is how to spell that. > > > > And that issue was *not* spelled out in the PEP. > > Funny, I just checked rev. 1.1 of PEP 238, and it contains the same > language about adding // as before. Maybe you never saw the PEP, but > assumed the worse based on the discussion? I just discovered how to access older versions of PEPs and checked 1.3, which I at least partly read and you are right. My view and memory of the PEP was distorted by anti-int-div float-div-religion being pushed as fact by the PEP author and some other proponents, who continue to this day. Some current examples nearly identical to several previous attempts: * "Many other languages do division correctly - Scheme, Perl and Tcl, for instance." My claim: this is a religious statement. Obvious implication of such statements: Python currently does division wrongly. Subtler implication in at least some statements of this sort: it is not intelligent to advocate that Python continue doing division wrongly. * "Integer division is a lousy tool in this particular example.." [converting bytes to Kbytes]. Combined with the previous line, this response denies the possibility of using (bytes + k/2)/k to round (or that the original poster would have known how to do so) and claims that int(float(bytes)/float(k)+.5) is factually better. I disagree. * "Nobody said [int division] wasn't of any use, people just claim it is *less* useful, and so should not be the most easily accessible." (from Moshe himself, last night). Since in any situation the most useful form of division is the one that most easily gives the correct answer, the premise is incorrect. So why do proponents even now keep repeating an incorrect and unnecessary claim to justify the change? Since the difference between '/' and '//' is too trivial to hardly discuss, I tend to interprete the 'conclusion' to be an attempt, even now, to justify something that really would be less accessible and more obnoxious than '//', like div(i,j) or divmod(i,j)[0]. When proponents of the change keep trying to justify making int div less accessible, is it any wonder that people think that that is what they really intend? [snip] > > If 238 had been written originally something like the following (which > > it now is), I would have argued *much* less. > > Shall I rub it in? :-) ...:-) Since I just recently accepted the long-term desirability of the change, you're treading on thin ice. But since you added two smileys to make sure I saw at least one, I'll take this as good-natured ribbing. > > Situation: Python '/' currently overloads and confounds two arithmetic > > operations: whole-number result division and fractional result > > division. This confuses some people. > > Proposal: Make '/' consistently mean fractional division and introduce > > a new operator '//' for truncated-result division. > > Acknowledgement: This semantic replacement is a bit different from > > most any previous change to Python. Extra care will be needed to make > > the transition as smooth as possible. > This is exactly what the PEP said all the time. NO, NO, NO! Contrary to what I said above, it still does not. Moshe writes, "Rationale The behavior of integer division is a major stumbling block ..." This prejudiced view, which too many people have unnecessarily bundled with the proposed change itself, is quite different from the division-neutral rationale you quoted above, which locates the 'problem' in the conflict *between* the two meanings. To repeat: ''' Situation: Python '/' currently overloads and confounds two arithmetic operations: whole-number result division and fractional result division. This confuses some people. ''' which I would today follow with: ''' Contention: Even though there will be many transition problems, it will be in the long term interest of some current and many future Python programmers to better separate the two meanings of 'division'. ''' Proponents have pointed out that if someone writes a function like def speed(distance, time): return distance/time without checking inputs for conformance with preconditions and if function users violate the preconditions (by feeding in two ints in this case), the function will generally return a subtlely wrong answer. Okay, but the same is just as true of def minmaxpart(n,k): return (n+k-1)/k The problem is the close overlap of the two meanings, not either in itself. I strongly recommend that the PEP Rationale (and Abstract) be rewritten in a neutral manner starting with something like "The conflict and confusion between the two closely related meanings of number division is a stumbling block in the writing of correct Python programs." In suggesting that a straightforward, if troublesome, separation of meanings be divorced from attempts to assign blame to one of the two meanings, I am attempting to help make the proposal more palatable to those, like me, who do not and will not accept the religious-philosophical views behind that assignment of blame. > > (Just noticed: http://python.sourceforge.net/peps/pep-0238.html > > now proposes a *2 year* int/int warning period starting with 2.3. It > > still needs a stipulation that someone write an intdiv checker to help > > automate replacements.) > > Hm??? I don't see that on the URL you give. Maybe you live in an > alternate universe where PEP 238 has a different contents than in mine? Your sarcasism is improving, but look again: ''' PEP: 238 Title: Non-integer Division Version: $Revision: 1.6 $ ... Changing the Semantics of the / Operator ... The warning will be off by default in the 2.2 release, and on by default for in the next Python release, and will stay in effect for 24 months. ''' Shall *I* rub it in? ;-) In *my* universe, 24 months is (24/12 =) 2 years ;-) > --Guido van Rossum (home page: http://www.python.org/~guido/) Terry J. Reedy From jdavis at empires.org Wed Jul 25 20:22:57 2001 From: jdavis at empires.org (Jeff Davis) Date: Thu, 26 Jul 2001 23:50:57 +2328 Subject: SuSE 7.2 + apache/mod_python References: <mailman.996176328.5610.python-list@python.org> Message-ID: <X8887.7994$6I3.281793@news.pacbell.net> I have dealt with my fair share of similar problems, but haven't seen this specific one. Many problems are associated with conflicting modules, especially suexec, although it doesn't look like that's your problem. Seems like a lower-level apache error with the apache API (disclaimer: I am not entirely sure about this). I would try: 1) try disabling other associated modules and if you can get it to work with any config at all, try to isolate a conflict. 2) use a new version of mod_python. I believe 2.7.5 is out. This is more likely to help you but could take a little more time than (1). I would even try upgrading apache (I think it's 1.3.20). 3) use simpler ./configure options. It might be an obscure option set that slipped through the testing. It looks like a tough problem, best of luck. I hope one of my suggestions points you in the right direction. Regards, Jeff Davis Gary Perez wrote: > Hi, all. > > I've asked the mod_python list about this twice already (no luck there). > > I'm having problems getting mod_python to work under apache. Here's the > relevant info: > > SuSE Linux 7.2, kernel 2.4.4, reiserfs > Apache 1.3.19 + Python 2.0 + mod_python 2.7.2 > > Installed (and reinstalled) apache, python (no threads) and mod_python a > few times. > > Set up the test directives in httpd.conf, proper .py module in the > htdocs/test directory as per the documentation. > > When I hit the target URL, apache kicks out an internal server error... > > ERROR LOG > [Wed Jul 18 15:58:02 2001] [notice] Apache/1.3.19 (Unix) (SuSE/Linux) > mod_layout/1.0 mod_throttle/3.0 mod_fastcgi/2.2.2 mod_ssl/2.8.3 > OpenSSL/0.9.6a PHP/4.0.4pl1 mod_perl/1.25 mod_dtcl mod_python/2.7.2 > Python/2.0 configured -- resuming normal operations > [Wed Jul 18 15:58:02 2001] [notice] suEXEC mechanism enabled (wrapper: > [/usr/sbin/suexec) Wed Jul 18 15:58:18 2001] [error] [client > [192.168.100.100] > python_handler: Dispatch() returned nothing. > > If anyone has any experience in this area or ideas as to what I can do > to figure out this annoying behavior, I'd greatly appreciate any help. > > Thanks very much, > -Gary From tim.one at home.com Sun Jul 22 16:01:31 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 22 Jul 2001 16:01:31 -0400 Subject: PEP0238 lament In-Reply-To: <E15OOXV-0003x3-00@darjeeling> Message-ID: <LNBBLJKPBEHFEDALKOLCIECKLAAA.tim.one@home.com> [TIm] > I wish the definition of continuity were easier to teach too, but that > doesn't mean I'll settle for an easier definition that doesn't actually > work <wink>. [Moshe Zadka] > Here is one that is easier to teach, if you just reverse the order > of teaching calculus and first-order logic and basic set theory. > > A function is continuous at c if, when embedding the world of Reals > into a saturated model (or, say, 2^{Beth_omega} saturated, if you > don't want to get into subtle assumptions), for every infinitesimal x, > f(c+x)-f(c) is an infintesimal. > > Of course, you might think that teaching about saturation is hard -- > well, it might be ;-) Na, they always leave *some* of the foundations in intro calculus courses fuzzy. H. Jerome Keisler wrote a very good intro calculus text based on non-standard analysis, unfortunately now out of print. See http://www.math.wisc.edu/~keisler/books.html for publication details. He didn't try to explain the intricacies of model theory, he just spelled out "the rules" for working with infinitesimals and got on with it. Huge steaming masses of epsilon-delta proofs were conspicuous by absence, so he was able to get to "the interesting stuff" a lot quicker that way. A good feel for the flavor of the approach can be gotten by skipping to the end ("Part IV: Turning Calculus into Algebra") of http://online.sfsu.edu/~brian271/nsa.pdf and reading "~=" as "infinitely close to". > i-always-blamed-cauchy-and-weirstrass-for-tormenting-the-world- > with-epsilons-and-deltas-ly y'rs, Z. i-personally-blame-guido-for-letting-it-stand<wink>-ly y'rs - tim From bsass at freenet.edmonton.ab.ca Thu Jul 12 16:50:35 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Thu, 12 Jul 2001 14:50:35 -0600 (MDT) Subject: Long Live Python! In-Reply-To: <021e01c10b04$74352820$0300a8c0@arthur> Message-ID: <Pine.LNX.4.33.0107121323300.21929-100000@bms> On Thu, 12 Jul 2001, Alex Martelli wrote: > "Bruce Sass" <bsass at freenet.edmonton.ab.ca> writes: > ... > > The point was that python and sh operate on different levels. > > So they do. Python operates, much like Perl and most other > scripting languages, mostly by operations in the languages > itself and its libraries; sh (although bash and ksh move it a > bit away from that) basically relies on external programs. Python, Perl, Bash, etc., have moved the nototion of scripting away from the earlier connotations (which came first sh, or Python, Perl, Bash, etc.) > > $ cat file*1 file*2 file*3 | tee file4 | wc -cwl >> file5 > > > > (i.e., concatenate some unknown number of files whose names match one > > of three patterns, write the result to a file and count the > > characters, lines and words, appending that result to a different > > file) > > > > is what in Python.... > > ...2 lines, 3, 4, an explicit loop, a function or two, or maybe a > > program (i.e., some imports, assignments, blocks of code, ...)? > > If you do not need cross-platform operation, you can do it the > same way (except that you most always need to import...): > > import os > os.system('cat file*1 file*2 file*3 | tee file4 | wc -cwl >> file5') > > This, of course, is anything BUT idiomatic, because you have no > control at all -- you're delegating everything to external programs, > just like in sh. What will happen on OS/2, Macintosh, Windows, > VMS, or a Sony Playstation? What happens if there are too many > files called 'file'+something+'2' and you overflow the number of > arguments allowed on some older Unix-ish box? Etc, etc. Most > likely, one would program it differently, solidly, and portably: ...and if I wanted a robust, cross-platform implementation I would write a program... but all I [just for the sake of argument] want is to save a little bit of typing... > import fileinput > from glob import glob > > file4 = open('file4','w') > lines = words = chars = 0 > for line in fileinput.input(glob('file*1')+glob('file*2')+glob('file*3')): > file4.write(line) > lines += 1 > words += len(line.split()) > chars += len(line) > file4.close() > file5 = open('file5','a') > file5.write("%s lines, %s words, %s chars\n"%(lines,words,chars)) > file5.close() Q.E.D. ? > But the fact that one CAN do it differently doesn't mean the "different" > way is inferior. os.system and friends are there, for those times where > you want to operate this way. So are excellent facilities for operating > differently. It's silly to claim that giving you a choice makes Python > inferior to sh for such operations. ... of course it depends on what the objective is. It is silly to claim that `Python is just as good at ... as ...' when examples like the above are so easy to come up with. """ import os os.system('cat file*1 file*2 file*3 | tee file4 | wc -cwl >> file5') """ Is Ok when you are in the Python Interpreter, but would you do... $ python -c "import os;os.system('cat file*1 file*2 file*3 | tee file4 | wc -cwl >> file5')" ...from the command line that comes up when you login? Keep in mind that I never claimed Python to be inferior to anything, just that it is a "horrible scripting language" (and am now getting shot at for not qualifying the statement :). > > Ya, I know, for some... "script" == "interpreted", for the rest of > > us... "script" == "automating a sequence of command line operations". > > I guess it was a mistake to play off that bit of ambiguousness as an > > introduction to the point. > > "script"=="interpreted" seems just silly. But where do the *command > line* operations get into the "scripting" concept?! "Automating a > sequence of operations" seems just right. Yes, that is sorta what I wanted to say... > That sh is basically able > to do it for (some) "command line" operations, but not really for ones > based on other paradigms, is sh's problem -- it doesn't define the > concept of 'scripting'. For example, with VIM (Vi IMproved), I can use > Python for scripts, which automate sequences of editing operations > that are anything *but* "command-line" -- one doesn't *HAVE* to > resort to command-line-oriented editors (ed, ex, sed, ...) to script them, > as long as the available scripting language and infrastructure are > good enough. ...and I deserve the virtual slap-upside-the-head for mentioning "commandline" in that context without qualifying it... > sh and its descendants just _aren't_ good enough for > the kind of rich, complicated scripting tasks that Python (and, though > I loathe to admit it, Perl, Tcl, VBScript, &c) handle with ease today. ...then would want to argue about the difference between a "script" and a "program". I see it this way, if a script is only, "Automating a sequence of operations" -- C programs are scripts -- there must be more to it, eh. Just for fun (dictionaries are fun, but unless the majority of the definitions agree... it is still, really, just connotation) I did: --- $ dict "scripting language" <...> >From The Free On-line Dictionary of Computing (06 Jun 01) [foldoc]: scripting language <language> (Or "glue language") A loose term for any language that is {weakly typed} or {untyped} and has little or no provision for complex {data structures}. A program in a scripting language (a "{script}") is often {interpreted} (but see {Ousterhout's dichotomy}). Scripts typically interact either with other programs (often as {glue}) or with a set of functions provided by the interpreter, as with the {file system} functions provided in a {UNIX shell} and with {Tcl}'s {GUI} functions. Prototypical scripting languages are {AppleScript}, {C Shell}, MSDOS {batch files}, and {Tcl}. (2001-03-06) --- [Ousterhout's dichotomy... mainly refers to the arbitrary catagorization of languages into "interpreted" vs. "compiled".] <shrug> At least I know I'm not alone with my OF restricted view of what `scripting' is. - Bruce From chrishbarker at home.net Thu Jul 5 16:49:42 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 05 Jul 2001 13:49:42 -0700 Subject: There's got to be an easy way to do this References: <ABEE81BE08ADD311B6A1009027DE908D0BD87D90@conmsx03.conway.acxiom.com> <mailman.994351690.22119.python-list@python.org> <9i27i8$gd9bq$1@ID-11957.news.dfncis.de> Message-ID: <3B44D2E6.A7024AFE@home.net> > > > I am reading in a phone number field and would like to throw away > everything > > > except the digits. Being an old C programmer, I know how I would do > this. > > > but with all of the data structure support native to Python, I'm sure > there > > > is "an obvious way" to do it (perhaps it's because I'm not Dutch:-). I havn't see this whole thread, but did anyone suggest the translate string method?: >>> table = "".join([chr(x) for x in range(256)]) >>> remove = table.replace("0123456789","") >>> "555-343:564-othergarbage987".translate(table,remove) '555343564987' I imagine it's a lot faster that REs. (I'm only imagining). Note: does anyone know if there is a way to use the delete part without the translate part? -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 Thu Jul 26 17:54:50 2001 From: guido at python.org (Guido van Rossum) Date: Thu, 26 Jul 2001 21:54:50 GMT Subject: Operator symbol for "nb_intdivide" References: <C0Z77.8508$uM6.1020602@news1.telusplanet.net> Message-ID: <cpg0bj5pb3.fsf@cj20424-a.reston1.va.home.com> Peter Dobcsanyi <petrus at pobox.com> writes: > But, I don't like the "//" operator symbol what we are supposed to use > for implementing "a // b == floor(a/b)". Here are my reasons, in not any > particular order reflecting (my subjectively assigned) importance: > > - It is ugly, two characters. Lots of operators are two characters (**, <<, ==). > - Some languages use it for starting comments. So? Some languages use a semicolon as a comment. Does that mean we can't use it as a statement separator? > - "//" is hard to read, i.e. quickly clearly distinguish from "/" > the other division operator. I don't believe this. If you can't distinguish / from //, you need new glasses. :-) > - When the transition period over (around 3.x or something) the > visual and typing characteristic of "//" can be source of error. *Any* choice of symbol can be a source of error. > At some stage in the future, the warnings will be turned off, everybody > knows the new rules. But typing mistakes, oversights happen, so I can > accidentally write "/" instead of "//" and vice versa: > > def foo(x,y): > # stuff here > ... > z = x / y > .. > # blah blah > .. > > i_wanted_int_div_but_mistyped_then_did_not_notice_for_a_while = foo > > And there is no warning any more. *Usually* this will be clear very quickly because at some point the expected resulting integer will be fed into an operation that requires integers, e.g. list[i] or i<<n. > I would like to suggest to use a clearly distinguishable one-character > symbol for the "nb_intdivide". PEP238 is to fix a "design fault". If we > go for it despite of all the _temporary_ pain, we should not be shy, > there is nothing wrong with doing it radically not just semantically but > also visually. One of the nice virtue of the Python language is that it > is readable, keep it this way. > > "nb_intdivide" and "nb_divide" are very different let's show this > difference. Among the still free symbols ("?", "@", "$" I guess) I > would suggest to use "$" for the integer division. > > Running_for_cover_ly y'rs, You had me there for a moment... :-) --Guido van Rossum (home page: http://www.python.org/~guido/) From gtcopeland at earthlink.net Thu Jul 12 21:57:42 2001 From: gtcopeland at earthlink.net (Greg Copeland) Date: 12 Jul 2001 20:57:42 -0500 Subject: SocketServer returns bad file descriptor References: <74cc9702.0107110622.6d95a609@posting.google.com> <mailman.994925661.7628.python-list@python.org> Message-ID: <m2y9ptwpyh.fsf@mouse.copelandconsulting.net> Thomas Wouters <thomas at xs4all.net> writes: > > This looks suspiciously like a bad bug Guido fixed in the SocketServer > module just a few days ago. If so, it'll be fixed in Python 2.2 and Python > 2.1.1 (of which the release candidate should be released tomorrow, if all > goes well.) You can grab the CVS tree for either and find out -- the > SocketServer.py module can just be dropped into your current Python library > directory. You can get it through SourceForge, using ViewCVS: > Man! I just finished asking about this a couple of minutes ago!!! Thanks!!! Greg From JamesL at Lugoj.Com Fri Jul 27 14:50:12 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Fri, 27 Jul 2001 11:50:12 -0700 Subject: PEP 238 (revised) References: <cp4rrz5onj.fsf@cj20424-a.reston1.va.home.com> <slrn9m3bt8.114.sill@sill.silmarill.org> Message-ID: <3B61B7E4.5C6DFF01@Lugoj.Com> Andrei Kulakov wrote: > > On Thu, 26 Jul 2001 22:09:06 GMT, Guido van Rossum <guido at python.org> wrote: > > > > The correct work-around is subtle: casting an argument to float() > > is wrong if it could be a complex number; adding 0.0 to an > > argument doesn't preserve the sign of the argument if it was minus > > zero. > > When is 0 different from -0? When doing ones-complement arithmetic. Not too many machines use that anymore, and the ones that did (or do) should have comparison logic to consider -0 == 0. The CDC Cyber series used ones-complement. From philh at comuno.freeserve.co.uk Sun Jul 8 15:20:31 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Sun, 8 Jul 2001 20:20:31 +0100 Subject: Bug in rfc822 Message-ID: <slrn9khcjv.c7q.philh@comuno.freeserve.co.uk> Python Bug Report #437395 states: The rfc822 and smtplib modules need to be checked for conformance with RFC 2822, which obsoletes RFC 822. (Added this to the tracker so we don't lose track of this.) I have just found out that rfc822.py doesn't conform to RFC2822. As an example, when we have a field: From: From: A. N. Other <another at nowhere.org.ca> then getaddr("From") returns ('', 'A.N.Other') which is incorrect. When the from line is changed to: From: From: A N Other <another at nowhere.org.ca> then getaddr("From") correctly returns ('A N Other', 'another at nowhere.org.ca') The relevant parts of the syntax specified in rfc2822 are: from = "From:" mailbox-list CRLF mailbox-list = (mailbox *("," mailbox)) / obs-mbox-list mailbox = name-addr / addr-spec name-addr = [display-name] angle-addr display-name = phrase phrase = 1*word / obs-phrase obs-phrase = word *(word / "." / CFWS) >From rfc2822, section 4.1: Note: The "period" (or "full stop") character (".") in obs-phrase is not a form that was allowed in earlier versions of this or any other standard. Period (nor any other character from specials) was not allowed in phrase because it introduced a parsing difficulty distinguishing between phrases and portions of an addr-spec (see section 4.4). It appears here because the period character is currently used in many messages in the display-name portion of addresses, especially for initials in names, and therefore must be interpreted properly. In the future, period may appear in the regular syntax of phrase. I have added a comment to bug #437395, to this effect. Do I need to notify anyone else? The Bug Report says it was submitted by Fred Drake, and assigned to Barry Warsaw. -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From sdm7g at Virginia.EDU Thu Jul 26 20:53:34 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Thu, 26 Jul 2001 20:53:34 -0400 (EDT) Subject: Suggestion for impriving list comprehensions In-Reply-To: <cpofq75qax.fsf@cj20424-a.reston1.va.home.com> Message-ID: <Pine.NXT.4.21.0107262020310.744-100000@localhost.virginia.edu> On Thu, 26 Jul 2001, Guido van Rossum wrote: > paul at svensson.org (Paul Svensson) writes: > > > I would like to suggest that we add a "while condition" clause > > to list comprehensions, similar to the "if condition" clause, > > but terminating the list comprehension on the first false condition. > > The above example could then be written as > > > > [x for x in fib() while x < 50] > > Neat, but maybe not general enough. How do you request the first N? > And fuzzy: does this include or exclude the first x >= 50? > > How about a library of functions for iterator algebra? E.g. > How about: >>> def dowhile( seq, test ): ... for x in seq: ... if test(x): yield x ... else: break ... >>> def until( seq, test ): ... for x in seq: ... yield x ... if test(x) : break ... >>> [ x for x in until( range(100), lambda x: x > 12 ) ] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] >>> [ x for x in until( fib(), lambda x: x > 50 ) ] [1, 1, 2, 3, 5, 8, 13, 21, 34, 55] >>> [ x for x in dowhile( fib(), lambda x: x < 50 ) ] [1, 1, 2, 3, 5, 8, 13, 21, 34] >>> ( where fib is the generator version ) And maybe, Icon inspired: >>> def every( s ): ... return [ x for x in s ] >>> every( range(10) ) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> every( iter( fib().next, 55 ) ) [1, 1, 2, 3, 5, 8, 13, 21, 34] >>> every( dowhile( fib(), lambda x: x < 50 )) [1, 1, 2, 3, 5, 8, 13, 21, 34] >>> If there was a version of iter that was: iter( genfunc, boolfunc ) along with: iter( genfunc, sentinal ) But checking for whether the second arg is callable is no good if it's possible to iterate thru functions,methods or classes. Maybe a three arg version: iter( genfunc, sentinal, boolfunc ) and if you don't care about the sentinal, pass an arg that won't be produced by the generator. ( None maybe, depending. ) [ But maybe the generator versions above are better. I'm still getting used to this new stuff. Sometimes the syntax seems a bit awkward. I hope that this __future__ stuff is not cast in stone until we've had time to see how it works. ] -- Steve Majewski From tim.one at home.com Wed Jul 25 18:01:44 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 25 Jul 2001 18:01:44 -0400 Subject: importing modules In-Reply-To: <3b5f38c5.112013116@news.libero.it> Message-ID: <LNBBLJKPBEHFEDALKOLCOEDPLBAA.tim.one@home.com> [Duilio Foschi] > http://www.hvision.nl/~ivnowa/newsite/Python/Python-DX/python-dx.html > > "Hans Nowak's Python-DX is a version of Python for 32-bit DOS. > Python-DX is equivalent to Python 1.5.2, but Hans no longer maintains > it, so it's doubtful that Python 1.6 will be supported. " > > what shoud I do ? If I were you, I'd ask Hans -- it's his package. Did you read his FAQ? Specificially 6. Python runs, but I get error messages/cannot find library files? at <http://www.hvision.nl/~ivnowa/newsite/Python/Python-DX/ Python-DX_FAQ/python-dx_faq.html> > Or - put it in a different way - which is fully working version for > Dos I should download ? Sorry, I don't know of any actively maintained Python for DOS. Python runs on all flavors of Windows, but official support for DOS was dropped some time ago due to utter lack of user interest and user volunteers. Anyone else know of one? From tundra at tundraware.com Fri Jul 27 00:40:01 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 27 Jul 2001 04:40:01 GMT Subject: Distributed computing using SOAP. What about speed ? References: <LBA77.58$bXi.175168000@news.telia.no> <dc6f5c99.0107251655.f3c625b@posting.google.com> <3B5FC733.5186D588@tundraware.com> <dc6f5c99.0107261825.7e74fa89@posting.google.com> Message-ID: <3B60EEA0.70BC492A@tundraware.com> A gracious Graham Dumpleton wrote: <SNIP> > I will look at your paper. You may want to look further at the Python > manual for OSE and you might see it ain't quite what you first had in > mind. I guess I should clarify something. In order to have "transactional correctness" you have to have a reliable transport somewhere in the stack below the transactional elements (or transport reliability has to be synthesized at the transactional layer - a really bad idea). So long as the synchronous semantics of the reliable (connection-oriented, usually, although there have been attempts made at reliable datagrams) transport are not exposed to the *distributed application*, we can do what is needed. For example, if the underlying transport is RPC over http (as in SOAP), that's fine if: 1) Distributed apps don't see the RPC semantics and spin-lock waiting for calls to complete. 2) Transport reconnection is automatic and invisible to the application which sees the appearance of an apparently "always up, but not always fast" network underneath it. 3) All this layering of protocols is not excessively punative in performance. 4) The underlying speeds-n-feeds are up to the task of setting up and tearing down sessions for each object invocation. For seriously big apps, they are NOT, so you have either session pool, or run dedicated sessions based on the applications topology and multiplex access across those sessions. In an ideal world, you's have a layering scheme something like this: Chunk of distributed application. | and/or | ------------------------------------------- tx Queuing API | Direct Message Passing API ------------------------------------------- tx Q Manager M| | M ---------------- | Reliable Messaging Layer -------------------------------------------- Where, "M" is a pluggable Reliable Comms Transport M management & security -------------------------------------------- facility for each layer Speeds, Feeds, & Wire M in question -------------------------------------------- (You'll notice that my picture is a bit different than the usual one in which Q management lives *below* the messaging layer. This is a matter of taste because you can accomplish the same things either way. In any case, if you need message persistence as a class of service (almost all enterprises need this on occasion), you will end up implementing a disk-based Q under the Messaging Layer above and beyond what the Transactional Q Manager has to do.) The problem is that everyone is more-or-less proposing that chunks of a distributed application talk some simple API (.NET/J2EE) which connects directly to the Reliable Comms Transport layers which is The Path To Hell as I describe in the paper. One other point. The natural unit of distribution (how big a "chunk" should be distributed) is NOT an object (except for object programmers ;). Distributing things at the granularity of an object is just *begging* for trouble when you need to recover from a network outage, a machine failure, or some other badness. Distributed objects are swell inside a small, contained, topology, but sending millions of objects into orbit around the Net (as both .NET and EJB/J2EE/et al propose) will make all our applications run with the reliability we've come to know and love with Windows - i.e. prepare to "reboot" your distributed applications components regularly. A far better scheme is to first do a thorough Business Process Flow analysis and let that suggest what the major unit is applications *functionality* might be. Then distribute at the more coarse-grained "fat component = several thousand objects" level. This is how we essentially divided up what was the largest commercial TX processing system about 20 years ago (airline) - no objects, but the idea was the same. We went from one very saturated giant mainframe to 7 mainframes (barely keeping up ;). We distributed at the very coarse-grained level of "This machine does domestic fare quotes.", "This machine does intl fare quotes.", "This machine does reservation bookings.", "This machine loses your luggage.", and so on. While this approach is heresey to the "everything is an object and distributed objects are the wave of the future" religion being taught to the youngsters in school, it is the only rational way to put up a system that runs at 20,000+ TPC/A per second, has 1 minute of outage per year, and serves 100,000+ global customers with guaranteed round-trip response times of <4 sec for the biggest customers. (This is only possible on a private network - you cannot begin to approach this on the internet because of unpredicatable propagation delays in the fabric.) IOW, you can distribute at the object level only if you are certain that the system as a whole can be recovered from failure in an adequately short (as defined by the business requirements) period of time. For the typical web shopping or even simple B2B application, this might be feasible over the Net. But, at least in my experience, for really big mission-critical systems where human life or the economic survival of an institution is at stake, distributed objects won't cut it. I will look into OSE further - now I'm intrigued. ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From leenutter at australia.edu Sun Jul 22 11:30:25 2001 From: leenutter at australia.edu (Lee Nutter) Date: Mon, 23 Jul 2001 01:30:25 +1000 Subject: Hello, References: <mailman.995736253.29035.python-list@python.org> <etd3d7qxi88.fsf@w20-575-7.mit.edu> <9jeafl$46q$1@nntp9.atl.mindspring.net> Message-ID: <3B5AF191.9030609@australia.edu> Thanks for all you helps guys! It has given me a few things to think about :) When I get to writing big programs, I will use normal log files. You have twisted my arm :) But for now, I was just messing around, so I will implement some of your ideas / code. Thanks again! From paulp at ActiveState.com Wed Jul 4 13:12:09 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Wed, 04 Jul 2001 10:12:09 -0700 Subject: Comment on PEP-0238 References: <3B3BE855.A6223E70@3-cities.com> <cp7kxvlake.fsf@cj20424-a.reston1.va.home.com> <Y4J%6.4084$Z6.2010194@news1.rdc2.pa.home.com> <mailman.994016102.30019.python-list@python.org> <7ef50c46.0107020554.31cc948b@posting.google.com> <mailman.994084684.19932.python-list@python.org> <7ef50c46.0107030657.2e0fc92b@posting.google.com> <mailman.994177387.31239.python-list@python.org> <9ht7ki$pao$1@nntp6.u.washington.edu> <mailman.994191428.24168.python-list@python.org> <3B42B707.9EF02768@3-cities.com> Message-ID: <3B434E69.BC7B960C@ActiveState.com> "Robert J. Harrison" wrote: > >... > > If a tree falls in the forest and the BDFL is not there to hear it, > does it make a sound? Seriously, if the powers that be have a rigid > opinion on this subject, I'd like to be put of our misery. Or is > this discussion contributing to decision making? I doubt that this particular discussion is contributing to his decision making because it's a rehash of discussions that have been had before a hundred times. I'm sure he's got better things to do than read it. It could be productive if it lead to a new community consensus. Guido does listen when enough people tell him he's wrong. But when half say he's wrong and half say he's right, he's most likely to go with what he's already decided. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From grzegorz at ugrad.cs.ualberta.ca Wed Jul 25 16:36:51 2001 From: grzegorz at ugrad.cs.ualberta.ca (Grzegorz Dostatni) Date: Wed, 25 Jul 2001 14:36:51 -0600 Subject: Selecting text in Tkinter.Text Message-ID: <Pine.GSO.4.21.0107251431370.5757-100000@csu038.cs.ualberta.ca> Hello. What I want to do sounds simple. I've created a widget that extends Tkinter.Text widget. It supposed to display database tables. I want the user to be able to select rows (ie ignore borders/empyspaces, etc) in an intelligent manner. I can bind a function to '<B1-Motion>' but I haven't been able to figure out how to change the current selection to what I want? (ie. modify sel.first to be the beginning of the row for example). I know what i need is probably somewhere in the documentation... I'll keep on reading it, hope someone helps me though ;-) Greg _-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_ Some family trees bear an enormous crop of nuts. Wayne H. Drawing on my fine command of language, I said nothing. *Anonymous From vAbazarov at dAnai.com Sun Jul 29 00:31:37 2001 From: vAbazarov at dAnai.com (Victor Bazarov) Date: Sun, 29 Jul 2001 04:31:37 GMT Subject: Unusual minidom behaviour: Part Deux References: <vKJ77.12050$Up.355596@sea-read.news.verio.net> <j466cdv68p.fsf@informatik.hu-berlin.de> <umC87.8184$Kd7.4940000@news1.rdc1.sfba.home.com> <mailman.996373135.2559.python-list@python.org> Message-ID: <JkM87.10500$Kd7.5942572@news1.rdc1.sfba.home.com> "Paul Prescod" <paulp at ActiveState.com> wrote... > Victor Bazarov wrote: > > > >... > > > How exactly did you find out about that? If one of the threads would > > > raise an exception that is not caught, would you see the traceback or > > > would it get eaten silently by the calling Java application? > > > > I don't know the answer to that question. However, I think that > > any exception that is not caught in Python code would be caught > > in Python interpreter my Java application runs. Is it not true? > > He didn't ask about whether the *exception* is getting eaten siliently. > He asked about the traceback. i.e. the text written to stderr in the > event of an exception. No, I am reading all the Python output and if there were any, I'd have seen it. Victor -- Please remove capital A's from my address when replying by mail From emile at fcfw.fenx.com Tue Jul 10 22:08:51 2001 From: emile at fcfw.fenx.com (Emile van Sebille) Date: Tue, 10 Jul 2001 19:08:51 -0700 Subject: Comment on PEP-0238 References: <01Jul10.184408pdt."3453"@watson.parc.xerox.com> Message-ID: <12a201c109ae$7a3bbf60$0a06a8c0@FENX.COM> That shouldn't affect what I'm after. I've managed to put together a python based simple implementation that does add, subtract, multiply and divide so far, though no negatives yet. As I work through that, I'm considering how this may/should impact things so I can flesh out a potential PEP. Maybe by next week or so. Now if only the customers would cooperate and stop giving me new projects so I can get some time... Emile van Sebille emile at fenx.com --------- ----- Original Message ----- From: "Bill Janssen" <janssen at parc.xerox.com> To: "Guido van Rossum" <guido at python.org>; <emile at fenx.com> Cc: <python-list at python.org> Sent: Tuesday, July 10, 2001 6:44 PM Subject: Re: Comment on PEP-0238 > Actually, if you're going to go in this direction, why not do what I > proposed for HTTP-NG, which is to use a "denominator" rather than a > decimal precision? The denominator implicitly specifies the precision. > > So, if I want two decimal places, I specify "denominator 100", which > mean that the result will be figured in hundredths. This easily > allows one to work in 16ths, 3rds, or other fractional amounts. > > >>> denominator 100 > >>> print 2/7 #-> 0.28 > >>> denominator 7 > >>> print 2/7 #-> 0.285714285714... > > This is, of course, just another use of rationals, since the > denominator used must be stored with each value. > > At the very least, if you use "precision" to mean decimal precision, > use "decimal_precision". > > Bill > > From nhodgson at bigpond.net.au Fri Jul 6 20:27:02 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Sat, 07 Jul 2001 00:27:02 GMT Subject: Postgres support References: <gul1kts5l6aolk55o7vguk97uorjd08j9f@4ax.com> <5174eed0.0107061058.5446dac9@posting.google.com> Message-ID: <qHs17.2494$4B5.15547@news-server.bigpond.net.au> Edward Wilson: > Python will only appeal to scientific developers researching > the "impossible to do" until it handles databases on a first > class scale. Oh, and another point, ODBC is dead. Microsoft > has already abandand it for OLEDB a COM based library. > References to ODBC need not apply. Python's COM support handles ADO which is the most commonly used interface to OLEDB. Using calldll you can even call the lower level OLEDB directly although there is generally no need to do so - the reason I did this was when writing an OLEDB provider to perform experiments and for testing. BTW, Microsoft is already moving on to ADO.NET and, of course, Python for .NET will be able to use it. Neil From mikael at isy.liu.se Tue Jul 31 02:56:44 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Tue, 31 Jul 2001 08:56:44 +0200 (MET DST) Subject: [OT] Number theory [Was: A use for integer quotients] In-Reply-To: <slrn.pl.9mcgi8.fpt.qrczak@qrnik.zagroda> Message-ID: <XFMail.20010731085639.mikael@isy.liu.se> On 31-Jul-2001 Marcin 'Qrczak' Kowalczyk wrote: > Really? In Polish a different form of "there were" and "errors" > is needed depending on whether > n%10 in (2,3,4) and (n//10)%10 != 1 > or not :-) At last, I have reason *not* to learn Polish. :o) One-language-down-a-few-thousand-to-go-ly y'rs /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson <mikael at isy.liu.se> WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 31-Jul-2001 Time: 08:53:51 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From stevee at recombinant.demon.co.uk Tue Jul 3 15:08:18 2001 From: stevee at recombinant.demon.co.uk (Stephen D Evans) Date: Tue, 03 Jul 2001 20:08:18 +0100 Subject: accessing class data members References: <3B420804.9882D166@bioeng.ucsd.edu> Message-ID: <3B421822.572A5CDD@recombinant.demon.co.uk> Curtis, It's a question of style/performance. Neither obj.temperature nor obj.get_temperature() are necessarily better. Accessing a class variable directly or indirectly via a function are both valid and have advantages/disadvantages depending on the language/task. For indirect variable access via a function: * In a compiled language the indirect access via a function call can be optimised away by the compiler, so there may be no loss of runtime speed. * In Python there is the overhead of a function call, therefore potentially slower. * If the function does not exist, the code crashes. * Debugging is easier as all accesses to the variable can be trapped/traced. For direct variable access: * In Python this is quicker. * It is possible to set a 'typo', e.g. obj.temperature_oops = t without any complaint, but not (always) retrieve one e.g. t = obj.temperature_oops may or may not work. * Possibly harder to debug the code. For quick and dirty debugging in Python it is possible to override the __getattr__ and __setattr__ class methods and thus provide the equivalent of obj.get_temperature() and obj.set_temperature(t) while using obj.temperature in the code. Use has to be made of the __getattr__/__setattr__ asymmetry. class UpperClassTwitOfTheYear: """An example for debugging only""" def __setattr__(self, name, value): if name == 'temperature': name = 'hidden_temperature' # rename, place debugging code here self.__dict__[name] = value def __getattr__(self, name): assert name=='temperature' # should only be called for this return self.__dict__['hidden_temperature'] Having looked at a lot of Python code and programmed in Python regularly for over a year, I generally use direct access to the class variable in Python i.e. obj.temperature Stephen D Evans Curtis Jensen wrote: > In many OO languages, and theory, it is often the case that when you > want to know the value of some data member, that a function is written > to return that value. However, in Python it seems that people just > access the data member directly. > > for example: > if there were a class that represented a physical object. In the class > there were data members that held the objects temperature and location. > If I wanted to know the temperature of an object, I could just use > obj.temperature. Though in other languages, the convention seems to > call a function that returns the value, like: obj.get_temperature. > > Which is better? > > -- > Curtis Jensen > cjensen at bioeng.ucsd.edu > http://www-bioeng.ucsd.edu/~cjensen/ > FAX (425) 740-1451 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-list/attachments/20010703/ce95ec10/attachment.html> From JamesL at Lugoj.Com Sun Jul 22 16:29:45 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Sun, 22 Jul 2001 13:29:45 -0700 Subject: PEP0238 lament References: <mailman.995826216.11537.python-list@python.org> Message-ID: <3B5B37B9.4D7A80CD@Lugoj.Com> Tim Peters wrote: > By show of hands, about 3/4ths of the > participants agreed that 3/4 should not return 0, but rather *something* x > such that x*4 had a better chance of being confused with 3 than with 0. > There was no consensus on exactly what 3/4 should return -- rational or HW > float or decimal float were the most popular alternatives. This has probably already been brought up, but perhaps the problem lies not with the "/" operator, but one step earlier in distinguishing the meaning of: x = 3 and x = 3. That is subtle difference that can cause quite different results later on. Or, one may try to teach that when ALL arguments of an operator are in one "set", such as the set of integers, then one must expect a result that is an element from THAT set, not another set, such as the set of real numbers or from the set of complex numbers. Set theory seems to be taught fairly early on in math, I think. It has been my observation that people can often quickly grasp and make use of the common underlying general principles behind things after having seen only a few examples, provided there is a CONSISTENT underlying principle. A handful of general rules may be easier to teach than a collection of special cases. So can and should Python adopt an underlying principle along the lines where one can grasp the following pattern: integer = integer operator integer real = integer operator real real = real operator integer real = real operator real complex = integer operator complex ... I prefer a handful of general rules, and operators that obey them. From tim.hochberg at ieee.org Fri Jul 27 10:24:12 2001 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Fri, 27 Jul 2001 14:24:12 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <eppstein-03540D.13070222072001@news.service.uci.edu> <LNBBLJKPBEHFEDALKOLCOECNLAAA.tim.one@home.com> <mailman.995899647.346.python-list@python.org> <tclolt053o18f8q0ntb7n4aggitdkmeg4h@4ax.com> <Io_67.23543$B7.3779351@ruti.visi.com> <slrn9lp2m5.vp.Gareth.McCaughan@g.local> <p56plt8q4rs3bgcqbepk61q2r3g0tr2vhe@4ax.com> <slrn9ls3ae.2fm.Gareth.McCaughan@g.local> <cpitghbq05.fsf@cj20424-a.reston1.va.home.com> <MWD77.27751$EP6.6983549@news1.rdc2.pa.home.com> <9jnt9p$qhe$1@newsy.ifm.liu.se> <SYV77.27286$B7.4239335@ruti.visi.com> <cpitgf7itx.fsf@cj20424-a.reston1.va.home.com> <WIY77.27607$B7.4257794@ruti.visi.com> <cp3d7j75jv.fsf@cj20424-a.reston1.va.home.com> <Uj587.32158$EP6.8364145@news1.rdc2.pa.home.com> <3b613855.540809753@wa.news.verio.net> <cpsnfi4h2a.fsf@cj20424-a.reston1.va.home.com> Message-ID: <gQe87.53150$Cy.6859156@news1.rdc1.az.home.com> "Guido van Rossum" <guido at python.org>: > bokr at accessone.com (Bengt Richter) writes: > > ISTM floor couldn't make an exact number out of an inexact one > > unless the inexactness was known to be constrained to the halfopen > > interval above the floor. > > Good point. I guess the question becomes, does "exactness" mean just precision, or both precision and accuracy. The result of floor is infinitely precise, but it's accuracy is potentially suspect. It seems that any[1] operation that converts imprecise numbers to precise numbers is going to have this problem , so it seems best just to define "exactness" to be "infinite precision" and live with the consequences. -tim [1] I suppose you could map all numbers to a constant and I suppose that wouldn't have any accuracy problems, but it's not very interesting. From loewis at informatik.hu-berlin.de Sat Jul 21 15:30:19 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 21 Jul 2001 21:30:19 +0200 Subject: Handling errors in PyXML/SAX References: <3B545EB5.6BB5DF57@wyeth.gsfc.nasa.gov> <j4vgkogipu.fsf@informatik.hu-berlin.de> <3B58922C.26289F15@wyeth.gsfc.nasa.gov> Message-ID: <j4puaugjw4.fsf@informatik.hu-berlin.de> Tom Bridgman <bridgman at wyeth.gsfc.nasa.gov> writes: > parser.parse(inputfilename) does work. It's not clear from the > documentation at http://py-howto.sourceforge.net/xml-ref/node20.html > that systemID is a file name, even though I was guessing this at a > couple of spots. In fact, in XML, system IDs are URLs; see the XML recommendation for details. To allow file names is an extension, and there is often heated debate as to whether this is desirable, since you cannot tell a file name from an URL (in particular if the file name is C:/foo/bar.xml). Regards, Martin From tim.one at home.com Mon Jul 23 22:15:01 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 23 Jul 2001 22:15:01 -0400 Subject: A use for integer quotients In-Reply-To: <3b5c990b.237461111@wa.news.verio.net> Message-ID: <LNBBLJKPBEHFEDALKOLCOEIGLAAA.tim.one@home.com> [Bengt Richter] > This reminds me, is Python configurable to run on a platform with no > floating point support? Not directly, but it doesn't use fp extensively. Support for complex numbers can be dropped via a preprocessor symbol, but we never build it that way so I wouldn't bet your life it still works <wink>. > With Linux being embedded all over the place, it seems like it > would come up. Do the mini hand-helds (not to mention cell phones) > have floating point? Most small platforms have (software) FP emulation libraries. From db3l at fitlinxx.com Wed Jul 4 16:18:38 2001 From: db3l at fitlinxx.com (David Bolen) Date: 04 Jul 2001 16:18:38 -0400 Subject: Phonebook entry in windows References: <mailman.994232826.25668.python-list@python.org> Message-ID: <ulmm478ip.fsf@ctwd0143.fitlinxx.com> Antonio Navarro Navarro <hostmaster at bemarnet.es> writes: > I need to write a stand-alone Python application that will run like a > daemon (started at windows boot) to create a Phonebook entry on a > Windows 95 machine, start up a connection, make some FTP transfers and > then hang up and delete the connection. > > I have been reading the mailing list and have found several references > to win32ras.CreatePhonebookEntry, EditPhonebookEntry, etc, but I don't > know if this functions are fully functional. The problem with the currently wrapped functions in win32ras is that they all involve GUI interaction with the user. That is, they behave just as if the user was creating or editing the entry. I do not believe that any functions are currently wrapped that will let you silently create such entries. > Where can I find more info, for example a working script that > creates-connect-disconnect-deletes a phonebook entry in Python ? Well, the rastest.py module in the demos directory of the win32all installation (under <pythonroot>/win32) exercises most of the functions including a sample of a callback with the Dial function. > Do you think It will be better to use a different approach ? (I prefer > not to use rasdial.exe, because I need to obtain full control of the > connection process). One suggestion is to have a fixed entry in the phonebook (already established) that you just reference in your win32ras.Dial call - you can still override the phone number at dial time. Alternatively if you can handle default phonebook entry settings, you can use win32ras.Dial directly without a phone book entry - just include all the parameters in the call. Note however that at least under NT 4, there is a bug that over time (and generally thousands of calls) can build up stray RAS parameter entries in your registry which make the dialing process very sluggish. The other option would be to write your own wrapper function around the RasSetEntryProperties function which can create an entry without any user interaction. Or, use a standalone utility (we did one locally but I'm sure there must be something around on the net) that can build a RAS entry and execute that from your code with os.system() or os.popen(). -- -- 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 sheila at spamcop.net Wed Jul 4 21:13:39 2001 From: sheila at spamcop.net (Sheila King) Date: Thu, 05 Jul 2001 01:13:39 GMT Subject: Config options on Tkinter Label Widget Message-ID: <anf7kt4edeq12n4kb7hjdd73jjhnck2bco@4ax.com> I'm trying my hand at a bit of Tkinter programming. I must say, the discussion in Mark Lutz' Programming Python, 2nd ed, is really excellent. Anyhow, I liked the suggestion in Chun's Core Python Programming for one of the exercises: "Label and Entry Widgets and Python I/O: Create a GUI application that provides and Entry field where the suer can provide the name of a text file. Open the file and read it, displaying its contents in a Label." So, I'm just starting out on the exercise, and I decided to mess around a bit with the look and feel of the application. (I've also snagged a local copy of Lundh's Tkinter reference and the Tkinter Life Preserver...so I think I have ample reference material.) So, here is my code so far: -------------------------------------------------------------- from Tkinter import * root = Tk() Directions = Label(root, text ='Enter name of File to Open:') Directions.config(anchor=W) inputBox = Entry(root, width=80) Directions.pack() inputBox.pack() mainloop() -------------------------------------------------------------- Now, notice the line where I am trying to configure on Directions the positioning of the text in the label: Directions.config(anchor=W) >From reading Lundh's reference, I thought that this would position the text all the way to the left of the label. However, it remains centered. Why isn't it moving to the left? What do I need to do to get that effect? Thanks, -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From rnd at onego.ru Tue Jul 10 06:36:58 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 10 Jul 2001 14:36:58 +0400 (MSD) Subject: backslash woes........ In-Reply-To: <3B4AC7C2.DD53F6BB@westerngeco.com> Message-ID: <Pine.LNX.4.21.BCL.0107101435480.1573-100000@suzi.com.onego.ru> On Tue, 10 Jul 2001, Martin Franklin wrote: > Hi all, > > > I am having trouble with windows path names (i'm a UNIX'ite) > I want to replace the common prefix of a list of file names > with a relative stub (./) I have this... > > def _removePrefix(self, fullfile): > print r'%s' %fullfile what about re.escape(fullfile) re.escape(os.sep) ? Does it cure the situation? > filename=re.sub(r'%s' %self.prefix, r'%s' %os.sep, r'%s' %fullfile) > print filename > return filename > > > Where fullfile is the - full filename... > and self.prefix is the os.commonprefix() > > > Currently I get an error:- > > traceback (most recent call last): > File "c:\python21\lib\lib-tk\Tkinter.py", line 1285, in __call__ > return apply(self.func, args) > File "r:\src\python\squeeze\dev\makesqueeze.py", line 161, in Finish > Squeeze(platFileList, open(filename, 'w'), self.prefix_or_path.get(), > config) > File "r:\src\python\squeeze\dev\Squeeze.py", line 58, in __init__ > self._apply(file) > File "r:\src\python\squeeze\dev\Squeeze.py", line 137, in _apply > file = self._removePrefix(fullfile) > File "r:\src\python\squeeze\dev\Squeeze.py", line 151, in _removePrefix > filename=re.sub(r'%s' %self.prefix, r'%s' %os.sep, r'%s' %fullfile) > File "c:\python21\lib\sre.py", line 63, in sub > return _compile(pattern, 0).sub(repl, string, count) > File "c:\python21\lib\sre.py", line 136, in _compile > raise error, v # invalid expression > error: bogus escape: '\\x' > > > I don't understand this as I am (trying) to use raw strings everywhere..... > (that's what the DOC's told me to do...) > > > 'Course on UNIX it all works perfectly well with or without the raw strings;-) > > > > > Hope _you_ can help > > Martin > Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From Scott.Daniels at Acm.Org Fri Jul 27 03:01:32 2001 From: Scott.Daniels at Acm.Org (Scott David Daniels) Date: Fri, 27 Jul 2001 00:01:32 -0700 Subject: File Reading , Reverse Direction References: <3B60F7EC.5275E026@lsu.edu> Message-ID: <tm24egqbpid338@corp.supernews.com> Reading backwards is tough, but reading forwards from a guaranteed conservative guess is pretty easy: file.seek(-2*MAX_LINE, 2) lines = file.readlines()[-2:] "Ratnakar Malla" <rmalla1 at lsu.edu> wrote in message news:3B60F7EC.5275E026 at lsu.edu... > I need to read from ... [the] 2 lines at the bottom of ... [a very long] file. > 1) Can i read the file in the reverse direction , so that I dont lose > time? > 2) If so how?? -Scott David Daniels Scott.Daniels at Acm.Org From opengeometry at yahoo.ca Sat Jul 14 13:51:17 2001 From: opengeometry at yahoo.ca (William Park) Date: Sat, 14 Jul 2001 13:51:17 -0400 Subject: python and applications In-Reply-To: <9ipv9k$nda$1@panix2.panix.com>; from aahz@panix.com on Sat, Jul 14, 2001 at 10:25:08AM -0700 References: <V%337.677940$166.13952126@news1.rdc1.bc.home.com> <9ipv9k$nda$1@panix2.panix.com> Message-ID: <20010714135117.A333@node0.opengeometry.ca> On Sat, Jul 14, 2001 at 10:25:08AM -0700, Aahz Maruch wrote: > tyler spivey <tspivey8 at home.com> wrote: > >how many blind programmers use python? > > No idea. Python is probably good for blind people because you usually > write less code in Python -- each statement in Python does more. If the original author meant "visually impaired", then I agree. Python code is short, easy to read, and easy to write. This would be important for limited screen space or letter-by-letter translation (grade 1 braille). -- William Park, Open Geometry Consulting, <opengeometry at yahoo.ca> 8 CPUs cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc. From aleaxit at yahoo.com Mon Jul 16 12:03:27 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 16 Jul 2001 18:03:27 +0200 Subject: Most efficient solution? References: <mailman.995289809.28477.python-list@python.org> Message-ID: <9iv38i0ppd@enews2.newsguy.com> "Jay Parlar" <jparlar at home.com> wrote in message news:mailman.995289809.28477.python-list at python.org... ... > for eachItem in A: > if eachItem in B: > A.remove(eachItem) > > Now, this will work fine, Are you sure about that? Normally, modifying the list you're iterating on does NOT work fine. Have you tested a decent variety of cases? For example: >>> a=['ciao']*7 >>> for x in a: a.remove(x) ... >>> a ['ciao', 'ciao', 'ciao'] >>> as you see, NOT all seven occurrences of 'ciao' have been removed. Before worrying about speed, I would suggest you first make sure your code is CORRECT... I think this loop will misbehave if any two successive items of A are both in B (only the first one will be removed). Are you sure this can't occur...? Alex From elecfsh at yahoo.com Mon Jul 16 08:23:34 2001 From: elecfsh at yahoo.com (elecfsh) Date: 16 Jul 2001 05:23:34 -0700 Subject: Network able Chess Message-ID: <86f9eea9.0107160423.1e1a0103@posting.google.com> Hey, For a while I have been wanting to write a little chess game that can be played over a network w/ some simple chatting features. I want to do this in Python, but I'm a little worried about doing the graphics. Any suggestions as far as gamming libraries? or any standard libraries I may have missed? Thanks. -Andrew From nperkins7 at home.com Mon Jul 16 20:52:15 2001 From: nperkins7 at home.com (Nick Perkins) Date: Tue, 17 Jul 2001 00:52:15 GMT Subject: list[] = var => list.append(var) (phpstyle) References: <4e2ddb70.0107141310.3c7ca355@posting.google.com> <9iqfge0gba@enews1.newsguy.com> <LF447.476898$eK2.98947068@news4.rdc1.on.home.com> <9iqlgi$kbg9g$1@ID-11957.news.dfncis.de> <kuzoa4hf75.fsf@lasipalatsi.fi> Message-ID: <3%L47.493641$eK2.102167240@news4.rdc1.on.home.com> "Erno Kuusela" <erno-news at erno.iki.fi> wrote in message news:kuzoa4hf75.fsf at lasipalatsi.fi... > > [reformatted for your reading pleasure] * Incorrectly!! > > In article <9iqlgi$kbg9g$1 at ID-11957.news.dfncis.de>, "Emile van > Sebille" <emile at fenx.com> writes: > > || "Alex Martelli" <aleaxit at yahoo.com> wrote in message > > || "Nick Perkins" <nperkins7 at home.com> wrote in message > || news:LF447.476898$eK2.98947068 at news4.rdc1.on.home.com... > * Just for the record, I (Nick Perkins) did not write any of this. * I responded to it. > ||| I think it should be neet if it would be possible to append a variable > ||| to a list by just using > ||| list_var[] = var_to_append > ||| It works that way in PHP and I think it's nice. > ||| > ||| Any comments? > > || list_var += var_to_append > || > || (which is how you express this today in Python) is equivalent > || and shorter. Python does NOT go out of its way to provide > || a zillion ways to write the same, identical thing. > > | Alex is right as long as var_to_append is already a list. > > not quite: > > >>> l1 = [1] > >>> l2 = [2] > >>> l1 += l2 > >>> l1 > [1, 2] > > vs. > > >>> l2.append(l1) > >>> l2 > [2, [1]] > > | For non-lists though you can also do > > | list_var += 1, > > | or, > > | list_var += (1,) > > hmm, does the sequence protocol really include __add__ing arbitrary > sequences? one would think lists would support it too if that > was the case. > > -- erno From cjensen at bioeng.ucsd.edu Thu Jul 26 16:00:20 2001 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Thu, 26 Jul 2001 13:00:20 -0700 Subject: Numeric.transpose (incorrect documentation) Message-ID: <3B6076D4.68B6840C@bioeng.ucsd.edu> the documenation for the "transpose" function for the "Numeric" module seems to be incoorect, or at least missleading. It says that transpose is suppose to return a "new" array. In fact it does not. It returns a pointer to the same array, only with transposed indicies. consider the example: Python 1.5.2 (#4, Sep 5 2000, 10:29:12) [C] on irix646 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> from Numeric import * >>> foo = zeros([5,10]) >>> bar = transpose( foo ) >>> foo array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) >>> bar array([[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) >>> foo[0,2] = 1 >>> foo array([[0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) >>> bar array([[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) >>> if bar was truely a new array, then changes to foo would not affect bar. In the example above, it does. This way actualy works better for my purposes, however, the documentation is missleading. -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From m.faassen at vet.uu.nl Wed Jul 4 19:42:23 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 4 Jul 2001 23:42:23 GMT Subject: Not enough Python library development [was PEP scepticism] References: <Pine.LNX.4.33.0107041355150.7776-100000@bms> <mailman.994283709.16414.python-list@python.org> Message-ID: <9i09kv$efs$1@newshost.accu.uu.nl> Paul Prescod <paulp at activestate.com> wrote: [how to get to a catalog] > Incremental steps are the only path that will lead to success. Right; we can always replace what we have at any point and throw the old stuff away (or better revise it and add the dependencies/security/ whatnot). Anyway, you can consider the PEP '2' proposal I posted today as such an incremental step. It is focused on the standard library but the model would be suitable for a high quality catalog system too. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From ransen_spam_me_not at nemo.it Wed Jul 25 12:59:29 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Wed, 25 Jul 2001 16:59:29 GMT Subject: control-C not responding, short example program References: <3b5d7220.664033@news.newsguy.com> <yoxhew1zejh.fsf@karhu.tp.spt.fi> Message-ID: <3b5efaca.2141033@news.newsguy.com> On 25 Jul 2001 09:52:18 +0300, Ville Vainio <vvainio at karhu.tp.spt.fi> wrote: >ransen_spam_me_not at nemo.it (Owen F. Ransen) writes: > > >> halt 500Mhz Windows 98 machine. It simply does not >> respond to control-C. Is there a way of doing this > >What about the good old control-break? I'll try it, but does Python respond differently to these two things? -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From dsh8290 at rit.edu Tue Jul 3 21:34:41 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 3 Jul 2001 21:34:41 -0400 Subject: No float limits In-Reply-To: <6957F6A694B49A4096F7CFD0D900042F27D4E0@admin56.narex.com>; from BPettersen@narex.com on Tue, Jul 03, 2001 at 05:47:58PM -0600 References: <6957F6A694B49A4096F7CFD0D900042F27D4E0@admin56.narex.com> Message-ID: <20010703213441.A26215@harmony.cs.rit.edu> On Tue, Jul 03, 2001 at 05:47:58PM -0600, Bjorn Pettersen wrote: | > From: D-Man [mailto:dsh8290 at rit.edu] | > | > On Tue, Jul 03, 2001 at 11:37:51PM +0200, J?rgen Hermann wrote: | > | Hi! | > | | > | I just stumbled over the fact that there is sys.maxint, but | > no sys.maxfloat | > | and sys.epsfloat. In case anyone thinks this is a valid | > addition, I'll come | > | up with a patch. | > | > What value would sys.maxfloat have? | > | > IIRC IEEE754 states that all ones (ie 0xFFFFFFFF for a single | > precision float) means infinity, so there really isn't a "max" value | > for a float. | | Perhaps not, but there is a maximum representable number, a.k.a. DBL_MAX | in your C library (same argument for DBL_EPSILON of course ;-) Ok, I'm over my head now. I'll let you float gurus fight it out :-). -D From rnd at onego.ru Wed Jul 18 12:23:23 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 18 Jul 2001 20:23:23 +0400 (MSD) Subject: Language change and code breaks In-Reply-To: <_bh57.32695$d4.1090608@e420r-atl1.usenetserver.com> Message-ID: <Pine.LNX.4.30.0107182005260.1370-100000@rnd.onego.ru> On Wed, 18 Jul 2001, Steve Holden wrote: >"Guido van Rossum" <guido at python.org> wrote in message >news:cpvgkq1f2b.fsf at cj20424-a.reston1.va.home.com... >> Roman Suzi <rnd at onego.ru> writes: >> >> > Windows is case-insensitive and thus "easy to use" only before one needs >> > to put web-pages on the real (UNIX) web-server. Then they understand all >> > the troubles with mised case, national-charset filenames, abbr~ted >> > filenames, local file references "C:\Mydocs\lalala", bmp-images etc. >> >> But it's still open for debate whether the problem here is Windows or >> Unix! All programming languages and file systems used to be >> case-insensitive, until the designers of Unix and C decided that it >> was too much work to write and use a case-insensitive comparison >> routine. It wasn't necessarily intended to be better, just easier to >> implement. But times have changed, and that's a lousy excuse. Maybe case-sensitiveness is an atavism, but I think that the Man and the man are too _different_ words. And MAN is yet another. Case-sensitivity is simple. Having one 0x0A is also simpler than 0x0A 0xD and thus having two different file types. Unix is simpler, that is why it survived for so long. >In the CP4E world, do you feel it is better to educate everybody to >understand that capitaisation has meaning, or dumb down the systems to allow >those without a finer appreciation of language to get what *they* expect, >thereby annoying the literate minority? I've never been quite sure how >inclusive the "E" in "CP4E" is intended to be, but you may find that spoken >natural language is the only acceptable user interface, given the literacy Even spoken language will not help, because people just plainly do not know how things are called even on their GUI systems. They hardly know what OS is and they talk strictly about what they see, without understanding of underlying processes. More than that, many 'puter users are lame enough not to learn things! (believe me, I am working at ISP tech. support...) So probably CP4E is Utopia or "E" != humankind, but some part of it. And thus there is no need to make thing too complex in trying to do them simple. I think that CP is for everyone who is open to learn things as they are, without overly simplification or complication. If I give variable name 'Name', then I mean to call it so. And I will not be disappointed when I try to call it by 'name' and it will not answer. These are basic things even from pre-Eve times, when Adam called things. >problems of even "advanced" societies. Now, even I couldn't disagree that >there's no upper case spoken language, unless it's the traditional British >device of > > S-H-O-U-T-I-N-G S-L-O-W-L-Y A-T F-O-R-E-I-G-N-E-R-S There are no spoken language IDEs yet. And if I am not mistaken, there will never be. Because it is much simpler to program more or less complex things with written language. Spoken command language could be of use with some AI systems or simple systems which know some set of prescribed commands. Otherwise, it is too easy for computer to give patients metil. when the doctor wanted etil. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Wednesday, July 18, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Hard work never killed anyone, but why chance it?" _/ From paulp at ActiveState.com Thu Jul 5 08:00:40 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Thu, 05 Jul 2001 05:00:40 -0700 Subject: Not enough Python library development [was PEP scepticism] References: <7BD10B680501D411B9DF009027E06F32197DA0@exchange> Message-ID: <3B4456E8.8420459A@ActiveState.com> Max M?ller Rasmussen wrote: > >... > > Obviously there is something I have missed here. > > If what we need is a system that can manage modules, versions, > interdependencies, searching, different comunication protocols like ftp, > http, webdav, a web interface and a Python client, Why don't we just write > it in Zope? Zope is certainly part of the solution. But Zope isn't where you want to store a bunch of large archives. It would be better to use the file system. And Zope doesn't itself manage the interdependencies. That information has to come from the module. But we have no way to define those interdependencies right now. And as you said, Zope doesn't help much with the client app. And Zope doesn't really help you to build binary modules in a safe way. And what categorization scheme (not technology) do you use? So Zope is a good start (just as Distutils is a good start). -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From skip at pobox.com Sun Jul 22 14:57:16 2001 From: skip at pobox.com (Skip Montanaro) Date: Sun, 22 Jul 2001 13:57:16 -0500 Subject: HOWTO: exit In-Reply-To: <Pine.LNX.4.33.0107221315300.4146-100000@cc489744-a> References: <Pine.LNX.4.33.0107221315300.4146-100000@cc489744-a> Message-ID: <15195.8716.946086.989620@beluga.mojam.com> adam> how do I exit from a script? You can call sys.exit() or raise the SystemExit exception: beluga:skip% python Python 2.1.1c1 (#13, Jul 10 2001, 17:30:38) [GCC 2.96 20000731 (Linux-Mandrake 8.0 2.96-0.48mdk)] on linux2 Type "copyright", "credits" or "license" for more information. >>> raise SystemExit beluga:skip% python Python 2.1.1c1 (#13, Jul 10 2001, 17:30:38) [GCC 2.96 20000731 (Linux-Mandrake 8.0 2.96-0.48mdk)] on linux2 Type "copyright", "credits" or "license" for more information. >>> import sys >>> sys.exit() beluga:skip% -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From thomas at xs4all.net Wed Jul 4 12:19:18 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Wed, 4 Jul 2001 18:19:18 +0200 Subject: Python for air traffic control? In-Reply-To: <9htebs$ck2@news1.gtech.com> References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> <9hrj3q$cj1@news1.gtech.com> <mailman.994154525.14580.python-list@python.org> <9htebs$ck2@news1.gtech.com> Message-ID: <20010704181918.Y8098@xs4all.nl> On Wed, Jul 04, 2001 at 07:42:51AM +1000, Peter Milliken wrote: > > The only way to make sure a program works is by testing each and every > > line in each and every circumstance, regardless of which programming > > language you use. For something like ATC, you *do not* want to rely on > > anything else. Using Python would at least allow you to find and fix > > problems a lot faster -- you won't be carrying around NULL or undef > > values without noticing it. > > Do you check the return value of every fprintf()/fclose() function call > > you make ? You should! > Well, you show your inexperience/ignorance in two places here Thomas :-) Neither, actually. My innocence, maybe, and my faith in numbers, but not inexperience (I'm not) and not ignorance (at least, not that I know.) > 1. No program EVER has 100% coverage during testing (unless it is trivial - > this for the nitpickers :-)). The bigger the program the less likely full > coverage has been achieved, ATC's are big programs. Anyone who claims they > have 100% tested an ATC are either fools or liars - "every line and every > circumstance" are NOT POSSIBLE, if you think they are then I don't have > anything more to say other than get a few more years real world experience > :-). So, if you plan to 100% test a python ATC "each line and every > circumstance" then my original confidence that it would never be put into > production holds (that's one of the reason languages have exception > handlers - to catch the error that the programmer didn't foresee) :-). You should try to re-read my message: I didn't say it was possible, or even plausible (I happen think it's possible but implausible) just that it is the only way it'll work. It also depends on what you call 'testing': open source software, especially popular open source software, is continuously tested, in the real world. Most bugs in Python nowadays are bugs in new features, or on new platforms, because a lot of the possible combinations of what/when have been covered. The real world is the testing, and proving, grounds <wink>. If you read the rest of the thread, you'll note that the ATC software runs in acceptance testing for *years*. That's a lot of testing time. If you're that deep into testing, you'll be done catching the 'typical' Python bug, and just catch algorithm errors. Peter v/d Linden's excellent and highly entertaining "Deep C Secrets" has some good examples of that (and no, they aren't about C or C++.) Nothing, and I do mean *nothing*, in the language could have prevented those errors. > 2. Strongly typed languages don't include C/C++, so your example is > meaningless i.e. a strongly typed language would at least FORCE you to > assign/test the return value of an function - not like C/C++ which allows > you to ignore any return values. This is not to say that an application > written in a such a language wouldn't still ignore the return value after > the assignment - that is a function of programmer ability (another point in > my original email) - to fix that is up to testing and code review. I didn't say C was strongly typed, nor did I say Perl was strongly typed. Those two, and Python, are just my 'main' languages, and I just used them to express what I meant: programmers can ignore error codes, and catch exceptions and ignore them. There isn't much a language can do about that. But that still doesn't mean that strongly typed languages are the best for reliable code. How does a strongly (and statically, I presume you mean) typed language FORCE you to assign/test the return value of a function, by the way ? I don't think I ever heard of a language that did that... My experience with true strongly, statically typed languages must be smaller than I thought. -- Thomas Wouters <thomas at xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From James_Althoff at i2.com Mon Jul 9 17:51:22 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Mon, 9 Jul 2001 14:51:22 -0700 Subject: Is Python Dead? Long Live Python! Message-ID: <OFFC26B3E9.4A427F51-ON88256A84.0077D6B8@i2.com> James Logajan wrote: >James_Althoff at i2.com wrote: >> >> Edward Wilson wrote: >> <snip> >> >Java is WAY too slow for serious development of any kind. >> <snip> >> >> Might we be over-generalizing just a wee bit, perhaps? My company is >> generating hundreds of millions of dollars of revenue with products written >> in Java (with major pieces implemented in Jython :-). >> >> (I suppose *serious development* is relative <wink>). > >"A few billion here, a few billion there, and pretty soon you're talking >real money." A few hundred million? A mere pittance! Obviously no one who >wants to make real money develops in Java! > >(Do I really need to add a wink or smiley??) Nah. I'm sure Everett Dirksen is smiling somewhere "out there". Jim From arnulf at spirea.net Mon Jul 30 08:56:48 2001 From: arnulf at spirea.net (Arnulf Heimsbakk) Date: Mon, 30 Jul 2001 14:56:48 +0200 Subject: Error on mimetools? References: <9k368v$a8q$1@news.uit.no> <j4puair3bb.fsf@informatik.hu-berlin.de> Message-ID: <9k3l62$d31$1@news.uit.no> I'm using only the raw base64 text. It is the same text I used in my winzip experiment and in python test program I've made. It works in winzip but not with python code. As I mentioned python gives me a file slightly bigger than winzip. It's about 300 bytes bigger. I'm without clues to this one. It does not seem to be any logic in the error. Arnulf "Martin von Loewis" <loewis at informatik.hu-berlin.de> wrote in message news:j4puair3bb.fsf at informatik.hu-berlin.de... > "Arnulf Heimsbakk" <arnulf at spirea.net> writes: > > > I'm trying to decode a mime64 message in python with mimetools. I have > > tested the "body" with windows winzip. It decodes correctly. When I try to > > decode it in python, it do not decode correctly. I get a file with slightly > > increased size. The heading of the file seems the same, but when I test this > > with a jpg file - the file gets corrupted when decoded with python's > > mimetools. > > > > Is there a error in mimetools? Or is my approach entirly incorrect. My code > > is below: > > > > out = StringIO() > > mimetools.decode(StringIO(self.body), out, 'base64') > > return out.getvalue() > > It very much depends on what self.body is in this context. To use > mimetools.decode, you must be sure that it is the raw base64 bytes, > i.e. without any headers and trailers. > > Regards, > Martin > From eppstein at ics.uci.edu Sun Jul 22 16:07:02 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Sun, 22 Jul 2001 13:07:02 -0700 Subject: PEP0238 lament References: <mailman.995826216.11537.python-list@python.org> Message-ID: <eppstein-03540D.13070222072001@news.service.uci.edu> In article <mailman.995826216.11537.python-list at python.org>, "Tim Peters" <tim.one at home.com> wrote: > By show of hands, about 3/4ths of the > participants agreed that 3/4 should not return 0, but rather *something* x > such that x*4 had a better chance of being confused with 3 than with 0. Well then, float is a very bad choice for what to return, or then how do we explain when 3/4 * 4 = 3 (exactly) but 3/10 * 10 != 10? I would be a lot happier with integer / integer = rational (as in Mathematica's programming lang), but float is just ugly. It is turning exact values (integers) into approximate ones (float) when I didn't tell it to. It's almost as bad as if integer subtraction always truncated to 16 bit values -- a lot of the time that would give sort of reasonable answers but it's a gratuitous approximation where you didn't expect one. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From thecalm at NOSPAM.btinternet.com Tue Jul 3 19:52:15 2001 From: thecalm at NOSPAM.btinternet.com (G. Willoughby) Date: Wed, 4 Jul 2001 00:52:15 +0100 Subject: i'm trying to get user input from a Tkinter Entry field... Message-ID: <9htlpd$ki$1@plutonium.btinternet.com> i'm trying to get user input from a Tkinter Entry field, this is the code i am using: [snip...] def getNew(): result1=str(newName.get()) print result1 [snip...] Button(frame1, text="Add New Entry", command=getNew).grid(row=0,column=0) newName=Entry(frame1).grid(row=1,column=0) [snip...] it somehow doesn't work, any ideas? P.S. no classes are used anywhere in this program. G. Willoughby From niemeyer at conectiva.com Mon Jul 23 15:04:50 2001 From: niemeyer at conectiva.com (Gustavo Niemeyer) Date: Mon, 23 Jul 2001 16:04:50 -0300 Subject: [phawkins@connact.com: Re: python and applications] In-Reply-To: <20010723140032.A71300@ifour.com.br>; from gustavo@ifour.com.br on Mon, Jul 23, 2001 at 02:00:32PM -0300 References: <20010722144735.A2737@ifour.com.br> <20010723114109.G27699@tux.distro.conectiva> <20010723140032.A71300@ifour.com.br> Message-ID: <20010723160450.C1028@tux.distro.conectiva> Gustavo, > >> libraries. C has no support for IO, garbage collections, dynamic > >> memory allocation, etc...... Many thing that C "does" comes from > >> external libraries. Being small, and without any kind of special > > > >So does python. What do you think you're doing when you use something > >like "import sys" in your program? Yes, many of these libraries > >are part of a "standard set", but that doesn't change things. You > >have POSIX and other standards on the C side. > > As i told, i am just a python beginner! You need not to get hungry. I'm not hungry at all. I just don't agree with you, and explained my arguments. [...] > I am enjoying python too. But C has a small learning curve, since it's > very simple!If you think C is not simple, try C++. Important: i am not > saying python is not simple. Yes, I was comparing it with Python (we're in the python list). > >> program. The most sofistaced feature C provides is loop (while, do > >> while, for), the lowest level C feature are pointer. If you master > >> pointer and loop in C, you may be concidered a C guru. the problem is > > > >Ouch... What's a feature for you?? If you're talking about the language > >constructs, as far as I remember, Guido is always trying to have the > >minimum possible set of language constructs in python (no do/while, no > >switch, no enum, etc). I don't think this is a bad thing, but I don't > >understand your position. > > I am confused! Why python folks come up with version x, x.y, x.y.z and > ++x, x.f, x.3! I don't really understand! Once the > interpreter/compiler is written, there is no need to come up with new > version, at least if you don't change the language. Is python immature > yet? Please, don't get me wrong, i cannot really understand what is > going. There is no need for new versions of a language if it's mature > enough, right! As i told, C has only two versions, Standard and ANSI, > the last one remains the same for years and i doubt something will > change in the upcoming years. Have you seen gcc 3.0? It's a compiler... compilers change all the time, just like interpreters. Python is not as stable as C, no doubts. But releasing new interpreters is usual, just like compiler releases. Even because the standard library is part of the game. Besides that, the C standards are not as static as you may think. The latest one (from ISO) I know about was adopted officially in 1999. Some of the changes were even borrowed from C++. ;-) (have a look at http://web.onetelnet.ch/~twolf/tw/c/c9x_changes.html) > >> that C++ is easier than C - All i do is laughting. Serious IT stuff > >> never get project developed in C++. > > > >We have lots of well known projects developed in C++ (qt, apt, etc). > > Being well known does not make a software good! MS Windows is well > known! is it an OS you would put a critical service? I guess "being > well knonw" is no argument to trust in order to declare some thing > good. QT is well done. Have a look by yourself. > >C has very complex data types, from the point of view of a Python > >programmer. As I told, these languages have different purposes and > >one has to be careful when making such comparisions. > > Sorry, i do not known a single one data type C naturally holds? The > only types i known in C are: long, float, int (and its derivated). I > don't really known anymore. You can build anything with structs (yes, they are types as well). You just don't have "out-of-the-box" lists, dictionaries and alike. That kind of stuff *shouldn't* be part of lower level languages. As I told, comparing C and Python at that level is useless. -- Gustavo Niemeyer [ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ] From marka at sundance.com Thu Jul 19 09:50:55 2001 From: marka at sundance.com (Mark Ainsworth) Date: Thu, 19 Jul 2001 14:50:55 +0100 Subject: Examples of using XML and Python? Message-ID: <3b56e5fa$1@shiva.ukisp.net> Has anyone got any simple examples of using Python and XML? The plan is to use XML as the data format for information files. These need to be able to be read, for data extraction, and also written too for modification. I am VERY new to this. Python is O.K. but I haven't got a clue about SAX, DOM etc. Many thanks. Mark A. From aahz at panix.com Tue Jul 3 10:57:37 2001 From: aahz at panix.com (Aahz Maruch) Date: 3 Jul 2001 07:57:37 -0700 Subject: Is this a true statement: Part III References: <9hsckg$4rt$1@taliesin.netcom.net.uk> Message-ID: <9hsmh1$gtt$1@panix2.panix.com> In article <9hsckg$4rt$1 at taliesin.netcom.net.uk>, MDK <no at spam.com> wrote: > >The thing that I found interesting about the Part II posts were the >positive things said about the C language. Is C that much different >than C++? Why the leaning towards C over C++? I thought C++ was >supposed to be the 'New and Improved C.' Let me give you a real-life example: I'm not a C programmer, but I've used C a bit. I've also read some books about C++ over the years. The company I was working for hired a contrator to write a DLL to interface between two parts of the system we were writing. The contractor chose to use C++. The DLL that was delivered failed miserably in following the spec, but it worked just barely well enough that we postponed rewriting it due to lack of time. As these things always play out, the need to rewrite the DLL came up on very short notice, basically one week was what we had to meet a deadline (the biggest problem with the DLL was that it worked okay with text files but choked on binaries). Although I was the least competent C/C++ programmer available, I was elected to do the rewrite because I was the expert on the APIs the DLL used. I managed to do the rewrite in a week, but only by sticking to straight C code. The rewrite was cleaner, simpler, and faster. -- --- 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'm not tense, i'm just terribly, terribly alert" --unknown From tjreedy at home.com Thu Jul 26 14:22:03 2001 From: tjreedy at home.com (Terry Reedy) Date: Thu, 26 Jul 2001 18:22:03 GMT Subject: Building a minimal Python 2.2 for Windows References: <Pine.LNX.4.21.0107261804050.25190-100000@bcryachts.atsat.com> Message-ID: <fdZ77.30592$EP6.7869594@news1.rdc2.pa.home.com> "Morten W. Petersen" <morten at thingamy.net> wrote in message news:Pine.LNX.4.21.0107261804050.25190-100000 at bcryachts.atsat.com... > Hia, > > I've just tried to build a small Python distribution that will fit on a > floppy disc (to do some cleanups on the filesystem without starting > windows itself); however, the message python22.dll is needed.. > > ..now, I've just copied a couple of files from the install directory, > files like python22.exe and certain .py and .lib files, can't find the > python22.dll file though.. > > Any ideas? Try /windows/system for python22.dll and python22.lib (don't know if you need the latter) Terry J. Reedy From s713221 at student.gu.edu.au Fri Jul 20 22:04:59 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Sat, 21 Jul 2001 12:04:59 +1000 Subject: Language change and code breaks References: <Pine.LNX.4.33.0107191316390.24983-100000@bms> <mailman.995571273.18192.python-list@python.org> <9j7gv8$9mg@dispatch.concentric.net> <cppuawfqbm.fsf@cj20424-a.reston1.va.home.com> Message-ID: <3B58E34B.52A137FD@student.gu.edu.au> Guido van Rossum wrote: > > "Tim Randolph" <timothyrandolph at yahoo.com> writes: > Thanks for reminding me! This is in fact the group I have in mind > when I say non-programmer -- true non-programmers of course wouldn't > be using Python... :-). In my usage, a "programmer" is someone who > is a professional code-slinger, 8-12 hours a day. A "non-programmer" > is someone whose profession is something else (e.g. chemist, or > webdesigner, or rocket scientist) but who occasionally needs to > program. > > > As a member of this group, who is especially fond of Python for how > > easy it is to pick up where I left off days or weeks before, I would > > very much prefer a case *insensitive* language with tools that > > enforce *uniform* case usage. > > And that's of course what I have in mind. > > > Nobody wants to see fOo and FOO and foo with the same meaning, but > > nobody wants to see foo and FOO and foo at all in the same program > > with distinct meanings. I also don't think the cutesy c=C() makes > > for readable code -- at least for this sometime programmer. > > Exactly. > > --Guido van Rossum (home page: http://www.python.org/~guido/) Yes, but by your definition I'm a non-programmer (Though I do have three versions of python floating on my machine at the moment.) and I prefer case-sensitivity! I use it as a convention to remind me what is what. (Note: Not to distinguish c and C *grins* well not all the time, but between instance alpha and class FormattedText.) Additionally as a BSc graduate I have a strong mathematical background so as another poster has commented, I often use mixed cases for very short code blocks. for i in len(I): .......... .......... When it's a simple block of code, especially when I'm in prototyping mode, I prefer to not have to bother about thinking up clever names for my code. *puts on his halo* Of course I clean things up later *grins*. My vote would be in either giving IDLE TAB completion/correction that recognises case errors, or more helpful NameErrors (Perhaps wrapped into the IDLE code.) - if there's anything an occasional programmer can do to help, I'd be glad to volunteer. Perhaps testing ...? One of my python versions is the 2.2 prerelease - I haven't tested it much, but it seems to work ok. I like the use of the yield keyword (Though I'll be glad when the from __future__ etc requirement disappears in 2.3.), and I assume the generator method returns values on the next() function for a compatibility issue with something else, rather than just calling the object directly? Additionally, yes the nested scopes DOES make code behave more as I expect it to! *thumbs up* -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From qrczak at knm.org.pl Mon Jul 23 17:03:08 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 23 Jul 2001 21:03:08 GMT Subject: PEP0238 lament References: <mailman.995917312.15332.python-list@python.org> Message-ID: <slrn.pl.9lp48c.h5i.qrczak@qrnik.zagroda> Mon, 23 Jul 2001 15:41:18 -0400, Tim Peters <tim at digicool.com> pisze: >> I think you'll find it's the picking of languages where 1/2 = 0.5 that >> has to be done carefully - I can think of Pacal, Modula 2, LISP and - >> taking into account your correction - Perl and JavaScript. > > LISP doesn't belong in that list, but members of the Algol family do. I don't know about Lisp standards, but in clisp implementation (/ 1 2) is a rational which is = to 0.5. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From kens at sightreader.com Thu Jul 26 20:02:03 2001 From: kens at sightreader.com (Ken Seehof) Date: Thu, 26 Jul 2001 17:02:03 -0700 Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <eppstein-03540D.13070222072001@news.service.uci.edu> <LNBBLJKPBEHFEDALKOLCOECNLAAA.tim.one@home.com> <mailman.995899647.346.python-list@python.org> <tclolt053o18f8q0ntb7n4aggitdkmeg4h@4ax.com> <Io_67.23543$B7.3779351@ruti.visi.com> <slrn9lp2m5.vp.Gareth.McCaughan@g.local> <p56plt8q4rs3bgcqbepk61q2r3g0tr2vhe@4ax.com> <slrn9ls3ae.2fm.Gareth.McCaughan@g.local> <cpitghbq05.fsf@cj20424-a.reston1.va.home.com> <MWD77.27751$EP6.6983549@news1.rdc2.pa.home.com> <9jnt9p$qhe$1@newsy.ifm.liu.se> <SYV77.27286$B7.4239335@ruti.visi.com> <cpitgf7itx.fsf@cj20424-a.reston1.va.home.com> <WIY77.27607$B7.4257794@ruti.visi.com> <cp3d7j75jv.fsf@cj20424-a.reston1.va.home.com> Message-ID: <024c01c1162f$5e7b56e0$6501a8c0@pacbell.net> ----- Original Message ----- From: "Guido van Rossum" <guido at python.org> Newsgroups: comp.lang.python To: <python-list at python.org> Sent: Thursday, July 26, 2001 2:18 PM Subject: Re: proposed language change to int/int==float (was: PEP0238 lament) > [Guido] > > >> >The important thing is that i//j will return the same value > > >> >regardless if i and j ar ints or floats; ditto for the new i/j. > > [Grant] > > >> If that's important, why won't the other math operators do it??? > > [Guido] > > >Huh? They do (apart from unavoidable round-off errors). 1+2 == 1.0+2.0. > > [Grant] > > They compare equal with the "==" operator, but they are not > > the same value: > > > > >>> 1+2 > > 3 > > >>> 1.0+2.0 > > 3.0 > > >>> > > > > ... unless 3 and 3.0 are "the same value". In which case my > > definition of that phrase is merely different than yours. > > [Guido] > Well, they have the same *mathemtical* value, and Python does its > darndest to treat them as equal everywhere. For example, a dict with > int keys can be indexed with corresponding float or complex values. > Exceptions are operations that intrinsically require ints, e.g. list > indexing. (This would change under a unified numeric system though, I > expect, unless inexact numbers are excluded from being used as > sequence indices.) > > --Guido van Rossum (home page: http://www.python.org/~guido/) > -- This scares me. The whole numeric unification thing seems to be hiding all the intrinsically difficult properties of numbers. Kind of like Windows ME trying to hide all the intrinsically difficult properties of computers. Hiding difficult properties usually makes those properties more difficult in the long run, while appeasing beginners in the short run. This is not a good trade off. Here's some questions that come to mind that have a "sweep the can of worms under the rug" theme: 1. If inexact numbers are excluded from being used as sequence indices, won't there be a tendency for programs to have more special case bugs? The value of a variable in a calculation might be usually exact, but inexact once in awhile. So floats can be used as indices until there is a precision error? Yikes! And I have a funny feeling in my stomach that this is just the tip of the iceberg. Floats may or may not turn out to be exact depending on details of a particular run. This is a Bad Thing. Integers are always exact. This is a good thing. 2. Wouldn't a function in an extension module that takes a number as an argument be significantly more difficult to write, since it would have figure out the actual runtime type of the number and deal with all the different cases? Right now, I just have to verify the type. Seems like even if you somehow solve the problem of breaking python code, you will break extension code badly. One thing I like about python is that it is highly compatible with its extension language. The further we get from the current symmetry between python and C/C++ the harder it will be to write extensions. The same goes for case sensitivity BTW. 3. Why do you expect it to be wise to hide all the numeric issues under a level of abstraction? The issues will still exist, but will just be more obscure. Right now, we have a simple and explicit numeric system with simple and well understood problems. Trying to make it simpler for beginners by adding complexity to the overall system won't work. The basic fact is that all conceivable numeric systems suck badly for different reasons, (including the one we currently have). And for every problem there is a solution that's even worse. Just keep what we have. It sucks less badly than all of the alternatives. Even the / operator has it's virtues. It make integers a closed set with respect to all the basic operators. This is a Good Thing. The grand unification of numbers is the other way to try to create a closed set, so it's not surprising that the 1/2 debate eventually lead to it. But it won't work because the different kinds of numbers really are different and trying to stuff them into the same set is inherently unnatural. I'd accept 1/2 == 0.5 with 1//2 == 0 as the integer quotient operator, but going further than that is a mistake IMHO. Kinda-weird-that-computers-are-so-lousy-at-dealing-with-numbers-ly yrs, - Ken "Things should be made as simple as possible -- but no simpler." - A. Einstein From mirko.liss at web.de Wed Jul 4 13:00:10 2001 From: mirko.liss at web.de (Mirko Liss) Date: Wed, 4 Jul 2001 19:00:10 +0200 Subject: Not enough Python library development [was PEP scepticism] In-Reply-To: <3B428CC9.1F944ECD@seebelow.org> References: <mailman.993846706.12635.python-list@python.org> <3B428CC9.1F944ECD@seebelow.org> Message-ID: <20010704170016.7C12CBD.NOFFLE@niccolo.ke4.de> On Tue, 3 Jul 2001, Grant Griffin wrote: > I think the problem here might be one of marketing, combined with a lack > of corporate sponsorship. To that end, I propose this resource be > called "Python Program Archive Network", or PyPAN, for short. That might If you're just looking for a fancy acronym, what about calling it "Supplementary Python Archive Manager" ? The name might be changed later depending on whether the project turns out being scrappy, strange, striking, satisfactory, sumptuous or hopefuly superb. regards, Mirko From tjreedy at home.com Fri Jul 27 21:05:32 2001 From: tjreedy at home.com (Terry Reedy) Date: Sat, 28 Jul 2001 01:05:32 GMT Subject: Language change and code breaks References: <Pine.LNX.4.33.0107191316390.24983-100000@bms> <mailman.995571273.18192.python-list@python.org> <9j7gv8$9mg@dispatch.concentric.net> <cppuawfqbm.fsf@cj20424-a.reston1.va.home.com> <mailman.995734717.26373.python-list@python.org> <3B5DF101.9B2E4631@earthlink.net> <cpofq9a858.fsf@cj20424-a.reston1.va.home.com> <A%287.1144$oc6.134253@e420r-atl3.usenetserver.com> <cpvgke2zf1.fsf@cj20424-a.reston1.va.home.com> Message-ID: <wdo87.35525$EP6.9091573@news1.rdc2.pa.home.com> In the essay that began this thread, I wrote "Deletions: If a feature is directly deleted, it presumably is rarely used and not too useful." I made mention of the only pure Python deletion that I know of, the removal of the unused 'access' keyword. The discussion, somewhat heated, initially focused on the proposed division change. After about a week, Guido mentioned the idea of deleting case sensitivity from Python. Since Guido labeled my essay a 'useful summary' and never directly challenged any of it, including the deletion principle laid out above (nor did anyone else), since case sensitivity is commonly used by people who consider it helpful to essential, since its removal would break much code and outrage many people, since the above are, to me, bad things to do, since, to me, it is a 'problem' hardly worth discussing, since it can instead be accomplished in an editor/IDE without break and outrage, since Python, while not a language of intentional duplication, is one of flexibility, and since its removal could likely be easily be reversed in a parallel fork of Python --- I was puzzled, didn't take the proposal seriously, only skimmed the resulting discussion, and kept quiet. After a few days, I noticed that 'case' heat had replaced 'division' heat, thought Guido clever for the diversion, and kept quiet to let the 'joke' continue. It seems I was wrong about Guido's seriousness. So I am back to being puzzled and would like to return to my original topic. Leaving the case proposal aside, does anyone have a serious alternative to the delete criterion quoted above? If so, what, in general, should be the less-than-finite burden placed on someone proposing to delete a feature usefully used more than rarely? For a hypothetical example, what would be needed to justify removing underscores (which must confuse beginners as much as case) either from all public identifiers or just from public builtin identifiers? (I personally would prefer that the latter, at least, had been the rule f rom the beginning.) Terry J. Reedy From donovanhide at bigfoot.com Mon Jul 16 12:46:01 2001 From: donovanhide at bigfoot.com (Donovan Hide) Date: Mon, 16 Jul 2001 17:46:01 +0100 Subject: Partition Problem References: <tku1tt92ac2g8e@corp.supernews.co.uk> <3B4FBEA0.D5A6DC8A@engcorp.com> <9ioru22pc9@enews4.newsguy.com> <3B5042C2.F821D916@engcorp.com> <9itb14$2oi$1@newsg1.svr.pol.co.uk> <Xns90E0B338278B2arneleitheno@148.122.208.74> Message-ID: <9iv5e9$bru$1@newsg1.svr.pol.co.uk> Hi, thanks for the input, newsgroups are great! After scratching my head last night, I came up with a non-recursive algorithm which works for specific values of k (6 in the following example), as follows: from math import * def P(n,k): res=[] for a in range (n-k+1,int(ceil(n/k)-1),-1): for b in range(a,0,-1): for c in range(b,0,-1): for d in range(c,0,-1): for e in range(d,0,-1): for f in range(e,0,-1): if (a+b+c+d+e+f)==n: res.append([a,b,c,d,e,f]) return res a=P(20,6) for x in range(0,len(a)): print a[x] [15, 1, 1, 1, 1, 1] [14, 2, 1, 1, 1, 1] [13, 3, 1, 1, 1, 1] ...... ...... [4, 4, 4, 4, 2, 2] [4, 4, 4, 3, 3, 2] [4, 4, 3, 3, 3, 3] I'm sure it is possible to make this recursive, but I'm going to explore Alex's, Emile's and Arne's versions first. Another aspect of this problem I'm trying to do, is to find all the permutations of 20 and also 17. Is there a module available fo such standard combinatoric questions? Emile mentions Tim's klistcombs, is this a snippet from a library of functions? Thanks for all the help, it's making learning python really interesting. My ultimate aim is to prototype an animation doping system for the traditional practice of line-testing. I work for an animation company and there is a serious dearth of effective, simple software out there for this purpose. Any comments or experience of image file handling with Python? PIL and ImageMagick look like the obvious routes to follow. More specifically, has anyone linked python to the vidcap API of MS Windows. This would be useful for capturing frames of animation through a video camera. Anyway, a pint is waiting for all of you in your pub of choice (so long as it is in London!) Cheers, Donovan Hide. From timr at probo.com Tue Jul 10 02:07:28 2001 From: timr at probo.com (Tim Roberts) Date: Mon, 09 Jul 2001 23:07:28 -0700 Subject: Newbie asks: How to translate this line of C to Py References: <tkl15g5on0mla8@news.supernews.com> Message-ID: <nr6lktshij2lugi6p3825507qmd18b4erp@4ax.com> "Steve S.L. Wong" <steve at hkit.net> wrote: >while (command = strtok(line_ptr,";"),line_ptr=0,command) { >} while line_ptr.split(';'): ...do stuff... -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From com-nospam at ccraig.org Tue Jul 17 17:12:23 2001 From: com-nospam at ccraig.org (Christopher A. Craig) Date: 17 Jul 2001 17:12:23 -0400 Subject: Python 2 times slower than Perl References: <8f41cfd.0107171238.6ff33b9b@posting.google.com> <ku7kx7gtzk.fsf@lasipalatsi.fi> Message-ID: <87itgrmf9k.fsf@elbereth.ccraig.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Erno Kuusela <erno-news at erno.iki.fi> writes: > if you put the code in a function, it will be a fair bit faster > since global variable access is slower than local variable access. This is, in this case, incorrect. Unless I am horribly mistaken, the higher cost of dealing with globals is that you first have to do a failed lookup in the local dictionary. (Plus failed lookups are more expensive than successful ones) In this particular case the local dictionary is the same as the global one, so I don't see how moving to a function would offer a time savings. - -- Christopher A. Craig <com-nospam at ccraig.org> "Tragedy is when I cut my finger. Comedy is when you fall in an open sewer and die." Mel Brooks. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: Processed by Mailcrypt iEYEARECAAYFAjtUqjcACgkQjVztv3T8pzsrTQCfRDCvNaHn8NhnHWUu1j42vI1i 7DQAoKg0+pweTRul6FdtfM7Et4xOKDs6 =3wsl -----END PGP SIGNATURE----- From pinard at iro.umontreal.ca Mon Jul 2 20:12:16 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 02 Jul 2001 20:12:16 -0400 Subject: Python for air traffic control? In-Reply-To: <9hqtkk$b5a$1@panix6.panix.com> References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> <bebbba07.0107021206.70a22aa8@posting.google.com> <mailman.994111084.403.python-list@python.org> <9hqtkk$b5a$1@panix6.panix.com> Message-ID: <oq8zi66fbz.fsf@lin2.sram.qc.ca> [Aahz Maruch] > In article <mailman.994111084.403.python-list at python.org>, > William Park <opengeometry at yahoo.ca> wrote: > >Of course, you idiot... > Is there some reason you're calling Russ an idiot? Let's try to keep > comp.lang.python flamefree, please. I did not like reading this either, but thought it might have been some linguistic idiom, that escapes my knowledge of English or American humour. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From andreas at andreas-jung.com Sun Jul 15 11:37:13 2001 From: andreas at andreas-jung.com (Andreas Jung) Date: Sun, 15 Jul 2001 10:37:13 -0500 Subject: (no subject) Message-ID: <031801c10d44$058f9e40$9865fea9@SUXLAP> http://www.python.org/doc/Comparisons.html "kj0" <kj0 at mailcity.com> wrote in message news:9is8rm$46d$1 at panix3.panix.com... > Where can I find a reasonably non-partisan but also reasonably > detailed comparison of the more popular OO languages (C++, Java, > Python, etc.). (All the comparisons I've found are clearly slanted to > demonstrate the superiority of the authors' favorite OO language--I'm > sure it would be easy to find one written by unapologetic Python > advocates :-) ) From nospam at nospam Fri Jul 13 13:52:05 2001 From: nospam at nospam (Rufus V. Smith) Date: Fri, 13 Jul 2001 13:52:05 -0400 Subject: More on "with" statement Message-ID: <3b4f3600$0$15367@wodc7nh6.news.uu.net> I went to the FAQ to check the entry about a "with" statement that is available in other languages. I can only think of two reasons to use it. 1) You're a lazy typist. (Or haven't learned to cut and paste) 2) You are generally concerned that multiple references to the same object with complex, multilevel access might be confusing to the reader or not optimized by the compiler. I used to like the "with" statement in Pascal or VB. Very useful for using or setting multiple fields. However, as programs got large it could get difficult knowing if the field was a local, global, or part of a with block that started several pages back (in Pascal at least. VB used a preceding '.', which is a good idea). A better solution is to assign a temporary reference. This is possible in C++: DeeplyHiddenStruct & rdhs = &SomeClass.SomeMemberArray[SomeIndex].SomeStruct; rdhs.Field1 = NewValue; DoSomethingWith(rdhs.Field2); etc. which IMO is easier and cleaner than SomeClass.SomeMemberArray[SomeIndex].SomeStruct.Field1 = NewValue; DoSomethingWith(SomeClass.SomeMemberArray[SomeIndex].SomeStruct.Field2); I don't know if the same thing can be done in VB. Isn't it possible to do this in Python by simple assigning to a new object reference? rdhs = SomeObject.SomeMemberArray[SomeIndex].SomeStruct The other advantage in the alternate reference is seen when copying fields from one object to another: rdest = <some object > rsrc = <some compatible object> rdest.field1 = rsrc.field1 rdest.field2 = rsrc.field2 etc. I am a newbie just cutting my fangs in Python, but if I'm right about this, perhaps this preferred workaround should be added the the FAQ. If I'm not... never mind... From grante at visi.com Tue Jul 24 13:10:40 2001 From: grante at visi.com (Grant Edwards) Date: Tue, 24 Jul 2001 17:10:40 GMT Subject: PEP0238 lament References: <mailman.995839419.19134.python-list@python.org> <9jgvbc$dos$1@newshost.accu.uu.nl> <slrn.pl.9lopjh.308.qrczak@qrnik.zagroda> <Yg_67.23542$B7.3778752@ruti.visi.com> <slrn.pl.9lovfr.4na.qrczak@qrnik.zagroda> <buqqltkne23s66b27rn31p6e9ip2a3m53q@4ax.com> <slrn.pl.9lqvmg.n1b.qrczak@qrnik.zagroda> Message-ID: <k_h77.23757$B7.3910692@ruti.visi.com> In article <slrn.pl.9lqvmg.n1b.qrczak at qrnik.zagroda>, Marcin 'Qrczak' Kowalczyk wrote: >>>> Language design mistake. >>> >>>It allows to write code which increments a number of unknown type >>>by one. How would you write it in your universe? > >> Literals can be used for any type where the representation matches, >> so incrementing is not a problem. > >Ok, this applies to Ada and Haskell. But how to fix the "design >mistake" in Python? > >IMHO it doesn't have a practical fix, For some definitions of "practical". My definition of practical doesn't include changing the meaning of "/" between minor revs of a language. ;) To be honest, I would prefer than int/float or float/int throws an exception (and should possibly do the same for "+", "-", etc.). If you want to mix them, then tell the compiler what to do. Explicit is better than implicit: y = x/float(i) j = int(x)/i >as long as a literal is an expression with type independent >from the context. This implies that implicit conversions from >int to float and rational are unavoidable in Python. Why? >Without them some reasonable code is hard to write. I guess I never ran into such a situation. -- Grant Edwards grante Yow! Was my SOY LOAF left at out in th'RAIN? It tastes visi.com REAL GOOD!! From chuxxx at swbell.net Wed Jul 18 11:46:17 2001 From: chuxxx at swbell.net (Charles Crain) Date: Wed, 18 Jul 2001 10:46:17 -0500 Subject: Which Python version to code for? Message-ID: <tlbbqas5b6hvff@corp.supernews.com> I am part of the team working on SCons, the build tool for the Software Carpentry project. We have an interesting quandry before us: what is the earliest version of Python we should support? On the one hand, we would like to use the latest and greatest and be able to take advantage of the several powerful features added in recent Python releases. On the other hand, we would like to avoid putting any barriers to adoption of our product that might arise from requiring users (particularly those in large organizations with high-intertia IT departments) to upgrade Python versions in order to use it. It occurs to us that this is a general question facing anyone wishing to release a Python product. Do you code for the latest and greatest, or do you try to figure out what release is most "common" (in this case, still 1.5.2, since it ships with most major Linux distros) and code for that? Is there any consensus as to what to do here? In particular, does anyone have a feeling for how pmuch of a pain people consider upgrading Python versions so that they may run a particular piece of software? In my experience, upgrading Python versions, and even running concurrent versions, is pretty easy. Thanks for anyone that can help out. -Charles Crain From guido at digicool.com Fri Jul 20 13:03:32 2001 From: guido at digicool.com (Guido van Rossum) Date: Fri, 20 Jul 2001 13:03:32 -0400 Subject: RELEASED: Python 2.1.1 Message-ID: <200107201703.NAA16871@cj20424-a.reston1.va.home.com> I've released Python 2.1.1 today. This is the final version of this bugfix release for Python 2.1, and should be fully compatible with Python 2.1. There should be *no* reason to use 2.1 any more. Many thanks to Thomas Wouters for being the release manager! Pick up your copy here: http://www.python.org/2.1.1/ Python 2.1.1 is GPL-compatible. This means that it is okay to distribute Python binaries linked with GPL-licensed software; Python itself is not released under the GPL but under a less restrictive license which is Open Source compliant. PS: I've noticed some disarray of mail sent through python.org; this seems to have to do with the dysfunctional ORBS "spam-checker". See http://mail.python.org/pipermail/python-dev/2001-July/016151.html for details. --Guido van Rossum (home page: http://www.python.org/~guido/) From cliechti at mails.ch Sat Jul 14 14:46:41 2001 From: cliechti at mails.ch (chris liechti) Date: 14 Jul 2001 20:46:41 +0200 Subject: Need help with socket server code References: <mailman.995132124.31082.python-list@python.org> Message-ID: <Xns90DED3F7A2560cliechtimailsch@62.2.32.50> i can not see how printing the same list over and over again when no data arrives.... but i think you are looking for s.setblocking(0) where s is your socket object. keep in mind that this will print the list relatively fast and you will get 100% CPU usage. as an other poster mentioned: if you want to do two or more things at the same time - use threads (module threading). then you can run your (blocking) communications stuff in a separate thread. chris <cliechti at mails.ch> "Shane Anglin" <shane.anglin at mtni.net> wrote in news:mailman.995132124.31082.python-list at python.org: > Here's the basics of what I want to do with my new app: > Main loop is: > 1 - check socket for any incoming data > 1a - if no data on socket, go to 2, else get the data and place it into > a list 2 - print out list > 3 - go to 1 and do it all over again > > Currently, I can create a TCP socket server app using examples that > will sit and wait (idle 99% of the time) and accepts the incoming data > just fine, my 'print list' part is not processing at all until I get > any new data in... for example, 1-wait on a client connect on socket, > when a connection happens, get data, 2- place new data into list, print > list, 3 -go to 1 and do it all over again... in this scenario, #1 has > the rest of my code 'hostage' until a client connection is made and > closed. > > Thanks a bunch! > Shane Anglin > shaneanglin at bigfoot.com > From cliechti at mails.ch Fri Jul 27 15:30:35 2001 From: cliechti at mails.ch (chris liechti) Date: 27 Jul 2001 21:30:35 +0200 Subject: Launching Python from Python References: <3B619A9E.9E940B28@bioreason.com> Message-ID: <Xns90EBDB73DC54Dcliechtimailsch@62.2.32.50> do you realy need separate python interpreters? you could "import" the other module and run the main function in a thread look at the module "Threading". something like that: ------ import threading import test t = threading.Thread( target=test.main ) t.start() ------ the test.main function runs then in the background chris Jay O'Connor <oconnor at bioreason.com> wrote in news:3B619A9E.9E940B28 at bioreason.com: > All, > > I'm trying to launch another program from a Python program. The other > program happens to be another Python program. I thought spawnle would > be the proper place. However, it doesn't seem to be working. > > import os > pid = os.spawnle (os.P_NOWAIT, > "c:\\python20\\python.exe", > ["c:\\james\\development\\python\\test.py"], > {"PYTHONPATH":"c:\\james\\python"}) > > my understanding is that this should spawn the other process, running > the python runtime and passing in my script name. > > However, it doesn't quite happen. What happens is that it launches > python in interactive mode. If I import sys, sys.path has my added path > above, buy sys.argv is an array with one empty string. > > Any ideas why it doesn't work? Any other ideas on how to launch another > python program from within one? > > This is on WinNT, BTW > > Take care, > Jay O'Connor > oconnor at bioreason.com > -- chris <cliechti at mails.ch> From duncan at NOSPAMrcp.co.uk Tue Jul 24 03:45:18 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Tue, 24 Jul 2001 07:45:18 +0000 (UTC) Subject: Partition Problem References: <tku1tt92ac2g8e@corp.supernews.co.uk> <3B5042C2.F821D916@engcorp.com> <9itb14$2oi$1@newsg1.svr.pol.co.uk> <Xns90E0B338278B2arneleitheno@148.122.208.74> <9iv5e9$bru$1@newsg1.svr.pol.co.uk> <fSI47.12086$p7.3693169@news1.rdc2.pa.home.com> <Xns90E1337E8B341arneleitheno@148.122.208.74> <0oR47.12485$p7.4220508@news1.rdc2.pa.home.com> <Xns90E1CD0C46990arneleitheno@148.122.208.67> <Usa57.127$EP6.29198@news1.rdc2.pa.home.com> <tlavt7jeqqt7b3@corp.supernews.co.uk> <ac677656.0107201451.6f5e120d@posting.google.com> <Xns90E765BFABFB7duncanrcpcouk@127.0.0.1> <eppstein-E10BDA.10010023072001@news.service.uci.edu> Message-ID: <Xns90E8581225ABCduncanrcpcouk@127.0.0.1> David Eppstein <eppstein at ics.uci.edu> wrote in news:eppstein- E10BDA.10010023072001 at news.service.uci.edu: > Nice, but shouldn't the len(seq)==1 test actually be <=1? > The empty sequence has one permutation, not zero. Oops. Missed that, thanks. Tom_Good1 at excite.com (Tom Good) wrote in news:ac677656.0107230857.1a9a12be at posting.google.com: > Bravo! That's a good one. When you say you prefer having the > "return" in there, is your purpose to emphasize that execution does > not "fall through" the first "yield"? As I originally wrote it the return stopped it executing the main body and attempting to permute a 0 length sequence. Since I had written it so that permuting a 0 length sequence gave no permutations, this meant the return simply cut out a lot of code that had no net result. However, once it is fixed to correctly return one permutation of an empty sequence the return becomes essential. -- 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 frandebo at latt.if.usp.br Wed Jul 25 13:33:12 2001 From: frandebo at latt.if.usp.br (Francisco) Date: Wed, 25 Jul 2001 14:33:12 -0300 Subject: A few things :) In-Reply-To: <mailman.996068624.2375.python-list@python.org> References: <mailman.996068624.2375.python-list@python.org> Message-ID: <Pine.LNX.3.96.1010725135955.24282B-100000@latt.if.usp.br> On Wed, 25 Jul 2001, Lee Nutter wrote: Hello Lee, > Im a beginner, and although (i think) I know the base language all > right, I haven't really made anything. Can anyone recommend anything for > a first project? I don't know what areas of interest you have or anything else but since you asked, I will recommend what I used :) I did a (very) simple program of artificial life, the Penna model, that was intended to study biological aging. If you are scared about the words 'artificial life', well... don't be, it is indeed a very simple model that actually does something :) The description of this Penna Model can be found at "Theoretical approuch to biological aging" Physica A 253 (1998) pags 366-378. I don't know if that article is open to be retrieved from internet from any machine (I'm inside an IP block from college, so I have access). If you want to take a look at it and can't download the article, e-mail me and I'll send you a pdf file. DISCLAIMER: I don't have anything to do with the people who wrote that article bla bla bla :^P I just used it to learn python. NOTE: a more in depth analysis of that model is found at: "Dynamics of the bit-string model of age strutured populations" Physica A 242 1997 195-218 ( <- in this case, I had classes with the guy who wrote the article) > Also, I was just wondering, Why do you use python? To me its a hobby. > Why do some of you use it over other languages? I love the language, > don't get me wrong, I was just curious :) I use it for parallel programing (with the hard work done with embedded Fortran code), **lot's** of statistical analysis (over the output of the Fortran code), plotting of all that is aidded by python and also for lots of smaller numerical calculations (with Numerical Python). cheers, -- Francisco. S?o Paulo, Brasil. __o `\<, _____(*)/(*)_____ From sassman at nucentrix.net Sat Jul 14 03:38:07 2001 From: sassman at nucentrix.net (Mark Sass) Date: Sat, 14 Jul 2001 02:38:07 -0500 Subject: SQL Proxy question Message-ID: <UzS37.2$QX5.751@eagle.america.net> Hi All, I am fairly new to Python but have a decent background in programming. I am trying to write some code to proxy authentications to a MS SQL database server. The concept is basically to proxy authentication that uses NTLM or SQL authentication either encrypted or clear text. I have done some packet sniffing to see how the packets work, and it seems fairly straight forward, but I need further assistance. Can anyone point me to some M$ doc that details the packet structure or have some code that already does this? Your help is much appreciated. Thanks, Mark Sass From gerryq at indigo.ie Mon Jul 9 22:17:31 2001 From: gerryq at indigo.ie (Gerry Quinn) Date: Tue, 10 Jul 2001 02:17:31 GMT Subject: BASIC or Python? References: <3d157fa0.0107051904.7ec368b8@posting.google.com> <slrn9kcfuq.2b7g.kamikaze@kuoi.asui.uidaho.edu> <0t_17.14670$Fk7.131382@news.indigo.ie> <slrn9kkgfp.dj6.kamikaze@kuoi.asui.uidaho.edu> Message-ID: <uBt27.15141$Fk7.136713@news.indigo.ie> In article <slrn9kkgfp.dj6.kamikaze at kuoi.asui.uidaho.edu>, kamikaze at kuoi.asui.uidaho.edu (Mark 'Kamikaze' Hughes) wrote: >[ Followups set where they belong. ] > >Sun, 08 Jul 2001 14:52:13 GMT in <0t_17.14670$Fk7.131382 at news.indigo.ie>, >Gerry Quinn <gerryq at indigo.ie> spake: >> In article <slrn9kcfuq.2b7g.kamikaze at kuoi.asui.uidaho.edu>, > kamikaze at kuoi.asui.uidaho.edu (Mark 'Kamikaze' Hughes) wrote: >>> Likewise, Python's string handling is IMO just brilliant; slicing is >[...] >>>string"""`. What's not to love? >> >> Remember that the meaning of a line depends on its indentation. Plenty >> not to love, IMO. > > That has nothing to do with strings, though. > > However, do you not indent your code in C? >if(foo) >bar(); > in a longer example would be unreadable and unmaintainable. Python >just eliminates the curly braces, and assumes you wrote exactly what you >meant. It also eliminates those idiotic religious arguments over >indentation style, because there's only one correct indentation style. > > It's a very old, very bogus argument, dragged out every time by the >people who haven't used Python; once you program in Python, it becomes a >non-issue. > In case anyone is fooled, here's an example from the tutorial at www.python.org, which also has a FAQ on what Python is for: >>> for n in range(2, 10): .. for x in range(2, n): .. if n % x == 0: .. print n, 'equals', x, '*', n/x .. break .. else: .. print n, 'is a prime number' .. Now some people may very well find that lovable, but I certainly don't. Note how the clever language design means that the 'else' must be level-indented with the 'for'. No doubt longer programs are even more fun. The FAQ on increasing speed helpfully notes that function calls are expensive... The second print statement is one character offset from the 'if' - I don't know whether that is necessary or not. It is unlikely that I will ever wish to know. - Gerry Quinn From moryossi at barak-online.net Sat Jul 28 06:33:15 2001 From: moryossi at barak-online.net (Yossi Mor) Date: Sat, 28 Jul 2001 12:33:15 +0200 Subject: Creating package in Python Message-ID: <3b6288fc$1@news.barak.net.il> Hello I am new with Python and i would like to ask several questions: 1. For creating a package i have to create a *.py script that will group selected modules and contain the following script __init__.py. -> Can you elaborate on this script definition. 2. I have tried to create a package that contains 2 modules and succeeded in importing the package itself but not a module inside the package for example 'import pkg.fib1' - what was wrong ? Thanks Yossi From greg at cosc.canterbury.ac.nz Thu Jul 12 00:43:34 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Thu, 12 Jul 2001 16:43:34 +1200 Subject: Comment on PEP-0238 References: <mailman.994892540.32695.python-list@python.org> Message-ID: <3B4D2AF6.7F76CBA1@cosc.canterbury.ac.nz> Tim Peters wrote: > > If precision is adjustable, seems to me it's "usually explicit" (which you > just said you don't want) or "usually implicit" (which you just said you > don't want). If you have another idea, let's hear it -- but remember I said > at the start that the issue can't be wished away. I don't want it implicit on some global or dynamically-scoped state. Some sort of lexically-scoped precision-setting statement might be acceptable, but I'm not sure that's really appropriate either. It seems to me that, if you want adjustable precision at all, you want to adjust it in a very fine-grained way based on the kind of data you're using and what you're doing with it. For example, if you're adding up amounts of money, you want 2 decimal places. But you *only* want to apply that to the numbers which represent money, not the ones which represent the rate of GST or the price per metre of the material you're costing, etc. So the notion of precision being part of some sort of context that you establish and then go off and do your calculations seems fundamentally wrong-headed. You'd be changing the context almost operation-by-operation. I don't know what the best solution to this is. I feel it lies somewhere in the direction of using specialised data types which know their own precision and also what precisions are needed for various combinations of them. For example, a Money type would have a precision of 2dp, GSTRate maybe 4dp. They would know that Money * GSTRate --> Money, so the result should have 2dp. Etc. > Haven't used it, and didn't find any reference docs on the web that admitted > to such a thing in Hypertalk; seemed to imply it handled 19-digit > arithmetic, with a numberFormat property to control (only) *display* > precision. That's the problem -- it *wasn't* just used for display! The only data type in Hypertalk was the string, so storing a number anywhere counted as "displaying" it, and the numberFormat got 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 robin at jessikat.fsnet.co.uk Mon Jul 23 08:42:25 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Mon, 23 Jul 2001 13:42:25 +0100 Subject: PEP0238 lament References: <mailman.995839419.19134.python-list@python.org> <cEN67.17775$EP6.4652917@news1.rdc2.pa.home.com> <cp3d7ngazy.fsf@cj20424-a.reston1.va.home.com> Message-ID: <7lG$+VAxuBX7Ew5z@jessikat.demon.co.uk> In article <cp3d7ngazy.fsf at cj20424-a.reston1.va.home.com>, Guido van Rossum <guido at python.org> writes ....excuses etc elided the pep no matter how written is still about breaking one of the traditional arithmetic properties that has been carried into many computer languages. I am of the if it ain't broke don't fix it school. As others point out explicit is better than implicit. int op int --> int is pretty easy to remember as is the fact that mixed arithmetic promotes the lower arithmetic operands. The leadership is wrong on this and not for good reasons. -- Robin Becker From chrishbarker at home.net Tue Jul 24 17:07:40 2001 From: chrishbarker at home.net (Chris Barker) Date: Tue, 24 Jul 2001 14:07:40 -0700 Subject: A way to accommodate laguage changes References: <3B5CB83B.F3B7D51@home.net> <5E877.23798$EP6.5677355@news1.rdc2.pa.home.com> <23891c90.0107240128.4715d705@posting.google.com> <3B5DC56F.3B84E77D@alcyone.com> Message-ID: <3B5DE39C.543DA6@home.net> Erik Max Francis wrote: > Paul Boddie wrote: > > > "from __past__ import" anyone? ;-) > > This occurred to me as well, but it still doesn't address the problem of > backward compatibility. With a from __past__ import construct or not, > legacy code will still break. The problem is not fixing old code, it's > being unable to fix old code that is no longer accessible (either from > being passed around or by being instrumented at a client site). Exactly. I think everyone would be a LOT happier if you could run old code on a new interpreter, without ANY CHANGES AT ALL. I think my proposal will allow that, someone plese commment on 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 opengeometry at yahoo.ca Mon Jul 2 21:17:42 2001 From: opengeometry at yahoo.ca (William Park) Date: Mon, 2 Jul 2001 21:17:42 -0400 Subject: Python for air traffic control? In-Reply-To: <134760338.994108231348.JavaMail.root@boots>; from 18k11tm001@sneakemail.com on Mon, Jul 02, 2001 at 03:13:05PM -0700 References: <134760338.994108231348.JavaMail.root@boots> Message-ID: <20010702211742.A4372@node0.opengeometry.ca> On Mon, Jul 02, 2001 at 03:13:05PM -0700, Russ Paielli wrote: > Gee, that's profound. You must be some kind of genius. I would have > never figured that out. I scored in the top 1% in math on the > Graduate Records Exam. How did you do, moron? > Yes, a brain. Please don't wast my time anymore with your crap. Ask silly question, get silly answer. Please stop asking "Can Python do this, can python do that..." Just read the docs, and do it. If you can't read, there people who can help you with that too. -- William Park, Open Geometry Consulting, <opengeometry at yahoo.ca> 8 CPUs cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc. From johnroth at ameritech.net Wed Jul 25 14:51:30 2001 From: johnroth at ameritech.net (John Roth) Date: Wed, 25 Jul 2001 11:51:30 -0700 Subject: Eliminating upgrade risk Message-ID: <tlu596rosgngd9@news.supernews.com> After enduring the PEP 238 threads for far too long, as well as other threads, I've come to the conclusion that Python is simply too unstable for real use. Now, I've got a slightly different background here. Much of my professional life was in IBM mainframe shops, where installing a new version of the operating system, major utilities and language processors was essentially **guaranteed** not to break running applications. I can remember numerous upgrades where I had to do absolutely nothing on the applications side. I also have been in shops where programs written in the mid '70s are still running the same executable! You can't always guarantee 100% compatibility while providing new functionality, but you can certainly provide the framework. The root of most of the upgrade problems (PEP 238 being the exception) is that keywords come from the same namespace as other names. Most languages have this problem, and most languages don't solve it, either. Therefore: the Proposal (ta da!) Add a new statement named "required". This statement, if present, must occur before any other statement in a module except comments and docstrings. If it is not present, it will not be considered a reserved word in the remainder of the module. If it is, it will be so considered. It also won't be considered as a new statement if it's immediately followed by an "=" sign. The rest of the statement is simply a list of keyword, value pairs, where the keywords can be added to from release to release with impunity. The syntax for the pairs could be keyword = value, or keyword: value, with commas between the pairs. I have no real opinion on the matter, other than that it allow for essentially unlimited extensibility. The initial set of keywords could be: earliest-release: <release number> latest-release: <release number> tested-release: <release number> earliest-release means that the module requires at least that level of the Python system. Python releases that recognize the requires statement will refuse to run (or import) the module if they are at an earlier level. latest-release means that the module is known not to work on later releases of Python. Python releases later than this level will compile and run the module using the prior release's semantics. tested-release simply means that it was working on that release, and may not work on later releases. This is documentation only; the Python interpreter will automatically supply messages when it is running under a command line, but not if it is running under a GUI. A second part of this would be an optional file named "__requires__.py" in any directory that contained python source or executables. This would contain requires statements for (some of) the various modules in the directory that supply or override the requires statement in the module. Hopefully, this is going to provide more food for thought than fuel for the flames. John Roth From matt_yarbrough at hotmail.com Sun Jul 1 19:44:39 2001 From: matt_yarbrough at hotmail.com (matt yarbrough) Date: Sun, 01 Jul 2001 19:44:39 Subject: import error Message-ID: <LAW2-F114N7miR9Odut0000a7c7@hotmail.com> I'm having trouble with a zope product I'm trying to use, in that it errors on the following line: from ZPublisher.HTTPRequest import html_quote This is the first line in the module. I notice that ZPublisher is a folder rather than a module, and I'm wondering if this is something that may have worked in 1.5 but not in 2.1. The folder is also not a child of the current folder but is actually a sibling of the current folder. Could this be rather a PYTHONPATH issue? _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com From aleaxit at yahoo.com Tue Jul 10 17:22:11 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 10 Jul 2001 23:22:11 +0200 Subject: getting argument names from a function References: <6%F27.4784$yh2.453987@weber.videotron.net> <Pine.SOL.4.30.0107101835460.10785-100000@my.nada.kth.se> <W9I27.5835$yh2.510569@weber.videotron.net> Message-ID: <9ifriv013re@enews2.newsguy.com> "dan" <dan at eevolved.com> wrote in message news:W9I27.5835$yh2.510569 at weber.videotron.net... > Actually, that grabs the entire namespace of the function, not just the > function variables. I haven't found anything in the func_code tree that > contains only the function argument keys... ... > >> def aFunction(arg1, arg2): > >> print arg1, arg2 > >> > >> is there a way I can get to the arguments of aFunction (i.e. 'arg1' and > >> 'arg2')? >>> def aFunction(arg1, arg2): ... print arg1, arg2 ... >>> dir(aFunction) ['__dict__', '__doc__', '__name__', 'func_closure', 'func_code', 'func_defaults' , 'func_dict', 'func_doc', 'func_globals', 'func_name'] >>> aFunction.func_code.co_varnames ('arg1', 'arg2') If the function has both arguments and other local variables, the arguments come first in ...co_varnames. ...co_argcount is the number of arguments. So: def argsof(f): co = f.func_code return co.co_varnames[:co.co_argcount] should be what you want. Alex From tim.hochberg at ieee.org Mon Jul 23 18:53:42 2001 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Mon, 23 Jul 2001 22:53:42 GMT Subject: PEP0238 lament References: <mailman.995839419.19134.python-list@python.org> <lZX67.36860$Cy.4285646@news1.rdc1.az.home.com> <11moltg2i6s1ftkpku5dkr0cmifn9f5q1o@4ax.com> <Ew_67.36904$Cy.4360445@news1.rdc1.az.home.com> <eppstein-E3BB02.12500023072001@news.service.uci.edu> Message-ID: <WV177.36940$Cy.4447774@news1.rdc1.az.home.com> "David Eppstein" <eppstein at ics.uci.edu> wrote: > So what problems was PEP 238 proposed for anyway? > I still haven't seen even one good example where int/int->float semantics > is the right thing to do. That's odd -- you must exist in a completely different part of compuspatial continuum than I do. In my experience when I define a function that involves division I generally want it to either compute using float-division or floor-division[1]. I know which type of division I want when I write the function, and it doesn't depend on what the inputs as[2]. I don't think I've ever seen a case where I want to see the type of division change from floor-division to float-division based on the input types. Consider two functions: the number of pillars on a bridge and electrical impedance per unit length: def pillars_per_bridge(bridge_length, pillar_sep): return bridge_length / pillar_sep def impedance_per_length(impedance, length): return return impedance / length In the first case I _always_ want to do floor-division. In the second I always want to do float-division. To get these to work now I need to do something like: def pillars_per_bridge(bridge_length, pillar_sep): return int(bridge_length) / int(pillar_sep) def impedance_per_length(impedance, length): return (1.0*return impedance) / length Which is not too horrible, but it is extra cruft. So let me turn your question around. Can you give an example where you want the type of division (float vs floor) to change depending on the type of input (int, float, complex)? I can't, although I suspect there must be some. I also suspect they're very rare. When _I_ use an operator, it means just what I choose it to mean--neither more nor less. or-at-least-it-should-ly yours, -tim [1] I'm going to use floor division rather than int-division in my terminology because those crafty math people tell us you can't really divide integers because there a boxing rather than a soccer venue (or maybe vice-vera), and because the term integer-division is not well defined; witness the difference in how integer division is done in C and python. [2] As long as they're "numbers". Whatever that means on a given day. From tundra at tundraware.com Mon Jul 9 21:00:01 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 10 Jul 2001 01:00:01 GMT Subject: Python Idiom Question References: <3B4A4126.7AD3CDD0@tundraware.com> <3B4A4E7D.F16F2C4B@Lugoj.Com> Message-ID: <3B4A51CF.7EE1ACA@tundraware.com> James Logajan wrote: > > Tim Daneliuk wrote: > > > > What is the equivalent python idiom to the following 'C' code: > > > > while (x=getchar() != 'N') > > { > > Do something} > > > > In other words, is there a convenient way to simultaneously get > > input, from say, raw_input() or f.read(), and check the return > > value agains some logical construct, re pattern match, or whatever? > > What is wrong with: > > while 1: > x=raw_input() > if x == 'N': break > Do something Nothing - I was just doing a quick idiom check to make sure I was in the ballpark. Tnx for the reply. -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From dsh8290 at rit.edu Tue Jul 3 18:24:43 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 3 Jul 2001 18:24:43 -0400 Subject: No float limits In-Reply-To: <9htdv6$phu$01$1@news.t-online.com>; from jh@web.de on Tue, Jul 03, 2001 at 11:37:51PM +0200 References: <9htdv6$phu$01$1@news.t-online.com> Message-ID: <20010703182443.C26134@harmony.cs.rit.edu> On Tue, Jul 03, 2001 at 11:37:51PM +0200, J?rgen Hermann wrote: | Hi! | | I just stumbled over the fact that there is sys.maxint, but no sys.maxfloat | and sys.epsfloat. In case anyone thinks this is a valid addition, I'll come | up with a patch. What value would sys.maxfloat have? IIRC IEEE754 states that all ones (ie 0xFFFFFFFF for a single precision float) means infinity, so there really isn't a "max" value for a float. -D From aleaxit at yahoo.com Thu Jul 12 14:56:59 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 12 Jul 2001 20:56:59 +0200 Subject: Long Live Python! References: <Pine.LNX.4.33.0107121131290.21768-100000@bms> Message-ID: <021e01c10b04$74352820$0300a8c0@arthur> "Bruce Sass" <bsass at freenet.edmonton.ab.ca> writes: ... > The point was that python and sh operate on different levels. So they do. Python operates, much like Perl and most other scripting languages, mostly by operations in the languages itself and its libraries; sh (although bash and ksh move it a bit away from that) basically relies on external programs. > $ cat file*1 file*2 file*3 | tee file4 | wc -cwl >> file5 > > (i.e., concatenate some unknown number of files whose names match one > of three patterns, write the result to a file and count the > characters, lines and words, appending that result to a different > file) > > is what in Python.... > ...2 lines, 3, 4, an explicit loop, a function or two, or maybe a > program (i.e., some imports, assignments, blocks of code, ...)? If you do not need cross-platform operation, you can do it the same way (except that you most always need to import...): import os os.system('cat file*1 file*2 file*3 | tee file4 | wc -cwl >> file5') This, of course, is anything BUT idiomatic, because you have no control at all -- you're delegating everything to external programs, just like in sh. What will happen on OS/2, Macintosh, Windows, VMS, or a Sony Playstation? What happens if there are too many files called 'file'+something+'2' and you overflow the number of arguments allowed on some older Unix-ish box? Etc, etc. Most likely, one would program it differently, solidly, and portably: import fileinput from glob import glob file4 = open('file4','w') lines = words = chars = 0 for line in fileinput.input(glob('file*1')+glob('file*2')+glob('file*3')): file4.write(line) lines += 1 words += len(line.split()) chars += len(line) file4.close() file5 = open('file5','a') file5.write("%s lines, %s words, %s chars\n"%(lines,words,chars)) file5.close() But the fact that one CAN do it differently doesn't mean the "different" way is inferior. os.system and friends are there, for those times where you want to operate this way. So are excellent facilities for operating differently. It's silly to claim that giving you a choice makes Python inferior to sh for such operations. > Ya, I know, for some... "script" == "interpreted", for the rest of > us... "script" == "automating a sequence of command line operations". > I guess it was a mistake to play off that bit of ambiguousness as an > introduction to the point. "script"=="interpreted" seems just silly. But where do the *command line* operations get into the "scripting" concept?! "Automating a sequence of operations" seems just right. That sh is basically able to do it for (some) "command line" operations, but not really for ones based on other paradigms, is sh's problem -- it doesn't define the concept of 'scripting'. For example, with VIM (Vi IMproved), I can use Python for scripts, which automate sequences of editing operations that are anything *but* "command-line" -- one doesn't *HAVE* to resort to command-line-oriented editors (ed, ex, sed, ...) to script them, as long as the available scripting language and infrastructure are good enough. sh and its descendants just _aren't_ good enough for the kind of rich, complicated scripting tasks that Python (and, though I loathe to admit it, Perl, Tcl, VBScript, &c) handle with ease today. Alex _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com From paul at boddie.net Thu Jul 12 06:59:36 2001 From: paul at boddie.net (Paul Boddie) Date: 12 Jul 2001 03:59:36 -0700 Subject: LAMBDA IS IT USELESS? References: <tO837.679712$166.14009323@news1.rdc1.bc.home.com> <3B4D3CF1.889B57BB@cosc.canterbury.ac.nz> Message-ID: <23891c90.0107120259.333a8a9a@posting.google.com> Greg Ewing <greg at cosc.canterbury.ac.nz> wrote in message news:<3B4D3CF1.889B57BB at cosc.canterbury.ac.nz>... > EricIDLE wrote: > > > > def mult(x,y): > > return x * y > > f = reduce(lambda x,y: x*y,n) [mult is not needed if lambda is used] > It's a matter of taste. Some people like the ability > to write very trivial functions like your mult() in-line. Amplifying the above explanation... In this case, the use of lambda is convenient because * can't behave like a function, so you need a quick way of wrapping * up to act like one. The lambda construct lets you define a function "in-line" (as stated above) without needing to call it something, or having it take up space somewhere in your source file. The "mult" function could be seen as "overkill" by some people in that such a standalone function isn't likely to be widely useful and therefore doesn't justify its existence as a standalone function. In cases where you want to apply complicated expressions, the use of a separate function becomes more compelling. Where control flow constructs such as "if" are required, a separate function is necessary. So, lambda is really only useful when you want to apply simple expressions as if they were functions. Of course, a daring extension to the Python language could let the following be written: f = reduce(*, n) Or: f = reduce(*.as_function(), n) But I'm not one to advocate this kind of thing. ;-) Besides, there are still cases that this wouldn't address. For example: f = reduce(lambda x, y: x + y/2, n) :-) Paul From JamesL at Lugoj.Com Wed Jul 25 00:06:15 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Tue, 24 Jul 2001 21:06:15 -0700 Subject: Proposal for .py2, py3, etc. extensions. Was: A way to accommodate laguage changes References: <3B5CB83B.F3B7D51@home.net> <5E877.23798$EP6.5677355@news1.rdc2.pa.home.com> <23891c90.0107240128.4715d705@posting.google.com> <3B5DC56F.3B84E77D@alcyone.com> <3B5DE39C.543DA6@home.net> <3B5DE7F3.EB5EC5F1@Lugoj.Com> <3B5E1075.94167ECD@home.net> Message-ID: <3B5E45B7.2C4AE40@Lugoj.Com> Note: I should have called this a proposal for a new source file suffix to match the terminology used in the library reference manual. I'll use "suffix", rather than "extension", henceforth. Chris Barker wrote: > In the long, run, I think relying on file extensions ios a bad idea. > Among othetr things, Python code is not neccesarily stored in files at > all (at least not when passed to the interpreter) But, but, Python ALREADY relies on file name suffixes! The "import" statement: import <module> does NOT cause the interpreter to scan through every file in every directory in sys.path, examining the contents of each and use some magical mechanism to determine which ones are Python and are the module <module>. It looks for files named <module>.so (or whatever the extension suffix for the given platform), <module>.pyc, <module>.pyo, and <module>.py. It generally REQUIRES proper suffixes to do its job. If it finds a .pyc then I believe it looks at the "magic string" in it to determine which version of python it was compiled with. That would tell the interpreter what behavior to use for the "/" operator (or any other language change) for that module. Compiled byte code files theoretically shouldn't be a problem, since the "magic string" should already differentiate versions (although I'm not sure what, say, a 1.5.2 interpreter does when it encounters a "non-conformant" magic string for a later release). I'm also not sure what unusual uses users have made of the "compile" function in the py_compile module, but I would be surprised if anyone was using it with unusual file extensions. (Much less breakage is likely here than that which would be caused by a change to "/" semantics.) Actually, even there one could use the rule that if the file doesn't end in .py2, (or whatever) then assume the source was written under older versions. (However, a 1.5.2, say, might be accidentally be fed a .py2 this way; the proposal isn't 100% perfect. Just 98.7%.) As far as I can see, there shouldn't be any obstacles getting the "imp" module and the "import" statement to deal with a mix of .py and .py2 files. This proposal basically adds an alternate suffix for source files. To summarize, a new source code suffix has these properties: 1) Both humans and interpreters may know immediately by inspection of the source file name what version of syntax and semantics to apply to the source code. 2) Does not require old code to be rewritten in any way. 3) Does not require new code to have any special versioning statement embedded in it. 4) Beginners can be instructed to use only the latest version suffix for their source files until they have reached a high enough level of competence and familiarity before trying to comprehend older code. 5) Provides the language designer(s) more latitude in designing in otherwise code-breaking changes while still protecting the time invested in legacy code. 6) Forces the language designer(s) to collect many changes to the language in fewer quantum leaps. (That is, if one is limited to .py0, .py1, .py2, ... .py9, then greater care will be taken in not "using up" the rather small number of version numbers so quickly. I consider this a useful property.) That is it; I can think of some minor objections or esthetic complaints, but can't see any show stoppers unless I basically misunderstand some Python internals. From thomas at xs4all.net Mon Jul 2 03:20:13 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 2 Jul 2001 09:20:13 +0200 Subject: Augmented Assignment (was: Re: PEP scepticism) In-Reply-To: <1e9801c1029f$92682940$0a06a8c0@FENX.COM> References: <B43D149A9AB2D411971300B0D03D7E8B0FC21C@natasha.auslabs.avaya.com> <1e9801c1029f$92682940$0a06a8c0@FENX.COM> Message-ID: <20010702092013.K8098@xs4all.nl> On Sun, Jul 01, 2001 at 07:34:07PM -0700, Emile van Sebille wrote: > > It would be quite legal for id(b) to be identical in one case - since b > > is the only reference to the tuple, the original tuple could be > > collected, and a new tuple with the same id() could be allocated. It's > > unlikely, but possible. > I'm not sure that's true. It looks like the old (collectible) reference > exists until the STORE_FAST is executed, and IIRC, individual byte code > commands are atomic and execute until completion without interference. > Do I have that right? You do. The new tuple gets created before the old one is destroyed. Even if my *first* attempt at augmented assignment (which used new two-argument bytecodes to do inplace-operation-and-store in 1 bytecode) had been accepted, it probably wouldn't have worked that way: you don't want to destroy the old value until you are sure you can create the new value without raising an exception. -- Thomas Wouters <thomas at xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From aleaxit at yahoo.com Sun Jul 15 14:33:12 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 15 Jul 2001 20:33:12 +0200 Subject: not safe at all References: <mm8tkt4te3qnbpv3nh5nhsi591o1osln73@4ax.com> <slrn9ku3c3.mrk.9nick9m@localhost.localdomain> <u26ukt4vot7b1qu02hkp8l1pnmdi0sfp3l@4ax.com> <3B4F743C.66778F9F@tundraware.com> <9ip1qa012en@enews4.newsguy.com> <3B509C1F.B2E7ABD6@tundraware.com> <9iqea10f19@enews1.newsguy.com> <3B50DE63.4217DC08@tundraware.com> Message-ID: <9isnio08c@enews1.newsguy.com> "Tim Daneliuk" <tundra at tundraware.com> wrote in message news:3B50DE63.4217DC08 at tundraware.com... ... > > What gave you the idea that anybody around here is interested > > in "serving abstract ideas"? I'm interested in serving *our > > customers*, all 10,000+ of them at last count -- ensuring > > None of whom give a damn if your code is portable (unless you're > selling programming tools like compilers) or how elegantly Go tell that to a (hopefully hypothetical) customer who's just done some system upgrade, preferably right after the program with which he spends the majority of his working hours has just stopped working. "Oh but you don't give a damn if my code is portable, so why are you giving all of these damns right now?". Even if all it takes to get him back to work is a few downloads of upgraded versions -- a few hours' time to locate, grab and install them -- you WILL hear damns aplenty. > architected it might be - they just want your application to run > on their system. How it does so, is your problem, not theirs. There is a grammatical error here. "their system" is singular. It would be a singular customer indeed (for our products) who owned one single system (without significant upgrades) and only ran our programs on that single (singular) system. Change the sentence to "they just want your applications to run on a wide variety of systems, offering several trade-off points between cost, performance, stability, familiarity of other system tools to their employees, &c, so that choosing your applications does not constrain their abilities to choose the platforms they equip their employees with, upgrade them with the newest processors or graphic cards when they think the price/performance is right for that, and so on". In other words, they just want our applications to be portable -- you're right that HOW we achieve that desideratum (just like, how do we achieve high performance, rich functionality, low price, backwards compatibility, solidity, and a zillion other typical customer desiderata) doesn't (well, _shouldn't_ -- reality is often different) concern them. But portability is a plus in itself for the customer, just like performance &c, because a typical customer in our field doesn't own ONE system -- much less does he or she kid him or herself that 'ONE' unchanged system is what he or she will own for a long, long time. It so happens that _right now_ we can get away (for most customers) with only offering portability among a relatively narrow range of platforms -- yes, we ARE losing business where (for example) the customer specifies that design applications must run on Macintosh whatever (because that's the system used in certain key departments of the customer's firm/suppliers/customers/whatever, and the customer doesn't trust translation utilities to be perfect, and so wants to make SURE the same application runs on all systems in a certain set) as well as Windows 2000, &c; i.e., where a potential customer specifies among the requisites a wider portability than we can offer right now. But, we estimate that the loss due to non-universal portability is lower than what it would cost us to achieve universal portability (including quality assurance on each supported platform, of course). It's not an abstract, far away issue: it's just as concrete and important as any other customer desideratum, such as top performance, low footprint, low price, total solidity, and so on. Of course, what the customer really wants is: everything, for free, yesterday, etc, so one must trade-off between various such desiderata -- but portability IS typically one of them. It may be different in fields (if there are any) where every customer believes (rightly or wrongly) that the application he or she buys will run for all of its useful lifetime on a single unchanging system configuration. I suspect that may be true of applications with relatively short useful lifes (such as games), or when the customer is too naive to understand how constraining it will soon prove to be unable to upgrade his or her machines because of portability constraints of the application being purchased. Neither of these issues applies to CAD and PDM software, and, I'm sure, to many other fields in the area of software development. Alex From guido at python.org Fri Jul 27 14:00:08 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 27 Jul 2001 18:00:08 GMT Subject: Eliminating upgrade risk References: <mailman.996217251.21555.python-list@python.org> <3B61A275.82581457@Lugoj.Com> Message-ID: <cp8zha2qxw.fsf@cj20424-a.reston1.va.home.com> James Logajan <JamesL at Lugoj.Com> writes: > I've checked the Google archives, and I've come to the conclusion that you > are of the position that anyone who doesn't constantly upgrade should not be > supported, in the sense that if they report bugs, write books about Python, > or ask for porting assistance, their questions will all be answered with > "Upgrade first, then we'll talk". Is that basically correct? Since you don't pay him for fixing bugs or answering questions, what's wrong with Tim's desire to avoid discussing things that have been fixed already? Maybe here's a business for somebody: maintain old versions of Python. I don't think that PythonLabs has the manpower of financial resources to add this to our already growing list of tasks. Or maybe you want to become a platinum sponsor of the PSF? --Guido van Rossum (home page: http://www.python.org/~guido/) From philipprw at gmx.at Wed Jul 18 14:14:56 2001 From: philipprw at gmx.at (Philipp Weinfurter) Date: 18 Jul 2001 18:14:56 GMT Subject: bug in python's scope handling? Message-ID: <slrn9lbkhg.1at.philipprw@chello213047126184.14.univie.teleweb.at> hi everyone! a = 1 def func1(): b = a + 1 right, the local variable b is assigned the value of the global variable a. so far, so good. def func2(): a = a + 1 and now the local variable a is assigned... uh, nothing because it produces an UnboundLocalError. now, i admit that no programmer should ever write such code, but i still consider this a bug. what _should_ happen, is this: the right side of the assignment is evaluated first, thus adding 1 to the value of the global variable a, then the result should be assigned to the local variable a, no? then From gustafl at algonet.se Tue Jul 3 19:12:25 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 3 Jul 2001 23:12:25 GMT Subject: AttributeError: 'getopt' module has no attribute 'GetoptError' References: <Xns90D3ECC92390Dgustaflalgonetse@194.213.69.152> Message-ID: <Xns90D4C665646gustaflalgonetse@194.213.69.148> gustafl at algonet.se (Gustaf Liljegren) wrote: > Try to use the getopt module, but get the error in the subject line. > What's wrong? Still a true mystery. > Another question about getopt: Are options optional by nature? You > can't have a mandatory option? Found the answer to this myself: "Unlike GNU getopt(), after a non-option argument, all further arguments are considered also non-options. This is similar to the way non-GNU Unix systems work." What I want to do is something like: python script.py <single command> <some options> <some arguments> Hm...maybe I should write my own getopt? Maybe someone already did? :-) Regards, Gustaf Liljegren From cgale1 at _remove_home.com Fri Jul 13 03:30:52 2001 From: cgale1 at _remove_home.com (Van Gale) Date: Fri, 13 Jul 2001 07:30:52 GMT Subject: Any way to get current file position in xml.parsers.expat? References: <slrn9kt86i.750.clgonsal@keeshah.penguinpowered.com> Message-ID: <Msx37.103186$%a.4410093@news1.rdc1.sdca.home.com> "C. Laurence Gonsalves" <clgonsal at keeshah.penguinpowered.com> wrote in message news:slrn9kt86i.750.clgonsal at keeshah.penguinpowered.com... > Unfortunately, I can't find any way to get the current position in the > file when using ParseFile. I know that if expat throws an ExpatError, > that will contain the line and column number, but that doesn't help me > in this situation, as the file is 'well formed' XML as far as expat is > concerned. > > So is there any way to ask the expat parser where it is in the file? > Even a byte offset from the beginning of the file would be better than > nothing. I'm pretty sure ErrorColumnNumber, ErrorLineNumber, and ErrorByteIndex are updated even when there is no error. Van From rnd at onego.ru Tue Jul 17 09:13:58 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 17 Jul 2001 17:13:58 +0400 (MSD) Subject: list and implicit continuation may cause bugs in Python programs In-Reply-To: <tnc8ltsd0p882c369q100a5e9s5ehuaans@4ax.com> Message-ID: <Pine.LNX.4.21.BCL.0107171709200.704-100000@suzi.com.onego.ru> On Tue, 17 Jul 2001, Toby Dickenson wrote: > Roman Suzi <rnd at onego.ru> wrote: > > >>> Do not forget commas: > >>> > >>> list =[ "update", "y", "m", "d", "y1", "m1", "d1", "event", "url", > >>> "preview" ] > >>> > >>> list =[ "update", "y", "m", "d", "y1", "m1", "d1", "event", "url" > >>> "preview" ] > >>> > >>> Does PyChecker check for these kind of things? > >>> > >> > >>For what reason should it check ? Both is valid Python code. In the second > >>case 'url' and 'preview' are concatenated. This is dedicated behaviour. > >> > > > >PyChecker is about determining ambiguity, like lint > >will give you warnings about > > > >if (a=b) { }; > > > >in C code. > > Which, as I am sure you know, is no more ambiguous in C than the > Python fragment above. It is not ambiguous for the translator. Still lint-like tools could report such problems as warnings, because it is too easy to make error here. I even think, that things like: for i in list: if cond: do_something else: somethingelse must be reported. Just like TAB/space mixes. This will lead to much more readable code. Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From Richard.Suchenwirth at kst.siemens.de Wed Jul 11 14:11:52 2001 From: Richard.Suchenwirth at kst.siemens.de (Richard.Suchenwirth) Date: Wed, 11 Jul 2001 20:11:52 +0200 Subject: shortest match regexp operator anyone? References: <yv266cz4aom.fsf@lionsp093.lion-ag.de> Message-ID: <3B4C96E8.668FB82A@kst.siemens.de> Harald Kirsch wrote: ... > 2) TASK: Find the first '<A>' and match, if it is followed by a 'B' > SOLUTION: ??? > > An approximation for (2) is '^[^<>A]+<A>B', but it does not match > 'A<A>B', which it should. > > With non-greedy matching, another approximation is '^.*?<A>B', however > this matches 'xx<A>y<A>B', although it should not. Maybe I don't understand the exact problem, but wouldn't regexp {(<A>)B} foo<A>Cbar<A>B -> matched fulfill task 2? -- 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 tim.one at home.com Mon Jul 30 01:13:57 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 30 Jul 2001 01:13:57 -0400 Subject: [OT] Number theory [Was: A use for integer quotients] In-Reply-To: <3b6409e0.2079581@nntp.sprynet.com> Message-ID: <LNBBLJKPBEHFEDALKOLCKEDDLCAA.tim.one@home.com> [David C. Ullrich] > ... > (Did they change the rules recently? Don't recall > relevance to Python being a criterion here...) You're exempt from the rules, David: letting you wax mathematical is just our way of sucking you deeper into the Python community <wink>. integral-hugs-and-rational-kisses-ly y'rs - tim From max at alcyone.com Sun Jul 22 14:00:28 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 22 Jul 2001 11:00:28 -0700 Subject: subclassing Exceptions References: <9ihklt8u0vvh1aa0mg6tadbmjo9mot47e0@4ax.com> <3b5a69a3$0$320$6e49188b@news.goldengate.net> <ubrklto6t10pidmh5bld02glmcmjd9jdvq@4ax.com> Message-ID: <3B5B14BC.FAEDC762@alcyone.com> Sheila King wrote: > OK, interesting. I didn't realize you could make an exception without > subclassing it. You can, but the library reference (2.2, Built-in Exceptions) states that user-defined exceptions _should_ be derived from exceptions.Exception, and suggests that this behavior might be enforced in the future. It's generally good practice. > However, I noticed earlier this evening, from browsing the > exceptions.c > source (as noted elsewhere in this thread), that the Exceptions seem to > have 3 methods and 1 datamember, namely: > > methods: > __init__ > __getitem__ > __str__ > > and the datamember > __doc__ And an `args' method, as the library reference states: 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. >>> try: ... raise Exception ... except Exception, e: ... pass ... >>> dir(e) ['args'] > So, I would imagine that if you subclass it, and do not specifically > define these methods/data listed above, that you at least inherit them > from the base class. Whereas, if you create an "exception" that does > not > derive from a base Exception class, it would not have these methods. Correct. A class you intend to use for exceptions is just like any other class; there's nothing special about it. Only when you derive from exceptions.Exception does it make it clear you plan to use the class for exception handling, and since you derive from the Exception class you get standard behavior for free even if you do not extend it. > Hmm...I just tried a little experiment in the interactive shell to see > if I could confirm/deny my above theory, and it gave me surprising > results that I do not understand, and which seem to indicate no > difference between deriving it from an Exception class or not. Well, if you don't understand the results, it's going to be a little hard telling you what you did wrong or what you misunderstood without knowing what you actually did. :-) -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ History is a bucket of ashes. \__/ Carl Sandburg Erik Max Francis' bookmarks / http://www.alcyone.com/max/links/ A highly categorized list of Web links. From mal at lemburg.com Sat Jul 14 12:04:04 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Sat, 14 Jul 2001 18:04:04 +0200 Subject: PEP: Defining Unicode Literal Encodings (revision 1.1) References: <Pine.LNX.4.30.0107141805550.5125-100000@rnd.onego.ru> Message-ID: <3B506D74.634EA1F@lemburg.com> Roman Suzi wrote: > > On Sat, 14 Jul 2001, M.-A. Lemburg wrote: > > >directive unicodeencoding = 'latin-1' > > >#!/usr/local/python > >""" Module Docs... > >""" > >directive unicodeencoding = 'latin-1' > >... > >u = "H?ll? W?rld !" > >... > > Is there any need for new directive like that? > Maybe it is possible to use Emacs-style "coding" directive > in the second line instead: > > #!/usr/bin/python > # -*- coding=utf-8 -*- > ... I already mentioned allowing directives in comments to work around the problem of directive placement before the first doc-string. The above would then look like this: #!/usr/local/bin/python # directive unicodeencoding='utf-8' u""" UTF-8 doc-string """ The downside of this is that parsing comments breaks the current tokenizing scheme in Python: the tokenizer removes comments before passing the tokens to the compiler ...wouldn't be hard to fix though ;-) (note that tokenize.py does not) -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From loewis at informatik.hu-berlin.de Sat Jul 21 15:31:27 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 21 Jul 2001 21:31:27 +0200 Subject: xml.dom.minidom + py2exe References: <9ilk1r$quo$1@maud.ifi.uio.no> <9im880$jjh8j$1@ID-59885.news.dfncis.de> <j4wv56z400.fsf@informatik.hu-berlin.de> <Xns90E2BDCEA67E7gmcmhypernetcom@199.171.54.194> <j4snfsgin1.fsf@informatik.hu-berlin.de> <9j8uu1$lujt7$1@ID-59885.news.dfncis.de> Message-ID: <j4n15ygju8.fsf@informatik.hu-berlin.de> "Thomas Heller" <thomas.heller at ion-tof.com> writes: > More and more I have the impression (from an freeze/install/py2exe > point of view, I don't know too much about xml and PyXML) that > installing PyXML should *replace* the Lib/xml module. > By replace I mean that Lib/xml should be deleted/renamed, > and PyXML should be installed into xml somewhere in sys.path. I think this was discussed when the original _xmlplus solution was developped, and rejected: distutils should never write into the standard library. Regards, Martin From dirck at pacbell.net Fri Jul 13 14:48:37 2001 From: dirck at pacbell.net (Dirck Blaskey) Date: 13 Jul 2001 11:48:37 -0700 Subject: Long Live Python! References: <mailman.994969462.27792.python-list@python.org> <hevsktcrnpckttnkgi1arcue5kjjsbrrb5@4ax.com> Message-ID: <6c8b7eb9.0107131048.4b400d2d@posting.google.com> Dennis Roark <denro at earthlink.net> wrote in message news:<hevsktcrnpckttnkgi1arcue5kjjsbrrb5 at 4ax.com>... > James_Althoff at i2.com wrote: > >What is it about Python that would, in your experience, make it only "good > >for short programs <100 lines". > > Lack of type safety; lack of forcing variable names to be > declared before use. (In a long program, how hard it is to > find a bug that is simply the misspelling of a variable!) > > I really like Python, but for at least the reasons above, I > can't see it for long programs. With Python, you don't know if your code is going to work until it's actually been tested. Hmm... :) I don't think type safety makes that go away, though it does help to catch some bugs at compile time. With Python, at least there's no 'illusion of safety' for code that hasn't been tested. --------------------------------------------------- if it hasn't been built, it doesn't compile, if it hasn't been executed, it doesn't run, if it hasn't been tested, it doesn't work, if it hasn't been used, it's not correct, and if it hasn't been checked-in, it doesn't exist. --------------------------------------------------- From brian_zhouNOSPAM at techie.com Fri Jul 13 17:40:28 2001 From: brian_zhouNOSPAM at techie.com (Brian Zhou) Date: Fri, 13 Jul 2001 14:40:28 -0700 Subject: Apache & Python References: <20010713.15394573@mis.configured.host> Message-ID: <995060457.436160@emperor.labs.agilent.com> Apache & PythonBesides CGI or mod_*, one more alternative is jython servlet, esp. when you have Java components. See http://jywiki.sourceforge.net/index.php?JythonServlet for some examples. -Brian "Paul Duquette" <pauld at metrocast.net> wrote in message news:20010713.15394573 at mis.configured.host... I have installed python 2.1 on my windows2k machine and would like to know how to use Python with Apache. I can't find any config instructions anywhere. The python faq tells me how to configure it with IIS but I didnt see anything about Apache. Hopeing you Python experts out there can point me in the right direction. Thanks From joonas.paalasmaa at nokia.com Thu Jul 5 06:37:35 2001 From: joonas.paalasmaa at nokia.com (Joonas Paalasmaa) Date: Thu, 05 Jul 2001 10:37:35 GMT Subject: system exec ? References: <9i1er4$mth$1@news.businessobjects.com> Message-ID: <3B4443FB.E9D32C12@nokia.com> alphaZeta wrote: > > Hi, > > I didn't find any documentation (lib and tut) about how to execute a program > in a python script. > Does anybody know ? > > For example : I would like to store in a variable the result of a call to > the system. > alike : >>> a = sys.exe("ls -l") a = os.popen("ls -l","r").read() From bokr at accessone.com Mon Jul 23 20:35:49 2001 From: bokr at accessone.com (Bengt Richter) Date: Tue, 24 Jul 2001 00:35:49 GMT Subject: A use for integer quotients References: <mailman.995866298.23496.python-list@python.org> <eppstein-E19F08.00451323072001@news.service.uci.edu> <3B5BDCB4.A2010560@letterror.com> <3B5C48A0.56D88724@alcyone.com> <7ikoltclv5sjr376ua6m1jlk3a9l1qftju@4ax.com> <3b5c990b.237461111@wa.news.verio.net> <dk9plto33uqab4t2ooil3t543kr7siekmr@4ax.com> Message-ID: <3b5cbf31.247227744@wa.news.verio.net> On Tue, 24 Jul 2001 00:05:12 +0100, Stephen Horne <steve at lurking.demon.co.uk> wrote: >On Mon, 23 Jul 2001 21:34:51 GMT, bokr at accessone.com (Bengt Richter) >wrote: > >>On Mon, 23 Jul 2001 19:15:33 +0100, Steve Horne <sh at ttsoftware.co.uk> wrote: >>[...] >>> >>>Fixed point arithmetic emulated by using integers with a scale factor, >>>though, works very nicely. Better still when there's a language >>>feature to do this automatically, but if we added fixed point types to >>>Python we'd need *another* division operator - four so far including >>>the rational one ;-) >>> >>This reminds me, is Python configurable to run on a platform with no >>floating point support? > >I believe so - there was even a Python for Psion palmtops at one >point, and the 3 series certainly doesn't have hardware floats. > >All it requires, I imagine, is that the C or C++ (not sure which) >compiler that you build Python on must have a correctly implemented >'double' type - the implementation of the floats in software or >hardware should be irrelevant bar performance concerns. > No, I meant really no floating point, including software. What if you had zero use for floating point, and wanted the benefit of a small footprint? I wonder if the implementation is factored to where not using floating point would let you substitute small exception-raising stubs for otherwise large (?? usually, floating point carries a lot of baggage along in the C/C++ world) chunks concerned with floating point. Then that could be a make option. I was wondering if someone's been there done that. >Linux Python is distributed both as source and as binary, and a source >distro will compile and install itself with very little fuss if you >know the basics of Linux. It should just install and work. > Yes, no prob. From gregj at pdxperts.com Thu Jul 19 04:24:25 2001 From: gregj at pdxperts.com (Greg Jorgensen) Date: Thu, 19 Jul 2001 08:24:25 GMT Subject: Python 2 times slower than Perl References: <8f41cfd.0107171238.6ff33b9b@posting.google.com> <9j3rvk$26bt$1@norfair.nerim.net> <3B559B30.61A90EA@jam.rr.com> <9j4af20d2o@enews4.newsguy.com> Message-ID: <ZOw57.375583$p33.7544629@news1.sttls1.wa.home.com> "Alex Martelli" <aleaxit at yahoo.com> wrote in message news:9j4af20d2o at enews4.newsguy.com... > Perl and Python ruled the roost in Prechelt's tests (from the POV > of development speed), indistinguishable from each other. C and C++ > made the fastest executables on average. Java was bad on both > scores -- very slow programs taking a long time to develop. Other > scripting languages (Tcl, Rexx) gave intermediate development times > but extremely slow results. Somebody else claims to have rerun the > same experiment with Common Lisp, getting runtimes competitive with > C and C++ and development speed competitive with Perl and Python. > > We could definitely do with more such tests...!!! With all respect, why? Other than Usenet fodder what good are these tests? The large majority of programmers don't pick their development language anyway. When programmers do have a choice, they choose what they are most comfortable with. Showing that language XYZ is faster than ABC, or that XYZ programmers are more productive, will sway few corporate IT managers or project leads with deadlines and time-to-market pressures. In my experience implementation languages are chosen based on (a) what is already in use, (b) what the platform supports, (c) what an outside vendor or third-party product forces the client to adopt, (d) someone's personal preference, or (e) attempts to rescue doomed projects with a silver-bullet technology. Language decisions are not influenced much by benchmarks. Most readers of this newsgroup already are convinced of Python's worth, and we'll do what we can to spread the word. But how many of us Python devotees will abandon Python because some benchmark shows that Perl or C is faster? Who cares? Every comp.lang.* newsgroup needs a parallel group where students, junior programmers, and the newly unemployed can post benchmarks of loops doing multiplications and debate language trivia. They can graduate to the main newsgroup when they understand how pointless those benchmarks and debates really are. I know who the audience is for these timing tests: In the cubicle next to mine is a junior programmer (fresh from Sun Java training classes, his first language) who frequently gets into long discussions with other programmers about language trivia and "performance." His projects are always late because he over-designs and ends up with unusable class structures. Over the course of the last few months he has wasted hundreds of hours of his own time, and incessantly interrupted other people, because he doesn't understand Excel or SQL. He's writing a set of functions--he calls it a class library--to calculate vacation time for various types of employees. His code is supposed to replace a perfectly good spreadsheet that everyone understands. Sign me, cynical and sick of worthless benchmarks. Greg Jorgensen PDXperts LLC Portland, Oregon, USA From robin at jessikat.fsnet.co.uk Thu Jul 26 14:33:43 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 26 Jul 2001 19:33:43 +0100 Subject: re bad leadership In-Reply-To: <26072001.2@wanderer.local.jae.dyndns.org> References: <0+yM4IAgmKX7EwIQ@jessikat.fsnet.co.uk> <26072001.2@wanderer.local.jae.dyndns.org> Message-ID: <YC0HXJAHKGY7Ew2v@jessikat.demon.co.uk> In message <26072001.2 at wanderer.local.jae.dyndns.org>, J?rgen A. Erhard <juergen.erhard at gmx.net> writes >>>>>> "Robin" == Robin Becker <robin at jessikat.fsnet.co.uk> writes: > > Robin> it doesn't matter what the leadership says is right. The > Robin> popular vote is against the stupid float '/' operator. > >Robin, has it ever occured to you that the majority might be *for* >that change? But because we feel Guido *will* implement that change, >we don't see a need to speak up. sure it has, but this is a process. If no one says anything then it will go through on the nod; even polite discussion doesn't seem to get through. After ranting a bit it seems that there are quite a few people of a similar persuasion. Change for change's sake is just plain wrong and as I've said many times I don't want this marvellous language to become a theoretician's language; it's too useful for that. C style division may not have many nice properties, but it sure gets the job done; many algorithms like to partition their index sets. -- Robin Becker From steve at lurking.demon.co.uk Mon Jul 23 16:47:49 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Mon, 23 Jul 2001 21:47:49 +0100 Subject: A modest PEP0238 suggestion References: <3b5c6e08.27535083@aplnews> Message-ID: <kr2pltsb9gmehe4vtqm8so37924tdfs59s@4ax.com> On Mon, 23 Jul 2001 18:35:14 GMT, matthew.feinstein at jhuapl.edu (Matt Feinstein) wrote: >Why not make the operator // do what the -old- division operator did, >so that the only change that has to be made for backwards >compatibility is replace all /'s with //'s? Nice and easy for the hobbyist - NOT a sane option for professional users who've bet their reputations on Python, and besides. It's precisely what the PEP is suggesting - change the functionality of the existing operator for no particularly strong reason, and expect everyone to change to a *new* operator to support a *different* functionality. One minor problem is that according to the PEP the original behaviour will *not* be supported by *any* single operator - you have to figure out for every single use whether the change is necessary - it is not a no-brainer. More important is all the software that is somehow in-the-field - a VERY serious problem. From quiptiq at yahoo.com.au Thu Jul 12 08:20:01 2001 From: quiptiq at yahoo.com.au (Quiptic) Date: 12 Jul 2001 22:20:01 +1000 Subject: LAMBDA IS IT USELESS? References: <tO837.679712$166.14009323@news1.rdc1.bc.home.com> <3B4D3CF1.889B57BB@cosc.canterbury.ac.nz> <23891c90.0107120259.333a8a9a@posting.google.com> Message-ID: <87lmlumj9q.fsf@ivory.localhost> paul at boddie.net (Paul Boddie) writes: > In this case, the use of lambda is convenient because * can't behave > like a function, so you need a quick way of wrapping * up to act like > one. Just as an aside, this wrapper already exists: import operator >>> reduce(operator.mul, range(1,10)) 362880 From philh at comuno.freeserve.co.uk Wed Jul 11 17:33:11 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Wed, 11 Jul 2001 22:33:11 +0100 Subject: Is Python Dead? Long Live Python! References: <E566B020833BD311B6610008C791A39705CA5230@il93exm04.css.mot.com> <mailman.994880540.7664.python-list@python.org> Message-ID: <slrn9kphgn.ns4.philh@comuno.freeserve.co.uk> On Wed, 11 Jul 2001 21:40:53 +0200, J?rgen A. Erhard <juergen.erhard at gmx.net> wrote: >--pgp-sign-Multipart_Wed_Jul_11_21:40:43_2001-1 >Content-Type: text/plain; charset=ISO-8859-1 >Content-Transfer-Encoding: quoted-printable > >>>>>> "Kemp" =3D=3D Kemp Randy-W18971 <Randy.L.Kemp at motorola.com> writes: > > Kemp> So an interesting question is raised. > >Is it? > > Kemp> If PHP and Ruby are gaining acceptance because they address > Kemp> business needs, what needs to be done to carry Python in > Kemp> that direction? > >*If*! We can debate to no end whether PHP and Ruby are gaining >acceptance, in business circles. > >And PHP and Ruby are quite different beasts. PHP is very popular in open source projects. Ruby less so. -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From grey at despair.dmiyu.org Fri Jul 20 17:06:08 2001 From: grey at despair.dmiyu.org (Steve Lamb) Date: Fri, 20 Jul 2001 21:06:08 GMT Subject: Language change and code breaks References: <mailman.995378792.16515.python-list@python.org> <cpvgkq1f2b.fsf@cj20424-a.reston1.va.home.com> <slrn9lc1rt.6j0.grey@teleute.dmiyu.org> <20010719084721.75050AE1.NOFFLE@niccolo.ke4.de> Message-ID: <slrn9lh79k.op.grey@teleute.dmiyu.org> On Thu, 19 Jul 2001 10:47:18 +0200, Mirko Liss <mirko.liss at web.de> wrote: >On Wed, 18 Jul 2001, Steve Lamb wrote: >[..case-sensitivity..] >> Eh, preference is for case sensitivity. Besides, I far prefer case >> sensitivity with tab completion than case insensitivity without. :) >What about case-sensitive Python combined with case-insensitive >tab-completion in IDLE? With an option to switch it off, of course. Erm, two things. 1: I was referring to shells, not Python there. 2: I don't use IDLE and never will. -- 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 steve at lurking.demon.co.uk Tue Jul 31 16:09:42 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Tue, 31 Jul 2001 21:09:42 +0100 Subject: XML for meta-information (was Re: Deposing Dictators) References: <9jmjne$q54$1@wisteria.csv.warwick.ac.uk> <n0r2mto4fv52lhqh4i2u8dl9ja44ad3uog@4ax.com> <wpL87.5132$CQ1.206410@news.pacbell.net> <3B639329.65EE0546@engcorp.com> Message-ID: <mk2emt08pscn61rper6hil2l9euqt5oq9n@4ax.com> On Sun, 29 Jul 2001 00:38:01 -0400, Peter Hansen <peter at engcorp.com> wrote: >Dirck Blaskey wrote: >> >> "Steve Horne" <sh at ttsoftware.co.uk> wrote: >> > ... >> > 1. A lot of the ideas turn out not to be for a programming language >> > as such at all. Rather, it combines the ideas of literate programming >> > with a kind of replacement for make. An XML notation would allow >> > source code in a range of languages to be packaged in a linked set of >> > XML files with documentation, detailed specification of the build >> > process and explicit requirements for the run-time and build-time >> > environment. It would allow you to specify, for instance, that the >> > source code for this C++ module contains a constant structure derived >> > according to xxx principles (for the documentation) and can be >> > generated by running yyy script in zzz version of Python (or >> > whatever). >> >> Unless you have compelling reasons for using XML, I would suggest >> the alternative of using Python itself as the meta-language. > >I think there are always compelling reasons for using XML. XML >is not code -- it's data. Python is for expressing algorithms >'n such. XML is perfect (well, maybe not quite) for meta- >information, or at least as perfect as we've come up with to date. My thoughts exactly. XML is not designed to be human-friendly, it is only designed to be human-readable as a last resort. >I like Steve's idea above, although it sounds like it might >be a little "monolithic" if one didn't take care to keep the >pieces separate. Of course with XLink there's no reason the >pieces of information relating to a single module all have >to be in the same physical file. The root element in most files would be <component>, I think, though there would be a file with root element <project>, some files with root elements such as <tool> (to describe compilers, interpreters, linkers and other tools, and how to call them) and possibly several others. I haven't looked into XLink yet, but certainly some kind of link-following mechanism would be present. In fact, I expect that '#include', 'import' and similar lines would generally be generated automatically using tool-derived cross-reference information. The need for include guards could be removed from C and C++ components - you would know absolutely that precisely the declarations you have declared an interest in are understood by your code with no chance of double-inclusion. I want pieces to be kept separate, but the division should be based on the components - not on whether the file contains documentation, source code, build instructions, test cases or whatever. Information related to the same component should be kept in the same file, and it should be the tools job to cross-reference and correlate the information required to generate documents, executables or whatever. From malcolm at commsecure.com.au Fri Jul 13 11:16:15 2001 From: malcolm at commsecure.com.au (Malcolm Tredinnick) Date: Fri, 13 Jul 2001 23:16:15 +0800 Subject: dependencies question on 2.1-5 In-Reply-To: <f18d2785.0107130516.7e126e9f@posting.google.com>; from larryd@musicalheritage.org on Fri, Jul 13, 2001 at 06:16:55AM -0700 References: <f18d2785.0107130516.7e126e9f@posting.google.com> Message-ID: <20010713231615.C5436@Vetinari.home> On Fri, Jul 13, 2001 at 06:16:55AM -0700, Lawrence D wrote: > Hello everyone. I have seen the following question asked, but I still > do not understand what packages I need. > > RedHat 7.0 > Kernel:2.2.17-8 > > The error I get when I try and build: > 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 These two are in openssl-0.9.6. > libexpat.so.0 is needed by python2-2.1-5 And this is from the expat package (I think it's expat-1.1 for Red Hat 7.0 and expat-1.95 for Red Hat 7.1). > What packages am I missing? Slightly offtopic: you can always find this out by going to http://rpmfind.net and typing in the name of the library in the search box. Cheers, Malcolm -- Borrow from a pessimist - they don't expect it back. From perry at stsci.edu Mon Jul 9 11:08:47 2001 From: perry at stsci.edu (Perry Greenfield) Date: Mon, 9 Jul 2001 11:08:47 -0400 Subject: Comment on PEP-0238 References: <mailman.994532533.10229.python-list@python.org> Message-ID: <9ichdv$rik$1@tomm.stsci.edu> "Tim Peters" <tim.one at home.com> wrote in message news:mailman.994532533.10229.python-list at python.org... >> ... >> 1. First we introduce a new function div() and a future statement that >> makes integer division return a float result for a specific module. > > I want to make a pitch for naming it idiv() instead. The "i" should > strongly remind that the result is an integer, something "div" says only to > former Pascal programmers. Seems a Positive Good to me if, e.g., > > idiv(5.0, 3.0) > > returned 1 too; i.e., that idiv(i, j) mathematically return floor(i/j). I sense some confusion here (or maybe I'm confused). The original point was that someone could simply search and replace the existing '/' operator with the 'div' operator. The existing '/' does not guarantee an integer result (if one of the operands is a float for example). So providing an idiv operator that always returned an integer result would not suffice for the original desire which was to have an operator with the same semantics as the existing division operator. Or do I misunderstand? Perry Greenfield From roy at panix.com Mon Jul 23 13:26:36 2001 From: roy at panix.com (Roy Smith) Date: 23 Jul 2001 13:26:36 -0400 Subject: PEP0238 lament References: <3B5B37B9.4D7A80CD@Lugoj.Com> <LNBBLJKPBEHFEDALKOLCMECPLAAA.tim.one@home.com> <mailman.995900686.5170.python-list@python.org> Message-ID: <9jhmoc$9nm$1@panix6.panix.com> > Tim> Why is that? It's because unlike any other builtin arithmetic > Tim> operation, "/" today can cause *catastrophic* loss of information > Tim> silently, and in ordinary cases. Surely assignment causes catastrophic loss of information, no? If I say "x = 4", havn't I lost the old value of x? Multiplication by zero causes catastrophic loss of information too. Should we redefine how those operations work too? From SBrunning at trisystems.co.uk Tue Jul 31 05:17:42 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Tue, 31 Jul 2001 10:17:42 +0100 Subject: The best gui library for newbies. Message-ID: <31575A892FF6D1118F5800600846864D78BF3B@intrepid> > From: William Park [SMTP:opengeometry at yahoo.ca] > Start with Tkinter, since it's part of standard distribution and been > around for a while. There is also a book called "Python and Tkinter > Programming" by Grayson from Manning <www.manning.com>. Never having programmed a GUI before, I found this impenetrable. "Programming Python, 2nd Edition" by Mark Lutz, OTOH, got me going in no time. *Then* I found John Greyson's book useful. YMMV. 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 martin.franklin at westerngeco.com Tue Jul 10 10:15:29 2001 From: martin.franklin at westerngeco.com (Martin Franklin) Date: Tue, 10 Jul 2001 15:15:29 +0100 Subject: backslash woes........ References: <3B4AC7C2.DD53F6BB@westerngeco.com> <Xns90DA74BD3B968duncanrcpcouk@127.0.0.1> <3B4ADD33.CA2836D1@westerngeco.com> <Xns90DA8FF2145Bduncanrcpcouk@127.0.0.1> Message-ID: <3B4B0E01.89E7E7AA@westerngeco.com> Thanks for your time Duncan I think I am beginning to get it. I did not use re at all when I only needed to support this function on UNIX and then when windows came along I (for some unknown reason) reached for re as a solution.... I am beginning to regret this now ;-) Anyway as I said in reply to someone else in this thread I have a working solution (and a better understanding) Thanks to all, Martin. Duncan Booth wrote: > > Martin Franklin <martin.franklin at westerngeco.com> wrote in > news:3B4ADD33.CA2836D1 at westerngeco.com: > > >> I think you maybe misunderstand what raw strings do. Raw strings > >> simply prevent any backslash character that is present in the string > >> from being interpreted as an escape sequence. They don't affect the > >> processing or use of the string in any way. Since none of your literal > >> strings contain backslashes there is no reason to use raw strings. > >> In regular expressions backslashes are special, but so are many other > >> characters that could appear in filenames, even on Unix. > > > > > > You are right I don't understand... My strings do include backslashes > > (they are windows filenames from os.path.walk()) I Have indeed changed > > to using string.replace() - having read the HOW TO on > > www.python.org.... and it seems to work (without using raw strings....) > > This all seems very confusing! > > > > Let me try to explain. A raw string is a change in notation, not a change > in the string itself. So r'%s' is exactly the same as '%s' or "%s" or > '''%s''' or '\x25\x73', but r'\x25\x73' is a string containing 8 characters > two of which are backslashes. > If you write a string containing a backslash, e.g. 'c:\autoexec.bat' the > backslash may be interpreted as beginning an escape sequence, so in this > case you get 'c:\x07utoexec.bat' as the \a converts to a bell character. > Writing r'c:\autoexec.bat' or writing 'c:\\autoexec.bat' both give you a > identical string containing exactly 15 characters. Both of these are > strings (there is no separate raw string type), and each of them contains > exactly one backslash character: > > >>> file1 = r'c:\autoexec.bat' > >>> file2 = 'c:\\autoexec.bat' > >>> print file1 > c:\autoexec.bat > >>> print file2 > c:\autoexec.bat > >>> print repr(file1) > 'c:\\autoexec.bat' > >>> print repr(file2) > 'c:\\autoexec.bat' > >>> print len(file1), len(file2) > 15 15 > >>> print type(file1), type(file2) > <type 'string'> <type 'string'> > > In other words the r prefix on a raw string simply changes the way > the string literal is regarded at compile time, it has no further effect on > the processing of data after Python has compiled your code. > > If your program reads data from a file, or indeed gets it anywhere else, > then backslashes have no special meaning. Only string literals do this > special interpretation. > > The real confusion creeps in because backslash also has a special meaning > in regular expressions. So to put a backslash into a regular expression you > must escape it by preceding it with another backslash, and to write two > backslashes in literal string you must either use a raw string or write 4 > backslashes. So the string for a regular expression that matches one > backslash followed by an 'x' could be written as: > s = '\\\\x' > s = r'\\x' > s = re.escape('\\x') > s = re.escape(r'\x') > In all of these s ends up as the same three character string: two > backslashes followed by an 'x'. > > Why the 'x'? Because for reasons that escape me, raw strings cannot end > with a single backslash: > >>> r'\\' > '\\\\' > >>> r'\' > File "<stdin>", line 1 > r'\' > ^ > SyntaxError: invalid token > > I hope this makes things a bit clearer. > -- > 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 Wed Jul 11 11:58:07 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Wed, 11 Jul 2001 11:58:07 -0400 Subject: Bug in rfc822 References: <slrn9khcjv.c7q.philh@comuno.freeserve.co.uk> <QFc27.8798$e5.1167735@newsb.telia.net> <2ih27.49242$he.3402812@e420r-atl1.usenetserver.com> <cp66d2i59b.fsf@cj20424-a.reston1.va.home.com> <slrn9kkcu1.gh1.philh@comuno.freeserve.co.uk> <mailman.994727597.27647.python-list@python.org> <9ihnv5$e2v$1@macareux.ens-lyon.fr> Message-ID: <15180.30607.11847.673371@anthem.wooz.org> >>>>> "EJ" == Emmanuel Jeandel <ejeandel at ens-lyon.fr> writes: EJ> Playing with rfc822 is good, but i think mailbox.py has also EJ> several problems. When you do mailbox.next(), the function EJ> return a rfc822.Message but i wanted to use my class EJ> MyMessage, so i have to rewrite : I added a default argument to the _Mailbox class in Python 2.2's mailbox.py module: class _Mailbox: def __init__(self, fp, factory=rfc822.Message): self.fp = fp self.seekp = 0 self.factory = factory so when a new mail message object needs to be created, it'll call self.factory (i.e. factory must be a callable). I use this in Mailman to create instances of my own Message class (subclassed from mimelib.Message.Message). Python 2.2's mailbox.py should be compatible with earlier versions of Python, and if you don't have cvs access, you can grab it from http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/dist/src/Lib/mailbox.py?rev=1.31&content-type=text/vnd.viewcvs-markup Hope that helps, -Barry From tim at vegeta.ath.cx Tue Jul 17 04:26:34 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Tue, 17 Jul 2001 08:26:34 GMT Subject: Python vs. Perl sockets (was Re: OO misconceptions References: <mailman.994969462.27792.python-list@python.org> <hevsktcrnpckttnkgi1arcue5kjjsbrrb5@4ax.com> <mailman.995046506.2514.python-list@python.org> <9ir1l7$3ja$1@panix2.panix.com> <9irfbc11jaq@enews1.newsguy.com> <slrn9l49me.p58.tim@vegeta.ath.cx> <mailman.995268208.1394.python-list@python.org> <slrn9l6kci.qqs.tim@vegeta.ath.cx> <3B538E16.65394C9D@engcorp.com> <slrn9l7a8r.rpe.tim@vegeta.ath.cx> <3B53B339.B6698858@engcorp.com> <slrn9l7lfm.t2g.tim@vegeta.ath.cx> <yoxsnfwggcy.fsf_-_@karhu.tp.spt.fi> Message-ID: <slrn9l7ubt.tq9.tim@vegeta.ath.cx> Me parece que Ville Vainio <vvainio at karhu.tp.spt.fi> dijo: > tim at vegeta.ath.cx (Tim Hammerquist) writes: > > > Fair enough. =) Python does sound like a good choice in this case, > > despite Perl's strength in sockets. > > What do perl sockets have that python sockets don't? I'm doing > logistics/socket stuff in Python also, and haven't had any problems > with Python sockets and threads. A lot more goes into socket > programming than bind& accept: concurrency, queues... Not a challenge of Python's capability. Just that Perl's socket handling (AFAIK) is closer to the core code. You are entirely correct, however. > *cough* Bareword file handles *cough* * heh * BFHs are pre-deprecated (just like global vars: not technically preferred, but hardly less used) =) -- C combines all the power of assembly language with all the ease of use of assembly language. -- trad From wqh-2 at 263.net Mon Jul 30 22:58:28 2001 From: wqh-2 at 263.net (sdf) Date: Tue, 31 Jul 2001 10:58:28 +0800 (CST) Subject: may any one post an example for xml which use method appendchild(xml) Message-ID: <3B661ED4.11870@mta2> thanks __________________________________________ DVD??????????10?? http://shopping.263.net/category02.htm ?????????????????????? http://shopping.263.net/category10.htm From nhodgson at bigpond.net.au Sat Jul 28 18:35:23 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Sat, 28 Jul 2001 22:35:23 GMT Subject: Colon and underscores References: <39506f84.0107280205.1638011@posting.google.com> <slrn9m5r4n.2ue.sill@sill.silmarill.org> Message-ID: <L6H87.69279$Xr6.307583@news-server.bigpond.net.au> Andrei Kulakov: > Besides, editors detect that : and autoindent for you. Imagine for instance > that you are 5 levels of indentation to the right, if there were no colons > you'd have to hit enter and then <tab> 5 times! No thanks :P Editors can also detect that you started the line with a structuring keyword (if, def, ...) and indent. The colon is really only needed when you want to place the body on the same line: if a: b = 1 I'd be happy to see Python without the colons at the end of lines but its no big deal. Neil From thecalm at NOSPAM.btinternet.com Wed Jul 4 18:37:22 2001 From: thecalm at NOSPAM.btinternet.com (G. Willoughby) Date: Wed, 4 Jul 2001 23:37:22 +0100 Subject: i'm trying to get user input from a Tkinter Entry field... References: <9htlpd$ki$1@plutonium.btinternet.com> <3B42E57D.B9D11046@ccsr.cam.ac.uk> Message-ID: <9i05or$fl5$1@plutonium.btinternet.com> Yes thats it! if i shift the grid statement to a new line, all is ok, ta, Gary. "XiaoQin Xia" <XQ.Xia at ccsr.cam.ac.uk> wrote in message news:3B42E57D.B9D11046 at ccsr.cam.ac.uk... Dear G. Willoughby, I think the problem is in the line: newName=Entry(frame1).grid(row=1,column=0) # here newName is the return value of grid(), i.e, None, instead of a Entry object. things may be better if you write as: newName=Entry(frame1) newName.grid(row=1,column=0) Cheers, Xia Xiao-Qin "G. Willoughby" wrote: i'm trying to get user input from a Tkinter Entry field, this is the code i am using: [snip...] def getNew(): result1=str(newName.get()) print result1 [snip...] Button(frame1, text="Add New Entry", command=getNew).grid(row=0,column=0) newName=Entry(frame1).grid(row=1,column=0) [snip...] it somehow doesn't work, any ideas? P.S. no classes are used anywhere in this program. G. Willoughby From pobrien at orbtech.com Sun Jul 15 17:36:03 2001 From: pobrien at orbtech.com (Patrick K. O'Brien) Date: Sun, 15 Jul 2001 21:36:03 GMT Subject: Naked function call syntax References: <3b4fa037.1845423078@wa.news.verio.net> <wvk47.45349$J91.2359350@bgtnsc06-news.ops.worldnet.att.net> Message-ID: <71o47.37639$C81.3113896@bgtnsc04-news.ops.worldnet.att.net> Here is a slightly better version, in that it handles parameters: class PseudoKeyword: '''A callable class that calls a method passed as a parameter. Good for creating a pseudo keyword in the python runtime environment. The keyword is really an object that has a repr() that calls itself which calls the method that was passed in the init of the object. All this just to avoid having to type in the closing parens on a method. So, for example: >>> quit = PseudoKeyword(SomeObject.someMethod) >>> quit SomeObject.someMethod gets executed as if it had been called directly and the user didn't have to type the parens, like "quit()". This technique is most applicable for pseudo keywords like quit, exit and help. ''' def __init__(self, method): # XXX Should probably check that this is a callable object. self.method = method def __call__(self, *args, **kwds): self.method(*args, **kwds) def __repr__(self): self() return '' -- Patrick K. O'Brien Orbtech "I am, therefore I think." From djc at object-craft.com.au Fri Jul 13 06:53:07 2001 From: djc at object-craft.com.au (Dave Cole) Date: 13 Jul 2001 20:53:07 +1000 Subject: Python: Database to Web Part II References: <5174eed0.0107060820.ff90805@posting.google.com> <slrn9kc0ov.1ob.gerhard.nospam@lilith.hqd-internal> <86pub5361i.fsf@hellcat.itga.com.au> Message-ID: <m34rshxfqk.fsf@vole.object-craft.com.au> >>>>> "gnb" == Gregory Bond <gnb at itga.com.au> writes: gnb> gerhard.nospam at bigfoot.de (Gerhard H?ring) writes: >> If you want a commercially supported Python module that implements >> the Python DB-API, you should give Python another try and check out >> the mxODBC module. It's the only module for which you can buy >> commercial support, AFAIK. gnb> Dave Cole has floated the idea of commercial support for his gnb> Sybase module. I had almost given the idea away until a poster raised the issue that he could not really use a database module which the developer did not consider a serious development project (or words to that effect). For people who are of a like mind - for release 0.30 and later we are going to offer commercial support. This should do a number things: 1- Convince potential users that we do take development and support for the module seriously. 2- Provide us with a little bit of compensation for what we would probably do anyway. If an income stream can be derived from the module then additional features and bugfixes become a higher priority relative to other tasks which do not generate a cash flow. 3- If you work for an organisation which has a policy of only using software which is commercially supported - you will soon have the option of using the Sybase module. The terms and cost of the support contract have not been decided yet. - Dave -- http://www.object-craft.com.au From michael.g.abbott at ntlworld.com Wed Jul 25 10:06:57 2001 From: michael.g.abbott at ntlworld.com (Michael Abbott) Date: Wed, 25 Jul 2001 14:06:57 GMT Subject: A use for integer quotients References: <yCK67.17615$EP6.4467503@news1.rdc2.pa.home.com> <mailman.995860718.9550.python-list@python.org> <mailman.995862939.15013.python-list@python.org> <mailman.995883879.12071.python-list@python.org> <3B5C5665.8D41D1F1@tundraware.com> <slrn.pl.9los0f.jh4.qrczak@qrnik.zagroda> <3B5C749A.59F97320@tundraware.com> <JDa77.97061$Rr4.549007@ozemail.com.au> <Xns90E97C9849AD5robindotgarneratinam@172.18.25.3> Message-ID: <Xns90E9992EFB8CFmichaelrcpcouk@194.168.222.9> Robin Garner <robin.garner at i.name.com> wrote in news:Xns90E97C9849AD5robindotgarneratinam at 172.18.25.3: > "michael" <serrano at ozemail.com.au> wrote in > news:JDa77.97061$Rr4.549007 at ozemail.com.au: > > In most maths the sets are made explicit, and operators are defined as > functions with specific domains. There are standard embeddings of > Integers into Rationals and Reals, and if you are working with real > numbers, then 2 and 2.0 are generally taken to stand for the same > thing. But strictly speaking the Integer 2 and the Real Number 2 are > different entities. You would be hard pressed to find anyone writing > the natural number 2 as 2.0. Indeed. The domain and sets of operations are crucial, and it is important to keep integers and reals separate. Of course we know that there is a injective mapping from integers to reals which preserves all sorts of nice properties the integers (but *not* all properties), but integers are not reals! > > Since the Integers aren't a field, there isn't a generally accepted > function > > / : Int x Int -> Int. > > that agrees with the function > > / : Real x Real -> Real > > for all (a,b) where b is divisible by a. However, since the integers are a "Euclidian domain", there is a function divmod : Int x Int -> Int x Int with the expected properties (where a/b is a plausible name for the first half of the result of this operation). From tdelaney at avaya.com Wed Jul 4 19:57:11 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Thu, 5 Jul 2001 09:57:11 +1000 Subject: Python for air traffic control? Message-ID: <B43D149A9AB2D411971300B0D03D7E8B0FC23A@natasha.auslabs.avaya.com> > But the best & highest-motivated guru can only do so much if > hampered by too-heavy process, inadequate tools, &c. And one > can't always choose (client needs given process and tools, but This bit I agree with wholeheartedly > motivation is high anyway e.g. because of VERY good $$ bonus... > that still doesn't give the same productivity as when process > and tools are optimally chosen). And this I don't. I've found that I've rarely been motivated to perform well in a project based on the $$$ I was to receive for it (when I was a contractor). Once I accepted how many $$$ I was getting, that was the end of it (after that, the money is uninteresting and indeed annoying because you have to chase it). Instead, environment, requirements and straight-out interest level of the project motivate me. If I'm working with good people, on an interesting project, and able to work how I feel comfortable (start work when I'm ready, which is usually 10am, be able to organise to get time off if I need it, etc) then I tend to work better. Note: casual clothes is not an option - I have *never* worn a tie or trousers in my professional career, and I never will. The most formal I've gone to is to wear a button-up shirt at one place, but that won't happen again. Unfortunately, I've yet to find a place that will let me work in boxer shorts like I do at home ... :) Tim Delaney From bsass at freenet.edmonton.ab.ca Tue Jul 17 14:31:24 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Tue, 17 Jul 2001 12:31:24 -0600 (MDT) Subject: PEP: Defining Python Source Code Encodings In-Reply-To: <3B540EBA.EE5372BD@lemburg.com> Message-ID: <Pine.LNX.4.33.0107171117070.11975-100000@bms> On Tue, 17 Jul 2001, M.-A. Lemburg wrote: <...> > - which format to use for the magic comment, e.g. > > * Emacs style: > > #!/usr/bin/python > # -*- encoding = 'utf-8' -*- This should work for everyone, but will it confuse emacs?. I suppose, "# # ...", or "### ...", or almost any short sequence starting with "#" will work, eh. > * Via meta-option to the interpreter: > > #!/usr/bin/python --encoding=utf-8 This will require editing if python is not in /usr/bin, and can not be used to pass more than one argument to the command (python, in this case). > * Using a special comment format: > > #!/usr/bin/python > #!encoding = 'utf-8' This is confusing, and will only work on *nix (linux?) iff it is the second (or later) line; if it is the first line... it will fail because there is probably no executable named "encoding" available, and if there is, "= 'utf8'" is unlikely to exist. please, Avoid character sequences that have other meanings in this context. I think this should be done as a generic method for pre-processing Python source before the compiler/interpreter has a look at it. e.g., # ## encoding utf-8 triggers whatever you encoding fans want, # ## format noweb runs the source through a filter which can extract code noweb marked up code, and maybe even installs the weaved docs and tangled code (via distutils?) # ## MySpecialMarkup runs the source through a filter named MySpecialMarkup. MySpecialMarkup could be anything: extensions to docstrings, a proprietary binary format, an entire package-in-a-file! Generally: #<magic> <directive> [<arguments>] If Python does not know what the <directive> is it should either look in a set location for a program of the same name then use its output as the source, or look into a table that maps <directive> to a procedure which results in Python source. - Bruce From pchilds at ithink.net Tue Jul 24 14:41:10 2001 From: pchilds at ithink.net (Paul) Date: Tue, 24 Jul 2001 18:41:10 GMT Subject: Learning Python Message-ID: <20010724.144042.1258638252.27706@localhost.localdomain> I would like to know what sources are available for learning how to program with python. Any help would be appreciated very much. Thanks in advance. From rnd at onego.ru Fri Jul 6 14:03:02 2001 From: rnd at onego.ru (Roman Suzi) Date: Fri, 6 Jul 2001 22:03:02 +0400 (MSD) Subject: formatting enhancement idea Re: Most important text processing examples In-Reply-To: <01070609564400.07365@frock.ddmweb.com> Message-ID: <Pine.LNX.4.30.0107062143370.15616-100000@rnd.onego.ru> On Fri, 6 Jul 2001, Sam Penrose wrote: >class PartialStringSubstitution(UserDict): > def __init__(self, dict={}): > UserDict.__init__(self, dict) > def __getitem__(self, key): > return UserDict.get(self, key, '%(' + key + ')s') BTW, you can use anything but "(" and ")" in format strings: >>> print " -- %(2+2)s -- " % {"2+2": 4} -- 4 -- (Guido, please, do not change "%" to disallow it!) It is really easy to include something like: text = EvaluatingFormat("""lalala %(2+2)s ... %(anything[0])s ... %({a+b}*c)s """, vars()) with {} used instead of (). (I had a piece of code for that, but can't find it now. It was, I remember, more efficient than DocumentTemplate) You can even make a special class for string and redefine "%" to do evaluation transparent... BTW, it could be supercool feature to have built-in something like: a=2 b=2 """ %(a+b)z """ % {'__eval__': eval, '__dict__': vars()} to produce: 4 And, also, it could be of some interest to make hooks into formatting procedure. (If it will do no slowdown ;-) (something similar to SAX ;-) to allow to define calls for individual format identifiers.) Probably, this idea is too old-fashioned in the world of XML though... def i_format(value, len, zero, ...): return "%s" % value ... __format__.hook(i_format=i_format) ... print "%012i" % 2.3 23 (and not 000000000023, because we defined though) This feature could be useful, for example, to redefine rounding rules of floating point formats, etc... Wadda yu think? Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Friday, July 06, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ ""Stupid" is a boundless concept." _/ From steve at lurking.demon.co.uk Tue Jul 24 00:22:52 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Tue, 24 Jul 2001 05:22:52 +0100 Subject: PEP0238 lament References: <mailman.995939441.3705.python-list@python.org> Message-ID: <v9splts0932691b080rllm4h03id32u152@4ax.com> On Mon, 23 Jul 2001 21:08:19 -0400, "Arthur Siegel" <ajs at ix.netcom.com> wrote: >Will I have any problem with // and / - using them appropriately > >Doubt it. For new code, certainly. >Can I handle case sensitivity any way you give it to me. > >Cake. I really think this is only going to cause minor problems - it's the kind of thing that sounds worse than it is. Even in case sensitive languages, defining same-bar-the-case identifiers is normally considered confusing and just plain bad anyway. >Why is two years of discussion going on as if someone like >myself is not fully representative. I simply have no reason >to believe I am not. And will scrutinize carefully any evidence >which contends otherwise. I cannot believe I am the only person who has gone out on a limb advocating Python and who is now going to end up looking a right arse. The only one shouting so much ATM, maybe ;-) As for two years of discussion - I wish I'd noticed it then, not now, but that ain't what happened. >Will Python be a better language after it is done. I don't have a >good basis to disagree with that assertion. Same here - but there is definite cause for serious doubt. From max at alcyone.com Sat Jul 21 20:23:36 2001 From: max at alcyone.com (Erik Max Francis) Date: Sat, 21 Jul 2001 17:23:36 -0700 Subject: Here's a puzzle... References: <20010721195640.15632.00000532@ng-mh1.aol.com> Message-ID: <3B5A1D08.C2CF58DE@alcyone.com> TheDustbustr wrote: > Unless my logic is flawed, this should return 'PRIVMSG': > > sender='Angel' > print data[len(sender)+2:string.find(data[len(sender)+2:],' ')] > > It prints '' (an empty string). Is my logic flawed, or does Python > dislike a > string splice determined by a function? Your logic is flawed. Break the splice limits into pieces: 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. >>> import string >>> sender='Angel' >>> data=':Angel PRIVMSG Wiz :here is my message!' >>> data[len(sender)+2:string.find(data[len(sender)+2:],' ')] '' >>> len(sender)+2 7 >>> string.find(data[len(sender)+2:],' ') 7 -- 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 revolution will not televised \__/ Public Enemy Polly Wanna Cracka? / http://www.pollywannacracka.com/ The Internet resource for interracial relationships. From db3l at fitlinxx.com Wed Jul 25 20:56:42 2001 From: db3l at fitlinxx.com (David Bolen) Date: 25 Jul 2001 20:56:42 -0400 Subject: A modest PEP0238 suggestion References: <mailman.996104447.4969.python-list@python.org> Message-ID: <uofq8cxth.fsf@ctwd0143.fitlinxx.com> "Tim Peters" <tim.one at home.com> writes: > [Grant Edwards] > > The problem is that it's not _us_ (people who write Python programs) who > > decide what version of Python is running on a system. > > It's slowly dawning on me that some people don't ship Python *with* their > apps. What are you, nuts <0.9 wink>? From PySol to Zope, everyone who > gives a rip about stability ships the software they develop with. > > I see I have 12 copies of the Microsoft C runtime library on my Win98 box at > the moment, and for the same reason: serious Windows app developers are > careful to isolate themselves from C runtime changes too. And then of course they get bit when, depending on the OS at hand, it decides to use an already loaded (but incompatible) copy anyway :-) -- -- 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 thecalm at NOSPAM.btinternet.com Sat Jul 28 15:27:52 2001 From: thecalm at NOSPAM.btinternet.com (G. Willoughby) Date: Sat, 28 Jul 2001 20:27:52 +0100 Subject: What RE would i use to match this whole word? Message-ID: <9jv3mi$5lv$1@neptunium.btinternet.com> What RE would i use to match this whole word, 'Rasping' i was using: searchString = re.compile('Rasping', re.IGNORECASE) but this don't seem to be right. Im missing something! any help would be appreiciated! G. Willoughby From skip at pobox.com Wed Jul 18 11:46:59 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 18 Jul 2001 10:46:59 -0500 Subject: Python 2 times slower than Perl In-Reply-To: <8f41cfd.0107172305.5e2f3a70@posting.google.com> References: <8f41cfd.0107171238.6ff33b9b@posting.google.com> <Xns90E24820E1F1ehoutezeelandnetnl@212.115.192.220> <3B54D9A2.45C23B14@Lugoj.Com> <8f41cfd.0107172305.5e2f3a70@posting.google.com> Message-ID: <15189.44915.757599.303504@beluga.mojam.com> >> The revised stupid testing py is: >> #!/usr/bin/env python >> def f(): >> for i in xrange(2.5, 1e7, 1.): >> j = 2.5 * 2.5 >> print i, j >> f() Note that the end condition for this loop is not quite the same as your original while loop version. Before, the loop was i = 2.5 while i < 1e7: j = 2.5 * 2.5 i += 1 which resulted in a final value for i of 10000000.5. The xrange fuction should be called as xrange(2.5, 1e7+1.0, 1.0) so that i terminates the loop with a value >= 1e7. Even so, note that both the range and xrange functions coerce their arguments to ints: >>> range(2.5, 1e2, 1.0) [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99] >>> xrange(2.5, 1e2, 1.0)[-1] 99 so at the end of for i n xrange(2.5, 1e7+1, 1.): pass i has an integer value of 10000000, not a float value of 10000000.5, as was the case for the while loop version. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From kirschh at lionbioscience.com Wed Jul 25 03:47:39 2001 From: kirschh at lionbioscience.com (Harald Kirsch) Date: 25 Jul 2001 09:47:39 +0200 Subject: question about handling pointers in C extensions References: <9jkhdv$r3o$1@nntp6.u.washington.edu> Message-ID: <yv2lmld4fhg.fsf@lionsp093.lion-ag.de> "Russell E. Owen" <owen at astrono.junkwashington.emu> writes: > I would like a bit of help with handling pointers in C extensions. I > hope this is a simple question. > > I want to write a Python interface to a device driver library. One > starts by opening the device and getting a particular kind of pointer, > e.g. (simplified): > DevType *dev_open() > > Is the following reasonable, or is there a better way to do this? > > static PyObject *open (PyObject *self, PyObject *args) > ) { > PyObject *py_dev_p; > DevType *dev_p; > > /* call the C routine to open the device */ > dev_p = dev_open(); > if (dev_p == NULL) { > PyErr_SetString(PyExc_RuntimeError, "open failed"); > return NULL; > } > > /* convert device pointer to a Python Long object */ > py_dev_p = PyLong_FromVoidPtr ((void *) dev_p); This makes py_dev_p into a reference you own, therefore ... > if (py_dev_p == NULL) { > return NULL; > } > > /* increment reference and return the PyLong */ > Py_INCREF (py_dev_p); > return Py_BuildValue("O", py_dev_p); ... neither INCREF nor BuildValue are needed. > } In the long run you want to define your own PyObject type in which you store the DevType *dev_p. The cast to long is a bit of a hack. Something like typedef struct { PyObject_HEAD; DevType *dev_p; } DeviceObject; You then want a related PyTypeObject along the lines of PyTypeObject deviceTypeObject = { PyObject_HEAD_INIT(NULL); 0, "Device", sizeof(DeviceObject), 0, /**** more things to come, your book should have an example. }; Don't forget in your init code to deviceTypeObject.ob_type = &PyType_Type; I found it like this in the docs, I think. Having your own type of objects makes things a bit saver, because you now can write: static PyObject* close (PyObject *obself, PyObject *args) { DeviceObject *self; if( !obself ) { /* this was called as a module function like device.close(arg) where 'device' is the name of your module */ if( !PyArg_ParseTuple(args, "O!", &deviceTypeObject, &self) ) return NULL; } else { /* this was called like fin = device.open() fin.close() so we are sure already that obself is of the correct type */ self = (DeviceObject*)obself; } /* Now do it */ whateverCloseFunctionIsNecessary(self->dev_p); Py_INCREF(Py_None); return Py_None; } Harald Kirsch -- ----------------+------------------------------------------------------ Harald Kirsch | kirschh at lionbioscience.com | "How old is the epsilon?" LION bioscience | +49 6221 4038 172 | -- Paul Erd?s *** Please do not send me copies of your posts. *** From paulp at ActiveState.com Wed Jul 25 19:29:32 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Wed, 25 Jul 2001 16:29:32 -0700 Subject: Static method and class method comments References: <9jn382$lqf$1@license1.unx.sas.com> Message-ID: <3B5F565C.5F452AC5@ActiveState.com> >Kevin Smith wrote: > > I am very glad to see the new features of Python 2.2, but I do have a minor > gripe about the implementation of static and class methods. My issue stems > from the fact that when glancing over Python code that uses static or class > methods, you cannot tell that a method is a static or class method by looking > at the point where it is defined. > ... Agree strongly. This will also be a problem for documentation generation tools, type extraction tools and class browsers. I believe it would be easy to add a contextual keyword > class C: > def static foo(x, y): > print "classmethod", x, y -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From XQ.Xia at ccsr.cam.ac.uk Thu Jul 12 06:53:18 2001 From: XQ.Xia at ccsr.cam.ac.uk (XiaoQin Xia) Date: Thu, 12 Jul 2001 11:53:18 +0100 Subject: Need to change the icon in the title bar of a Tk() window Message-ID: <3B4D819E.FE528677@ccsr.cam.ac.uk> Hi, anybody, I need to change the icon in the title bar of a Tk() window, but failed to find any method to do it. In addtion, what kinds of image files are accepted for Tkinter to place on the title bar? Xiao-Qin Xia From paulp at ActiveState.com Sat Jul 28 16:07:32 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sat, 28 Jul 2001 13:07:32 -0700 Subject: FEEDBACK WANTED: Type/class unification References: <cp66cd12yp.fsf@cj20424-a.reston1.va.home.com> Message-ID: <3B631B84.2229B634@ActiveState.com> I'm reading the section on the introspection API but I don't understand something. 1. If I am sitting at an interpreter prompt and I have an object how do I figure out the complete list of currently available attributes available on that object. 2. If I have an object that hides its attributes behind an __getattr__, is there any way to tweak the list returned by the API described above? If I understand correctly, doing this is not sufficient: >>> T = foo.__class__ >>> T <type 'Foo'> >>> dir(T) I don't think that this will get base class attributes or attributes hidden in __getattr__. And even if it did, it would be nice to have a single API that combined instance attributes and class attributes according to the fallback rules. i.e. I'd like something as close to this as is realistically possible: def attrs(x): return [y for y in all_possible_strings if hasattr(x, y)] -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From skip at pobox.com Mon Jul 16 17:24:36 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 16 Jul 2001 16:24:36 -0500 Subject: Most efficient solution? In-Reply-To: <20010716202955.LXMI20827.femail3.rdc1.on.home.com@jparlar> References: <20010716202955.LXMI20827.femail3.rdc1.on.home.com@jparlar> Message-ID: <15187.23444.135787.640637@beluga.mojam.com> Jay> I've never noticed the list behaviour before that you pointed out, Jay> what causes that, if you don't mind my asking? When you execute something like for elt in somelist: yadda(elt, yadda, yadda) the for loop keeps an index into the list (internally - you can't access it) and calls somelist.__getitem__[index] as you traverse the list (ignore the upcoming iterator stuff). If you change the parts of the list you haven't yet visited there is no way to convey this to the for loop. If the list might change as you are traversing it the normal Python idiom is to traverse the list back-to-front: for i in range(len(somelist)-1, -1, -1): elt = somelist[i] yadda(elt, yadda, yadda) -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From tjreedy at home.com Thu Jul 26 15:00:39 2001 From: tjreedy at home.com (Terry Reedy) Date: Thu, 26 Jul 2001 19:00:39 GMT Subject: PEP0238 lament References: <3B5B3676.40F39389@alcyone.com> <eppstein-03540D.13070222072001@news.service.uci.edu> <mailman.995836120.7223.python-list@python.org> <vyIKbWAP62W7EwC+@jessikat.fsnet.co.uk> <9jg6ei$ges7$1@sky.inp.nsk.su> <23891c90.0107230118.752e3f00@posting.google.com> <u3tnlt0480u7o655p988bsr9p3vc1g14ee@4ax.com> <slrn9lp1ui.vp.Gareth.McCaughan@g.local> <bl7pltkl8bv0eecsfcr90v45hh0aek72u7@4ax.com> <m2puaqh6t2.fsf@mycroft.actrix.gen.nz> <Xns90E8B2C2EF3FBmichaelrcpcouk@194.168.222.8> <m2ofq9g4he.fsf@mycroft.actrix.gen.nz> <Xns90E9954091A7Fmichaelrcpcouk@194.168.222.9> <mtwv4wzzwd.fsf@astron.berkeley.edu> <m2y9pc5ljc.fsf@mycroft.actrix.gen.nz> Message-ID: <rNZ77.30642$EP6.7885925@news1.rdc2.pa.home.com> "Paul Foley" <see at below> wrote in message news:m2y9pc5ljc.fsf at mycroft.actrix.gen.nz... > Yes, that's pretty much what I was getting at. Lisp isn't text > containing parentheses, it's lists or trees of objects, which has no > parentheses (unless you have some reason to want to represent a > parenthesis-object in your code; e.g., as a character). The printed > representation of > > a > / \ > b c > > as (a b c) is just an easier-to-deal-with form of "marshal" output. Has anyone writen an environment that uses the 'proper' 2-D, unmarshalled tree form? I think I might prefer such. > Nothing says you have to use that particular print representation, > though everybody does who can tolerate the flattened form. Terry J. Reedy From tjenkins at devis.com Tue Jul 10 12:01:58 2001 From: tjenkins at devis.com (Tom Jenkins) Date: Tue, 10 Jul 2001 12:01:58 -0400 Subject: Why database modules are incomplete References: <5174eed0.0107060820.ff90805@posting.google.com> <yox66d25zkd.fsf@karhu.tp.spt.fi> <23891c90.0107090815.3685a9@posting.google.com> <m3k81h1u3d.fsf_-_@vole.object-craft.com.au> <5174eed0.0107100719.e14dfbe@posting.google.com> Message-ID: <3B4B26F6.8010305@devis.com> Edward Wilson wrote: > > What would be constructive for Python would be for others to donaite > ther time to testing your work just as you donante your time writing > extensions in the first place. This gets at the "Workgroup" > mentality/approach I have been talking about. In other words, it's > not enough for you, working alone to produce a great Sybase extension. > Rather, those of us who hope to use your module should be willing to > help build it, lending our time as testers. My personal feeling is > that if ten or twenty folks would jump in and help you out, in a year > (working part-time) Python could have a diamond hardened Sybase > module. If the same were done with Oracle, SQL Server, and DB2, > Python too could have a serious killer app in the way of db > accessibility. Python is way cooler than PL/SQL or any other language > used for writing db apps for that matter. > Ed - You keep harping on this whole Oracle, SQL Server blah, blah, blah issue. Do you not realize that DCOracle is written, maintained, and supported by Digital Creations for use in their clients applications? And mxODBC is also written and supported for a fee by the author's corporation? What more do you want? -- Tom Jenkins devIS - Development Infostructure http://www.devis.com From opengeometry at yahoo.ca Mon Jul 16 12:21:13 2001 From: opengeometry at yahoo.ca (William Park) Date: Mon, 16 Jul 2001 12:21:13 -0400 Subject: Most efficient solution? In-Reply-To: <20010716132133.DIZO21397.femail2.rdc1.on.home.com@jparlar>; from jparlar@home.com on Mon, Jul 16, 2001 at 09:19:09AM -0400 References: <20010716132133.DIZO21397.femail2.rdc1.on.home.com@jparlar> Message-ID: <20010716122113.A908@node0.opengeometry.ca> On Mon, Jul 16, 2001 at 09:19:09AM -0400, Jay Parlar wrote: > > for eachItem in A: > if eachItem in B: Try if BB.has_key[eachItem]: where BB is dictionary whose keys are strings in list B, ie. BB = {} for i in B: BB[i] = None (or any value) > A.remove(eachItem) -- William Park, Open Geometry Consulting, <opengeometry at yahoo.ca> 8 CPUs cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc. From deepak9999 at mail.com Fri Jul 6 00:29:50 2001 From: deepak9999 at mail.com (Deepak) Date: 5 Jul 2001 21:29:50 -0700 Subject: Tkinter doesn't work for MFC applications with Embedded Python? Message-ID: <48365474.0107052029.12d28427@posting.google.com> Hi, I tried to go through all the related postings on the newsgroup regarding this. However, I haven't figured out a way to get Tkinter working in an MFC application that uses embedded python interpreter... Here is the simple code that I am trying in the MFC application The code in C is simple like this: - #include <Python.h> void myFunc (int argc, char **argv) { Py_Initialize (); PySys_SetArgv (argc, argv); PyRun_SimpleString ("execfile('myTkinterApp.py')"); } The code in Python script (myTkinterApp.py) is like this: - try: import Tkinter print 'Tkinter successfully imported' try: root = Tkinter.Tk () print 'Successful' except: print 'failed' except: print 'Could not import Tkinter' The result is that it prints: - Tkinter successfully imported failed The STDOUT is redirected to print to one of the MFC windows. I tried to run this by changing the STDOUT to default (standard) STDOUT. However, even that did not help. Any examples or suggestions will be extremely valuable. Deepak From fumingw at yahoo.com Thu Jul 26 14:09:17 2001 From: fumingw at yahoo.com (Fuming Wang) Date: 26 Jul 2001 11:09:17 -0700 Subject: indetation problem Message-ID: <b0fd9226.0107261009.33a6b066@posting.google.com> I am experiencing indentation problems when mixing tabs and spaces in my code. They appear in correct indentation in my editor, but cause error when running them. I am using Python 2.2a1. I reproduced the problem in following interactive sequence: >>> def dummy(): ... < tab >a = 1 ... <sp><sp>b = 2 File "<stdin>", Line 3 IndentationError: unindent does not match any outer indentation level. Question: is this something new, or it has always been there. It is strange that I have been using Python for several years, but only notice this behavior recently. Thanks, Fuming Wang From brian at supremecasino.com Thu Jul 5 15:10:57 2001 From: brian at supremecasino.com (brian at supremecasino.com) Date: 5 Jul 2001 19:10:57 -0000 Subject: A New Slot Machine Means Big Bonuses For All Message-ID: <20010705191057.47252.qmail@multiwebhosting.com> An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-list/attachments/20010705/f9b8ee95/attachment.html> From Arthur_Siegel at rsmi.com Tue Jul 31 13:59:50 2001 From: Arthur_Siegel at rsmi.com (Arthur_Siegel at rsmi.com) Date: Tue, 31 Jul 2001 12:59:50 -0500 Subject: case sensitivity redux (was Re: Language change and code breaks) Message-ID: <0089EBDB.N22121@rsmi.com> Alex writes - >Maybe, if a _small_ fight >is needed to ENABLE (as opposed to FORCE:-) use of a >semi-smart, case-preserving tool, it MIGHT be worth it, >if the fight be small enough...? Why would anyone oppose a detached elective tool? We may be mean, but not recreationally mean. ART From wheelege at tsn.cc Wed Jul 25 02:56:46 2001 From: wheelege at tsn.cc (Glen Wheeler) Date: Wed, 25 Jul 2001 16:56:46 +1000 Subject: Language change and code breaks References: <Pine.LNX.4.33.0107191316390.24983-100000@bms> <mailman.995571273.18192.python-list@python.org> <9j7gv8$9mg@dispatch.concentric.net> <cppuawfqbm.fsf@cj20424-a.reston1.va.home.com> <mailman.995734717.26373.python-list@python.org> <3B5DF101.9B2E4631@earthlink.net> <cpofq9a858.fsf@cj20424-a.reston1.va.home.com> Message-ID: <033001c114d6$f8d43c20$0200a8c0@ACE> From: "Guido van Rossum" <guido at python.org>: > <snip!> > But never mind, I'm giving up on making *Python* case-insensitive. > The hostility of the user community is frightening. > Now everybody, hang your heads in shame! From david7 at visto.com Mon Jul 23 15:55:21 2001 From: david7 at visto.com (David) Date: 23 Jul 2001 12:55:21 -0700 Subject: Using QT to change menu bar Message-ID: <ac71c3f1.0107231155.7f07f467@posting.google.com> Can anyone tell me how to use QT and python to do the following: Usually when you do a mouse over an item on any windows menu bar, you will see a boarder around that item. Now I need to do is to make it not to have any border, and also highlight the item when I do a mouse over. Usually only the item in sub menu will be highlighted when you do a mouse over. Thank you! From thomas at xs4all.net Tue Jul 10 11:56:33 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 10 Jul 2001 17:56:33 +0200 Subject: PEP: Procedure for Adding New Modules (please comment) In-Reply-To: <3B4B1F25.996D8514@yahoo.com> References: <mailman.994749518.7874.python-list@python.org> <3B4B1F25.996D8514@yahoo.com> Message-ID: <20010710175633.A8098@xs4all.nl> On Tue, Jul 10, 2001 at 03:34:52PM +0000, Paul Winkler wrote: > > This is an area where community contributions are almost non-existent. > > If anyone is looking for a low-commitment way to help Python out, pick > > your favorite library module and contribute some good tests for it! > > There's a decent orientation Lib/test/REAMDE to help you get started. > > The regrtest.py framework is baroque and inadequately documented, but it > > can run both unittest- and doctest-based tests in natural ways now. > This sounds like a good idea. In fact I think I'll do that. Should we work > from CVS, or is Python 2.1 OK? CVS is always best, since a number of tests were added since 2.1. It also gives you an excuse to check out the cool new features in 2.2: iterators and generators :) -- Thomas Wouters <thomas at xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From alf at leo.logilab.fr Mon Jul 16 11:37:07 2001 From: alf at leo.logilab.fr (Alexandre Fayolle) Date: Mon, 16 Jul 2001 15:37:07 +0000 (UTC) Subject: Most efficient solution? References: <mailman.995289809.28477.python-list@python.org> <slrn9l5urp.nto.alf@leo.logilab.fr> <etdn164rk7f.fsf@quiche-lorraine.mit.edu> Message-ID: <slrn9l62om.o1k.alf@leo.logilab.fr> On 16 Jul 2001 11:02:12 -0400, Alex <new_name at mit.edu> wrote: > >> You may get some speedup by making B a dictionary, and using has_key() >> to see if the word is there. This should get you a O(log(n)) instead >> of O(n) inside the loop. To gain further performance, use filter to >> skim A. > >What's n, here? This looks linear in the length of A, and constant time >in the number of unique elements in B, to me. I was referring to the inner loop. n is the number of elements in B (or of keys in C). 'item in B' is O(n), and 'C.has_key(item)' is O(log(n)). You still have to multiply by len(A) for the whole program. Alexandre Fayolle -- LOGILAB, Paris (France). http://www.logilab.com http://www.logilab.fr http://www.logilab.org Narval, the first software agent available as free software (GPL). From bsass at freenet.edmonton.ab.ca Thu Jul 26 13:12:09 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Thu, 26 Jul 2001 11:12:09 -0600 (MDT) Subject: from __past__ import integerDivision (was Re: A modest PEP0238 suggestion) In-Reply-To: <006301c115ce$33c0bc80$0101010a@local> Message-ID: <Pine.LNX.4.33.0107261028580.11619-100000@bms> On Thu, 26 Jul 2001, Chris Gonnerman wrote: <...> > The "original" semantics under my proposal would be "invented" as already > deprecated, and would be removed in 3.0 as the current plan stands. We > have deprecated and subsequently removed things before without the > __future__ directives and it didn't kill us; hence I see the question of > "transitory implications" as only of minor concern. Remember, explicit > (even in documentation) is better than implicit. I'm not sure then, why "original" would be needed if it will be removed when 3.0 comes out. My understanding is that the original semantics will be available until 3.0, without any additional work. Or maybe they will be available via an option only, for the release just before 3.0. If you can convince the `powers that be' that the original semantics should be retained as an incompatible option, then "from __numeric__ import ..." would seem to be a reasonable course of action. Ditto if you want rationals, etc., to be an option instead of builtin; although a plain "import rationals" would look nicer. However, if you are after an alternative to an ugly command line switch... then let's convince Guido that the __past__ need not stick around forever, because at some point the past becomes so distant as to have no direct bearing on the present and can safely be ignored). Guido gets to play god and decide when the __past__ is distant enough to have support for it dropped. - Bruce p.s. - Explicit documentation is no good if it doesn't get read, and while we can't do anything about those who don't read all the pertinent docs, we can at least not lead them into thinking that a transitory feature will stick around because we have implemented it in such a way as to imply it may be permanent. From paulp at ActiveState.com Tue Jul 17 13:00:19 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Tue, 17 Jul 2001 10:00:19 -0700 Subject: [Python-Dev] Re: PEP: Defining Unicode Literal Encodings (revision 1.1) References: <LNBBLJKPBEHFEDALKOLCGEHKKOAA.tim.one@home.com> <3B50C1FF.7E73739B@ActiveState.com> <200107150126.VAA23781@cj20424-a.reston1.va.home.com> <3B51CFB0.ACE9070D@ActiveState.com> <mailman.995217986.28167.python-list@python.org> <3b521a83.2007802417@wa.news.verio.net> Message-ID: <3B546F23.F3DFEB9B@ActiveState.com> Bengt Richter wrote: > >... > If the scope is always a complete file, what about just building on > the -U in #!/usr/bin/python -U, and letting all interested programs > look for flags? Note that there are many Python files that are not meant to be directly executable as scripts. e.g. most files in the standard library do not have shebang lines. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From MarkH at ActiveState.com Sun Jul 15 05:39:01 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Sun, 15 Jul 2001 09:39:01 GMT Subject: win32net.NetUserGetInfo error References: <350a368d.0107131301.1bd4d921@posting.google.com> Message-ID: <3B5164F3.9020203@ActiveState.com> Peder Jakobsen wrote: > import win32api > import win32net > > userName=win32api.GetUserName() > info=win32net.NetUserGetInfo(None, userName, 1) > > I get the following error Works for me. I guess you have a domain controller, or the username actually exists on another server. Off the top of my head I can't recall exactly how to determine the controllers on the network - hopefully someone else will help. Mark. From sh at ttsoftware.co.uk Mon Jul 23 08:50:51 2001 From: sh at ttsoftware.co.uk (Steve Horne) Date: Mon, 23 Jul 2001 13:50:51 +0100 Subject: PEP0238 lament References: <mailman.995814276.15005.python-list@python.org> <3B5BC1C3.41330762@cosc.canterbury.ac.nz> Message-ID: <jt4oltg3ekdlig096677p295f7mnbumteu@4ax.com> On Mon, 23 Jul 2001 18:18:43 +1200, Greg Ewing <greg at cosc.canterbury.ac.nz> wrote: >Arthur_Siegel at rsmi.com wrote: >> >> If I was told that experinced programmers might >> appreciate this change for any possible reason - >> I'd be quiet as a mouse. > >I'm an experienced programmer, and I appreciate the >change on the grounds that different operations on >the same data should be spelled differently. It's not a different operation on the same data. It's the same operation on a different datatype. Floating point division simply extends integer division to some extend past the point - quite appropriate when dealing with floats, but extending a principle is not the same as defining a fundamentally different operation. You might as well claim floating point addition is different from integer addition - that also requires a different algorithm and gives a different result. But that is only a small part of the problem. The real problem is compatability. You disagree? - then may the bugs of a thousand divisions infest your code forever ;-) -- Steve Horne Home : steve at lurking.demon.co.uk Work : sh at ttsoftware.co.uk From eppstein at ics.uci.edu Mon Jul 23 19:12:13 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Mon, 23 Jul 2001 16:12:13 -0700 Subject: PEP0238 lament References: <mailman.995839419.19134.python-list@python.org> <lZX67.36860$Cy.4285646@news1.rdc1.az.home.com> <11moltg2i6s1ftkpku5dkr0cmifn9f5q1o@4ax.com> <Ew_67.36904$Cy.4360445@news1.rdc1.az.home.com> <eppstein-E3BB02.12500023072001@news.service.uci.edu> <WV177.36940$Cy.4447774@news1.rdc1.az.home.com> Message-ID: <eppstein-1C3F40.16121323072001@news.service.uci.edu> In article <WV177.36940$Cy.4447774 at news1.rdc1.az.home.com>, "Tim Hochberg" <tim.hochberg at ieee.org> wrote: > Which is not too horrible, but it is extra cruft. So let me turn your > question around. Can you give an example where you want the type of division > (float vs floor) to change depending on the type of input (int, float, > complex)? I can't, although I suspect there must be some. I also suspect > they're very rare. Rather than arguing about nonexistent situations, let's make an analogy: In Python, "123"+"456" = "123456" but 123+456=579. These are two different operators that happen to have the same symbol. I really don't see why integer-division and floating-point-division should be treated any differently from this case. Maybe it would have been more type-safe to have defined a language in which string concatenation was defined by some other symbol ++, so that "123"++"456" would equal "123456" but "123"+"456" would automagically coerce the arguments into integers and return 579. You could argue either way on the abstract merits of such a language. But that's not the language we have now, the automagic coercion violates the "better explicit than implicit" principle, and there are too many calls to the string-concatenation '+' operator to change them without great pain. Another possible step instead of breaking integer division would be to add a warning for any int/float or float/int division, to make it more explicit that the two kinds of division are different and that you need to make up your mind which one you want to do. Take out all the automagic and make people use explicit casts. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From sh at ttsoftware.co.uk Fri Jul 20 11:47:04 2001 From: sh at ttsoftware.co.uk (Steve Horne) Date: Fri, 20 Jul 2001 16:47:04 +0100 Subject: Pedants R us (was RE: Language change and code breaks) References: <cppuawfqbm.fsf@cj20424-a.reston1.va.home.com> <mailman.995640935.26598.python-list@python.org> Message-ID: <b1kglto0o6j0bgpl5vc55ja4adbktobgdj@4ax.com> On Fri, 20 Jul 2001 15:53:52 +0100, "Tony J Ibbs (Tibs)" <tony at lsl.co.uk> wrote: >Guido van Rossum wrote: >> In my usage, a "programmer" is someone who is a >> professional code-slinger, 8-12 hours a day. > >Eek - I hope you don't really mean that last subclause! A *real* programmer gets in a good six hours code-slinging in their sleep - that period when all the hard problems find their neat original solutions. Apart from the ones that get scribbled on a beer-mat, that is ;-) What do mean, get a life? - There's no Python port for the life platform yet! -- Steve Horne Home : steve at lurking.demon.co.uk Work : sh at ttsoftware.co.uk From akuchlin at mems-exchange.org Tue Jul 31 21:36:51 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 31 Jul 2001 21:36:51 -0400 Subject: 2.2 features References: <mailman.996258542.15795.python-list@python.org> <slrn9m61bs.atb.quinn@retch.ugcs.caltech.edu> <slrn.pl.9m6a5m.kmu.qrczak@qrnik.zagroda> <cpae1lzio7.fsf@cj20424-a.reston1.va.home.com> <9k7il0$7dv$1@panix2.panix.com> Message-ID: <3dd76gv9vw.fsf@ute.cnri.reston.va.us> aahz at panix.com (Aahz Maruch) writes: > is if you're trying to do > > if x in [int, long]: > > which starts being rather ugly as the only reason for an idiom's > existence. Plus it's actually would be wrong, I think. 'in' uses the == operator, so that expression returns true if the object x is the int or long type object. Do we want to explain that 'x in int' and 'x in [int,long]' do quite different things? +1 on ripping 'x in int' out of CVS. Like children, it's sorta cute at first glance but becomes annoying after longer acquaintance and contemplation. --amk From philh at comuno.freeserve.co.uk Wed Jul 11 21:25:13 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Thu, 12 Jul 2001 02:25:13 +0100 Subject: How popular is Python, anyway? (was: Long Live Python!) References: <E566B020833BD311B6610008C791A39705CA5230@il93exm04.css.mot.com> <mailman.994804336.23495.python-list@python.org> <slrn9koofo.mjk.philh@comuno.freeserve.co.uk> <slrn9kpgtq.5ug.gergo.barany@hold.otthon.at> Message-ID: <slrn9kpv3p.ooh.philh@comuno.freeserve.co.uk> On 11 Jul 2001 21:20:02 GMT, Gergo Barany <gergo.barany at gmx.net> wrote: >phil hunt <philh at comuno.freeserve.co.uk> wrote: >> [snip flamebait crap] > >If anyone is going to to respond to this thread, *please* take >comp.lang.c out of the Newsgroups: list. We don't do advocacy here. >Followups set. My post was an entirely objective statistical summary, and contained no subjective or opinion-based data at all. If you think that facts are "crap" and hard statistical analysis is "flamebait" then all I can say is that it is up to others to decide, on the basis of your posts, how "crappy" you are. -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From machin_john_888 at hotmail.com Fri Jul 13 08:56:41 2001 From: machin_john_888 at hotmail.com (John Machin) Date: 13 Jul 2001 05:56:41 -0700 Subject: Regural expression puzzle for gurus References: <3B4EA0C8.9F697D06@vip.fi> <3B4EA470.AA7B0D12@nokia.com> Message-ID: <92ae279c.0107130456.6cc2d272@posting.google.com> Joonas Paalasmaa <joonas.paalasmaa at nokia.com> wrote in message news:<3B4EA470.AA7B0D12 at nokia.com>... > Pekka Niiranen wrote: > > > > I have a string in the middle of a text starting with #-sign and ending > > to \W. > > I can find it with re.compile('#\w+') and would like to replace it by > > adding a > > # -sign also to the end of it. > > > > Example: > > > > original string: xx:yy:#AAA.!:-#BBB:2324:#CCC:!"?% > > > > after replacement: xx:yy:#AAA#.!:-#BBB#:2324:#CCC#:!"?% > > > > How can I do replacement with a single regural expression line ? > > > > I have found a solution like: > > text = 'xx:yy:#AAA:-#BBB:aa' > > line = re.compile('#\w+') > > list = line.findall(text) > > for i in range(len(list)): > > text = text.replace(list[i],list[i]+'#') > > > > >>> text > > 'xx:yy:#AAA#:-#BBB#:aa' > > > > I would like to do this without the for -loop (unless somebody can > > convince > > me the found solution is the fastest available) > > Try this. > > import re > text = """xx:yy:#AAA.!:-#BBB:2324:#CCC:!"?%""" > print re.sub(r"(#\w+)(\W)", r"\1#\2", text) > > - Joonas The \W is not only unnecessary but will cause failure if the input string ends in the desired pattern -- there would be nothing for \W to match. Quite simply, all you need is: re.sub(r"(#\w+)", r"\1#", text) From hcsgss at texlife.com Thu Jul 26 15:51:58 2001 From: hcsgss at texlife.com (Galen Swint) Date: Thu, 26 Jul 2001 14:51:58 -0500 Subject: Why Johnny Can't Distribute Processing. WAS: Distributed computing using SOAP. What about speed ? In-Reply-To: Tim Daneliuk <tundra@tundraware.com> "Why Johnny Can't Distribute Processing. WAS: Distributed computing using SOAP. What about speed ?" (Jul 26, 6:30pm) References: <LBA77.58$bXi.175168000@news.telia.no> <dc6f5c99.0107251655.f3c625b@posting.google.com> <3B5FC733.5186D588@tundraware.com> <mailman.996163788.16805.python-list@python.org> <3B6060C3.A6E69FF5@tundraware.com> Message-ID: <1010726145158.ZM95844@anson.hcs.tl> On Jul 26, 6:30pm, Tim Daneliuk wrote: > > 1) Aynchronous APIs to the messaging and queuing manager > 2) Platform-neutrality: From mainframes to desktops > 3) Class-Of-Service selection > 4) Per-event, selectable write through to backing store > 5) Bindings for C and Java, and also the major scripting langs: Python, TCL, Perl, VBA > 6) Remote management and recovery capability > 7) Plugable security and encryption. > This is an interesting set of criteria. At GaTech, where I am the other 9 mos of the year, we are working on a project called "Infosphere" and Infosphere to address some of these concerns. Right now we are built on top of a framework called "ECho" which is a high-performance event messaging system that runs on several platforms (mostly Solaris, WinNT, Linux, with support for Java up-and-coming). Not all of this functionality is built in, but you can add it easily. For instance, not only could you do logging to a backing store, but you can do remote logging just as easily. Security, I think, is slowly being added, and class-of-service is actually one of the major goals for the near-term. ECho is a very efficient framework, and I think they built an RPC using it that was faster than SunRPC. Right now you're probably most interested in ECho: http://www.cc.gatech.edu/systems/projects/ECho but Infosphere is just ramping up http://www.cc.gatech.edu/projects/infosphere Galen Swint From thomas at xs4all.net Sun Jul 15 07:12:55 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Sun, 15 Jul 2001 13:12:55 +0200 Subject: converting from perl: variable sized unpack In-Reply-To: <15183.48231.771283.235523@anthem.wooz.org> References: <roy-B2459F.22112513072001@news1.panix.com> <15183.48231.771283.235523@anthem.wooz.org> Message-ID: <20010715131255.Z5396@xs4all.nl> On Fri, Jul 13, 2001 at 11:28:39PM -0400, Barry A. Warsaw wrote: > >>>>> "RS" == Roy Smith <roy at panix.com> writes: > > RS> What's the best way to translate this perl snippet into > RS> python: > > RS> ($f1, $f2, $f3, $f4, $f5, $f6) = split ('\s+', $line); > > RS> The obvious translation would be: > > RS> [f1, f2, f3, f4, f5, f6] = string.split (line) > > RS> but the problem is that line may have fewer than 6 fields on > RS> it. Perl handles this smoothly by leaving the "extra" > RS> variables undefined, whereas python raises a ValueError > RS> exception. What I'd like to do is have the extra field > RS> variables left as null strings. > Python doesn't work this way, but I've been thinking about writing a > PEP to make sequence unpacking less strict. Oh, cool. Here are some ideas for you, from my second-most favourite language, LambdaMOO. It's the language that learned me programming, and laid the groundwork for my love of Python -- it's an amazingly Pythonic language, probably because it was developed at PARC Xerox to teach basic OOP concepts. I strongly suspect either ABC or Python influenced MOO (or viceversa) but no-one ever came forward to admit it :) Anyway, MOO lists are created using '{}'s like in ABC, and indexing starts with 1, not 0. And MOO lists can't be added with '+', so there is a special 'splice' operator that 'unpacks' a list in-place: the MOO expression caps = {"A", "B"}; l = {"a", "b", @caps, "c", "d"} Is the same as the Python caps = ["A", "B"] l = ["a", "b"] + caps + ["c", "d"] And this '@' syntax comes back in the 'sequence unpacking' MOO has. The LambdaMOO Programmers Manual explains this so nicely, you could almost copy this into your PEP :-) >From ftp://ftp.lambda.moo.mud.org/pub/MOO/ProgrammersManual.html (also available in .tex, .dvi, .ps and .txt from the same location): """ Spreading List Elements Among Variables It is often the case in MOO programming that you will want to access the elements of a list individually, with each element stored in a separate variables. This desire arises, for example, at the beginning of almost every MOO verb, since the arguments to all verbs are delivered all bunched together in a single list. In such circumstances, you could write statements like these: first = args[1]; second = args[2]; if (length(args) > 2) third = args[3]; else third = 0; endif This approach gets pretty tedious, both to read and to write, and it's prone to errors if you mistype one of the indices. Also, you often want to check whether or not any extra list elements were present, adding to the tedium. MOO provides a special kind of assignment expression, called scattering assignment made just for cases such as these. A scattering assignment expression looks like this: {target, ...} = expr where each target describes a place to store elements of the list that results from evaluating expr. A target has one of the following forms: variable This is the simplest target, just a simple variable; the list element in the corresponding position is assigned to the variable. This is called a required target, since the assignment is required to put one of the list elements into the variable. ?variable This is called an optional target, since it doesn't always get assigned an element. If there are any list elements left over after all of the required targets have been accounted for (along with all of the other optionals to the left of this one), then this variable is treated like a required one and the list element in the corresponding position is assigned to the variable. If there aren't enough elements to assign one to this target, then no assignment is made to this variable, leaving it with whatever its previous value was. ?variable = default-expr This is also an optional target, but if there aren't enough list elements available to assign one to this target, the result of evaluating default-expr is assigned to it instead. Thus, default-expr provides a default value for the variable. The default value expressions are evaluated and assigned working from left to right after all of the other assignments have been performed. @variable By analogy with the @ syntax in list construction, this variable is assigned a list of all of the `leftover' list elements in this part of the list after all of the other targets have been filled in. It is assigned the empty list if there aren't any elements left over. This is called a rest target, since it gets the rest of the elements. There may be at most one rest target in each scattering assignment expression. If there aren't enough list elements to fill all of the required targets, or if there are more than enough to fill all of the required and optional targets but there isn't a rest target to take the leftover ones, then E_ARGS is raised. Here are some examples of how this works. Assume first that the verb me:foo() contains the following code: b = c = e = 17; {a, ?b, ?c = 8, @d, ?e = 9, f} = args; return {a, b, c, d, e, f}; me:foo(1) error--> E_ARGS me:foo(1, 2) => {1, 17, 8, {}, 9, 2} me:foo(1, 2, 3) => {1, 2, 8, {}, 9, 3} me:foo(1, 2, 3, 4) => {1, 2, 3, {}, 9, 4} me:foo(1, 2, 3, 4, 5) => {1, 2, 3, {}, 4, 5} me:foo(1, 2, 3, 4, 5, 6) => {1, 2, 3, {4}, 5, 6} me:foo(1, 2, 3, 4, 5, 6, 7) => {1, 2, 3, {4, 5}, 6, 7} me:foo(1, 2, 3, 4, 5, 6, 7, 8) => {1, 2, 3, {4, 5, 6}, 7, 8} Using scattering assignment, the example at the begining of this section could be rewritten more simply, reliably, and readably: {first, second, ?third = 0} = args; It is good MOO programming style to use a scattering assignment at the top of nearly every verb, since it shows so clearly just what kinds of arguments the verb expects. """ I think I would really enjoy seeing fromaddr, toaddr, subject="(no subject)", contenttype="text/plain" = f() (though I know that's syntactically impossible, *snif* ;) and user, domain, @aliases = getinfo() in Python, though I doubt I ever will :) -- Thomas Wouters <thomas at xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From tim.one at home.com Tue Jul 3 21:47:44 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 3 Jul 2001 21:47:44 -0400 Subject: Eiffel better than Python ? In-Reply-To: <f20ea932.0107030100.6c740683@posting.google.com> Message-ID: <LNBBLJKPBEHFEDALKOLCKEEFKMAA.tim.one@home.com> [Tomasz Stochmal] > Should I stop using Python and jump on Eiffel wagon ? You didn't say what you want to accomplish. If the idea of "provably correct" programs appeals to you, Eiffel will give you more help than any other practical language I know of. But since your post didn't lay out your assumptions, your goals, or how you view language characteristics as fitting in with either, you're not a *natural* candidate for embracing Design by Contract <0.6 wink>. From tundra at tundraware.com Wed Jul 11 15:00:01 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 11 Jul 2001 19:00:01 GMT Subject: Tuple Semantics - Rationale'? Message-ID: <3B4CA0A8.20B53230@tundraware.com> I'm curious about why python was designed to handle the tuple semantics described below the way it does. Perhaps one of you language experts can 'splain it to me. I have a data structure that looks like this (each of the elements is a string): ds = ( ( (name-1, descrip-1), ( (argA-1, argB-1), ... (argA-n, argB-n) ) ), ... ( (name-n, descrip-n), ( (argA-1, argB-1), ... (argA-n, argB-n) ) ), ) One of the tuples of ds has a single arg pair. That is, it looks like this: ( (name-n, descrip-n), ( (argA-1, argB-1) ) ), But, at runtime, python sees is as this: ( (name-n, descrip-n), (argA-1, argB-1) ), >From what I've read, to force the data structure to be maintained correctly, I have to add a trailing comma to the single arg pair like this: ) (name-n, descrip-n), ( (argA-1, argB-1), ) ), And that works fine. But *why* is the trailing comma designed into the language semantics this way. I've been scratching my head and cannot come up with a rationale'. It seems to me that the explicit use of the parens should be telling python that I want the second entry in each data structure to be a *tuple* of 0 or more tuples. Supposed I did want 0 argument pairs in that tuple, but I wanted to prepare the way for adding some later. Would I use: (()), (), ((,)) ??? 'Just curious... ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From aleaxit at yahoo.com Tue Jul 10 05:37:07 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 10 Jul 2001 11:37:07 +0200 Subject: Keys To The Kingdom References: <3B48F6D7.D9798E7D@tundraware.com> <slrn9ki0e0.vu.tim@vegeta.ath.cx> <3B4AC204.80941297@tundraware.com> Message-ID: <9ieic40622@enews3.newsguy.com> "Tim Daneliuk" <tundra at tundraware.com> wrote in message news:3B4AC204.80941297 at tundraware.com... > Tim Hammerquist wrote: > > > > > > This works for me: > > > > try: > > input = raw_input() > > except KeyboardInterrupt: > > # handle Ctrl-C > > > > The only difference I see is the capital 'B' you have in > > 'KeyboardInterrupt'. Change it to lowercase and see what happens. > > (Whoops, I spelled it wrong here, but correctly in my program.) > > This code fragment works fine under Unix (FreeBSD 4.3) but not under > Windows 2000. Is this a known bug or is there some magic I'm missing? It seems to me (trying under NT4) that raw_input() is generating an EOFError on Ctrl-C (or Ctrl-Break) rather than the exception you (reasonably expect), i.e. KeyboardInterrupt. Maybe try an except (KeyboardInterrupt, EOFError): # whatever to catch both...? Of course, on Unix EOFError would happen if the user hit Ctrl-D rather than Ctrl-C, and on Windows also on Ctrl-Z followed by a return, but... Alex From jonas.b at home.se Sun Jul 15 04:22:48 2001 From: jonas.b at home.se (Jonas Bengtsson) Date: 15 Jul 2001 01:22:48 -0700 Subject: Re-sizing images in Python? References: <q6547.41446$B56.8781902@news2-win.server.ntlworld.com> Message-ID: <4e2ddb70.0107150022.7e5bc118@posting.google.com> There is a great program that can do that (and much more). It is called ImageMagick (http://www.imagemagick.org/). There is a Python API to it but I havn't tested it myself. /Jonas B "Darren Watson" <Darren.Watson3 at ntlworld.com> wrote in message news:<q6547.41446$B56.8781902 at news2-win.server.ntlworld.com>... > I would be very grateful for any advice that fellow list members can provide > about Pythons ability to resize image files (jpg and gif). > > I would like to write a script that can process all the files in a directory > and resize the images to a specified size (passed in as an argument). > However, I am not sure if this is a task that Python 2.1 can perform or if > it is, which library to use. > > If possible I would like the script to scale images in order to 'best fit' a > particular area. > > Many Thanks From mkx at excite.com Mon Jul 2 17:42:56 2001 From: mkx at excite.com (mkx at excite.com) Date: Mon, 02 Jul 2001 21:42:56 GMT Subject: MS "bans" GPL Message-ID: <7iq1ktcmslo24kbr8qvob2g3hpgleuf025@4ax.com> Do the folks at MS _want_ us to find them unreasonable? http://dailynews.yahoo.com/h/zd/20010702/tc/ms_attacks_open_source_1.html "The license for Microsoft's Mobile Internet Toolkit, which is in its second beta release to developers, says that it may not be used with any software under the Free Software Foundation's General Public License (GPL) and six other forms of "potentially viral software." That language refers to open source code's freely available and shared code licensing agreements. The wording of the license cites the Linux OS and the Perl scripting language as examples." From reqhye72zux at mailexpire.com Tue Jul 31 11:36:02 2001 From: reqhye72zux at mailexpire.com (Robert Amesz) Date: Tue, 31 Jul 2001 15:36:02 GMT Subject: The best gui library for newbies. References: <dZj97.40636$9n7.62176316@newsserver.ip.pt> <mailman.996528841.13919.python-list@python.org> Message-ID: <Xns90EFAF63546DErcamesz@127.0.0.1> William Park wrote: > On Tue, Jul 24, 2001 at 12:21:48PM +0100, David A. wrote: >> H~i I program in python for some time now. And I would like to >> beegin doing some gui's and other graphical programming. The thing >> I want to know is wich one is the best gui toolkit for python when >> you are a newbie? Wxpython, tkinter?? Whatis important for me is >> easy of use and well documented!! this is what I am looking for. >> >> Thank you for any help in advance!!! > > Start with Tkinter, since it's part of standard distribution and > been around for a while. There is also a book called "Python and > Tkinter Programming" by Grayson from Manning <www.manning.com>. Start with wxPython, because it's scrumptious. Oh, yes, the demo is scrumptious too. Robert Amesz From shane.anglin at mtni.net Sat Jul 14 13:20:40 2001 From: shane.anglin at mtni.net (Shane Anglin) Date: Sat, 14 Jul 2001 13:20:40 -0400 Subject: Need help with socket server code Message-ID: <200107141320.AA116850868@mtni.net> Here's the basics of what I want to do with my new app: Main loop is: 1 - check socket for any incoming data 1a - if no data on socket, go to 2, else get the data and place it into a list 2 - print out list 3 - go to 1 and do it all over again Currently, I can create a TCP socket server app using examples that will sit and wait (idle 99% of the time) and accepts the incoming data just fine, my 'print list' part is not processing at all until I get any new data in... for example, 1-wait on a client connect on socket, when a connection happens, get data, 2- place new data into list, print list, 3 -go to 1 and do it all over again... in this scenario, #1 has the rest of my code 'hostage' until a client connection is made and closed. Thanks a bunch! Shane Anglin shaneanglin at bigfoot.com From cliechti at mails.ch Tue Jul 24 17:45:18 2001 From: cliechti at mails.ch (chris liechti) Date: 24 Jul 2001 23:45:18 +0200 Subject: question about handling pointers in C extensions References: <9jkhdv$r3o$1@nntp6.u.washington.edu> Message-ID: <Xns90E8F1B09448cliechtimailsch@62.2.32.50> seams reasonable for me. bt not that i have worked with python and c pointers. i've done this by making a python extension module that provides access to the device functions (were some GUI methonds). for me the cleanest thing would be writing a c extension module that provides a python class. this class has methods to communicate with the driver (thats no problem as it is written in c). that way you don's have to expose any pointers to the python code and you dont have to worry about memory leaks as a python object gets always finalized if no longer needed. just put your cleanup code in that classes __del__ method. here some exaple sourse as it would look for your approach: import mydriver handle = mydriver.open() mydriver.dosomething(handle, args) mydriver.close(handle) the above description gives you something like this: import mydriver dev = mydriver.open() dev.dosomething(args) dev.close() no "handle" carriend around - a nice obejct oriented solution. chris "Russell E. Owen" <owen at astrono.junkwashington.emu> wrote in news:9jkhdv$r3o$1 at nntp6.u.washington.edu: > I would like a bit of help with handling pointers in C extensions. I > hope this is a simple question. > > I want to write a Python interface to a device driver library. One > starts by opening the device and getting a particular kind of pointer, > e.g. (simplified): > DevType *dev_open() > > Is the following reasonable, or is there a better way to do this? > > static PyObject *open (PyObject *self, PyObject *args) > ) { > PyObject *py_dev_p; > DevType *dev_p; > > /* call the C routine to open the device */ > dev_p = dev_open(); > if (dev_p == NULL) { > PyErr_SetString(PyExc_RuntimeError, "open failed"); > return NULL; > } > > /* convert device pointer to a Python Long object */ > py_dev_p = PyLong_FromVoidPtr ((void *) dev_p); > if (py_dev_p == NULL) { > return NULL; > } > > /* increment reference and return the PyLong */ > Py_INCREF (py_dev_p); > return Py_BuildValue("O", py_dev_p); > } > > Also, are there any tricks or gotchas to passing the pointer in to > device control functions? > > I am assuming the inverse functions are the ticket (parse "O" format to > extract the PyLong, then use PyLong_AsVoidPtr). "O!" sounded interesting > to get a void* in one step, but what are the "Python type objects" one > can pass? Anyone have a simple example of a converter function for "O%"? > > I assume: > - there is no need to INCREF or DECREF the PyLong pointer (so long as my > extension only uses it locally, i.e. doesn't store it) > - eventually the user should call a Python interface to dev_close and at > that time the PyLong should be DECREFed. > > Any advice or warnings would be appreciated. I have been reading > "Extending and Embedding" and "Python/C API", but I still have doubts > I've got the pointer handling right. > > Regards, > > -- Russell > -- chris <cliechti at mails.ch> From loisel at math.mcgill.ca Fri Jul 6 16:25:21 2001 From: loisel at math.mcgill.ca (Sebastien Loisel) Date: Fri, 6 Jul 2001 13:25:21 -0700 Subject: c bindings Message-ID: <p9p17.50949$aW5.630440@dfw-read.news.verio.net> Hello. I apologize in advance, for I have already asked help from help at python.org for this very same problem. I didn't know about this newsgroup. I am writing an extension module. For this purpose, I have written a very short code generator, to create wrappers around my C library. For some simple test cases, it seems to work fine, but I am encountering core dumps with a more complete program. I don't think this is relevant, but I'm running python 1.5.2 in Linux. As I see it, I can either work hard and figure it out myself, but the fastest would probably be for a guru to tell me what I'm doing wrong. Of course, I hate looking at someone else's code just as much as the next guy, so I've had my code generator create the shortest useful binding I can have it generate, to see if there are any errors in that. If you guys could tell me if I've got a refcount wrong in there somewhere, I would appreciate greatly. I would also appreciate if you would cc my email address in your replies, for reference purposes in the future. Thank you very much, Sebastien Loisel ------snip here----- #include <Python.h> static PyObject *ErrorObject; // This code is automatically generated /* This function takes for argument a sequence of ints and returns a list of floats. */ static PyObject *example_py(PyObject *self, PyObject *args) { int j; PyObject *_; float *ret; int ret_size=-1; PyObject *ret_list; int *param; int param_size; PyObject *param_helper; if(!PyArg_ParseTuple(args,"O", ¶m_helper)) return 0; if(!PySequence_Check(param_helper)) { PyErr_SetString(ErrorObject,"arg should be a sequence"); return 0; } param_size=PySequence_Length(param_helper); param=gtc_must_malloc(param_size*sizeof(int)); for(j=0;j<param_size;j++) { _=PySequence_GetItem(param_helper,j); param[j]=PyInt_AsLong(_); Py_DECREF(_); } ret_size=param_size; ret=gtc_must_malloc(sizeof(float)*ret_size); for(j=0;j<ret_size;j++) ret[j]=param[j]+j/2.0; if(ret_size<0) abort(); ret_list=PyList_New(ret_size); for(j=0;j<ret_size;j++) { PyList_SetItem(ret_list,j,PyFloat_FromDouble(ret[j])); } free(ret); return ret_list; } static PyMethodDef example_methods[] = { {"example",example_py,1}, {0,0} // sentinel }; DL_EXPORT(void) initexample() { PyObject *m,*d; m=Py_InitModule("example",example_methods); d=PyModule_GetDict(m); ErrorObject = PyErr_NewException("example.error",0,0); PyDict_SetItemString(d,"error",ErrorObject); } From fredrik at pythonware.com Wed Jul 11 03:57:01 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 11 Jul 2001 07:57:01 GMT Subject: compiling c app in MSVC References: <mailman.994808297.31968.python-list@python.org> Message-ID: <hFT27.2515$z21.474249@newsc.telia.net> Brian Quinlan wrote: > 1. You can try to rebuild Python with MSVC5 (probably won't work > though) it works just fine. > (but the binary will not be compatible with everyone's Python). really? I've shipped VC5 built extensions for official 1.5.2, 1.6, 2.0, 2.1, and 2.2 distributions, and nobody has ever reported any compatibility problems... </F> From jkraska1 at san.rr.com Tue Jul 3 00:54:17 2001 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 02 Jul 2001 21:54:17 -0700 Subject: Augmented Assignement (was: Re: PEP scepticism) In-Reply-To: <20010702212238.Q32419@xs4all.nl> References: <oqlmm7tl6j.fsf@lin2.sram.qc.ca> <mailman.993952381.32699.python-list@python.org> <zbN%6.415855$oc7.58414702@news2.rdc2.tx.home.com> <q0avjto87p59hn7gv28r5cf1c84j2fb8c7@4ax.com> <naO%6.416271$oc7.58537852@news2.rdc2.tx.home.com> <vm40kt8knq3pplpv1rarjubl73vnl12ure@4ax.com> <20010702145211.M8098@xs4all.nl> <oqlmm7tl6j.fsf@lin2.sram.qc.ca> Message-ID: <5.0.0.25.0.20010702215108.02a92958@pop-server> >Changing the implementation two releases *after* the fact is going to Expecting the change of something is one thing and observing it's incorrectness is another. Be what may about the current implementation and future of Python, it is simply wrong that a = a + 1 is evaluated differently than a += 1. I'm not sure that this will matter much in the scheme of things; however, I do know that this behavior will likely always be surprising to the uninitiated. The equivalency of a = a + 1 to a +=1 is something that I'd wager is the first instinct of programmers approaching the form. C// From guido at python.org Sat Jul 21 18:31:00 2001 From: guido at python.org (Guido van Rossum) Date: Sat, 21 Jul 2001 22:31:00 GMT Subject: Case insensitivity References: <mailman.995506711.21636.python-list@python.org> <cpvgkofyru.fsf@cj20424-a.reston1.va.home.com> <mailman.995666017.20422.python-list@python.org> <atehltknbavv0irts7ousrh4ed8t36op5f@4ax.com> <cphew6fjao.fsf@cj20424-a.reston1.va.home.com> <1djjlt0ho504505v0ljfllb74o76acffjp@4ax.com> Message-ID: <cpelr9gbk7.fsf@cj20424-a.reston1.va.home.com> Sheila King <sheila at spamcop.net> writes: > So far, there have been about 8 responses. I think I need to allow a > week or two, especially since it is summer--many teachers on vacation > and not checking e-mail regularly--before it is worth sharing the > results. Especially, the one mailing list is moderated, and sometimes it > takes several days for the moderator to approve and post articles. Heck, > there's no rush here, right? Maybe I should just wait until mid- to > late-August. (The mailing lists have about 450 and 1900 members > respectively. Don't know what sort of return I will get.) Definitely no rush. This won't affect 2.2 in any way. --Guido van Rossum (home page: http://www.python.org/~guido/) From newgene at bigfoot.com Tue Jul 17 14:19:51 2001 From: newgene at bigfoot.com (newgene) Date: 17 Jul 2001 11:19:51 -0700 Subject: Two Simple Qs: Message-ID: <a50631f6.0107171019.74fb42a5@posting.google.com> I am quite new to python. I have 2 simple questions: 1. How can I run a simply Python script under IDLE directly? I wrote a start.py to do some routine work, like importing some medules and adding my working path into sys.path, before I start to work. This script is just like a macro or batch file under DOS. Now I have to open this file and then run it. I hope python have a statement can run it directly( maybe like 'run start.py'). 2. When I made some modification of my own module after I import this module,python can not recognized the modified module even I import it again. It raised the same error msg, but gave me the error line actually I have corrected, that is , it run as the old module but display the error from the newer module file. I have to restart python environment and import again, then my module run correctly. Is this a bug? And how to resolve it? Thank you. Newgene From mixo at beth.uniforum.org.za Mon Jul 30 03:58:30 2001 From: mixo at beth.uniforum.org.za (mixo) Date: Mon, 30 Jul 2001 09:58:30 +0200 Subject: Proxy Server Message-ID: <3B6513A6.C4B84218@beth.uniforum.org.za> How does one connect to an external mail server when you actually connect to the outside through a proxy server (which may or may not require a user id and or a password)? What I want to be able to do is , given an email address, get the mail host ,and using that host, verify that the email receipient exists before sending mail using "smtplib". From simonb at webone.com.au Thu Jul 12 23:51:07 2001 From: simonb at webone.com.au (simonb at webone.com.au) Date: Fri, 13 Jul 2001 13:51:07 +1000 Subject: ANNOUNCE: SCons (Python build tool) development under way References: <mailman.994953807.6320.python-list@python.org> Message-ID: <3B4E702B.8070008@webone.com.au> So this is not just for a python project (i can't see why you would need any "make" utility for a (purely) python project), but as a real replacement for make? ie. reads makefiles and such? Well, im rather confused about this... Simon. Steven Knight wrote: >This is to announce that active development of SCons is now underway at: > > http://scons.sourceforge.net/ > >SCons is a Python software construction (or software build) tool--that >is, a substitute or replacement for Make. SCons is implemented as a >Python script around a central set of Python build-engine modules. >SCons configuration files are actually executed as Python scripts, >allowing you to use full Python functionality to control your build. >You use Python functions and methods in the configuration files to tell >the central build engine about your input and output files. > >Other key features: Dependency calculations are done using MD5 >signatures, yielding more reliable builds than timestamp-based >dependency analysis. Most dependencies are handled automatically. >Building multiple targets in parallel (-j) is supported. It's easy to >add your own Builder objects and otherwise customize your build. > >SCons is still on its way to alpha release, so there's no official >package available for download at the moment--sorry. Much of the >infrastructure has been coded, though, and is available for anonymous >CVS checkout, or browsable via the CVS web interface under the SCons >project page at SourceForge: > > http://sourceforge.net/projects/scons/ > >The usual set of mailing lists (scons-announce, scons-devel, >scons-users) has been created. Follow the web site links to subscribe. > >A small development team (n == 3) is working towards finishing enough >documentation and basic functionality for a rapid series of alpha >releases in the (hopefully) near future. To help that effort, we'd like >to become larger than just a "small" team. If you're interested in >contributing, we'd love to hear from you. Check out the developer >guidelines on the SCons web site. > >Yes, SCons is the direct descendant of the ScCons design that won the >Software Carpentry build tool competition last year. It's been renamed >(dropped the extra 'c') to make it slightly easier to type, and to try >to reflect weakly the fact that this project is no longer directly >related to Software Carpentry. (Sorry, I don't know the current status >of Software Carpentry or the other tools they were planning.) > >The SCons design is based on the design of the Perl-based Cons software >construction tool: > > http://www.dsmit.com/cons/ > >SCons improves on the Cons architecture by incorporating several years >of practical experience with its strengths and weaknesses. (And, of >course, by being written in Python... :-) > > --SK > > From bsass at freenet.edmonton.ab.ca Tue Jul 31 17:38:56 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Tue, 31 Jul 2001 15:38:56 -0600 (MDT) Subject: case sensitivity redux (was Re: Language change and code breaks) In-Reply-To: <9k5tg301mn9@enews4.newsguy.com> Message-ID: <Pine.LNX.4.33.0107311455010.649-100000@bms> Hi, Welcome back. On Tue, 31 Jul 2001, Alex Martelli wrote: <...> > For those of you who can't really empathize with other's issues > and misfortunes, imagine being in a situation where you'd often > need to have source code read out loud to you (e.g. over a > phone), and/or you'd often want to dictate code (e.g. to some > kind of voice-recognition, dictation-taking automatic system). > What's case sensitivity giving you, that would compensate for > the serious bother it causes in those situations? Good point, but I'm not sure how much bother it will be. Case sensitivity is so common in everyday life that the standard tools must be able to work with it if they are to be (will be?) useful. I would imagine a VR system would let you say something along the lines of... "<runon> file input <equal-sign> <capitalize-words runon> file input" ...to get... "fileinput = FileInput" ...and that may be easy compared to... "one", "1", "1.", "1+0j" ...which would probably require a programming or python specific addon module for the VR system (in this fantasy world I'm constructing). As you suggested, tools could get pretty smart, maybe even automatically translating between case-sensitive and case-insensitive. e.g., source has "foo = Foo", VR user hears and uses "foo = fooa" Of course, that is no reason to not explore case-insensitivity; actually, it is a reason to explore it... someone has to figure out where the problem areas are (hopefully before cataracts and glaucoma catch up with me ;). - Bruce From brueckd at tbye.com Mon Jul 30 19:42:03 2001 From: brueckd at tbye.com (brueckd at tbye.com) Date: Mon, 30 Jul 2001 16:42:03 -0700 (PDT) Subject: Typing system vs. Java In-Reply-To: <9k4l5c$o985@news1.gtech.com> Message-ID: <Pine.LNX.4.33.0107301626270.22456-100000@ns0.tbye.com> On Tue, 31 Jul 2001, Peter Milliken wrote: > I have used a very strongly typed language (Ada), I haven't tried Haskall or > Ocaml as one repondent mentioned, but I claim that with Ada, 95-98% of > "normal" bugs are out of my programs once I get the compiler to produce > executable code. The only bugs that are left are the purely logic bugs. Only 2-5% of your bugs are purely logical!? While I'd agree that once your compiler produces executable code the bugs left are of the logical variety, that number seems incredibly low (or the number of bugs you initially have is ridiculously high ;-) ). Back to the topic: how much of this would you attribute to Ada's use of types versus its very thorough compiler (that checks a wide range of problems, not all of which may be type-related). > Once you have used a truly strongly typed language, then you would > never consider doing a large job (multiple programmers) in anything > else. I love and use Python, but anything more than a one man job > would see me turfing it for a better suited language. Sometimes I > think that even the idea of using Python may be a mistake because the > number of hours I have spent chasing down code bugs in my Python > programs that would have been caught by a decent typed language > compiler are too numerous to count :-). Excellent! You seem to have what I was looking for from the initial poster: a specific example. Can you post one please? I'd really like to better understand your perspective. Thanks! -Dave From sholden at holdenweb.com Sun Jul 8 16:33:18 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sun, 8 Jul 2001 16:33:18 -0400 Subject: Comment on PEP-0238 References: <3B3BE855.A6223E70@3-cities.com> <cp7kxvlake.fsf@cj20424-a.reston1.va.home.com> <Y4J%6.4084$Z6.2010194@news1.rdc2.pa.home.com> <mailman.994016102.30019.python-list@python.org> <92ae279c.0107071820.7ebb77f8@posting.google.com> <fH227.14742$i8.1300639@e420r-atl3.usenetserver.com> <etd4rsnchr3.fsf@pickled-herring.mit.edu> Message-ID: <Sp327.45930$he.3180482@e420r-atl1.usenetserver.com> "Alex" <new_name at mit.edu> wrote in message news:etd4rsnchr3.fsf at pickled-herring.mit.edu... > > Sorry, I think it actually would. :) > > >>> 5/.1 > 50.0 > >>> > Damn the bad habits Fortran is responsible for. I've never written that number as anything other than 0.1, and assumed nobody else would, either. Thanks! regards Steve -- http://www.holdenweb.com/ From michael at stroeder.com Tue Jul 3 14:09:42 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Tue, 03 Jul 2001 20:09:42 +0200 Subject: MS "bans" GPL References: <7iq1ktcmslo24kbr8qvob2g3hpgleuf025@4ax.com> <9hshbp$oqv$2@216.39.170.247> <slrn9k3ji4.49l.gerhard.nospam@lilith.hqd-internal> <9hst9p$oqv$5@216.39.170.247> Message-ID: <3B420A66.FB5E75A5@stroeder.com> David LeBlanc wrote: > > In article <slrn9k3ji4.49l.gerhard.nospam at lilith.hqd-internal>, > gerhard.nospam at bigfoot.de says... > <snip> > > > You don't try to spread FUD, do you? No matter what MS or > > any other company writes into their "license agreements", not > > everything is compatible with German or US or whatever laws. > > I'm gratified to know that you are aware enough to know that, and that > further you can afford to take Microsoft to court if needs be. Disclaimer: I'm not a lawyer. Well, at least here in Germany almost everything M$ or other similar software vendors write into their "license agreements" will fail in court (AGB-Gesetz) as long as you don't register the software. And the good things is that they would have to take you to court and prove their point of view. > Microsoft, like other companies and even > governments, either counts on people's ignorance or inability to contest > their behavior Nevertheless you're right that it's even annoying that they try to make people believe the crap they're writing about Open Source by "enforcing" such a license. Remember: Don't register software! > Opinion: It would not be illegal for Microsoft to make it a condition of > use that you not install open source software if you want to use their > OS. I don't think so. In Germany a software vendor cannot restrict the dedicated use (I hope I translated "bestimmungsgem??e Benutzung" correctly) of software. The dedicated use of an operating system is being a platform for running arbitrary applications. I think they would fail miserably in court - at least here in Germany (don't know anything about other countries). IMHO M$ will never try to really enforce such rules in a trial. Ciao, Michael. From rnd at onego.ru Mon Jul 9 10:04:22 2001 From: rnd at onego.ru (Roman Suzi) Date: Mon, 9 Jul 2001 18:04:22 +0400 (MSD) Subject: license suggestions? In-Reply-To: <slrn9kjb2u.ev8.philh@comuno.freeserve.co.uk> Message-ID: <Pine.LNX.4.21.BCL.0107091803300.3884-100000@suzi.com.onego.ru> I've said it already somewhere. I think licensing need it's own algebra to resolve equations (and non-equalities ;-) Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From JamesL at Lugoj.Com Sun Jul 22 19:37:00 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Sun, 22 Jul 2001 16:37:00 -0700 Subject: PEP0238 lament References: <mailman.995838436.11056.python-list@python.org> Message-ID: <3B5B639C.FF5961E7@Lugoj.Com> Tim Peters wrote: > Guido hears all the > complaints, and he's become convinced that this is a genuine and serious > flaw in the language: the current rules are *unusable* for too many people > too often. If you're not one of them, congratulations <wink>. I'm not > either -- I never get burned by this. But I see plenty of people who are, > and they're neither stupid nor careless; it's a common blind spot, so it > doesn't really matter that it's not one I (or you) suffer. Well, having learned one set of expectations, I can say that I WILL suffer some pain if this is changed. And it isn't a case of an expectation carried over from another language! Speaking of patterns, it unfortunately appears that Guido has a strong tendency to take the existing user base for granted, since he continues to keep the door open to code-breaking changes. There is only so much insult ("well, what you were doing was bad style anyway," or "you shouldn't have written code that depends on integer division(!)") and injury (the more Python you've written, the more likely something you wrote wont work with the latest version and will need to spend hours reviewing, just-in-case-anyway) before one decides that it just isn't worth the pain. I do not want to continue to write more Python and expose myself to further risk of having it either become dependent on an un-maintained and minority release (e.g. "sorry, you should have upgraded to 3.1 years ago; who writes stuff on 2.1 these days anyway?") or having a growing body of code to constantly shepherd along to insure it runs on the next release. That is the pragmatics from my point of view. And it doesn't give a damn what real or perceived "flaw" in the language is being addressed. From bkelley at wi.mit.edu Wed Jul 18 17:01:20 2001 From: bkelley at wi.mit.edu (Brian Kelley) Date: Wed, 18 Jul 2001 16:01:20 -0500 Subject: Nice graphs from class hierarchies? References: <mailman.995345248.18915.python-list@python.org> <m3itgsyo9k.fsf@kepler.ibp.de> Message-ID: <3B55F91F.A80DC806@wi.mit.edu> markus at kepler.ibp.de wrote: > Roman Suzi <rnd at onego.ru> writes: > > Does anyone know any other tool which can help automatically draw graphs > > (or only trees) with ability to output to PS? > > Dot (see http://www.graphviz.org/) is a powerful program that produces > reasonably beautiful output. I noticed that there was a perl and tcl interface to graphviz, is anyone working on a python interface for doing layouts? If not, I'll step up to the plate. If anyone is interested, I also have a python interface to the unix version of daVinci 2.1 at http://www.informatik.uni-bremen.de/daVinci/ The one redeeming element is that you can write the daVinci graph language directly in python (the syntax is the same as python syntax) for example from the tutorial: >>> g = Graph() >>> g(l("Node A",n("Module",[a("COLOR","#f31d8b"), a("OBJECT","Node A"), a("_GO","ellipse"), a("FONTFAMILY","helvetica")], ... ) You could also build up the graph independently >>> node = n("Module", [a("COLOR","green")]) >>> g(l(node)) Either of these would create a graphical output in the daVinci window. Not all the functionality is added but we had it set up so that you could watch graphs grow and see nodes get deleted. I'll dig this up from the archives and place it on the vaults of parnassus if anyone is interested. Brian Kelley Whitehead Institute From vAbazarov at dAnai.com Fri Jul 20 19:47:10 2001 From: vAbazarov at dAnai.com (Victor Bazarov) Date: Fri, 20 Jul 2001 23:47:10 GMT Subject: Unusual minidom behaviour Message-ID: <2q367.11670$Up.346617@sea-read.news.verio.net> Hi, If I am violating some rules by asking a question that has been asked and answered before, please forward me to FAQ or to a web page/site... I have searched the news archives and can't seem to find anything relevant. I am running a fairly complex system written in Python by using 'exec' method from a Java application. The trouble that I face is that the application (multi-threaded) unpredictably hangs in the minidom's "parse(filename)" function (I figured that by adding "trace" printouts to the Python code. The most puzzling fact is that the hang-up happens not every time I run, and it never happens if I run the same system from a command line. Additional information: if I introduce enough debug print-outs to the system's files, it seems to behave more stably. If I run the Java application under a debugger (even without stopping at any breakpoints), everything seems fine. My colleagues called the situation "maybe there's a race condition". Could it be minidom has problems multi-tasking? More additional information: I first encountered it with Python 2.0, upgrading to Python 2.1 didn't change a thing. This all is on Windows 2000 Pro. The file it needs to parse exists and is not locked. I have not tried the same system on a different OS. I will, I have to. Next week, for sure. I would be grateful for any, no matter how crazy, suggestion. Thank you for reading. Victor -- Please remove capital A's from my address when replying by mail From Lutz.Schroeer at kybernetik-manufaktur.de Mon Jul 2 11:40:20 2001 From: Lutz.Schroeer at kybernetik-manufaktur.de (Lutz Schroeer) Date: 2 Jul 2001 15:40:20 GMT Subject: GUI Builder for Python ? References: <aknrjt8j3cm3qcnpu6qsgvu313rlmi8emg@4ax.com> <3B3DE732.660AF0E1@earthlink.net> <3l1vjtg9cu1jcr78hdgnchmp8bt53cuhbi@4ax.com> Message-ID: <Xns90D2B3C8FB2D9Latzikatz@139.174.2.56> Lothar Scholz <llothar at mailandnews.de> wrote in news:3l1vjtg9cu1jcr78hdgnchmp8bt53cuhbi at 4ax.com: > On Sun, 01 Jul 2001 14:40:34 GMT, Ron Stephens <rdsteph at earthlink.net> > wrote: > I like commercial software if it is worth the money you pay. After > hacking a lot with "Free Software" i more and more hate this kind, > specially for things as complex as good GUI interfaces. Where nearly > all "Freeware" sucks at least at one point. But you do use Python, don't you? Maybe you should use some M$ Visual stuff that's very expensive and therefore has to be excellent... Latz From BPettersen at NAREX.com Thu Jul 12 12:06:58 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Thu, 12 Jul 2001 10:06:58 -0600 Subject: Newbie Question: Regular Expressions Message-ID: <6957F6A694B49A4096F7CFD0D900042F27DB95@admin56.narex.com> > From: fett at tradersdata.com [mailto:fett at tradersdata.com] > > I have a really dumb program that i would like to make > smarter. I need > to take a file on my hard drive and filter out everything > except for the > standings which are written in it. I have tried to use regular > expressions with no success, but i still think that they are probably > the best way. I created the following simple fix, but it is > unreliable > if the data changed posistions. > > > input = open('rawdata', 'r') > S = input.read() > print S[4021:6095] > > Output : > League Standings > American League > EAST W L PCT GB HOME ROAD EAST CENT WEST NL L10 STRK > Red Sox 43 29 .597 - 23-15 20-14 23-13 8-7 6-6 6-3 6-4 L2 > Yankees 41 31 .569 2.0 21-15 20-16 19-11 12-9 5-7 5-4 6-3 W2 > Blue Jays 35 38 .479 8.5 18-20 17-18 14-13 6-7 11-13 4-5 5-5 W3 > Orioles 34 39 .466 9.5 20-20 14-19 15-17 9-12 6-5 4-5 5-5 L1 > ........( it continues with all the standings) How about something like: def findTeam(team, lines): for line in lines: if line.startswith(team): print line break > > Also could you tell me if its possible to download the data from the > web-page in python so that it doesnt even have to deal with > opening the > file. import urllib fp = urllib.urlopen('http://www.yoursite.com') findTeam( fp.readlines() ) hth, -- bjorn From mhuening at zedat.fu-berlin.de Wed Jul 18 09:51:51 2001 From: mhuening at zedat.fu-berlin.de (Matthias Huening) Date: Wed, 18 Jul 2001 15:51:51 +0200 Subject: How to set a timeout? Message-ID: <9j446n$lom9k$1@fu-berlin.de> I have a function like this: ----- def read_pages(urllist): res = {} for x in urllist: try: res[x] = urllib.urlopen(x).read() except: pass return(res) ----- I now want the following behaviour: try to catch the webpage for 3 seconds; if it takes longer just skip this one and move on to the next. How can I achieve this? Thanks, Matthias PS Other suggestions for speeding up the process of reading lets say 100 webpages are welcome... From timothyrandolph at yahoo.com Thu Jul 19 16:46:32 2001 From: timothyrandolph at yahoo.com (Tim Randolph) Date: 19 Jul 2001 20:46:32 GMT Subject: Language change and code breaks References: <Pine.LNX.4.33.0107191316390.24983-100000@bms> <mailman.995571273.18192.python-list@python.org> Message-ID: <9j7gv8$9mg@dispatch.concentric.net> "Guido van Rossum" <guido at digicool.com> wrote in message news:mailman.995571273.18192.python-list at python.org... > > (2) Potentially, the group of non-programmers is much larger than the > group of programmers (and it's easier to teach programmers an > arbitrary rule than non-programmers). I think the distinction between programmers and non-programmers misses a third important group: "sometime programmers" -- people who code occasionally to for fun or to solve problems, but aren't in the trenches (or the cubes) day in and day out. As a member of this group, who is especially fond of Python for how easy it is to pick up where I left off days or weeks before, I would very much prefer a case *insensitive* language with tools that enforce *uniform* case usage. Nobody wants to see fOo and FOO and foo with the same meaning, but nobody wants to see foo and FOO and foo at all in the same program with distinct meanings. I also don't think the cutesy c=C() makes for readable code -- at least for this sometime programmer. little-logs-can-make-for-warm-fires-ly yrs, Tim Randolph > > --Guido van Rossum (home page: http://www.python.org/~guido/) > From ransen_spam_me_not at nemo.it Wed Jul 25 01:32:20 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Wed, 25 Jul 2001 05:32:20 GMT Subject: control-C not responding, short example program References: <3b5d7220.664033@news.newsguy.com> Message-ID: <3b5e59a7.3927973@news.newsguy.com> On Tue, 24 Jul 2001 14:49:35 GMT, ransen_spam_me_not at nemo.it (Owen F. Ransen) wrote: Thanks for all the suggestions, I am indeed running from within IDLE, and for various reasons I need to keep running in IDLE, I'll have a look at the suggestions and see if I can use one of those. Thanks again to all who replied -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From tundra at tundraware.com Thu Jul 26 03:20:03 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 26 Jul 2001 07:20:03 GMT Subject: A use for integer quotients References: <mailman.995866298.23496.python-list@python.org> <cpzo9veuml.fsf@cj20424-a.reston1.va.home.com> <230720010741551768%jwbaxter@spamcop.com> <cpae1tboxg.fsf@cj20424-a.reston1.va.home.com> <4h0tltgbrn2b50mueqd2vsgtt3psvkvosv@4ax.com> <slrn9luefe.5a2.Gareth.McCaughan@g.local> Message-ID: <3B5FC3AE.A8F664B9@tundraware.com> Gareth McCaughan wrote: <SNIP> > > By the way, any definition of "mathematician" that excludes > pure mathematicians is spectacularly broken. In that vein: A mathematician, a physicist, and an engineer were each asked to comment on the assertion "All odd numbers are prime." The mathematician at once gave a counterexample, 9. The physicist said "1 is prime, 3 is prime, 5 is prime, 7 is prime. Now at nine we see second order effects!" The engineer said "1 is prime, 3 is prime, 5 is prime, 7 is prime, 9 is prime..." -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From BPettersen at NAREX.com Thu Jul 19 17:20:36 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Thu, 19 Jul 2001 15:20:36 -0600 Subject: Language change and code breaks Message-ID: <6957F6A694B49A4096F7CFD0D900042F27DB9E@admin56.narex.com> > From: Guido van Rossum [mailto:guido at digicool.com] > > > TRuE, tHe ExPRESsiVity oF ThE lANGuaGE is ProBAbLY nOt cRipPled, > > hOWEvEr, tHere ARe SigNIficantLy FeweR ideNtIFIeRs > AVaILABlE whICh mEAns > > iT is LESs eXPRessIvE. IN pArTicULar, cOMmON Idioms liKE > naMiNg CLASseS > > stArTiNg WiTh UppER cASE lETtERS, AND instaNCeS OF THose cLAsSes > > begINNiNG with A lOwER caSE LettER CaN NO LongeR Be usED. > > Very funny (not). You misunderstood the intention. The programming > environment should be case-preserving, and automatically correct > identifiers to use the same case as used when they were defined. I'm not sure I understand what this means. Are you proposing a "non-programmer" IDE that automatically corrects incorrectly cased identifiers and keywords, or are you still suggesting that the language itself be case insensitive, but with a "non-programmer" IDE that just makes code look consistent? I don't think anyone would be opposed to an auto-correcting IDE. > > AS fAR aS thE Size Of thE VARious camPs, I haVE YeT tO sEe > a coMPeLLinG > > aRGuMeNt thAT THE grOup of noN-pRoGRaMmeRS THat WILl taKe up > > pRoGRAmmInG, ANd wiLL DO sO in PYTHon InsTEad oF VisUal > BasiC, Is any > > LARGeR Than The groUp of ProgRAmmERs. > > With your atttude, it will never happen. What attitude is that? The one where I'd rather write new programs than making sure the tens of thousand lines of Python I've allready written work with a case insensitive interpreter? I don't think I'm the only one with that attitude... :-) -- bjorn From quacko at lists.postmastergeneral.com Fri Jul 20 12:39:02 2001 From: quacko at lists.postmastergeneral.com (Quacko Lotto) Date: Fri, 20 Jul 2001 12:39:02 EDT Subject: PLAY TODAY! WIN $1,000,000 TOMORROW! Message-ID: <200107201650.KAA61450@s0227.pm0.net> **************************************** PLAY TODAY! WIN $1,000,000 TOMORROW! http://lotto.quacko.com **************************************** 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 *********************************************************** RED CARPET REWARDS AT GRAND BANKS CASINO http://www.grandbankscasino.com/default.asp?from=1072 *********************************************************** Red Carpet Rewards! The best way to earn free credits! Grand Banks casino is rolling out the Red Carpet for our patrons! For every $10 in real bets that you place, Grand Banks will credit your account with one comp point. Collect 100 comp points and you will receive one casino credit! It's so simple and calculated automatically for you. Example: Place a $100 wager on one hand of Blackjack and receive 10 Red Carpet Reward points. Do this 10 times & regardless of the outcome you will have amassed 100 Red Carpet Points. These 100 points now automatically convert to a FREE Grand Banks Casino credit! http://www.grandbankscasino.com/default.asp?from=1072 The Red Carpet Rewards Premier Program: For our more serious players we offer an even more aggressive plan to help you amass points more quickly! The structure is the same, but you will receive 1 Red Carpet point for every $7.50 placed in bets! Please note that Grand Banks reserves the right to invite patrons into the Premier program only. http://www.grandbankscasino.com/default.asp?from=1072 <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> * 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 kav062 at yahoo.com Fri Jul 27 17:08:36 2001 From: kav062 at yahoo.com (Kannan Vijayan) Date: 27 Jul 2001 14:08:36 -0700 Subject: File Reading , Reverse Direction References: <3B60F7EC.5275E026@lsu.edu> Message-ID: <a1364c9f.0107271308.66a5246@posting.google.com> Ratnakar Malla <rmalla1 at lsu.edu> wrote in message news:<3B60F7EC.5275E026 at lsu.edu>... > Hi, > I need to read from a very long file. But the only information I am > interested is > 2 lines at the bottom of the file. > 1) Can i read the file in the reverse direction , so that I dont lose > time? > 2) If so how?? > 3) I tried the normal way, but looks like, it is taking lot of time. > Thanx, > Ratnakar Malla > > -- A modification of Peter Hansen's code: i = -4096 file.seek(i, 2) lines = file.readlines() while len(lines) <= 2: i -= 4096 file.seek(i, 2) lines = file.readlines() lines = lines[-2:] The 4096 is about 1-4 pages on most filesystems, so it should be reasonably fast, and incur about the same amount of overhead as seeking -50. It's multiple seeks, but if your'e dealing with large files, it's better than going headfirst through the lines. -kannan From bernhard at intevation.de Thu Jul 26 13:36:23 2001 From: bernhard at intevation.de (Bernhard Reiter) Date: 26 Jul 2001 17:36:23 GMT Subject: Herbrip-0.1.0 released References: <slrn9lm5lq.5g3.philh@comuno.freeserve.co.uk> Message-ID: <9jpken$rqun$7@ID-89274.news.dfncis.de> [Posted and mailed] Hi Phil, good to see more Free Software for this topic. Here is my feedback. Herbivore seems to be too small as a project to get to critical mass. If GNUPG is integrated nicely in the MUA people actually start using it. (mutt is most advanced regarding the integration.) Handling actually is as easy as you describe it, except for the Key part. Herbivore avoids the hassle about the public key handling, which is its main advantage. On the other hand, people will have to learn this concept anyway for several reasons. Herbivore cannot handle MIME well (AFAIC), which is the hard part of MUA encrypting integration. Something like RFC2015 PGP/MIME is needed for the concept, too. Plugins for other platforms and reaching critical mass are the main technical problems preventing mass email encryption. Gnupg and the GPA-Project are trying to address this. Hopefully the Germany Ministry of Commerce will financially support another project to support excactly this goal. Bernhard In article <slrn9lm5lq.5g3.philh at comuno.freeserve.co.uk>, philh at comuno.freeserve.co.uk (phil hunt) writes: > Herbivore is an initiative to encourage more people to use > encrypted email. > Herbrip is a command-line implementation of the Herbivore > protocol. In the future, I plan to extend Herbrip's functionality > and integrate it into one or more open source email clients. -- 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 quinn at yak.ugcs.caltech.edu Wed Jul 11 18:22:16 2001 From: quinn at yak.ugcs.caltech.edu (Quinn Dunkan) Date: 11 Jul 2001 22:22:16 GMT Subject: Long Live Python! References: <mailman.994874959.29064.python-list@python.org> <slrn9kpe08.496.sill@sill.silmarill.org> Message-ID: <slrn9kpkco.32b.quinn@yak.ugcs.caltech.edu> On Wed, 11 Jul 2001 20:34:17 GMT, Rainy <sill at optonline.net> wrote: >On Wed, 11 Jul 2001 12:10:43 -0600 (MDT), Bruce Sass <bsass at freenet.edmonton.ab.ca> wrote: >> On Wed, 11 Jul 2001, phil hunt wrote: >>> On Tue, 10 Jul 2001 15:31:11 -0700, Paul Prescod <paulp at ActiveState.com> wrote: >> <...> >>> >Python does not have a niche and is not obviously a niche-friendly >>> >language. >>> >>> Sure it does: python's niche is as a scripting language that's also good >>> for longer programs. >> >> Hehe, you must have missed the recent thread about removing the first >> line from a text file... I thought it showed that Python is a horrible >> scripting language, way too verbose, it turned what should be a few >> lines of script into a program. > >Wasn't one solution only 2 lines? If I remember right it was Alex >Martelli's. open(output, 'w').writelines(open(input).readlines()[1:]) ... can I go back to using python a scripting language now? Here's a superior solution: import sys sys.stdout.writelines(sys.stdin.readlines()[1:]) A mere semicolon could turn this two line program monstrosity back into a beautifully script-like one line. From aleaxit at yahoo.com Thu Jul 12 06:26:40 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 12 Jul 2001 12:26:40 +0200 Subject: about extension module References: <mailman.994919065.24113.python-list@python.org> Message-ID: <9iju1002i7e@enews4.newsguy.com> "binto bient" <python_binto at yahoo.com> wrote in message news:mailman.994919065.24113.python-list at python.org... > > hi, is there somebody know the procedure to make... > extension module, because i confuse when i follow > Python/C API Reference Manual, by Guido van Rossum > what do i need to make extension module.. Try...: http://starship.python.net/crew/arcege/extwriting/pyext.html Alex From GeorgLohrer at gmx.de Mon Jul 2 12:05:10 2001 From: GeorgLohrer at gmx.de (Georg Lohrer) Date: Mon, 02 Jul 2001 18:05:10 +0200 Subject: Singleton classes (with no such thing as static variables) References: <MdY%6.168$iF.4908@news.lhr.globix.net> Message-ID: <v361kts2pk9o86stkn68pp5vdtb0ek7gg4@4ax.com> On Mon, 02 Jul 2001 11:45:24 +0100, Giles Constant <gilesc at hyperlink-interactive.co.uk> wrote: >Hi there, > >Being a C++ head, it's probably more a problem with my design than a python >problem, but I figured you guys would be able to help. > >I'm trying to make a class called "Environment" which will store some >global data such that all instances of the class have access to it. The >alternative is to create a single instance and pass it around every single >object in the entire project, but it gets used so frequently that it would >be rediculous. > >Is there a way of doing this, or do I need a new paradigm? :-) Maybe the latter one. I'm also an old fellow with C (over 15 yrs) and C++ (8 yrs) and I like sophisticated stuff (like Guru-of-the-week, etc.). But starting Python a year ago I've to throw away some of my current point of views. Sometimes because they are not common or even possible in Python or because I misunderstood the patterns of a interpreted language like Python. Oh, you could realize most of good object patterns in Python, too. But if it is necessary or even sensefull, it seems to be doubtful, because the concept and the paradigm of an interpreted language is really different. But, to be honest, it's more a feeling of getting a successfull approach towards a solution with Python. Two days ago, I reviewed some three months old code (rather running fine and correct) and I eliminated a lot of stuff and replaced it with more Python-like code (the old one was a more or less C++-to-Python translation) and the code runs faster and it spends a better feeling seeing the code (if you understand what I mean -- if you see a graceful piece of code in your favourite language it will be well-formed and you could see/feel it.) BTW, currently I'm doing half of my work in C++, the rest in Python, and I everytime like the return to Python. But I really "hate" the effective cycle of editing-running-debugging-editing. Sometimes there is a melange of all these things -- I've never had this ever before -- and it's marvellous. My speed of producing correct code was doubled, but with compiler-languages you always have some time for relaxing (during compilation/linking), but with languages like Python its away :-(( So, after one or two hours of pythoning, I need a rest for getting some relaxation. Like now, Ciao, Georg From wpt2097 at hotmail.com Tue Jul 31 02:31:55 2001 From: wpt2097 at hotmail.com (andreas) Date: 30 Jul 2001 23:31:55 -0700 Subject: Listing directorycontent in python Message-ID: <1aa68e6e.0107302231.dd024a2@posting.google.com> Hello. I have a simple question, I want to have a list of all files/dirs in a certain directory. An example would be that I want to know all filenames that end with "*.JPG" in the directory "/var/www/". I have not succeeded in doing this myself with "os.path"-module, so I am now asking for tips, hints, examples or pointers to answers of previous similar posts. I am using Python v1.5 most of the time. TIA Andreas From jp at ulgo.koti.com.pl Sat Jul 21 08:52:54 2001 From: jp at ulgo.koti.com.pl (Jacek =?iso-8859-2?Q?Pop=B3awski?=) Date: 21 Jul 2001 12:52:54 GMT Subject: VRML Message-ID: <slrn9liuit.a6f.jp@localhost.localdomain> Hello. I am writing car game for Linux. To create 3D objects I use Blender, save with alt+w which gives simple "videoscape format". I think VRML will be much better. It will be great to create converter between VRML and my own format. What I need is Python library which helps me read VRML. I searched www.python.org, freshmeat and sourceforge. I found some projects, but one is in C++ and not so easy (example app is huge!), seconds is in Python and I can't find "download" section anywhere. Can you help me? -- Turn round slowly Tell us what you see Oh no - The fly got the spider And now he's chasing me "Otherworld" - Ronnie James Dio From Heikki.Tuuri at innobase.inet.fi Sun Jul 8 11:18:24 2001 From: Heikki.Tuuri at innobase.inet.fi (Heikki Tuuri) Date: Sun, 08 Jul 2001 15:18:24 GMT Subject: a gadfly SQL question --- table creation References: <n237ktc10fithjhm8vj4pfkmrq7k4fjop8@4ax.com> <Xns90D5704F23F1Catodddexterpinioncom@203.2.194.51> <qlk7kto6lcqqsm2dslsmvrp5eeu3bhpdf7@4ax.com> <Xns90D59D0D33B09atodddexterpinioncom@203.2.194.51> <luf8kt4t8e5urfata61qfu9c90otqi9puv@4ax.com> <Xns90D5EB408F9D5atodddexterpinioncom@203.2.194.51> Message-ID: <4R_17.81$rR1.5521@read2.inet.fi> Hi! MySQL supports transactions through BDB and InnoDB on all platforms MySQL runs on. You have to download the -Max version of the MySQL binary from the MySQL website. See http://ww.innodb.com for more info. Regards, Heikki Tuuri Innobase Oy Andy Todd wrote in message ... >Joe Potter <jm7potter at hotmail.com> wrote in ><luf8kt4t8e5urfata61qfu9c90otqi9puv at 4ax.com>: > >>On Thu, 05 Jul 2001 05:26:39 GMT, andy_todd at spam.free.yahoo.com (Andy >>Todd) wrote: >> >>>Joe Potter <jm7potter at hotmail.com> wrote in >>><qlk7kto6lcqqsm2dslsmvrp5eeu3bhpdf7 at 4ax.com>: >>> >>>>On Thu, 05 Jul 2001 00:55:36 GMT, andy_todd at spam.free.yahoo.com (Andy >>>>Todd) wrote: >>>> >>>>>Joe Potter <jm7potter at hotmail.com> wrote in >>>>><n237ktc10fithjhm8vj4pfkmrq7k4fjop8 at 4ax.com>: >>>>> >[major snippage] >>> >> >>I am reading a book on SQL that covers MySQL. >> >>But, in this one post you covered my main problem. I could not find >>where the magic words like "cursor.fetchall()" were coming from. I was >>reduced to looking at the Gadfly code and making a list of magic code. >> >>But, with DB-API spec I see where they are coming from. > >Smashing. One final point. MySQL doesn't currently include transactions >(unless you are running it on GNU/Linux with the BSDDB extensions) so >beware of multi user commits and rollbacks. They can come in useful and yet >frustrate you endlessly. > >> >>All praise to Andy on this fine morning. >> >>Thanks ever so much. >> >[more snipping] >> >> >>Thanks again. >> >>Regards, Joe >> > >Always a pleasure, never a chore. > >Regards, >Andy > >-- >Content free posts a speciality From paul at boddie.net Wed Jul 25 05:10:22 2001 From: paul at boddie.net (Paul Boddie) Date: 25 Jul 2001 02:10:22 -0700 Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <mailman.995943227.11347.python-list@python.org> <23891c90.0107240109.5b7072d4@posting.google.com> <cpd76pbpfh.fsf@cj20424-a.reston1.va.home.com> Message-ID: <23891c90.0107250110.632b70e@posting.google.com> Guido van Rossum <guido at python.org> wrote in message news:<cpd76pbpfh.fsf at cj20424-a.reston1.va.home.com>... > paul at boddie.net (Paul Boddie) writes: > > > If someone had suggested using // for the int/int->float operation, I > > bet that hardly anyone would have complained, apart from some people > > who might consider it "language bloat". But instead, it seems that for > > the sake of some aesthetic principle the rug is being pulled out from > > under everyone whether they want to lie down or not. > > It's not just an aesthetic principle. The currently / behavior is a > design mistake that needs to be eventually eradicated, because it > makes writing reliable cood too hard and it makes writing subtly > broken code too easy. The only way to do that is to bite the bullet > -- otherwise Python will still have this problem in 10 years. I don't disagree with your assertion that it's a bad thing. The problem is that the / operator has a well-defined meaning in Python which you're seeking to change. Whether or not it has a desirable behaviour is almost irrelevant to the strongest argument to leave it be: that changing its behaviour will potentially break lots of old code. I haven't seen any adequate response to the proposal that a different operator (such as //, although I don't care so much) be used. And in the PEP, whilst backward compatibility is mentioned, it isn't addressed in any way which can be considered an acceptable treatment of the subject. > I can live with a temporary language wart that we're committed to > removing. I don't want to live with the wart forever, which the other > solution would do. You have designed a language which I and many others really enjoy using, and are really grateful for. Whilst programming languages tend to differ from natural languages by resisting change in order to promote robust, well-defined semantics, what you are doing here is analogous to issuing a decree that a particular word in English/Dutch/French (or your preferred natural language), where the word isn't exactly an infrequently used noun, now means something else. What do you propose we do with all the novels ever written in that language? Instigate a massive rewriting project? Burn them? Did Monty Python ever do a sketch about the Cultural Revolution? <1/3 wink> > (Another argument for PEP 238, which I made in another message, is > that it opens to way to a unified numeric model, hinted at by PEP > 228. I will update both PEPs to greatly improve the motivational > sections.) Your numerical aspirations are noble, but due to practical considerations won't some of us end up speaking "Dutch" and some of us speaking "Flemish"? ;-) Paul From alf at leo.logilab.fr Fri Jul 6 10:23:06 2001 From: alf at leo.logilab.fr (Alexandre Fayolle) Date: Fri, 6 Jul 2001 14:23:06 +0000 (UTC) Subject: pb with xmlrpclib References: <slrn9kbfd5.42n.alf@leo.logilab.fr> <3b45c3c4$1_7@news5.uncensored-news.com> Message-ID: <slrn9kbilr.4h3.alf@leo.logilab.fr> On 6 Jul 2001 14:57:27 +0100, Doug Fort <dougfort at dougfort.net> wrote: > >The XML-RPC standard only supports ASCII text. (I found this our from the >new O'Reilly book 'Programming Web Services with XML-RPC'. The book is >pretty light weight (I skimmed it in an hour) but it has some worthwhile >tidbits. Thanks for the reference, I'll try to get my hands on it. However, right now, I'm just using xmlrpc as a nice, quick and lightweight way of doing rpc between two python applications. (if someone can suggest another method, as easy as this one, I'll be glad to give it a try). Concerning the ascii stuff, could someone then explain to me what is meant on http://www.pythonware.com/products/xmlrpc/index.htm by : "xmlrpclib 0.9.9 (aka 1.0b1) is now available. This is a development release (hopefully the last one before 1.0 final), which adds support for encodings, Unicode, and HTTPS transports." ? ^^^^^^^^^^^^^^^^^^ TIA Alexandre Fayolle -- LOGILAB, Paris (France). http://www.logilab.com http://www.logilab.fr http://www.logilab.org Narval, the first software agent available as free software (GPL). From aahz at panix.com Tue Jul 3 18:59:16 2001 From: aahz at panix.com (Aahz Maruch) Date: 3 Jul 2001 15:59:16 -0700 Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hrj3q$cj1@news1.gtech.com> <bebbba07.0107031040.593143f8@posting.google.com> <9htgsb$ck3@news1.gtech.com> Message-ID: <9htio4$dtf$1@panix2.panix.com> In article <9htgsb$ck3 at news1.gtech.com>, Peter Milliken <peter.milliken at gtech.com> wrote: > >There are studies that indicate that productivity in strongly typed >languages is higher (2:1 in one study I read - unfortunately, they >are "thin" on the ground because you need two identical ability teams >doing the same application in two different languages to get meaningful >comparisions - but it has been done and that was the result) than >loosely typed languages. Note that Python *is* a strongly-typed language, it's just that it is dynamically typed instead of statically typed. -- --- 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'm not tense, i'm just terribly, terribly alert" --unknown From timr at probo.com Wed Jul 25 02:40:21 2001 From: timr at probo.com (Tim Roberts) Date: Tue, 24 Jul 2001 23:40:21 -0700 Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <eppstein-03540D.13070222072001@news.service.uci.edu> <LNBBLJKPBEHFEDALKOLCOECNLAAA.tim.one@home.com> <mailman.995899647.346.python-list@python.org> <tclolt053o18f8q0ntb7n4aggitdkmeg4h@4ax.com> Message-ID: <4dqslt4pj7algruf69gg3497m663gggjnf@4ax.com> Steve Horne <sh at ttsoftware.co.uk> wrote: > >Intellectual decline is not what it used to be ;-) - apparently the >avarage childs IQ these days (I forget the exact age range) is around >120. Must it's all the TV and video games ;-) The average child's IQ these days is 100. That is the very definition of IQ. -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mikael at isy.liu.se Wed Jul 25 03:41:02 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Wed, 25 Jul 2001 09:41:02 +0200 (MET DST) Subject: proposed language change to int/int==float (was: PEP0238 lam In-Reply-To: <9jlo4v$rhbl$1@sky.inp.nsk.su> Message-ID: <XFMail.20010725094057.mikael@isy.liu.se> On 25-Jul-2001 Andy Salnikov wrote: > To many of us, programmers, 1/2 is 0 with 1 as a reminder:) We are like > children, and any child will say _for sure_ that 1 cookie for two children > means one cookie for 1 child and 0 cookies for another:) Sorry, that throws an exception (i.e. one of the children gets mad). One cookie for two children means 0 cookies for both children, since mom or dad did not serve that one cookie at all. After all that is the meaning of 1/2 being 0 with 1 as a remainder. Then-again-some-cookies-can-be-cut-in-pieces-ly y'rs /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson <mikael at isy.liu.se> WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 25-Jul-2001 Time: 09:35:20 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From thecalm at NOSPAM.btinternet.com Thu Jul 19 15:00:46 2001 From: thecalm at NOSPAM.btinternet.com (G. Willoughby) Date: Thu, 19 Jul 2001 20:00:46 +0100 Subject: Make an *.EXE Using Python. References: <oAI17.647550$166.13393459@news1.rdc1.bc.home.com> <7b515e0f.0107081724.56b2a434@posting.google.com> Message-ID: <9j7ao4$ir$1@neptunium.btinternet.com> thanks that works great! but one more question... i have compiled my script to an .exe BUT is there a way of getting rid of the console window. i tried: pythonw setup.py py2exe instead of python setup.py py2exe but this only copied the 'tcl' dir to the 'dist' dir! any ideas??? Gaz. "eric_brake" <brakedon at hotmail.com> wrote in message news:7b515e0f.0107081724.56b2a434 at posting.google.com... > "EricIDLE" <grayson-wilson at home.com> wrote in message news:<oAI17.647550$166.13393459 at news1.rdc1.bc.home.com>... > > Hello, > > I was wondering is there a way to make a exe using Python? > > I seem to remeber vagely that there was a "Make EXE" choice under the file > > menu but its no longer there (If it ever was) so if you can give me a hand > > with this it would be great. > > You will need to create a "setup.py" file. Here is the working code that I use. > > from distutils.core import setup > import py2exe > setup(name = "filename", #not sure what this does, but it doesn't hurt anything > version = "1.0", #meta info, shows up in the exe you make > author = "John Doe", #meta info, your name > author_email = "johndoe at somewhere.com",#meta info, author email > scripts = ["yourfile.py"])#target script, the script you want to make an > #exe with From bit_bucket5 at hotmail.com Wed Jul 25 19:09:02 2001 From: bit_bucket5 at hotmail.com (Chris Stromberger) Date: Wed, 25 Jul 2001 23:09:02 GMT Subject: How to telnet to other unix machines and grep log files etc? References: <fa7108b0.0107250742.7b38c678@posting.google.com> <slrn9lu024.vpg.quinn@regurgitate.ugcs.caltech.edu> <slrn9lu0fg.vpg.quinn@regurgitate.ugcs.caltech.edu> <3E9DA22F3FF99072.0E52F24E38E09F05.89F1DF1C896E89C5@lp.airnews.net> Message-ID: <25jult8co0bqqu557i9i6jpmepvgepglug@4ax.com> On 25 Jul 2001 14:13:20 -0500, claird at starbase.neosoft.com (Cameron Laird) wrote: >In article <slrn9lu0fg.vpg.quinn at regurgitate.ugcs.caltech.edu>, >Quinn Dunkan <quinn at regurgitate.ugcs.caltech.edu> wrote: >>On 25 Jul 2001 17:22:12 GMT, Quinn Dunkan <quinn at regurgitate.ugcs.caltech.edu> >>wrote: >>>On 25 Jul 2001 08:42:44 -0700, Chris <bit_bucket5 at hotmail.com> wrote: >>>>Relative unix newbie. Would like to write a python script to do what >>>>I do manually--telnet to two different unix machines from a third unix >>>>machine. Grep through some log files, gather the grep results from >>>>the different machines and spit them out. I think I need to do >>>>something with popen, or popen2, or ??? I don't know where to start. >>>>Any pointers much appreciated. >>> >>>This is a shell task: >>> >>>(ssh machine1 'grep foo /sys/log/bar'; >>> ssh machine2 'grep baz /sys/log/faz') >results >>> >>>Create an RSA key with no passphrase if you don't want to have to type >>>passwords all the time. >> >>BTW, if you *really* wanted to use python for it, you couldn't use popen >>(stdio wins again!). You'd need to use ptys to trick telnet that it's being >>run by a terminal. That means either figuring out how unix ptys work and >>using pty.py, or installing expect and ExpectPy. Both are more work than >>installing openssh (and once you do that you can toss telnet anyway). >> >>Unless, of course, machine{1,2} don't have ssh and you have no control over >>them. There are any number of ugly hacks you could do at that point, and >>expect is one of them. >> >>or-publish-the-logs-on-the-web-and-use-wget-ly y'rs > >Exactly. That is, ssh is a fine way to solve these >problems--unless you don't have control over the re- >mote end. > >Long term, ExpectPy might be in better shape than >you realize. There are glimmers of hope that Expect >might be rewritten in a way that eases maintenance >of ExpectPy (and maybe brings Win* within range, too). >In the meantime, you might consider using stock Expect. >You might be able to get your job done with just a few >lines. If you need more, there are plenty of ways to >tie together Tcl and Python codings. Unfortunately, I have no control over either end! Not even over the Python installation. It's 1.5.6 (or whatever was just before 2.0). Was hoping there was some magically easy way to do this, like there usually is with Python. Thanks for the suggestions. From Juha.Syrjala at iki.fi Tue Jul 31 17:21:28 2001 From: Juha.Syrjala at iki.fi (Juha =?iso-8859-1?Q?Syrj=E4l=E4?=) Date: 31 Jul 2001 21:21:28 GMT Subject: decent syslog replacement? References: <mailman.996601142.13364.python-list@python.org> Message-ID: <9k77go$21du5$1@midnight.cs.hut.fi> In article <mailman.996601142.13364.python-list at python.org>, Nicholas Henke wrote: >Thanks...I forgot about the syslog - thing...The main problem is the >syslog disk thrashing...I guess I wasnt really clear about that. Are there >any clean options to buffer even more than syslog might do? One thing you might try is to use syslog to send the logs to another machine. This makes disk trashing happen in a different machine. And logging might not be too reliable since syslog uses UDP. There is also syslog replacement called syslog-ng which might be more efficient. -- Juha Syrj?l? From robin at jessikat.fsnet.co.uk Tue Jul 24 06:20:20 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Tue, 24 Jul 2001 11:20:20 +0100 Subject: A use for integer quotients References: <mailman.995866298.23496.python-list@python.org> <eppstein-E19F08.00451323072001@news.service.uci.edu> <3B5BDCB4.A2010560@letterror.com> <GbW67.19921$EP6.4914854@news1.rdc2.pa.home.com> <3B5C3713.A5201C5A@letterror.com> <mailman.995966145.31953.python-list@python.org> Message-ID: <3gDsvgAkvUX7EwIv@jessikat.fsnet.co.uk> In article <mailman.995966145.31953.python-list at python.org>, Glen Wheeler <wheelege at tsn.cc> writes ... > Right, I think this is a good time for everybody to cool down...Just is >clearly not being offensive here. > The same arguments are being stated over and over again by the pro 1/2==0 >side, and the same refutements are being stated by the other side. > My opinion is that if Guido wants it changed even in the light of all >these arguments, then so be it. Sure I'll have to change a little bit of >code, but that's alright. I distribute alot of my stuff as stand-alone >packages anyway - the user never has to worry about upgrading, unless it's >>MY< upgrade - which isn't going to break anything. > > Glen. I'll probably have to look at a lot of code, even Guido found a majority for the library / usages as relying on int behaviour; something he seemed surprised by. How odd, I am not at all surprised that programmers make real use of a useful behaviour. The whole PEP process is also broken by Guido's unilateral decision; we're informed by Tim that the he simply decided to correct a design fault. Our real failure is not appreciating that the leadership has different motives and plans for python than most of the current userbase. Is there a list of the other design failures that the mdfl plans to fix? I do hope case sensitivity is not one of them. -- Robin Becker From guido at python.org Tue Jul 24 17:46:15 2001 From: guido at python.org (Guido van Rossum) Date: Tue, 24 Jul 2001 21:46:15 GMT Subject: PEP0238 lament References: <5sdnlt072hm6hp17nluu6f0fqq4bvr6mj8@4ax.com> <mailman.995873261.11975.python-list@python.org> <916olt0p3kciv0evmotdg6jev9bl29l57i@4ax.com> <Xns90E77C7A1776Cjimpublishingresourc@207.126.101.100> <3B5C52EA.9430255E@alcyone.com> Message-ID: <cpofqaova7.fsf@cj20424-a.reston1.va.home.com> > Jim Abrams wrote: > > > Because every camel has its straw, I need to agree here. I, and most > > of my python buddies, fight with bloodstained teeth and nails to get > > python in our projects and developments. I can't see winning too many > > arguments when my opposition can pull out 'the division operator' to > > shoot me down. I can't see budgeting time and people to making sure > > the division operator works after an upgrade. I'd be laughed into data > > entry ;). Erik Max Francis <max at alcyone.com> writes: > Indeed. If this is implemented, it will be a black eye for Python. Any > anti-Python advocate will be able to point at this and say, "Look, > that's why you shouldn't switch to Python. The semantics of the builtin > operators changes from release to release." Problem is, they will be > absolutely right. This seems to be the crux of the anti-PEP-238 sentiments, and I want to take it very, very seriously -- without losing the PEP. If you agree that, if it weren't for breaking old code, PEP-238 would make Python a better language, what can we do about that old code? I propose the following measures. Let's discuss whether these are conservative enough, from the perspective of someone who has a large body of old working Python code. (From the perspective of someone who wants int division for other reasons, these can never be conservative enough. :-) (1) A very long wait period before the new division becomes the default. The PPE mentions at least two years; we can go over that. Python 2.2 will introduce the first release where it's *possible* to write "from __future__ import division"; we'll have to wait until 1.5.2 is only a faint memory (like 1.4 is now) and 2.2 pretty old. (The current release pace is two revisions per year, so two years would make 2.6 the first release where new division is the default.) (2) A command line option to change division semantics. I propose -Dnew to make the new division semantics the default, -Dold to make the old semantics the default. -Dold will be the default until the wait period is over, then -Dnew will become the default. The -D option is retired when nobody needs -Dold any more. Modules that contain a future statement always use the new default; there's no way to force the old default on a *per-module* basis (since that would be a language feature that could never be removed). (3) As of 2.2, all the standard library code should work regardless of the -D option. That is, all library modules (and modules in Demo and Tools) should use // whenever int division is required, and should use the future statement whenever float division is required. This is necessary so that use of the -D command line option doesn't break the standard library. Anything else? --Guido van Rossum (home page: http://www.python.org/~guido/) From aleaxit at yahoo.com Mon Jul 9 13:42:01 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 9 Jul 2001 19:42:01 +0200 Subject: [TO]What's the big deal with EJB? [Re: PEP scepticism] References: <mailman.993747643.21070.python-list@python.org> <9hfqb5$dsllb$3@ID-89274.news.dfncis.de> <3dhex01n1m.fsf@ute.cnri.reston.va.us> <etdk81vduw0.fsf_-_@lola-granola.mit.edu> <3d8zib16g7.fsf@ute.cnri.reston.va.us> <Xns90D3694AD53FBbeablebeable@30.146.28.98> <yoxd77fh4pr.fsf@karhu.tp.spt.fi> <9i201402voe@enews1.newsguy.com> <mailman.994350172.18735.python-list@python.org> <9i2jva23cm@enews2.newsguy.com> <3B45C48D.413A5E@divalsim.it> <9i56ph0eke@enews4.newsguy.com> <3B496B96.A0F46A0B@divalsim.it> Message-ID: <9icqb30gvq@enews2.newsguy.com> "Nicola Musatti" <objectway at divalsim.it> wrote in message news:3B496B96.A0F46A0B at divalsim.it... > Another question: hom much of the productivity increase would you > attribute to the core language and how much to the availability (or lack > thereof) of useful functionality in the language library? I'm just guessing here, because I did not even try to separate the effects. But offhand, I would say that, considering the specific tasks I was doing (proprietary protocols on top of sockets, basically, if the C++ vs Java comparison is still what we're talking about), the lack of the C++ Standard Library hurt by slightly more than the extras in Java's libraries helped. It might have been very different if my task had been to work cross-platform on an RDBMS, for example (assuming I could use JDBC in Java but not ODBC in C++, say) -- or other such tasks for which Java's extremely rich libraries help and C++ Standard Libraries plus C-level stuff (such as sockets in my case) don't, much. Alex From michael at stroeder.com Thu Jul 12 05:48:01 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Thu, 12 Jul 2001 11:48:01 +0200 Subject: Coexistence of SOAP-server and MS-IIS References: <3b4dd214.587664066@news.mch.sni.de> Message-ID: <3B4D7251.22638220@stroeder.com> Nikolai Kirsebom wrote: > > I have a web-server running IIS and would like to make a small > testapplication using the SOAP protocol. Is it possible to have both > IIS running and a SOAP-server running on the same machine, or will > they 'fight' for the same resources (communication). Never heard of running demons on different ports? Now's the time for you to learn about host:port addressing... Ciao, Michael. From tjreedy at home.com Tue Jul 31 14:43:09 2001 From: tjreedy at home.com (Terry Reedy) Date: Tue, 31 Jul 2001 18:43:09 GMT Subject: Control of flow References: <Pine.LNX.4.31.0107311355450.2321-100000@cb921.local> Message-ID: <1%C97.56179$EP6.12833513@news1.rdc2.pa.home.com> "Campbell" <cb921 at voice.co.za> wrote in message news:Pine.LNX.4.31.0107311355450.2321-100000 at cb921.local... > I use python to write telephony apps, and I find that a 'goto' is often > a nice tool (stop going 'aargh', its properly "useful" sometimes =). Indeed. Once, when revising a Unix serial port driver, I used a goto to efficiently escape from three levels of nested loops. Very useful there :-). However, using them to emulate, one at a time, state transition machines, seems like a road to madness, as in "> It gets worse quite easily". Given that you said 'apps' plural, and the example you gave thereof, I would first design a state transition structure that is specific to your application class but generic within it: initial and intermediate states are 'get data x with prompt x.vox'; terminal states are 'here is result y. thank you <click>". Then I would write a program to execute the machine defined by a particular set of states. At this point, 'programming' an app within the class would consist of drawing a transition diagram, which a client could inspect and sign off on, and then translating to the defined structure. Terry J. Reedy From peter at engcorp.com Fri Jul 6 00:00:04 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 06 Jul 2001 00:00:04 -0400 Subject: Two problems with backslashes References: <Xns90D4A141E71CDgustaflalgonetse@194.213.69.148> <mailman.994256588.17929.python-list@python.org> <Xns90D4AEEA4B92Agustaflalgonetse@194.213.69.152> <9hvcu5$fu4ja$1@ID-11957.news.dfncis.de> <Xns90D4BD1F823A1gustaflalgonetse@194.213.69.148> Message-ID: <3B4537C4.F8B4482E@engcorp.com> Gustaf Liljegren wrote: > > "Emile van Sebille" <emile at fenx.com> wrote: > > >#test.py: > >import getopt, sys > >print getopt.getopt(sys.argv[1:], "") > > > >F:\Python21>python test.py c:\test > >([], ['c:\\test']) [examples reinserted by peter at engcorp.com] > > > >So it appears to work here using getopt. Something else must be going > >on. Can you post an example that generates the string with the embedded > >tabs? > > Thank you. I had no idea that Python would add the extra backslash > automatically. Tried to isolate the problem before trying the whole thing > on getopt. This solved the problem on a more appropriate level. Gustaf, Python does _not_ "add the extra backslash". What is shown above as ([], ['c:\\test']) is just a printable *representation* of the content of the string, which actually contains only a single backslash. If you print a string directly (e.g. 'print "some text"') then the actual sequence of bytes in the string is output, and whatever non-printing characters (control characters) you may have will affect the output. If instead you print a tuple or list containing a string (or a tuple containing a list which contains a string as in the above example), Python will print instead a special representation of the data, and any contained strings will be printed with special control characters escaped so they don't mess up the output (and so that the same data could be used as input to generate exactly the same data again in certain ways). So: >>> a = 'c:\\test' >>> a 'c:\\test' >>> print a c:\test >>> print len(a) 7 >>> b = 'c:\test' >>> b 'c:\test' >>> print b c: est >>> print len(b) 6 The string 'a' contains seven bytes where the third byte is a backslash. The string 'b' contains only six bytes where the third byte is the tab character (formed when you use a backslash followed by a 't' in a string). It looks like you solved the problem, but from your message above it didn't sound like you had completely understood how string entry, string representations when printing, and raw strings all work in Python. I hope this helps a little. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From paul at boddie.net Fri Jul 27 05:38:46 2001 From: paul at boddie.net (Paul Boddie) Date: 27 Jul 2001 02:38:46 -0700 Subject: PEP 238 (revised) References: <cp4rrz5onj.fsf@cj20424-a.reston1.va.home.com> <3B60B3D5.664A3D7F@engcorp.com> Message-ID: <23891c90.0107270138.6bb70413@posting.google.com> Peter Hansen <peter at engcorp.com> wrote in message news:<3B60B3D5.664A3D7F at engcorp.com>... > > The updated PEP also makes no mention of a utility for scanning > existing code to check for potential problems. Is this considered > an intractable problem? Is there any commitment to doing this, > eventually, as part of the implementation of this PEP? Or is the > presence of the "warn" option considered sufficient (to allow for > testing, rather than scanning)? I'm really disappointed that the "migration" process hasn't been addressed in the PEP, since the disruptive nature of the changes to division constitute my principal objection to the adoption of these changes. I get the impression that there isn't a good solution to this problem, and since this situation could hinder "progress", it is being "swept under the carpet". But possibly the first thing anyone with any investment in the language should be thinking upon starting to read the PEP is: "How on Earth am I going to know what needs changing, and how much time and money am I going to be spending to adapt to this?" One could suggest (as I did before) that until such time as effective type inference/analysis tools are available, this change shouldn't go through. Paul From garry at sage.att.com Tue Jul 24 11:53:46 2001 From: garry at sage.att.com (Garry Hodgson) Date: Tue, 24 Jul 2001 15:53:46 GMT Subject: IPC10 Call For Tutorials Message-ID: <3B5D9A09.A49F7C7B@sage.att.com> We're now accepting proposals for tutorials for IPC10, the annual Python conference. We had a good batch last year, and are hoping to have some equally good ones this year. Tutorials can cover any topic related to Python or its use, so graphics, networking, web, XML, Zope, etc are all fair game. Anything that you think will be of interest to a segment of the Python community. With all the changes in the language, it might be nice to have a tutorial on advanced Python usage, covering new features, OO, functional programming style, etc. Or perhaps a team-taught class that combines multiple topics to build some non-trivial application, like using wxpython and the protocol libraries to build a news/mail reader. Feel free to come up with unusual topics or approaches, or to contact me with a half-baked idea. Maybe we can turn it into something good. The deadline for submitting proposals is Monday, October 1, 2001, but it would be great to have feedback sooner if you're thinking about submitting something. For more information, please see http://www.python10.org/p10-calltutorials.html -- 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 duncan at NOSPAMrcp.co.uk Tue Jul 10 09:18:08 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Tue, 10 Jul 2001 13:18:08 +0000 (UTC) Subject: backslash woes........ References: <3B4AC7C2.DD53F6BB@westerngeco.com> <Xns90DA74BD3B968duncanrcpcouk@127.0.0.1> <3B4ADD33.CA2836D1@westerngeco.com> Message-ID: <Xns90DA8FF2145Bduncanrcpcouk@127.0.0.1> Martin Franklin <martin.franklin at westerngeco.com> wrote in news:3B4ADD33.CA2836D1 at westerngeco.com: >> I think you maybe misunderstand what raw strings do. Raw strings >> simply prevent any backslash character that is present in the string >> from being interpreted as an escape sequence. They don't affect the >> processing or use of the string in any way. Since none of your literal >> strings contain backslashes there is no reason to use raw strings. >> In regular expressions backslashes are special, but so are many other >> characters that could appear in filenames, even on Unix. > > > You are right I don't understand... My strings do include backslashes > (they are windows filenames from os.path.walk()) I Have indeed changed > to using string.replace() - having read the HOW TO on > www.python.org.... and it seems to work (without using raw strings....) > This all seems very confusing! > Let me try to explain. A raw string is a change in notation, not a change in the string itself. So r'%s' is exactly the same as '%s' or "%s" or '''%s''' or '\x25\x73', but r'\x25\x73' is a string containing 8 characters two of which are backslashes. If you write a string containing a backslash, e.g. 'c:\autoexec.bat' the backslash may be interpreted as beginning an escape sequence, so in this case you get 'c:\x07utoexec.bat' as the \a converts to a bell character. Writing r'c:\autoexec.bat' or writing 'c:\\autoexec.bat' both give you a identical string containing exactly 15 characters. Both of these are strings (there is no separate raw string type), and each of them contains exactly one backslash character: >>> file1 = r'c:\autoexec.bat' >>> file2 = 'c:\\autoexec.bat' >>> print file1 c:\autoexec.bat >>> print file2 c:\autoexec.bat >>> print repr(file1) 'c:\\autoexec.bat' >>> print repr(file2) 'c:\\autoexec.bat' >>> print len(file1), len(file2) 15 15 >>> print type(file1), type(file2) <type 'string'> <type 'string'> In other words the r prefix on a raw string simply changes the way the string literal is regarded at compile time, it has no further effect on the processing of data after Python has compiled your code. If your program reads data from a file, or indeed gets it anywhere else, then backslashes have no special meaning. Only string literals do this special interpretation. The real confusion creeps in because backslash also has a special meaning in regular expressions. So to put a backslash into a regular expression you must escape it by preceding it with another backslash, and to write two backslashes in literal string you must either use a raw string or write 4 backslashes. So the string for a regular expression that matches one backslash followed by an 'x' could be written as: s = '\\\\x' s = r'\\x' s = re.escape('\\x') s = re.escape(r'\x') In all of these s ends up as the same three character string: two backslashes followed by an 'x'. Why the 'x'? Because for reasons that escape me, raw strings cannot end with a single backslash: >>> r'\\' '\\\\' >>> r'\' File "<stdin>", line 1 r'\' ^ SyntaxError: invalid token I hope this makes things a bit clearer. -- 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 peter at engcorp.com Mon Jul 9 03:34:01 2001 From: peter at engcorp.com (Peter Hansen) Date: Mon, 09 Jul 2001 03:34:01 -0400 Subject: Empty sys.path[0] References: <mailman.994518012.886.python-list@python.org> <Xns90D7B5DD9220gustaflalgonetse@194.213.69.148> <3B473741.2BE14CB0@engcorp.com> <Xns90D9116ADA12Bgustaflalgonetse@194.213.69.148> Message-ID: <3B495E69.ED0EBAC2@engcorp.com> Gustaf Liljegren wrote: > That works. Now I run it from the same directory, but still with the full > path: > > E:\test>python e:\test\syspath.py > e:\test > > That works too, but look here when I run it with only the filename: > > E:\test>python syspath.py > > Nothing! This is the problem I have. It think the second and third case > ought to mean the same. By now you should have seen my other post from Saturday which shows how to use os.path.abspath(), which converts relative paths to absolute ones by prepending os.getcwd() when required. sys.path[0] should perhaps show an absolute path, but there are probably arguments for why it should not, too. Just convert to an abspath and your troubles will be gone. :) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From s713221 at student.gu.edu.au Wed Jul 25 05:05:33 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Wed, 25 Jul 2001 19:05:33 +1000 Subject: A use for integer quotients References: <mailman.995866298.23496.python-list@python.org> <cpzo9veuml.fsf@cj20424-a.reston1.va.home.com> <9jhi8b$duv$1@pea.uk.research.att.com> Message-ID: <3B5E8BDD.3B0C9634@student.gu.edu.au> Duncan Grisby wrote: > > In article <cpzo9veuml.fsf at cj20424-a.reston1.va.home.com>, > Guido van Rossum <guido at python.org> wrote: > > >Of course, I'm well aware of the issues around maintaining old code. > >We will have to carry around "from __future__ import division" for a > >loooooong time. Python 2.2 is the first opportunity to introduce it, > >so let's not be shy. > > What is the suggested course of action for people (like me) who have > to maintain software which must run on more than one version of > Python? > > Cheers, > > Duncan. > > -- > -- Duncan Grisby \ Research Engineer -- > -- AT&T Laboratories Cambridge -- > -- http://www.uk.research.att.com/~dpg1 -- Um. Probably to explicitly state what type of result you're expecting to get back. Like the float(a)/b trick for a float return on present python, and an int(a/b) for an integer on future (post 2.3+) versions of python. *grins* As a moderate follower (yellow belt at best) it is a bit bewildering watching all the changes that have suddenly sprung up. But generators have got my vote! -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From donovan at sherbet.co.uk Mon Jul 23 07:20:02 2001 From: donovan at sherbet.co.uk (Donovan Hide) Date: Mon, 23 Jul 2001 12:20:02 +0100 Subject: List Question References: <mailman.995651315.21162.python-list@python.org> Message-ID: <tlo25942haqo15@corp.supernews.co.uk> Cheers, just goes to show there's more than one way to skin a cat. Donovan Hide. From fredrik at pythonware.com Fri Jul 6 03:07:23 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 06 Jul 2001 07:07:23 GMT Subject: Time for a Python "distribution" ? was:Not enough Python library development References: <mailman.993826974.11013.python-list@python.org> <cp1yo3l0si.fsf@cj20424-a.reston1.va.home.com> <mailman.994046162.21135.python-list@python.org> <3B44B63A.BB507CBF@home.net> <mailman.994368791.9779.python-list@python.org> Message-ID: <Lsd17.8383$e5.1082989@newsb.telia.net> Paul Prescod wrote: > Here's what an ActivePython user does to install 3 out of 4 those > modules: > > pyppm install Numeric > pyppm install egenix-mx-base > pyppm install PIL and then he does "import Image", gets an import error (JPEG62.DLL missing), and sends me a nastygram ;-) where's the PPM protocol docs? how do I add new nodes to the PPM distribution network? Cheers /F From paulp at ActiveState.com Tue Jul 3 16:16:27 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Tue, 03 Jul 2001 13:16:27 -0700 Subject: Comment on PEP-0238 References: <3B3BE855.A6223E70@3-cities.com> <cp7kxvlake.fsf@cj20424-a.reston1.va.home.com> <Y4J%6.4084$Z6.2010194@news1.rdc2.pa.home.com> <mailman.994016102.30019.python-list@python.org> <7ef50c46.0107020554.31cc948b@posting.google.com> <mailman.994084684.19932.python-list@python.org> <7ef50c46.0107030657.2e0fc92b@posting.google.com> <mailman.994177387.31239.python-list@python.org> <9ht7ki$pao$1@nntp6.u.washington.edu> Message-ID: <3B42281B.EAB20330@ActiveState.com> I knew I shouldn't get dragged into this. :) The problems with the current situation are well-documented. Every Python book introduces this feature with a statement along the lines of: "this is something that's going to be different than you expect...be careful." It is one of Guido's oldest regrets. Arguing about it isn't really going to change anything. Either someone will step up and do the implementation, in which case the behaviour likely will change, as Guido wants it to, or nobody ever will, in which case the status quo will remain. Donn Cave wrote: > > Quoth Paul Prescod <paulp at ActiveState.com>: > ... > | Nobody argues against understanding. But understanding is eased if you > | do what people expect. People believe that the integers are a special > | case of floats. Python encourages them in that belief in most places > | other than this one. > > Integer is not a special case of float, they're both special cases > of number. Why not say integers are pure numbers and floats are > corrupt, hence coercion favors the float because you can corrupt > the pure easier than you can purify the corrupt? > ... > > Floating point is just a can of worms. I'll take that as a vote in favor of PEP 240. :) http://python.sourceforge.net/peps/pep-0240.html -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From nas at python.ca Fri Jul 27 21:05:02 2001 From: nas at python.ca (Neil Schemenauer) Date: Fri, 27 Jul 2001 18:05:02 -0700 Subject: Suggestion for impriving list comprehensions In-Reply-To: <LNBBLJKPBEHFEDALKOLCGEJDLBAA.tim.one@home.com>; from tim.one@home.com on Thu, Jul 26, 2001 at 11:39:10PM -0400 References: <Pine.NXT.4.21.0107262020310.744-100000@localhost.virginia.edu> <LNBBLJKPBEHFEDALKOLCGEJDLBAA.tim.one@home.com> Message-ID: <20010727180502.A31572@glacier.fnational.com> Tim Peters wrote: ... > for x in whatever: > > magically applies iter() to whatever under the covers (nothing off there), > but if "whatever" is a generator(-function), iter(whatever) is an error. Huh? Why would you want to iterate over the function itself? Neil From skip at pobox.com Wed Jul 11 18:16:40 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 11 Jul 2001 17:16:40 -0500 Subject: Undefining functions and classes In-Reply-To: <3B4EFA40@operamail.com> References: <3B4EFA40@operamail.com> Message-ID: <15180.53320.717257.503138@beluga.mojam.com> Vesselin> Does anyone know how to undefine a function or class in Python Try del func -- Skip Montanaro (skip at pobox.com) (847)971-7098 From s713221 at student.gu.edu.au Fri Jul 20 21:10:19 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Sat, 21 Jul 2001 11:10:19 +1000 Subject: Language change and code breaks References: <mailman.995378792.16515.python-list@python.org> <cpvgkq1f2b.fsf@cj20424-a.reston1.va.home.com> <_bh57.32695$d4.1090608@e420r-atl1.usenetserver.com> <9j4a6e0cpu@enews4.newsguy.com> <3B566ED8.E14732F8@cosc.canterbury.ac.nz> <9j5u2302v3e@enews3.newsguy.com> <3B57A65F.BDB6BAE5@cosc.canterbury.ac.nz> Message-ID: <3B58D67B.D3D3EDE8@student.gu.edu.au> Greg Ewing wrote: > > Alex Martelli wrote: > > > > I think it was a 19th century fancy, to start with. Extremely > > recent when compared to the amount of time mathematics > > has been written about. > > It's still a lot longer than computers have been around. > And the fact that they *did* adopt it suggests they > found it useful in some way. Perhaps because it let > them express things more succinctly? > > They seem to be satisified with the decision, too. > I've never heard a group of mathematicians debating > whether mathematics should go back to being > case-insensitive (if it ever really was to begin > with). Well, it was probably pragmatism that caused them to do it. Especially with physical mathematics, even using case sensitivity, they still have to resort to using the Greek alphabet and putting funny lines over/under/around perfectly ordinary letters to get enough symbols, and even there, there's a lot of recycling. *thinking of some of the arguments why we use j for complex numbers in python* i-already-been-taken-by-the-engineers-'ly yours -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From tundra at tundraware.com Thu Jul 5 17:10:01 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 05 Jul 2001 21:10:01 GMT Subject: Question about scope Message-ID: <3B44D696.61A8B915@tundraware.com> I thought I understood python scoping, but I guess I don't. Consider this code: FALSE = 0 TRUE = not FALSE FLAG = TRUE def FlagFalse(): FLAG = FALSE print str(FLAG) FlagFalse() print str(FLAG) I get: 1 1 But I expected: 1 0 If I declare FLAG as global in the function, it works properly, of course. I thought that python checked local scope for a variable first and if it did not find it, it appealed to the local namespace. What am I missing here - it's probably at the end of my nose, but I cannot seem to make sense of it... TIA, -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From mday at apple.com Fri Jul 27 20:02:39 2001 From: mday at apple.com (Mark Day) Date: Fri, 27 Jul 2001 17:02:39 -0700 Subject: Changing the Division Operator -- PEP 238, rev 1.12 References: <mailman.996263475.24304.python-list@python.org> Message-ID: <270720011702397113%mday@apple.com> In article <mailman.996263475.24304.python-list at python.org>, Guido van Rossum <guido at zope.com> wrote: > Here's a new revision of PEP 238. I've incorporated clarifications of > issues that were brought up during the discussion of rev 1.10 Thanks. Originally, I was uncomfortable with the change. But now I'm starting to warm up to it nicely. The threads about non-programmers (eg., medical technicians) getting caught by classic division was quite compelling. Sometimes I forget that programming itself isn't the goal. I think my original discomfort was due to using C for so long (and damaging my brain along the way). But maybe C is like tobacco, and if I quit, maybe my brain will eventually heal. One can hope. :-) -Mark From tim.one at home.com Sun Jul 1 21:31:03 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 1 Jul 2001 21:31:03 -0400 Subject: PEP 255: Simple Generators In-Reply-To: <eppstein-2897DB.09161529062001@news.service.uci.edu> Message-ID: <LNBBLJKPBEHFEDALKOLCOEMNKLAA.tim.one@home.com> [Toby Dickenson] > 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 <generator>: > yield x Toby, this is Python: we're not optimizing anything. WYSIWYG! Even the possibility for "optimimizing" that is off limits here: it crosses stack frames, with all the difficulties that entails. [David Eppstein] > ... one could use simple generators to implement a union-find data > structure (probably not the right way of actually implementing UF, > but...) Cute! The code snippet wasn't quite Python, so I'll attach a working light rewrite below. > ... > 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. It's allowed. What isn't allowed is for an *active* (non-suspended) generator to reinvoke itself (whether directly or indirectly) while still active; e.g., >>> def g(): ... i = me.next() ... yield i >>> me = g() >>> me.next() Traceback (most recent call last): ... File "<string>", line 2, in g ValueError: generator already executing Here's your union-find algorithm w/ a little test driver: class disjointSet: def __init__(self, name): self.name = name self.parent = None self.generator = self.generate() def generate(self): while not self.parent: yield self for x in self.parent.generator: yield x def find(self): return self.generator.next() def union(self, parent): if self.parent: raise ValueError("Sorry, I'm not a root!") self.parent = parent def __str__(self): return self.name names = "ABCDEFGHIJKLM" sets = [disjointSet(name) for name in names] roots = sets[:] from random import choice while 1: for s in sets: print "%s->%s" % (s, s.find()), print if len(roots) > 1: s1 = choice(roots) roots.remove(s1) s2 = choice(roots) s1.union(s2) print "merged", s1, "into", s2 else: break Here's "typical" output: A->A B->B C->C D->D E->E F->F G->G H->H I->I J->J K->K L->L M->M merged A into M A->M B->B C->C D->D E->E F->F G->G H->H I->I J->J K->K L->L M->M merged B into K A->M B->K C->C D->D E->E F->F G->G H->H I->I J->J K->K L->L M->M merged I into J A->M B->K C->C D->D E->E F->F G->G H->H I->J J->J K->K L->L M->M merged C into G A->M B->K C->G D->D E->E F->F G->G H->H I->J J->J K->K L->L M->M merged G into J A->M B->K C->J D->D E->E F->F G->J H->H I->J J->J K->K L->L M->M merged J into M A->M B->K C->M D->D E->E F->F G->M H->H I->M J->M K->K L->L M->M merged K into H A->M B->H C->M D->D E->E F->F G->M H->H I->M J->M K->H L->L M->M merged D into F A->M B->H C->M D->F E->E F->F G->M H->H I->M J->M K->H L->L M->M merged H into M A->M B->M C->M D->F E->E F->F G->M H->M I->M J->M K->M L->L M->M merged E into L A->M B->M C->M D->F E->L F->F G->M H->M I->M J->M K->M L->L M->M merged M into L A->L B->L C->L D->F E->L F->F G->L H->L I->L J->L K->L L->L M->L merged F into L A->L B->L C->L D->L E->L F->L G->L H->L I->L J->L K->L L->L M->L It seems a very clever way to avoid chasing up to the root each time. From paulsid at home.com Tue Jul 24 02:54:26 2001 From: paulsid at home.com (Paul Sidorsky) Date: Tue, 24 Jul 2001 00:54:26 -0600 Subject: A use for integer quotients References: <3B5BA29B.E08FEEE9@alcyone.com> <yCK67.17615$EP6.4467503@news1.rdc2.pa.home.com> <mailman.995860718.9550.python-list@python.org> <mailman.995862939.15013.python-list@python.org> <mailman.995883879.12071.python-list@python.org> <3B5C5665.8D41D1F1@tundraware.com> <slrn.pl.9los0f.jh4.qrczak@qrnik.zagroda> <3B5C749A.59F97320@tundraware.com> <eppstein-6E0A27.12470423072001@news.service.uci.edu> <415pltcn73cga0lmvtmgdn3vb02f7d28kr@4ax.com> <slrn.pl.9lp6u8.hhd.qrczak@qrnik.zagroda> <h69plt04ff8j36ma26k9b2l13e5i04hg6e@4ax.com> Message-ID: <3B5D1BA2.215716AB@home.com> Stephen Horne wrote: > I've been here already - mathematicians use the same set of operators > whatever set of values. They exact representations aren't available to > simple ASCII text files, so we use a single alternate representation. > The point is that we should the same symbol for the same meaning, > exactly the same as mathemeticians. When a mathematician asks 'I can't > find a divide symbol, how do I do that?' the answer should be simple - > it should not depend on which set of values he happens to be working > in at the time. > The fact that we need to choose an alternative symbol should not be > seen as a chance to break with principles that mathematicians have > applied successfuly since well before Christs time. While on the subject of choosing symbols, I think the thing that really bugs me most about this is that * and / are opposites (I won't say "inverses" just in case somebody gets me on a mathematical technicality), so shouldn't ** and // be opposites? I'll bet there will be at least a few newcomers (that is mainly who the change is being made for, right?) who will be casually browsing a Python operator list (e.g. section 2.5 of the reference manual), see both ** and // on there, learn what ** does, and assume // does the opposite. Or vice-versa. (This is regardless of whatever kind of division // will do.) Here's one example - it's easy think of many more: x = (2**4)//2 Here x == 8, but isn't it awfully tempting at first glance to think x == 4?! (Take the parentheses out and it's worse.) I know the subject of which symbol should be used was beaten to death a long time ago, and I don't want to revive that debate again so I'm not expecting anybody to reply. I just wanted to get this off my chest since it's been irking me all day and I wasn't around for the original debate. -- ====================================================================== Paul Sidorsky Calgary, Canada paulsid at home.com http://members.home.net/paulsid/ From thomas at xs4all.net Sun Jul 8 19:52:24 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 9 Jul 2001 01:52:24 +0200 Subject: Comment on PEP-0238 In-Reply-To: <3b48de4e.1402626870@wa.news.verio.net> References: <mailman.994427714.26169.python-list@python.org> <cpsngaja4g.fsf@cj20424-a.reston1.va.home.com> <FFv17.1178$Y6.656565@news1.rdc2.pa.home.com> <cpelrskgrr.fsf@cj20424-a.reston1.va.home.com> <9i7a7k$h9ks6$1@ID-11957.news.dfncis.de> <cp4rsok3i7.fsf@cj20424-a.reston1.va.home.com> <mailman.994531918.7040.python-list@python.org> <9i8512$haelg$1@ID-11957.news.dfncis.de> <cpk81jip74.fsf@cj20424-a.reston1.va.home.com> <3b48de4e.1402626870@wa.news.verio.net> Message-ID: <20010709015224.Q8098@xs4all.nl> On Sun, Jul 08, 2001 at 10:45:12PM +0000, Bengt Richter wrote: > Why not parameterize the concept with a single block-scope-introducing > keyword, e.g., 'semantics' or 'special' e.g., rewriting from above: > semantics PRECISION, 0: # everything behaves as it does now > print 2 / 7 # -> 0, ie to precision 0 decimal places > print 2/7.0 # -> 0.285714285714 > semantics PRECISION 1: # all calculations yield 1 decimal point > print 2 / 7 # -> 0.2, ie to precision 1 decimal places Doesn't fix the problems. What about this: semantics PRECISION, 0: x = 2/7 semantics PRECISION, 100: print x -- Thomas Wouters <thomas at xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From loewis at informatik.hu-berlin.de Fri Jul 20 03:32:50 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 20 Jul 2001 09:32:50 +0200 Subject: xml.dom.minidom + py2exe References: <9ilk1r$quo$1@maud.ifi.uio.no> <9im880$jjh8j$1@ID-59885.news.dfncis.de> <j4wv56z400.fsf@informatik.hu-berlin.de> <Xns90E2BDCEA67E7gmcmhypernetcom@199.171.54.194> Message-ID: <j4snfsgin1.fsf@informatik.hu-berlin.de> Gordon McMillan <gmcm at hypernet.com> writes: > You have to do a lot more than that. After all, once xml/__init__.py > runs and swaps itself for _xmlplus/__init__.py, then xml.sax.expatreader > refers to _xmlplus/sax/expatreader.py. The original reporter did not have PyXML installed, so no swapping of _xmlplus would happen on this installation. Regards, Martin From qrczak at knm.org.pl Sat Jul 7 16:11:48 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 7 Jul 2001 20:11:48 GMT Subject: Comment on PEP-0238 References: <mailman.994427714.26169.python-list@python.org> <cpsngaja4g.fsf@cj20424-a.reston1.va.home.com> Message-ID: <slrn.pl.9ker84.1sg.qrczak@qrnik.zagroda> Fri, 06 Jul 2001 16:30:34 GMT, Guido van Rossum <guido at python.org> pisze: > Here's my plan, "new division in four phases": I like it. > 1. First we introduce a new function div() and a future statement that > makes integer division return a float result for a specific module. Please aim at some replacement for floats here in the future. Recently I needed exact calculations on fractional numbers. The program renders texts in an artificial script (see <http://qrczak.ids.net.pl/vi-001.gif> for a sample - resolution is for printing at 300 dpi). Conversion of a vectorized form of a character (lines, quarters of ellipses and dots) into a bitmap needs reliable equality of coordinates, to check whether lines meet or not, to produce proper corners and ends, and to fit the shape into character size. Coordinates here are rational by nature. A computed shape consisting of evenly distributed lines is stretched vertically to fit into character size. I could do it on floats instead of rationals and test for equality by comparing abs(difference) with a small epsilon, but it would be ugly. The problem doesn't have intrinsic inaccuracies: it's digital, not analog. Unambiguously either there is a horizontal line at the top of the character or there is not. Lines either meet or not. It would not work well on floats without changes also for another reason. When a horizontal line of an integral width is positioned such that after rounding to whole pixels it could be equally well one pixel higher or lower, my code is careful to round coordinates of its higher and lower outline in the same direction, so the line has the correct width. Floating-point inaccuracies could make some lines one pixel narrower or wider than others. Unfortunately the program is not written in Python. I promise to reimplement it in Python when it supports rationals, i.e. when it guarantees that 1/3+1/6 == 1/2 :-) This would also be another use for generators, but I don't need to ask for them - they are going in anyway. This is another example when generators or lazy lists are very useful: several stages of processing should be pipelined, to not hold everything in memory as pages of output are produced. > I currently favor div(x, y) over x//y and x div y. I like div(x, y) and x div y equally well. x//y is not as clear. Don't you want to borrow Haskell's turning of an arbitrary binary function into an operator thus: x `div` y? :-) OCaml recently did. > Maybe also add mod(x, y) for symmetry Sure. This would remove the overloading of %, leaving it for sprintf. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From 18k11tm001 at sneakemail.com Thu Jul 5 03:41:13 2001 From: 18k11tm001 at sneakemail.com (Russ) Date: 5 Jul 2001 00:41:13 -0700 Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> <9hrj3q$cj1@news1.gtech.com> <bebbba07.0107031040.593143f8@posting.google.com> <9htgsb$ck3@news1.gtech.com> Message-ID: <bebbba07.0107042341.4283ca43@posting.google.com> "Peter Milliken" <peter.milliken at gtech.com> wrote in message news:<9htgsb$ck3 at news1.gtech.com>... > Perhaps if you are seriously looking into possible languages to use for > writing an ATC then you might be better off looking for some research > information about the relative merits of different languages rather than > asking a fairly obvious question in a news group that will only be read by > adherents of a particular language :-). I say "obvious" here because you > will find only Python lovers here. I love Python but I wouldn't use it to > write an ATC. Perhaps I should clarify that I am not proposing to use Python for a complete ATC system but rather for a relatively small, albeit key, component of a very large system. > The choice of languages for implementing various applications is sometimes > extremely suspect. I suspect that often it comes down to something like one > or more of the following reasons: > > "I know X, it is a good language" > "I can get programmers more easily in language X than language Y" > "We currently have programmers who know language X" > > I am not necessarily saying that choosing a language based upon the above > reasons is wrong, but it is hardly approaching the problem from an > engineering standpoint. There is literature available that compares the > relative merits of languages. To make an informed decision you really should > do some research and find out what information is available to help you make > the decision. The more information the better informed the decision. I am > sure as an aerospace engineer, you do studies into the various alternatives > for your design, why should choosing a programming language be any > different? I agree. However, I wouldn't know where to start with the formal literature, and even if I did I don't have enough time to pursue it in depth. My management is already worried that I am even considering Python (they'd never even heard of it), and they may well shoot it down even if it's my choice. (You'd no doubt praise them for that. :-) > > <cut> > > > > > Based upon Gerrit's observations, which I fully endorse, anybody who > doesn't > > > use the most strongly typed language they can find for an application > like > > > Air Traffic Control, has to put it mildly, rocks in their head :-). > > > > As I indicated in my original post, the lack of type checking does > > concern me. However, as I wrote in a later post, I also suspect that > > this concern is overblown. I am not a computer scientist or even a > > full-time programmer, so I don't pretend to be an expert in this area. > > I am an aerospace engineer, and I do some programming in support of my > > own research (but I am a Python beginner). > > > > There are studies that indicate that productivity in strongly typed > languages is higher (2:1 in one study I read - unfortunately, they are > "thin" on the ground because you need two identical ability teams doing the > same application in two different languages to get meaningful comparisions - > but it has been done and that was the result) than loosely typed languages. Let's cut right to the chase here. I like strong typing almost as much as you do, but I don't understand why I can't get it in Python, perhaps by specialized code-analysis tools. Is the problem just that the development tools are underdeveloped, or is there a fundamental technical reason that type-checking cannot be done? If it's the former, then I suggest that the tools be given a very high priority. If it's the latter, then perhaps type checking can be done under certain reasonable restrictions. Whatever the case, I want to have my cake and eat it too. :-) <cut> > PyChecker is still very imature and some things it will never (poor word to > use, since if someone wants to put in the effort, nothing is impossible :-)) > be checked by it. It will only ever be an aid. The ability of Python to > dynamically "change its behaviour on the fly" is one of its strengths but > also a weakness from the point of view of ensuring correctness and > reliability in such an application domain. Do you think PyChecker could ever be sophisticated enough to do static type checking? > Well, if you need more information, email me directly Russ - I'm more than > happy to help. The issue can be confusing with all of the Python lovers on > the list :-) Thanks. Russ From ejeandel at ens-lyon.fr Sat Jul 7 11:15:03 2001 From: ejeandel at ens-lyon.fr (Emmanuel Jeandel) Date: 7 Jul 2001 15:15:03 GMT Subject: anonymous variable Message-ID: <9i791n$3bh$1@macareux.ens-lyon.fr> Hello In a script i made, i have tuples (name, nb, size) in a list and i wanted to sort the list with respect to size. In python 1.5, i do : L.sort ( lambda (_,_, size1) (_,_,size2) : cmp(size1,size2)) _ is a variable that, according to the language reference manual, has no special meaning, and i find it adequate for meaning 'I don't use this value' I also write code such as (_,nb, size) = c, and so on But, in python 2.2 (0501 snapshot), it gives an error, _ being use twice in the definition of the fonction. I agree, but writing L.sort ( lambda (dum1, dum2, size1) (dum3, dum4, size2) : cmp (size1,size2)) is a bit too complicate for me. and writing L.sort ( lambda x y : cmp (x[2],y[2])) is not the solution because it is not as expressive as what i do before. In the majority of fonctionnal and logic programming languages, you have such a keyword, that says : 'We don't know what is its value, but who cares ?' Can we have the same in python ? Thanks in advance Emmanuel From xione at prodigy.net Thu Jul 26 15:04:22 2001 From: xione at prodigy.net (Xione Wrent) Date: Thu, 26 Jul 2001 19:04:22 GMT Subject: Tkinter Problem: Message-ID: <WQZ77.419$w04.68939031@newssvr17.news.prodigy.com> How do I display buttons as images, particularly Windows Bitmaps? Thanks... From djc at object-craft.com.au Wed Jul 11 09:40:26 2001 From: djc at object-craft.com.au (Dave Cole) Date: 11 Jul 2001 23:40:26 +1000 Subject: Why database modules are incomplete References: <5174eed0.0107060820.ff90805@posting.google.com> <yox66d25zkd.fsf@karhu.tp.spt.fi> <23891c90.0107090815.3685a9@posting.google.com> <m3k81h1u3d.fsf_-_@vole.object-craft.com.au> <5174eed0.0107100719.e14dfbe@posting.google.com> <m3g0c4hstf.fsf@vole.object-craft.com.au> <23891c90.0107110150.24b7d36@posting.google.com> Message-ID: <m3itgzfut1.fsf@vole.object-craft.com.au> >>>>> "Paul" == Paul Boddie <paul at boddie.net> writes: Paul> What could be interesting would be some kind of common test Paul> suite for database modules. It would give module developers Paul> something to aim for (for compliance with the DB-API), and Paul> module users something to use to verify how good a module is for Paul> their purposes. mxODBC has something like this for sanity Paul> checking, as well as for investigating certain aspects of type Paul> binding. That would be a good thing. I have a feeling that the DB-API is not strict enough to write anything but the most general test suite. >> You are 100% correct here. If only people were willing to try the >> module. For all I know there are more than 20 people who are using >> the module for serious work. Noone ever tells me, so how can I >> claim that I have a proven module? As I said before - there have >> been over 180 unique IP addresses which have downloaded the >> Sybase-0.2x module. Paul> Perhaps it works sufficiently well for the purposes of the users Paul> who downloaded it. Nevertheless, sure-fire ways to elicit Paul> feedback would be invaluable for module developers. Do any of Paul> these Sourceforge surveys ever get used? (Or are people too worn Paul> down by having too many meaningless "Who is your favourite Paul> actress?"/"What kind of geek are you?" surveys in their face Paul> whilst surfing?) I am as guilty as the next person here. I suspect that it just does not occur to people who use a module that the developer might be lacking positive feedback. It is a classic case of the volunteer's dilemma: http://www.heretical.com/games/vdilemma.html (excellent book - by the way) Everyone just assumes that other people will provide feedback so none is ever received. - Dave -- http://www.object-craft.com.au From peter at engcorp.com Thu Jul 26 08:29:42 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 26 Jul 2001 08:29:42 -0400 Subject: Use of iterators for state machine (was Re: 2.2 features) References: <mailman.996129288.32203.python-list@python.org> Message-ID: <3B600D36.242A8E82@engcorp.com> Tim Peters wrote: > > [Peter Hansen] [on iterators] > > I'm especially looking forward to using them to implement state machines. > > Have you read PEP 255 ("Simple Generators")? There's a long section at the > start discussing exactly that. [...] Clearly I had not :-). I shall. Thanks for the background. > If you don't think about it too much <wink>, it all works the way you > expect; if you do think about it too much, it takes an "aha!" (or maybe even > two) to figure out *why* it all works. It took me about 8 years to explain > it to Guido <wink> -- although, in his defense, he may wish to protest that > the first time he actually paid attention to what I was screaming at him, he > "got it" in about one minute flat. Thanks for leaving me an "out": I'll let you know when *I* actually start paying attention, since I don't entirely get it just yet. ;-) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From nas at python.ca Tue Jul 10 11:37:25 2001 From: nas at python.ca (Neil Schemenauer) Date: Tue, 10 Jul 2001 08:37:25 -0700 Subject: Profiler question In-Reply-To: <slrn9km60i.d3l.alf@leo.logilab.fr>; from alf@leo.logilab.fr on Tue, Jul 10, 2001 at 02:54:26PM +0000 References: <slrn9km60i.d3l.alf@leo.logilab.fr> Message-ID: <20010710083725.A12135@glacier.fnational.com> Alexandre Fayolle wrote: > I'm using the profile module to try to see where I could get some speedups > in an application, I'm getting troubles interpretting the results, especially > the cumulative times. Is there a known problem with profile and multithreaded > applications? If you're on a reasonably fast machine and the timer resolution is poor (e.g. Linux x68 is 100 Hz by default) then the results can be very strange. Changing HZ to 1024 in "include/asm/param.h" and recompiling the Linux kernel greatly improved my profile results. Neil From quacko at lists.postmastergeneral.com Fri Jul 27 17:40:01 2001 From: quacko at lists.postmastergeneral.com (Quacko Lotto) Date: Fri, 27 Jul 2001 17:40:01 EDT Subject: PLAY TODAY! WIN $1,000,000 TOMORROW! Message-ID: <200107272150.PAA63204@s0222.pm0.net> **************************************** PLAY TODAY! WIN $1,000,000 TOMORROW! http://lotto.quacko.com **************************************** 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! Great News Valued Customer!!! Use Your Visa or MasterCard NOW Virtually 100% GUARANTEED !!! No More Rejected Cards, Problems or Errors. TRY IT NOW! Buy $25 and Get $25 Free! Buy $50 and Get $50 Free! Buy $75 and Get $75 Free! 100% Match Bonus!! Combine the BEST in online casino games with FREE money and you've got some major excitement! Stop by 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 nhodgson at bigpond.net.au Mon Jul 23 23:27:09 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Tue, 24 Jul 2001 03:27:09 GMT Subject: PEP0238 lament References: <mailman.995926001.4339.python-list@python.org> <vmcpltkoo6137ko4hnivtl5a01b9dtq2e1@4ax.com> <3B5CE049.8F274BD@geocities.com> Message-ID: <hW577.26451$Xr6.212776@news-server.bigpond.net.au> Myles: > Ermm, fact correction : > not on the VB and VBA I have available to me. > > VB (admittedly v.4): > x = 1 \ 2 > MsgBox (x) > gives 0.5 Also in VBScript (on W2K): WScript.echo(1/2) displays "0.5". And QBasic PRINT 1/2 displays ".5" Neil From jajvirta at cc.helsinki.fi Mon Jul 16 08:29:17 2001 From: jajvirta at cc.helsinki.fi (Jarno J Virtanen) Date: 16 Jul 2001 12:29:17 GMT Subject: Python, C++, Java, Smalltalk, Eiffel,... References: <9is8rm$46d$1@panix3.panix.com> Message-ID: <slrn9l5ngp.87g.jajvirta@sirppi.helsinki.fi> 15 Jul 2001 10:20:38 -0400 kj0 wrote: > Where can I find a reasonably non-partisan but also reasonably > detailed comparison of the more popular OO languages (C++, Java, > Python, etc.). [snip] Here's one: http://www.lib.uchicago.edu/keith/crisis/ It's subjective, but he clearly states what he wants and then ranks programming languages according to the criterias. From barry at digicool.com Wed Jul 11 12:08:43 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Wed, 11 Jul 2001 12:08:43 -0400 Subject: Forth and Python side note References: <Pine.LNX.4.21.BCL.0107101932480.1573-100000@suzi.com.onego.ru> <Pine.LNX.4.30.0107111902400.2392-100000@rnd.onego.ru> Message-ID: <15180.31243.417520.826123@anthem.wooz.org> >>>>> "RS" == Roman Suzi <rnd at onego.ru> writes: RS> It's very intersting that searching revealed at least two RS> Forth interpreters written in Python: RS> google:"Forth Python" RS> One occured at Edu-sig in Oct 2000 and another one in 1994 in RS> Python-list. RS> (But no one attemted to implement Python in Forth) If Python had existed in 1986, I might have attempted it! you-forth-love-if-honk-then-ly y'rs, -Barry From tundra at tundraware.com Thu Jul 26 03:40:01 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 26 Jul 2001 07:40:01 GMT Subject: Distributed computing using SOAP. What about speed ? References: <LBA77.58$bXi.175168000@news.telia.no> <dc6f5c99.0107251655.f3c625b@posting.google.com> Message-ID: <3B5FC733.5186D588@tundraware.com> Graham Dumpleton wrote: > > "Thomas Weholt" <thomas at gatsoft.no> wrote in message news:<LBA77.58$bXi.175168000 at news.telia.no>... <SNIP> > > It's also clear that some problems might occur cuz the BaseHTTPServer which > > is used for the most part, have performance issues. Perhaps implementing the > > server using asyncchat etc. would increase performance ?? Why aren't the > > modules allready implemented with these tools available in the standard > > python lib allready, if that's the case? > > OSE is implemented using an event driven system model. This includes the HTTP > servlet framework, such that multiple requests can be handled at a time etc. > It includes mechanisms for knowing when connections block due to slow HTTP > clients so you can stop sending data back etc. > > OSE at its core is actually C++, with Python wrappers. Thus, you are getting > the efficiency of C++ but the simpler interfaces possible with Python. I have a related question. I come from a very high-scale, high-arrival rate transactional computing background. In this world, connection-oriented solutions like RPCs across wide-area networks are a big "no no" for a variety of reasons. (If you care more about why, I wrote a paper, years ago, in grad school on this topic. The specifics of the paper are quite out of date, but the general critique' of RPCs is still very much relevant, perhaps even moreso today with the proliferation of the internet. You can find it at: http://www.tundraware.com/RPCpaper/rpcpaper.pdf) The short reason for this is that connection-oriented solutions like RPCs create very "brittle" applications in highly distributed, high-performance environments. I am thus less than enthusiastic about SOAP as a solution. One really good alternative is transactional queuing with asynchronous read/write interfaces to the queues. I'm wondering if anyone is doing anything in this area with Python. -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From guido at python.org Sat Jul 28 11:35:44 2001 From: guido at python.org (Guido van Rossum) Date: Sat, 28 Jul 2001 15:35:44 GMT Subject: FEEDBACK WANTED: Type/class unification Message-ID: <cp66cd12yp.fsf@cj20424-a.reston1.va.home.com> When I released Python 2.2a1, the type/class unification feature was announced as TENTATIVE. It's been a while now (feels like a year, although I realize it's only been 10 days :), and I would like to see some feedback on this. If there's anyone who believes the type/class unification should not become a feature in Python 2.2, please speak up now or forever hold your peace... (But I'd rather you speak up!) Note that if you have concerns about backwards incompatibilities, the best thing you can do is point them out ASAP. I want to ensure that 2.2 (final) is as compatible with 2.1 as possible, while still providing the new exciting features that type/class unification makes possible. I realize the PEPs aren't done yet, but I believe that the separate introduction I wrote goes a long way towards explaining type/class unification. Read it here: http://www.python.org/2.2/descrintro.html Any questions, don't hesitate to ask. Just DON'T CHANGE THE THREAD TOPIC. I don't have time to read the entire newsgroup (I tried this week, and I didn't get to anything else :). --Guido van Rossum (home page: http://www.python.org/~guido/) From bokr at accessone.com Tue Jul 3 21:34:42 2001 From: bokr at accessone.com (Bengt Richter) Date: Wed, 04 Jul 2001 01:34:42 GMT Subject: Is Python Dead? References: <MNS%6.355$Xs4.225014@news.pacbell.net> <mailman.994049882.30354.python-list@python.org> <9hp1f002dp6@enews4.newsguy.com> <mailman.994078809.12040.python-list@python.org> <9hq62g0kiq@enews4.newsguy.com> <008701c1037d$f6280de0$0101010a@local> <mailman.994137125.12580.python-list@python.org> <OTj07.179491$ff.1395689@news-server.bigpond.net.au> Message-ID: <3b427333.981991248@wa.news.verio.net> On Tue, 03 Jul 2001 13:36:46 GMT, "Neil Hodgson" <nhodgson at bigpond.net.au> wrote: >Paul Prescod: >> Is anybody else suspicious about the sudden uptick of troll-like >> behavior on comp.lang.python? Keep an eye out and don't bother >> responding to anything inflammatory. > > Its that damned PSU - Martijn must have let something a little sensitive >out and they're flooding the group hoping to > I'm a bit new here, so I'd appreciate it if you could exp From aleaxit at yahoo.com Tue Jul 31 09:16:13 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 31 Jul 2001 15:16:13 +0200 Subject: Control of flow References: <Pine.LNX.4.31.0107311355450.2321-100000@cb921.local> Message-ID: <9k6b2u027hv@enews4.newsguy.com> "Campbell" <cb921 at voice.co.za> wrote in message news:Pine.LNX.4.31.0107311355450.2321-100000 at cb921.local... > Hi, > > I use python to write telephony apps, and I find that a 'goto' is often > a nice tool (stop going 'aargh', its properly "useful" sometimes =). Naah, you can always get the same effect with better structure:-). > Here is a little snippet that gets a month/day from a caller. If the > day entered is not in the range of days valid for the month entered, we > repeat from the top. Does anyone have a few minutes to waste helping > me?? How better can I code things that look like this: > > >>> snip <<< > while 1: > cont = 1 ## ugh! Agreed on the "ugh" - artificial "codeflow-control" variables ARE a horror (only marginally better than goto's:-). > month = getdtmf("enter2digs.vox", 2) > if month < 1 or month > 12: > play("invalidmonth.vox") > continue So far so good -- and indeed 'cont' is not used here:-) > while 1: > day = getdtmf("enterday", 2) > if day < 1 or day > Month[month]: > play("invalidday.vox") > cont = 1 > cont = 0 This won't work (I think you forgot a 'break' or two:-). This loop will never exit at all. What are the conditions under which you want to repeat this inner loop (letting the user enter a day for the fixed month) rather than redo the outer loop (letting the user enter the month again)? In general, you should move your validation code to auxiliary functions. Each auxiliary function can only exit with either a valid value for whatever it is accepting, or an indication to "redo from scratch" (or possibly, redo from a given point, though this may be cutting it slightly too fine:-). For example you might have: def getvalidated(prompt_voxfile, mysterycode, invalid_voxfile, lowerbound, upperbound): while 1: result = getdmf(prompt_voxfile, mysterycode) if lowerbound<=result<upperbound: return result play(invalid_voxfile) if you always wanted to keep retrying THIS part of data-entry until the user gets it right. This would need no looping at the outer (application) level). More likely, the user can also enter some code to mean "OK, let's do it over, from scratch". Suppose that getdmf() is coded so that it always returns None in that case. Then you might use the same convention for getvalidated, just change the if to if result is None or lowerbound<=result<upperbound: return result and the upper (application) level might be: while 1: month = getvalidated("entermonth", 2, "invalidmonth", 1, 13) if month is None: continue day = getvalidated("enterday", 2, "invalidday", 1, 1+Month[month]) if day is None: continue that's not too bad for a couple of entries, but it gets slightly tiresome when you have a zillion. That is (part of:-) what exceptions are for... class Invalid(IOError): pass def getvalid(prompt_voxfile, mysterycode, invalid_voxfile, lowerbound, upperbound): while 1: result = getdmf(prompt_voxfile, mysterycode) if result is None: raise Invalid if lowerbound<=result<upperbound: return result play(invalid_voxfile) and the upper application level: while 1: try: year=getvalid("entyear",2,"invyear",1970,2030) month=getvalid("entmonth",2,"invmonth",1,13) day=getvalid("entday",2,"invday",1,1+lastof(month,year)) spam=getvalid("entspam",3,"invspam",*spamspan(day,month,year)) eggs=getvalid("enteggs",1","inveggs",-spam,1) except Invalid: pass else: break Such regularity in the code strongly suggests encoding the changing parts (names of vox files, rules for limits) into a data table and writing a general function to "accept a bunch of stuff according to this table of rules", but that's just a further helpful refactoring -- you don't *have* to do it, it's just a possibility:-). Alex From guido at python.org Sat Jul 14 11:22:14 2001 From: guido at python.org (Guido van Rossum) Date: Sat, 14 Jul 2001 15:22:14 GMT Subject: Language change and code breaks References: <mailman.994958301.16016.python-list@python.org> <3B4E586D.35460F68@engcorp.com> <cpelrk39t9.fsf@cj20424-a.reston1.va.home.com> <3B4FAC17.48377423@engcorp.com> Message-ID: <cp7kxb351p.fsf@cj20424-a.reston1.va.home.com> Peter Hansen <peter at engcorp.com> writes (after much good stuff about transitioning): > After the transition period, screw the professional programmers > who won't take the time to modify their existing code and yet > who selfishly insist that their wonderful program *must* be > allowed to continue running under the new Python without > problem. Well, I don't know about you, but *I* am reluctant to say "screw you" to all those people who depend on Python script written by professional programmers who no longer work there. I also don't want to fork the code base. There are *still* folks using Perl4 scripts who can't upgrade. I don't want to do that to the community. So indeed, we'll need to be *very* careful with this kind of transition, providing tools, warnings, anything we can think of. --Guido van Rossum (home page: http://www.python.org/~guido/) From VesselinPeev at operamail.com Wed Jul 11 18:03:22 2001 From: VesselinPeev at operamail.com (Vesselin Iliev Peev) Date: Wed, 11 Jul 2001 18:03:22 -0400 Subject: Undefining functions and classes Message-ID: <3B4EFA40@operamail.com> Does anyone know how to undefine a function or class in Python i.e. if we execute def func() blah blah and then, supposedly unbind func executing func() will give us an error that the symbol is not defined If you anyone can point me to a way of doing this (preferably via C) or through Python, I'd be very grateful. As you can guess, I need this to conserve memory during prolonged interpreter execution (deleting unused function/class defs) Thanks in advance. From thecalm at NOSPAM.btinternet.com Tue Jul 3 16:29:45 2001 From: thecalm at NOSPAM.btinternet.com (G. Willoughby) Date: Tue, 3 Jul 2001 21:29:45 +0100 Subject: Hiding Console? Message-ID: <9ht9to$fei$1@neptunium.btinternet.com> Is there a way in your script to include a command that when run on a WinME/32 platform the console does not appear? such as the IDLE ide. I wanna write apps with neat little gui's using Tkinter but i dont want the console there when there run, any ideas? G. Willoughby. From tim.hochberg at ieee.org Thu Jul 26 11:33:55 2001 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Thu, 26 Jul 2001 15:33:55 GMT Subject: Toppling the numeric tower Message-ID: <DLW77.49367$Cy.6275542@news1.rdc1.az.home.com> I was thinking this morning (a dangerous occupation, I know) about the proposals to eventually unify Python's numeric model. I had all these great ideas and I got all fired up to write a long post, then I read PEP 228 and realized that my ideas were similar to what is in there. So instead of a nice long post, I'll write a short one instead. Recently Guido wrote that: > [SNIP] > A numeric tower > with rationals could look like this: > > int < long < rational < float < complex [SNIP] > Without rationals, it would look like this: > > int < long < float < complex > [SNIP] I'm not fond of the tower method of numeric conversions. It doesn't do a very good job of capturing the way numbers should be coerced. A better model is a cube. Along the first axis is exactness (e.g., rational vs. float), along the second axis complexness and along the last axis is precision/range. The precison/range axis is kind of dicey, but thankfully should not be needed for core Python numeric types. For discussion purposes, I'm going to assume that some forms of PEP 237, 238 and 239 are eventually adopted. In that case, integers and longs will be unified. The integers can then be completely emebedded into rationals. This leaves us with just one level of precision/range for exact numbers (infinite more or less) and one level of precision/range for inexact numbers (C double). This allows the numeric tower to be knocked down and stirred around to form a box: Real Complex | | rRational cRational -- Rational (Exact) rFloat cFloat -- Float (Inexact) Coercion goes from exact to inexact and from Real to Complex. PEP 228 proposes a single Number type with query methods to determine whether it's real/complex, exact/inexact, etc. I'll stay with that model since I'm not sure if builtin types can support multiple inheritance, which is what you would need to make the above model work nicely if the rRational, etc were to be separate classes. PEP 228 proposes the following query methods: > 1. isnatural() > 2. isintegral() > 3. isrational() > 4. isreal() > 5. iscomplex() > > a. isexact() This is too many. I would strip this down to A. iscomplex() B. isexact() C. isintegral() The first two correspond to the axes of the box. The last is included in the recognition that even though integers can be nicely embedded in the rationals, they are still very signifigant on their own and deserve their own query function. 1 and 4 can easily be written in terms of the other functions, so I don't think they are worth the baggage. Since all integers and floats can be represented as rationals, I'm not sure what the point of 3 is. Maybe I'm missing something? Anyway, that's my 2 cents on PEP 228 and the numeric tower. Enjoy, -tim From peter.milliken at gtech.com Wed Jul 4 20:00:18 2001 From: peter.milliken at gtech.com (Peter Milliken) Date: Thu, 5 Jul 2001 10:00:18 +1000 Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> <9hrj3q$cj1@news1.gtech.com> <mailman.994154525.14580.python-list@python.org> <9htebs$ck2@news1.gtech.com> <mailman.994263608.9373.python-list@python.org> Message-ID: <9i0cjt$ck9@news1.gtech.com> "Thomas Wouters" <thomas at xs4all.net> wrote in message news:mailman.994263608.9373.python-list at python.org... > On Wed, Jul 04, 2001 at 07:42:51AM +1000, Peter Milliken wrote: > > > > The only way to make sure a program works is by testing each and every > > > line in each and every circumstance, regardless of which programming > > > language you use. For something like ATC, you *do not* want to rely on > > > anything else. Using Python would at least allow you to find and fix > > > problems a lot faster -- you won't be carrying around NULL or undef > > > values without noticing it. > > > > Do you check the return value of every fprintf()/fclose() function call > > > you make ? You should! > > > Well, you show your inexperience/ignorance in two places here Thomas :-) > > Neither, actually. My innocence, maybe, and my faith in numbers, but not > inexperience (I'm not) and not ignorance (at least, not that I know.) > Well, sorry Thomas, my command of the English language isn't the best, I'm a fairly typical engineer i.e. I almost failed English in highschool :-). But I thought that was a reasonable definition for inexperience/ignorance i.e. "innocence" is generally present until experience takes it away (through pain and suffering, most times :-)) and "ignorance" is the lack of "knowing" about something. So, you seem to be confirming my original statement :-). Through your innocence you are inexperienced and you admit to (possibility of) your lack of your own knowledge :-). No offence intended here, BTW :-). > > 1. No program EVER has 100% coverage during testing (unless it is trivial - > > this for the nitpickers :-)). The bigger the program the less likely full > > coverage has been achieved, ATC's are big programs. Anyone who claims they > > have 100% tested an ATC are either fools or liars - "every line and every > > circumstance" are NOT POSSIBLE, if you think they are then I don't have > > anything more to say other than get a few more years real world experience > > :-). So, if you plan to 100% test a python ATC "each line and every > > circumstance" then my original confidence that it would never be put into > > production holds (that's one of the reason languages have exception > > handlers - to catch the error that the programmer didn't foresee) :-). > > You should try to re-read my message: I didn't say it was possible, or even > plausible (I happen think it's possible but implausible) just that it is the > only way it'll work. It also depends on what you call 'testing': open source > software, especially popular open source software, is continuously tested, > in the real world. Most bugs in Python nowadays are bugs in new features, or > on new platforms, because a lot of the possible combinations of what/when > have been covered. The real world is the testing, and proving, grounds > <wink>. > Once again, English/semantics could be causing a misunderstanding here (you speak American, I speak Australian :-)) but I thought that a reasonable interpretation of "by testing each and every line in each and every circumstance" equated to "100% coverage of a program". At least, my experience as a test engineer says that 100% coverage was "each and every line in each and every circumstance" :-). Anyway, at least we agree that whatever terminology we want to use, it is not possible/plausable to test to that level. You make the point that Python would help you find NULLs and undef's - well, the language of choice that I would use has this capacity as well :-). It "dumps" information the same way Python does i.e. if the programmer didn't foresee something then run-time checks will provide diagnostic information as to the problem area. It also provides "run-time" checks on the use of variables/values in a similar manner to Python. > If you read the rest of the thread, you'll note that the ATC software runs > in acceptance testing for *years*. That's a lot of testing time. If you're > that deep into testing, you'll be done catching the 'typical' Python bug, > and just catch algorithm errors. Peter v/d Linden's excellent and highly > entertaining "Deep C Secrets" has some good examples of that (and no, they > aren't about C or C++.) Nothing, and I do mean *nothing*, in the language > could have prevented those errors. Actually, a "strongly typed" language would get all of the bugs you are refering to out at compile time - and save you several years of testing :-). A strongly typed language will *only* leave the algorithimic type errors (there are probably a few errors that are exceptions but I am making a point through very minor exaggeration). This is personal, real experience here :-). I have also worked on a large(ish) C project in the '90's. 40+ programmers, It went for 7.5 years before the customer cancelled it. It was in acceptance testing for 4 of those years - they never got all of the bugs out of it. There was in the vicinity of 14,000+ problem reports (some portions of the application were completely re-written, so they didn't count towards this number :-)). So, I doubt seriously that you would catch all of the "typical" Python bugs :-). This was an example where the 25%-50% rule was exceeded :-). > > > 2. Strongly typed languages don't include C/C++, so your example is > > meaningless i.e. a strongly typed language would at least FORCE you to > > assign/test the return value of an function - not like C/C++ which allows > > you to ignore any return values. This is not to say that an application > > written in a such a language wouldn't still ignore the return value after > > the assignment - that is a function of programmer ability (another point in > > my original email) - to fix that is up to testing and code review. > > I didn't say C was strongly typed, nor did I say Perl was strongly typed. > Those two, and Python, are just my 'main' languages, and I just used them to > express what I meant: programmers can ignore error codes, and catch > exceptions and ignore them. There isn't much a language can do about that. > But that still doesn't mean that strongly typed languages are the best for > reliable code. > Sorry, since the context of my post was about typing, I assumed in your response implied something in that area that it obviously didn't. Yes, I agree, no matter what the language, a programmer is the source of any bugs in the code :-). There is nothing you can do about that. What you can do though (keep in mind the environment here, we are talking potentially hundreds of programmers - remember also the 25%-50% rule :-)) is provide a development environment that will "force" or "funnel" the programmers in producing *more* reliable code i.e. a strongly typed language will not allow a programmer to compile a truly incorrect program - so they couldn't even get to unit testing! :-). Programming teams have produced failures despite using a strongly typed language, there is no cure for the inherent weakness of the people factor. A language and a compiler is only a tool, some tools are better than others at particular aspects of the job. > How does a strongly (and statically, I presume you mean) typed language > FORCE you to assign/test the return value of a function, by the way ? I > don't think I ever heard of a language that did that... My experience with > true strongly, statically typed languages must be smaller than I thought. > Strong type checking means that when you tell a compiler that a function will return a value then the compiler will not allow a program to compile that doesn't have that return value assigned to *something* (of the appropriate type, as well :-)) i.e. a program variable or just used in a test case e.g if statement. The language that I have in mind is Ada - it is used primarily in the defence industry and therefore has the stigma of being a "defence language" and therefore not worth considering in the "real world" of commercial programming :-) (their loss :-)). It was designed to/using some strict computer science principles (please, no boffins jumping in here with corrections thanks :-)) of the day and encourages, through the language definition and operation of the compiler some very handy heuristics. It is a very "readable" language (uses keywords in the same style as Pascal and Modula). By default (you can turn it off when generating binaries for the live system), it generates automatic run-time checking of code i.e. if you define a data type that should only ever have a range of values of 0 - 255 then if you try and assign 256 to a variable of that type then it will raise an exception at runt-ime (this assumes that the compiler wasn't able to detect that at compile time though! a statement line like byte_var := 256; would raise an error from the compiler) - the application will either handle the exception via an exception handler (has to be programmed though, just like Python :-)) or it will abort the program and display diagnostic data (just like Python :-)). Many programmers, when they first meet a strongly typed language (such as Ada, but there are others) have a great deal of difficulty, because they are used to having a lot more "freedom" from the languages they are used to. But once you get past the barrier of producing correct code then it offers a great freedom - 90% of your "typical" bugs are found by the compiler at compile time rather than during unit testing :-). In my experience (I wrote code using Ada for about 4-5 years, I have about 10-12 years of coding in C, I have used C++ but not any any extent worth mentioning), the only bugs left after a successful compile are "algorithimic" - a truly great aid to productivity! :-). Most programmers can't get past that first hurdle though, they "hate" the language because it "won't let them do what they want" - but if they examined their code, they are always forced to admit that what they "wanted" wasn't "correct" :-). But Ada is like C or C++ - it doesn't "shine" in the areas of data manipulation that Python does. It doesn't have a huge array of support libraries, like Python, Perl and Java do etc. So productivity can be down purely because you have to write a lot of basic things from the ground up. Again, different languages have different applications areas. Python is not my choice for an ATC (as anyone may have guessed by now :-)), C/C++ would be a disaster! Of those mentioned, I believe Ada is a better choice, there may be others but I have no experience with those languages so I can't comment. Caveat: ANY LANGUAGE can produce working code for an application, it is just the amount or work and effort required to get there. Python *could* be used for an ATC application, so can assembler - but I haven't heard anyone advocating that one :-). Hope you have a good day, Peter From grante at visi.com Thu Jul 5 13:37:35 2001 From: grante at visi.com (Grant Edwards) Date: Thu, 05 Jul 2001 17:37:35 GMT Subject: Is this a true statement: Part III References: <9hsckg$4rt$1@taliesin.netcom.net.uk> <9hsmh1$gtt$1@panix2.panix.com> <qq69kt8id8j4j8rbo75871ikcdk3bpnuos@4ax.com> Message-ID: <zB117.9481$B7.1663062@ruti.visi.com> In article <qq69kt8id8j4j8rbo75871ikcdk3bpnuos at 4ax.com>, Steve Horne wrote: >Any language suffers when bad programmers use it. The biggest >reliability problems in C++ are... >2. Overuse of C features such as pointers, when standard > container templates would be more appropriate - or function > pointer callbacks and awkward methods of finding their context > data when classes with virtual functions would be more > appropriate. The availability of those C features is one of the major flaws in C++. >3. The age-old inherited problems with pointers Another flaw: C++ intentionally inherited those problems also. >4. Failing to use exception-safe patterns. Why was the language designed so that there is such a thing as an exception-unsafe pattern? >In short, C++ is for large systems that are going to be around >for years. There is a tradeoff in favour of greater reliability >and better maintainability - provided you really write C++ and >not some half-baked hybrid The basic problem is that C++ _is_ a half-baked hybrid. If you want a compiled, statically typed OO language, then I'd recommend using a real one like Modula-3. If you want something more dynamic, try something like Python. -- Grant Edwards grante Yow! I'm receiving a coded at message from EUBIE BLAKE!! visi.com From anderson at hp.com Fri Jul 27 20:21:45 2001 From: anderson at hp.com (Bill Anderson) Date: Fri, 27 Jul 2001 18:21:45 -0600 Subject: IPC10 Call For Tutorials References: <3B5D9A09.A49F7C7B@sage.att.com> <mmh77.25356$EP6.5928862@news1.rdc2.pa.home.com> Message-ID: <20010727.182145.933110197.16613@hp.com> In article <mmh77.25356$EP6.5928862 at news1.rdc2.pa.home.com>, "Terry Reedy" <tjreedy at home.com> wrote: > "Garry Hodgson" <garry at sage.att.com> wrote in message > news:3B5D9A09.A49F7C7B at sage.att.com... >> >> We're now accepting proposals for tutorials for IPC10, the annual >> Python conference. We had a good batch last year, and are hoping to >> have some equally good ones this year. > > How about someone doing "Surving Language Change"? (Only half jesting.) > > Is that mean to be Serving or Surviving. ;^) From andreas3004 at hotmail.com Fri Jul 20 03:22:52 2001 From: andreas3004 at hotmail.com (Andreas Kremer) Date: Fri, 20 Jul 2001 09:22:52 +0200 Subject: synchronized lists Message-ID: <9j8m49$22v$00$1@news.t-online.com> Hi, i have the following design problem: in different classes i have lists which consist of elements pointing to instances of other classes with lists. What i need to acchieve is that if an instance of one class is pointing towards another instance, the latter needs a pointer to the former in its list, too, to know who is pointing at it. The result would be at least two lists in each instance, one with pointers outwards to other instances, the other with pointer to instances which point to this instance. I was thinking about a superclass of synchronized lists, but that design did not look "nice". Also a connector doesnt seem to be the best idea. Has anybody an idea about how to acchieve this goal? Thanks in advance, Andreas. From grahamd at dscpl.com.au Fri Jul 27 06:29:24 2001 From: grahamd at dscpl.com.au (Graham Dumpleton) Date: 27 Jul 2001 03:29:24 -0700 Subject: Why Johnny Can't Distribute Processing. WAS: Distributed computing using SOAP. What about speed ? References: <LBA77.58$bXi.175168000@news.telia.no> <dc6f5c99.0107251655.f3c625b@posting.google.com> <3B5FC733.5186D588@tundraware.com> <mailman.996163788.16805.python-list@python.org> <3B6060C3.A6E69FF5@tundraware.com> Message-ID: <dc6f5c99.0107270229.4d7cf31@posting.google.com> Tim Daneliuk <tundra at tundraware.com> wrote in message news:<3B6060C3.A6E69FF5 at tundraware.com>... > So, here's what we need. We need a platform-neutral transactional messaging and > queing service with features like: > > 1) Aynchronous APIs to the messaging and queuing manager > 2) Platform-neutrality: From mainframes to desktops > 3) Class-Of-Service selection > 4) Per-event, selectable write through to backing store > 5) Bindings for C and Java, and also the major scripting langs: Python, TCL, Perl, VBA > 6) Remote management and recovery capability > 7) Plugable security and encryption. > > There are only two commercial products that come close to this, of which I > am aware. BEA bought the rights to the old DEC Message Queue product, but > I dunno if they're doing anything with it any more. And IBM, of course, > has MQ-Series, which has some of the above. I thought BEA bought up Tuxedo, or is that what the DEC stuff used to be called. Anyway, you might also want to look at TIB/Rendezvous and TIB/Rendezvous TX from Tibco (http://www.tibco.com/products/rv/index.html). JMS from the Sun also tries to address this area but obviously with the emphasis on Java. Others I can think of which might also be of interest are Ambrosia from Open Horizon (http://ohi.u1.com) and SmartSockets from Talarian (http://www.talarian.com). From what I have seen and heard, the stuff from TIBCO is quite good and probably the only one I would recommend to anyone. I guess I identify these product because of having more interest in the publish/subscribe side of things. Although most things address this as well as point to point or request/reply semantics these days. The products mentioned may not all address what you are talking about, I haven't looked at exactly what they do recently, but they probably do more than what they did the last time I looked. :-) From shalehperry at home.com Fri Jul 20 22:41:15 2001 From: shalehperry at home.com (Sean 'Shaleh' Perry) Date: Fri, 20 Jul 2001 19:41:15 -0700 (PDT) Subject: whats this mean? In-Reply-To: <20010720213533.19217.00000446@ng-fb1.aol.com> Message-ID: <XFMail.20010720194115.shalehperry@home.com> On 21-Jul-2001 TheDustbustr wrote: ># BEGIN CODE BLOCK > try: > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > s.bind((HOST, PORT)) > s.listen(1) > conn, addr = s.accept() > except socket.error, why: ## reference 1 > print "Server Error: " + errno.errorcode[why[0]] + ", " + why[1] ## > reference 2 > sys.exit(1) ># END CODE BLOCK > > what does reference 2 mean? what do those brackets do? And for reference 1, > what will 'why' hold if an error occurs? > >From the language reference, 4.2: <quote> When an exception is raised, an object (maybe None) is passed as the exception's ``parameter'' or ``value''; this object does not affect the selection of an exception handler, but is passed to the selected exception handler as additional information. For class exceptions, this object must be an instance of the exception class being raised. See also the description of the try statement in section 7.4 and raise statement in section 6.8. </quote> For fun, write an exception handler: try: do something except foo, e: print e print e[0], e[1], e[2] Remember, the python interpreter can also be run interactively. It is a great way to experiment and learn. From guido at python.org Thu Jul 12 21:57:54 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 13 Jul 2001 01:57:54 GMT Subject: Can anyone offer a suggestion? References: <9ikgpq$j1cff$1@ID-11957.news.dfncis.de> <6qsng2rqnr.fsf@abnoba.intevation.de> <9iko92$j1nkb$1@ID-11957.news.dfncis.de> Message-ID: <cpk81d37t6.fsf@cj20424-a.reston1.va.home.com> "Emile van Sebille" <emile at fenx.com> writes: > That's it! My class is invoking __rmul__, coercing the string to an > instance and doing the math. Emile, you might want to study operator precendence and execution order and such. Weren't you also the one who was surprised that 3+5*4 was 23 instead of 32? --Guido van Rossum (home page: http://www.python.org/~guido/) From neal at metaslash.com Tue Jul 10 17:10:18 2001 From: neal at metaslash.com (Neal Norwitz) Date: Tue, 10 Jul 2001 21:10:18 GMT Subject: getting argument names from a function References: <6%F27.4784$yh2.453987@weber.videotron.net> <Pine.SOL.4.30.0107101835460.10785-100000@my.nada.kth.se> <W9I27.5835$yh2.510569@weber.videotron.net> Message-ID: <3B4B6F38.759E5DDE@metaslash.com> def func(a, b, c): x, y, z = 0, 1, 2 numArgs = func.func_code.co_argcount print func.func_code.co_varnames[:numArgs] Neal -- dan wrote: > > Actually, that grabs the entire namespace of the function, not just the > function variables. I haven't found anything in the func_code tree that > contains only the function argument keys... > > thank you though, > Dan > > Fredrik Stenberg wrote: > > > > On Tue, 10 Jul 2001, dan wrote: > > > >> def aFunction(arg1, arg2): > >> print arg1, arg2 > >> > >> is there a way I can get to the arguments of aFunction (i.e. 'arg1' and > >> 'arg2')? > >> > >> I've tried dir(..) on the function object and subsequent object and can't > >> find what I'm looking for. Is it possible to do what I want? > >> > >> thanks, > >> Dan > > > > If the function has a func_code object you can try this approach, > > I have never use it myself and there probably is better ways. > > > > > > Use Ctrl-D (i.e. EOF) to exit. > >>>> def foo(bar,bar2): > > ... print "foobar" > > ... > >>>> foo.func_code.co_varnames > > ('bar', 'bar2') > > > > > > > > I think this will only work for functions written in python, and not > > extensions written in C (atleast thats what my brain thinks). > > > > /fredriks From bsb at winnegan.de Fri Jul 6 10:18:40 2001 From: bsb at winnegan.de (Siggy Brentrup) Date: 06 Jul 2001 16:18:40 +0200 Subject: GUI problems In-Reply-To: <7b515e0f.0107060511.6d8993f4@posting.google.com> References: <7b515e0f.0107051455.4194a679@posting.google.com> <7b515e0f.0107060511.6d8993f4@posting.google.com> Message-ID: <87ith62la7.fsf@winnegan.de> brakedon at hotmail.com (eric_brake) writes: > I don't know what happened, but this is how it's supposed to look > ("command=frame.quit" under "Button" was on the next line. Thanks for > any help That's an easy one, see below: > brakedon at hotmail.com (eric_brake) wrote in message news:<7b515e0f.0107051455.4194a679 at posting.google.com>... > > Why doesn't this TKinter script work? The blank window will come up, > > but the "quit" button doesn't appear inside it. Thanks for any help. > > > > import dice_gui #ignore this > > from Tkinter import * > > class fibon_gui: > > def __init__(self, master): > > frame = Frame(master) > > frame.pack() > > button = Button(frame, text="QUIT", fg="red", command=frame.quit) > > button.pack(side=LEFT) > > root = Tk() > > root.title('Play Dice') fibon_gui(root) > > root.mainloop() > -- > http://mail.python.org/mailman/listinfo/python-list > -- Siggy Brentrup - bsb at winnegan.de - http://www.winnegan.de/ ****** ceterum censeo javascriptum esse restrictam ******* From aleaxit at yahoo.com Sat Jul 7 03:38:20 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 7 Jul 2001 09:38:20 +0200 Subject: I'm Sure There's A Better Way References: <3B465858.CB7F38E8@tundraware.com> Message-ID: <9i6e5502d9g@enews4.newsguy.com> "Tim Daneliuk" <tundra at tundraware.com> wrote in message news:3B465858.CB7F38E8 at tundraware.com... > I want a function to check a string to make sure it is a legitimate > dollar amount. Which means it follows these rules: > > First character is numeric or "-" > At most, one "." is allowed and, if present, is followed by exactly two digits > All the remaining characters must be in the range "0" - "9" These specs seem to be equivalent to: optional: - one or more digits optional: . followed by two digits end of string This is very easy to express as a Regular Expression: r'-?\d+(\.\d\d)?$' So one function to check any string to see if it satisfies this pattern is: def isDollar(astring): import re return re.match(r'-?\d+(\.\d\d)?$', astring) Alex From piet at cs.uu.nl Fri Jul 27 14:28:58 2001 From: piet at cs.uu.nl (Piet van Oostrum) Date: 27 Jul 2001 20:28:58 +0200 Subject: Launching Python from Python References: <3B619A9E.9E940B28@bioreason.com> Message-ID: <wz66cefcph.fsf@sunshine.cs.uu.nl> >>>>> Jay O'Connor <oconnor at bioreason.com> (JO) writes: JO> All, JO> I'm trying to launch another program from a Python program. The other JO> program happens to be another Python program. I thought spawnle would JO> be the proper place. However, it doesn't seem to be working. JO> import os JO> pid = os.spawnle (os.P_NOWAIT, JO> "c:\\python20\\python.exe", JO> ["c:\\james\\development\\python\\test.py"], JO> {"PYTHONPATH":"c:\\james\\python"}) JO> my understanding is that this should spawn the other process, running JO> the python runtime and passing in my script name. JO> However, it doesn't quite happen. What happens is that it launches JO> python in interactive mode. If I import sys, sys.path has my added path JO> above, buy sys.argv is an array with one empty string. JO> Any ideas why it doesn't work? Any other ideas on how to launch another JO> python program from within one? There are two errors in your program: 1. spawnle doesn't have a list [args] as third parameter, but the parameters should be given individually. The format with the [args] is for spawnve. 2. You should supply an additional first argument in the argument list which indicated the name of the program called. It can be different from the filename, on Unix it is what ps displays. In your example python thinks it is called with no arguments. So make it either: pid = os.spawnle (os.P_NOWAIT, "c:\\python20\\python.exe", "python", "c:\\james\\development\\python\\test.py", {"PYTHONPATH":"c:\\james\\python"}) or pid = os.spawnve (os.P_NOWAIT, "c:\\python20\\python.exe", ["python", "c:\\james\\development\\python\\test.py"], {"PYTHONPATH":"c:\\james\\python"}) -- Piet van Oostrum <piet at cs.uu.nl> URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From tim.one at home.com Fri Jul 6 18:09:31 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 6 Jul 2001 18:09:31 -0400 Subject: lvalues and the lgb rule In-Reply-To: <J2q17.427820$eK2.86548710@news4.rdc1.on.home.com> Message-ID: <LNBBLJKPBEHFEDALKOLCAENMKMAA.tim.one@home.com> [Michael P. Soulier] > ... > In Python, previously unused lvalues cause that variable to > be dynamically declared. This is a flawed mental model: the local vs non-local distinction is made at compile-time, by static inspection of the program text. There's nothing dynamic about that (in the absence of "import *" and "exec" abuses). > x = 1 # if x did not previously exist, following the LGB rule, it is > # declared dynamically here Not dynamic. Just look at the code in an editor: if a name is bound anywhere within a code block, and isn't declared in a "global" stmt, then that name is local throughout the entire code block. > Now, while this is great for scripting, it can cause major > headaches with large programs if you're a bad typist. I expect bad typists have lots of other problems writing code too <wink>. > It can declare new variables accidentally, when you wanted to assign > to an existing one... > > myvar = 5 > . > . > myver = othervar A tool like PyChecker will detect that, in the example exactly as given, "myvar" and "myver" are *both* unreferenced, and flag both lines with warnings. > ...so here my typo of myver instead of myvar dynamically creates > myver instead of assigning othervar to myvar. It caused the compiler to believe you have two local vars, myvar and myver; it makes no difference which one comes first; space for both is allocated (in a sense) at compile-time. > It can also accidentally obscure globals. > > So, while the simple answer would be, "don't do that", we all > know that accidents happen. So, I was wondering if there is a way to > force declarations of variables to catch this kind of thing. Not in Python: "global" is its only declaration statement. Use PyChecker: http://sf.net/projects/pychecker/ > Is there, or is there anything in the works, to assign with very large > programs? The size of the program doesn't really matter; regardless of program size, if you don't keep your individual functions and methods to well under a screen of code almost all the time, you're going to have lots of problems (in Python or any other language; it may even be worse in Python, because indendation for grouping really doesn't work well when code blocks slobber over screen pages; that's one of the clever pressures in Python *nudging* you toward writing better code). guido-can-lead-you-to-clarity-but-he-can't-stop-you-from-peeing-in- the-stream<wink>-ly y'rs - tim From bokr at accessone.com Mon Jul 23 17:28:29 2001 From: bokr at accessone.com (Bengt Richter) Date: Mon, 23 Jul 2001 21:28:29 GMT Subject: A use for integer quotients References: <mailman.995866298.23496.python-list@python.org> <eppstein-E19F08.00451323072001@news.service.uci.edu> <3B5BDCB4.A2010560@letterror.com> <GbW67.19921$EP6.4914854@news1.rdc2.pa.home.com> <3B5C3713.A5201C5A@letterror.com> <eppstein-FE588D.09125623072001@news.service.uci.edu> Message-ID: <3b5c85aa.232500618@wa.news.verio.net> On Mon, 23 Jul 2001 09:12:56 -0700, David Eppstein <eppstein at ics.uci.edu> wrote: [...] >think it an improvement. Integers are exact. Floating point numbers are >approximate. Integers allow rearrangements like (a+b)+c=a+(b+c), floating >point numbers don't. If you need your numbers to be computed exactly, and >your programming language turns them into floats behind your back, it will >cause bugs. <philosophical nit> IMHO integer and floating point are not comparable concepts. One is an abstract mathematical concept and the other loosely identifies a set of tricks for representing numbers in hardware. Integer, rational, real, complex are what need to be represented, with provisions for specifying and monitoring of how "well" the number is represented. The first measure of how "well" is exact vs inexact. Exact doesn't need further qualification. Inexact does, and confusion reigns[1]. floating point, IEEE754, float, double, extended, short, int, long, long long (ick), decimal float, BCD, bi-quinary, string, pickling formats, etc., and compounds of same are different possible representation formats, limited only by imagination. The integer IV can be represented *exactly* in all those formats ;-). Exactness is not a property of the representation itself. E.g., Python's float can represent a bigger contiguous set of integers exactly than its int type (unless you're on an Alpha or such). Limitations != inexactness, but can sometimes produce it. It may be a safe convention to treat floating-point-represented numbers as inexact, but it is shoddy to mislead newbies by saying that floating point *is* inexact, implying that even 1.0 should be suspect[2]. It smacks of the arrogant paternalism that says, "Here's a safe way for you twits to think about this, so that what you don't know won't hurt you." OTOH, I think one could argue for hiding the existence of float in a language, on the grounds that it is a low level implementation detail, and ought not be visible except to developers and specialists. That's better than outright misleading. </philosophical nit> [1] Here we are characterizing the relationship of a pure number (whatever its source) to its representation. An exact number per se can result from an inaccurate measurement, so people don't like to call such a number exact. The word is overloaded. Since representation approximations and measurement errors can be compounded into the final result of a computation, people get confused about what's what. [2] An _even_ 1.0 _would_ be suspect ;-) From rnd at onego.ru Tue Jul 3 23:59:17 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 4 Jul 2001 07:59:17 +0400 (MSD) Subject: problem with sending email In-Reply-To: <ku3d8d31ve.fsf@lasipalatsi.fi> Message-ID: <Pine.LNX.4.30.0107040758050.6839-100000@rnd.onego.ru> On 4 Jul 2001, Erno Kuusela wrote: May be, web-server you are using imposes limitations of the length of files? Check resource.RLIMIT_FSIZE Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Wednesday, July 04, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Mediocrity requires aloofness to preserve it's dignity" _/ From juergen.erhard at gmx.net Tue Jul 10 15:11:53 2001 From: juergen.erhard at gmx.net (=?ISO-8859-1?Q?=22J=FCrgen_A=2E_Erhard=22?=) Date: Tue, 10 Jul 2001 21:11:53 +0200 Subject: Is Python Dead? Long Live Python! In-Reply-To: <5174eed0.0107091109.d3a53f6@posting.google.com> (web2ed@yahoo.com) References: <MNS%6.355$Xs4.225014@news.pacbell.net> <458b194a.0107050711.72007607@posting.google.com> <TH%07.3499$i8.339613@e420r-atl3.usenetserver.com> <458b194a.0107060959.6bd34b3f@posting.google.com> <7sn17.7740$i8.679052@e420r-atl3.usenetserver.com> <458b194a.0107071317.508ef7e4@posting.google.com> <mailman.994599260.9137.python-list@python.org> <5174eed0.0107091109.d3a53f6@posting.google.com> Message-ID: <10072001.2@wanderer.local.jae.ddns.org> >>>>> "Edward" == Edward Wilson <web2ed at yahoo.com> writes: Edward> Languages never die; they just fall out of use when they loose touch Edward> with the contemporary. Python will become more or less mainstream Edward> (live or die) on it's own merits. Edward> A scripting language should be good at scripting. From my Edward> observation, Python appears to be headed in more of an acedemic Edward> direction rather than that of mainstream commerce. Acedemics are Edward> good, it's where technology comes from. Unfortunately, I still Edward> haven't found a way to make money using Python. If I can't make money Edward> with Python, then Python is dead to me. I would imagine my voice Edward> represents a small crowd of developers, who wish they too could make Edward> money with and contribute to Python on a daily basis (on company Edward> time). Edward> If this is so, Python won't bennefit from the best developers, the Edward> developers who code for a living. From what I can tell, PHP and Ruby Edward> are flying past Python in acceptance rates. The difference that I see Edward> in these groups, is a sensitivity to industry, rather than an Edward> adoration for pure acedemic elegance. Edward> Beauty is only beauty if one can experience it. I can't experience Edward> Python on a day to day basis (in the workplace), so therefore I can't Edward> appreciate it. Edward> As far as ODBC--ODBC is too slow for what I do. I'm using Oracle Edward> Pro/C. Most serious developers would agree that ODBC is slow. Edward> Wheather Java decides to use (cheat with) ODBC or not is Java's Edward> problem. Java is WAY too slow for serious development of any kind. Edward> If it weren't, it would be the perfect language--if that were Edward> possible. Edward> Yes, native drivers for all db vendors. This is why I mentioned (in Edward> an earlier post) that this should be a community effort. Python could Edward> break the door down if it paid more attention to the needs of the Edward> commond professional. Satellite controlers are great too, but Edward> Priorities have meaining in a time of war. Bwahahahahha... heehee, *wheeeze*... please, stop, this is too good! My stomach's starting to hurt! "Java ... serious development of any kind." ... mua... mwua... Mwuahaha, Bwuahahaha! Bye, J PS: If ever you should have a need for a second career, try stand-up comedy. You should be good at it... PPS: I agree with Paul: it's hardly possible to take you seriously anymore. -- J?rgen A. Erhard (juergen.erhard at gmx.net, jae at users.sourceforge.net) MARS: http://members.tripod.com/Juergen_Erhard/mars_index.html "Perl Programmers are from Mars, Python Programmers are from Yorkshire" -- Alex in c.l.py -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 248 bytes Desc: not available URL: <http://mail.python.org/pipermail/python-list/attachments/20010710/4726bd4d/attachment.sig> From jeff at ccvcorp.com Wed Jul 25 13:49:26 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Wed, 25 Jul 2001 10:49:26 -0700 Subject: Alternate numeric proposal References: <mailman.995864377.19861.python-list@python.org> Message-ID: <3B5F06A6.36BB1AFC@ccvcorp.com> Chris Gonnerman wrote: > Why don't we add a hook to Python to control the numeric evaluation > rules directly? > > An object containing methods to handle numerical operations would > be registered with a statement like this: > > __builtins__.numerics = MyNumericObject() > Not too bad of an idea, perhaps... but, if we allow this to be done on the module level, then how is it different from "from __future__ import division" ?? The only difference being that, in the latter case, the implication is that the distinction (old v. new division) will eventually disappear. I'm not too thrilled about the division change, but... Guido's rationale, now that I've seen it, *is* consistent. He wants, in essence, to create a generic "number" type that switches internal representation between ints, longs, floats, and complex as needed. If you're looking at ints as a special subclass of floats, then the proposed semantics make sense. If you look at ints as a separate set, representing purely discrete quantities, then it doesn't. Given that automatic type conversions already treat ints in the former way, it could be difficult to make a compelling argument against float-division. And he *does* seem to be taking the code-breakage issue seriously... so, while I'd prefer / to retain its current meaning, I guess I can accept the change. Fortunately *I* don't have a large library of scripts to modify.... My one big recommendation in this issue, would be that, however many versions are released before float division becomes the default, that version--the code-breaking version--be called Python 3.0. This major of a change in core behavior seems to indicate a major-version change. I suspect this would also help with the PR aspect of code breakage--it's much easier to justify breaking old code with a major release than a minor release, and there's less likelyhood of someone upgrading to a new major version without at least checking the release notes--which, I would expect, would prominently declare that this release would create problems with legacy code. Jeff Shannon Technician/Programmer Credit International P.S. I *was* going to suggest that if case-blindness were to be accepted, that it be planned to become effective in the same release, thus having only one major code-breaking release instead of two, but fortunately, case-blindness seems to have been dropped and case sensitivity will remain as is (whew!). From aleaxit at yahoo.com Mon Jul 16 08:30:13 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 16 Jul 2001 14:30:13 +0200 Subject: Partition Problem References: <tku1tt92ac2g8e@corp.supernews.co.uk> <3B4FBEA0.D5A6DC8A@engcorp.com> <9ioru22pc9@enews4.newsguy.com> <3B5042C2.F821D916@engcorp.com> <9itb14$2oi$1@newsg1.svr.pol.co.uk> Message-ID: <9iumon01t0v@enews3.newsguy.com> "Donovan Hide" <donovanhide at bigfoot.com> wrote in message news:9itb14$2oi$1 at newsg1.svr.pol.co.uk... ... > question. What I am actually looking for is the enumeration of all the 6 > whole numbers greater than 0 that sum to 17. > After that, another enumeration is required, this time to find all 6 > whole numbers greater than 0 that sum to 20. Order is unimportant. ... > So, apart from this short bibliography, I am still stuck. I don't want So go back to the solution I already posted for a slightly different interpretation of your problem: def seqs(i, j, sumsofar, sumdesired, minok, thelist): # print 's',i,j,sumsofar,sumdesired,minok,thelist[:j] if i==j-1: missing = sumdesired - sumsofar if missing < minok: return 0 thelist[i] = missing print thelist return 1 elif i>=j or sumsofar+minok > sumdesired: return 0 thelist[i] = minok results = 0 while 1: more = seqs(i+1, j, sumsofar+thelist[i], sumdesired, thelist[i]+1, thelist) if not more: break results += more thelist[i]+=1 return results Apparently the only way in which this differs from what you'd like to do is that this forbids duplication, right? OK, then, so ALLOW duplication -- where's the problem?! Just change the recursive call so that the 5th parameter, 'minok', is passed as thelist[i] rather than thelist[i]+1. This means thelist ends up in nondecreasing, rather than strictly increasing, order. def seqs1(i, j, sumsofar, sumdesired, minok, thelist): # print 's',i,j,sumsofar,sumdesired,minok,thelist[:j] if i==j-1: missing = sumdesired - sumsofar if missing < minok: return 0 thelist[i] = missing print thelist return 1 elif i>=j or sumsofar+minok > sumdesired: return 0 thelist[i] = minok results = 0 while 1: more = seqs1(i+1, j, sumsofar+thelist[i], sumdesired, thelist[i], thelist) if not more: break results += more thelist[i]+=1 return results if __name__=='__main__': nr = seqs1(0, 6, 0, 17, 1, 6*[0]) print nr,'sets of 6 numbers that sum to 17' D:\py21>python sq.py [1, 1, 1, 1, 1, 12] [1, 1, 1, 1, 2, 11] ...snipped several lines... [2, 2, 3, 3, 3, 4] [2, 3, 3, 3, 3, 3] 44 sets of 6 numbers that sum to 17 D:\py21> So, where's the problem? Solving this for sets of 6 numbers that sum to 20 is left as an exercise for the reader -- not too difficult an exercise, I hope!-) (More interesting is to find optimizations that can be applied to this reference implementation:-). Another easy exercise: what would you change if the numbers were allowed to be from -1 upwards, rather than "greater than 0"...? General consideration: even where the problem statement does NOT constrain the order of the results (you just have to count them, whatever), it's often easier if results are generated in a systematic order -- this helps ensure against double-counting, you can print out the results you're supposed to be just-counting to help you debug things (and notice gaps more easily because of the systematic order, if you have a bug somewhere)... Alex From michael at stroeder.com Tue Jul 3 09:25:24 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Tue, 03 Jul 2001 15:25:24 +0200 Subject: Python for air traffic control? References: <bebbba07.0106291642.6c799d15@posting.google.com> <9hlfbn$6ok$1@nereid.worldonline.nl> <9hrj3q$cj1@news1.gtech.com> <9hsfue$oqv$1@216.39.170.247> Message-ID: <3B41C7C4.E444FCF8@stroeder.com> David LeBlanc wrote: > > The Canadians privatized their national air traffic control a few years > ago and oh my! the planes RUN ON TIME! Which does not say anything about safety. Well, time will tell... Ciao, Michael. From new_name at mit.edu Wed Jul 18 13:32:45 2001 From: new_name at mit.edu (Alex) Date: 18 Jul 2001 13:32:45 -0400 Subject: sys.argv not found References: <3B55962C.63F7E2EF@mit.edu> <bkh57.21065$PF1.1027936@e420r-atl2.usenetserver.com> <3B55B2C2.74A8FB3D@mit.edu> Message-ID: <etdlmlmuoqq.fsf@opus.mit.edu> Perhaps you have another module sys.py somewhere in your path. Try this from the interpreter: >>> import sys >>> sys <module 'sys' (built-in)> If this gives you a module name with a file path, you may want to try moving that file out of the way. Alex. From guido at zope.com Tue Jul 31 23:28:54 2001 From: guido at zope.com (Guido van Rossum) Date: Tue, 31 Jul 2001 23:28:54 -0400 Subject: 2.2 features In-Reply-To: Your message of "Tue, 31 Jul 2001 20:24:41 -0300." <20010731202441.M19610@tux.distro.conectiva> References: <cpofq524lr.fsf@cj20424-a.reston1.va.home.com> <slrn9m61bs.atb.quinn@retch.ugcs.caltech.edu> <slrn.pl.9m6a5m.kmu.qrczak@qrnik.zagroda> <cpae1lzio7.fsf@cj20424-a.reston1.va.home.com> <15206.48884.18637.676324@beluga.mojam.com> <200107311705.NAA16444@cj20424-a.reston1.va.home.com> <15206.61485.360973.566871@beluga.mojam.com> <200107311904.PAA17115@cj20424-a.reston1.va.home.com> <15207.1733.965818.91745@beluga.mojam.com> <200107312309.TAA17435@cj20424-a.reston1.va.home.com> <20010731202441.M19610@tux.distro.conectiva> Message-ID: <200108010328.XAA18293@cj20424-a.reston1.va.home.com> > I'm starting to like the is{subclass,instance}() version. It's probably > quicker for one to understand code written by others, and for > non-fulltime-python-programmers to remember what "in" means in each > context. You may be right. isinstance() and issubclass() are somewhat standard in other languages I believe, and hard to misunderstand. The form if x in list: ... looks a lot more confusing. I may withdraw this idea. --Guido van Rossum (home page: http://www.python.org/~guido/) From donn at u.washington.edu Fri Jul 13 13:25:42 2001 From: donn at u.washington.edu (Donn Cave) Date: 13 Jul 2001 17:25:42 GMT Subject: greenbeen seeks advice References: <9pF37.22474$g96.625691@news.easynews.com> Message-ID: <9inaum$nj4$1@nntp6.u.washington.edu> Quoth "wyatt stafford" <wyatts at onr.com>: ... | Beyond those mentioned above, may I have any recommendations for self study | resources (books, etc) or techniques that will help me be a good programmer, | in general? If you like working examples, I would get the source distribution and peruse the programs in the Demo subtree. Donn Cave, donn at u.washington.edu From tim at vegeta.ath.cx Sun Jul 15 18:18:28 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Sun, 15 Jul 2001 22:18:28 GMT Subject: Python, C++, Java, Smalltalk, Eiffel,... References: <9is8rm$46d$1@panix3.panix.com> Message-ID: <slrn9l46bt.p58.tim@vegeta.ath.cx> Me parece que kj0 <kj0 at mailcity.com> dijo: > Where can I find a reasonably non-partisan but also reasonably > detailed comparison of the more popular OO languages (C++, Java, > Python, etc.). (All the comparisons I've found are clearly slanted to > demonstrate the superiority of the authors' favorite OO language--I'm > sure it would be easy to find one written by unapologetic Python > advocates :-) ) What about Smalltalk? I know so many lifelong programmers that swear Smalltalk is the _ONLY_ true OO language. ;) (see signature at bottom for one of their many rationales) > I'm not looking to find out which of these languages is "better"; I > don't care for ranking here. What I want to know is how the various > popular OO languages compare in terms of OO and general programming > features (e.g. multiple inheritance; classes-as-objects; garbage > collection; closures; scoping; contracts; debugging; etc.). IMBANERHO[*], Python offers the greatest flexibility overall in the areas you listed. (And this from a long-time and unapologetic Perl monger!) However, you'd always be better off making the decision for yourself. Try them and see what works best for your applications. [*] In My Biased And Never Even Remotely Humble Opinion HTH -- C++: an octopus made by nailing extra legs onto a dog -- unknown From serrano at ozemail.com.au Tue Jul 24 04:47:40 2001 From: serrano at ozemail.com.au (michael) Date: Tue, 24 Jul 2001 18:47:40 +1000 Subject: A use for integer quotients References: <3B5BC73B.2D52E5E2@alcyone.com>, <3B5BA29B.E08FEEE9@alcyone.com>, <yCK67.17615$EP6.4467503@news1.rdc2.pa.home.com> <mailman.995860718.9550.python-list@python.org> <mailman.995862939.15013.python-list@python.org> <mailman.995883879.12071.python-list@python.org> <3B5C5665.8D41D1F1@tundraware.com> <slrn.pl.9los0f.jh4.qrczak@qrnik.zagroda> <3B5C749A.59F97320@tundraware.com> Message-ID: <JDa77.97061$Rr4.549007@ozemail.com.au> > Not formally, AFAIK. For example, 3 with no decimal point following > could be anything from 2.5 to 3.4. If I remember correctly, to be > fussy about it, you would need to specify 3.00/4.00 to get 0.75 or am > I missing something or misremembering my ancient maths courses ;) ? > I'm pretty sure that mathematicians say that three, 3, 3.00, iii are different numerals for the same number. This number is a real number, a rational number, an integer, and a natural number. > More importantly, the thing everyone is talking about here is an > integer operation yielding a real (float) result. Isn't this kind of > a "no-no" amongst mathematicians? I'm not sure whether the "inner product" from vector algebra could be considered an "operator", but it does operate on vectors and yields a scalar. > > Maybe I'm wrong here... From nperkins7 at home.com Tue Jul 24 13:36:07 2001 From: nperkins7 at home.com (Nick Perkins) Date: Tue, 24 Jul 2001 17:36:07 GMT Subject: Opening a file with Python References: <3b5be641_3@news.newsgroups.com> <9jhgm4$2mo$1@mtc1.mtcnet.net> <3b5d8947_5@news.newsgroups.com> <nzh77.543721$eK2.114049226@news4.rdc1.on.home.com> <3b5da934_2@news.newsgroups.com> Message-ID: <bmi77.543954$eK2.114107493@news4.rdc1.on.home.com> "Janos Blazi" <jblazi at hotmail.com> wrote in message > Yes, thx. Can you tell me the difference between python.exe and pythonw.exe? > And later I am going to use Tkinter in my program. Shall I need python.exe > or pythonw.exe? The only difference is that pythonw.exe does not pop open the dos window. Otherwise, they are the same. Both are fine for Tkinter. You could use python.exe while you are writing/debugging, then when it's all finished, switch to pythonw.exe ( change extension to .pyw ), so that users of your program don't have to see the dos window. In other words, just stick to python.exe and .py extensions unless you really want to get rid of the dos window. From vAbazarov at dAnai.com Thu Jul 26 11:56:22 2001 From: vAbazarov at dAnai.com (Victor Bazarov) Date: Thu, 26 Jul 2001 15:56:22 GMT Subject: Unusual minidom behaviour: Part Deux References: <vKJ77.12050$Up.355596@sea-read.news.verio.net> <j4lmlcglpm.fsf@informatik.hu-berlin.de> <cpu1zz7pve.fsf@cj20424-a.reston1.va.home.com> Message-ID: <G4X77.12074$Up.356481@sea-read.news.verio.net> "Guido van Rossum" <guido at python.org> wrote... > Martin von Loewis <loewis at informatik.hu-berlin.de> writes: > > > "Victor Bazarov" <vAbazarov at dAnai.com> writes: > > [...] > > The only situation where I've seen this, ironically, is if you attempt > to import the test module that's designed specifically to test this > lock, in the interactive interpreter on Windows. > > --Guido van Rossum (home page: http://www.python.org/~guido/) I just saw something that might be relevant. Please, don't jump the gun, I said "might". The other thread ("Re: Threads in Python version 1.5, thread doesn't start until calling process dies") is discussing a problem with threads in Python. The death of the calling process lets the system to go ahead. It may or may not be relevant, but I would like to hear your opinion on it. The big difference is that in the aforementioned posts the version of Python is 1.5.1 and I am using 2.0. Thank you very much for your time. Victor -- Please remove capital A's from my address when replying by mail From BPettersen at NAREX.com Mon Jul 16 10:09:19 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Mon, 16 Jul 2001 08:09:19 -0600 Subject: Language change and code breaks Message-ID: <6957F6A694B49A4096F7CFD0D900042F27DB98@admin56.narex.com> > From: Peter Hansen [mailto:peter at engcorp.com] > > Guido van Rossum wrote: > > > > Peter Hansen <peter at engcorp.com> writes (after much good stuff about > > transitioning): > > > > > After the transition period, screw the professional programmers > > > who won't take the time to modify their existing code and yet > > > who selfishly insist that their wonderful program *must* be > > > allowed to continue running under the new Python without > > > problem. > > > > Well, I don't know about you, but *I* am reluctant to say > "screw you" > > to all those people who depend on Python script written by > > professional programmers who no longer work there. > > "Screw you" might have been a little strong. (And for those just > joining, I _am_ one of those professional programmers about which > I was making the suggestion...) > > Nevertheless, I want to make the clear point (if I haven't already) > that I'm not suggesting screwing every such programmer... just > those who are actively using code which would be broken, who will > not take the time (however small we might make it) to modify the > source, and yet who "must" have their code work under the new Python. > > Are there really any people like that? Enough to make it > a key factor? I'm not sure I can even think of any realistic > cases where anyone like that exists (he said, trolling for > someone to point out an obvious example or two). Well, I for one wrote several thousands of lines of Python code in my last job, and I obviously have no influence on when they're going to upgrade to a newer version of Python. You can probably safely assume that they're not going to put a programmer on fixing programs that are running without any problems. More likely they would upgrade Python, realize that "a bunch" of Python scripts stopped working, and either roll back the Python upgrade, rewrite them in Perl/Java, or find someone with enough Python skills to fix the problems. Neither solution would be good PR for Python... -- bjorn From cer at tutopia.com Sat Jul 21 01:42:42 2001 From: cer at tutopia.com (Cristian Echeverria) Date: Sat, 21 Jul 2001 01:42:42 -0400 Subject: py2exe problem References: <mailman.995667696.25448.python-list@python.org> Message-ID: <9jb4a0$n00kv$1@ID-44371.news.dfncis.de> Ok "Jay Parlar" <jparlar at home.com> wrote: > #install.py > from distutils.core import setup > import py2exe > setup(name="webpass", scripts=["window1.py"], ) If your application uses any file apart from the *.py ones you need to use the data_files parameter. something like this: setup(name="webpass", scripts=["window1.py"], data_files=["file1","file2"]) > python install.py py2exe -w You can try compiling without the "-w" option and running the program from the command line on the test machine. Did you try this? What about msvcirt.dll and msvcrt.dll in your development machine and your test machine? If I remember wxPython update this dlls when this is installed. Remember that py2exe is intended to use with an installer like Inno Setup, if you move only your exe there is good chance that this can't run. From tjreedy at home.com Fri Jul 20 19:13:44 2001 From: tjreedy at home.com (Terry Reedy) Date: Fri, 20 Jul 2001 23:13:44 GMT Subject: Most efficient solution? References: <mailman.995289809.28477.python-list@python.org> <slrn9l5urp.nto.alf@leo.logilab.fr> <OeF47.11959$p7.3571067@news1.rdc2.pa.home.com> <wkk813nz6e.fsf@mail.connact.com> Message-ID: <IW267.7537$EP6.2447816@news1.rdc2.pa.home.com> <phawkins at connact.com> wrote in message news:wkk813nz6e.fsf at mail.connact.com... > >>>>> "TR" == Terry Reedy <tjreedy at home.com> writes: > > >> C = {} > >> for item in B: > >> C[item]=None > > TR> This sort of makes me wish we had dict comprehensions to match list > TR> comprehensions: > > TR> C = {item:None for item in B} > TR> or > TR> C = {item:1 for item in B} > TR> as revised and then discarded > > So what's wrong with list comprehensions? Observe, grasshopper: Confucius say: People who make gratuitous snide putdowns set themselves up to look like asses. > 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 time > > a = [str(i) for i in range(7500)] > b = [str(i) for i in range(0, 7500 * 5, 5)] > c = {} > > for item in b: > c[item] = 1 > > def dict(a,c): > start = time.clock() > for item in a: > d = filter(c.has_key, a) > stend = time.clock() > print "get: %6.2f"%(stend-start) > > def comp(a,b): > start = time.clock() > out = [i for i in a if i not in b] > stend = time.clock() > print "get: %6.2f"%(stend-start) > >>> comp(a,b) > get: 19.78 > >>> dict(a,c) > get: 154.77 For years, people have compared reduce(), map(), and filter() to equivalent contructs with for and if statements that do the same work and produce the same result. In the last year, such comparisons have been extended to list comprehensions, which, last I knew, are implemented by compiling them as if they had been written as some equivalent set of nested for and if statements. As I recall, most such results have been fairly close (within say, a factor of two), with details depending on the exact problem and platform (hardware + operating system + compiler + compiler settings). As a result, many or most people have continued using whichever construct they prefer on other grounds. This mishmash of hashes producing 1500-element lists and non-equivalent linear searches producing a 6000-element list says *nothing* about anything 'wrong' with either list comprehensions or the nested for and if statements they abbreviate. And even proper comparisions involving reduce, map, and filter would have nothing to do with dictionary comprehensions since none of them produce dictionaries. If my 'wish' become strong enough, I will follow the proper procedure for proposals and write a PEP so dict comprehensions either get added or have a documented reason after discussion why not. Terry J. Reedy From sam at ddmweb.com Fri Jul 6 12:00:23 2001 From: sam at ddmweb.com (Sam Penrose) Date: Fri, 6 Jul 2001 09:00:23 -0700 Subject: Most important text processing examples Message-ID: <01070609564400.07365@frock.ddmweb.com> For building dynamic web pages (generating, as opposed to parsing, strings), I find tweaking Python's string substitution idioms to be helpful. If you have a web template into which you want to drop some content, standard Python practice would be to read in a file that looks like this: template = """<html><head><title>%(title)s %(body)s""" #... then generate a dictionary that looks like: dict = {'title':'This is my title', 'body':'This is the body of my page'} #...and then combine the two with: html = template % dict #giving html == """This is my title This is the body of my page""" If you fail to include either the 'title' or 'body' keys on the dictionary, you will get a KeyError on the last step. When the target has many tags, some of which are only going to be filled with text in certain situations, keeping track of all the keys quickly becomes a tedious chore. If you insist on doing it manually, your code will be dominated by dictionary assignments. This is why so many of us have written frameworks for generating web pages. I rely on a dictionary-like object that returns an empty string if asked for a key it doesn't have. from UserDict import UserDict class NoKeyErrors(UserDict): def __init__(self, dict={}): UserDict.__init__(self, dict) def __getitem__(self, key): return UserDict.get(self, key, '') template % NoKeyErrors({'body':'This is the body of my page'}) #gives html == """ This is the body of my page""" ...rather than an error. In pages with a dozen or more possible keys, this allows me to write code that focuses on the keys that will be used in a given situation, rather than requiring every object to know about the keys used by every other object that uses the same template. I used to use another modification of UserDict: class PartialStringSubstitution(UserDict): def __init__(self, dict={}): UserDict.__init__(self, dict) def __getitem__(self, key): return UserDict.get(self, key, '%(' + key + ')s') which, if it fails to find a key, will re-insert the tag for the key. This allows you to make multiple passes over a single template: # early in the code html = template % PartialStringSubstitution( {'body':'This is the body of my page'}) # giving html == """%(title)s This is the body of my page""" # much later html = html % {'title':'This is my title'} #which also results in html == """This is my title This is the body of my page""" I only used this double-pass technique in one project, finding it easier to update a single NoKeyErrors object with various auxiliary dictionaries than to keep track of when I should make prelimary passes with PartialStringSubstitution dictionaries and which keys they should contain. There are many ways to tackle this kind of string handling, and you can probably do much better than my hacks. But if you want to write reasonably modular code on large string generating projects, you will need to find some way of decoupling the variables required by one situation from those required by all of the others. From paulp at ActiveState.com Fri Jul 13 14:27:15 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Fri, 13 Jul 2001 11:27:15 -0700 Subject: not safe at all References: Message-ID: <3B4F3D83.FDE549B@ActiveState.com> Dennis Roark wrote: > > ... > > Python is an attractive language. But for a large program I > would still rather be forced to declare the name of a > variable (and its type) rather than risk misspelling or > misuse 500 lines later in the program. My original note was > not intended to be an indictment of Python, but only to > bring up some reasons that for me make more strongly typed > languages like C++ or Object Pascal better at coding very > large projects. You seem to have just discovered Python's dynamicity. You may not yet be in a position to understand the *benefits* of this dynamicity in large programs which go along with its costs. Sometimes Python's dynamic features will allow thousands of lines of Java or C++ code to just melt away into a few lines of Python. That increases the overall reliability of the system. Python also makes testing much easier. Therefore you can do more testing in less time and thus improve the stability of your program. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From tangell at kicker.com Thu Jul 12 10:46:33 2001 From: tangell at kicker.com (T Angell) Date: 12 Jul 2001 07:46:33 -0700 Subject: Light Speed Socket Connections References: <3b4d6184.1698299906@wa.news.verio.net> Message-ID: bokr at accessone.com (Bengt Richter) wrote in message news:<3b4d6184.1698299906 at wa.news.verio.net>... > On 11 Jul 2001 22:32:16 -0700, tangell at kicker.com (T Angell) wrote: > > >I wrote some code to test how long it takes to make socket connections > >and ran it against several hosts around the world, here are some > >sample times: > > > >socket time: 0.0047459602356 > >socket time: 0.00469899177551 > >socket time: 0.00404000282288 > >socket time: 0.00537407398224 > > > [...] > > t1 = time.time() > For accurate timing, time.clock() > is recommended, I believe: > > """ > clock() > Return the current CPU time as a floating point number expressed in seconds. > The precision, and in fact the very definition of the meaning of ``CPU time'', > depends on that of the C function of the same name, but in any case, this > is the function to use for benchmarking Python or timing algorithms. > """ > """ > time() > Return the time as a floating point number expressed in seconds since the epoch, > in UTC. Note that even though the time is always returned as a floating point number, > not all systems provide time with a better precision than 1 second. > """ Oh, of course. Thanks! From tim.one at home.com Sun Jul 22 15:11:50 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 22 Jul 2001 15:11:50 -0400 Subject: doctest In-Reply-To: <9j8m10$n1t3p$1@ID-59885.news.dfncis.de> Message-ID: [Thomas Heller, reverts the string-methods changes to doctest.py in current CVS Python] > Thanks to cvs update -j 1.3 -j 1.2 and manually fixing the two or > threee conflicts it was easy, with _one_ exception: > > There is a 'from __future__ import generators' line, which > makes sense for 2.2, but throws SyntaxError in 2.1 and 2.0, > and ImportError in 1.5.2. > Unfortunately it cannot be wrapped by try: except: because > it must occur at the beginning of the file. > Any idea? What are you trying to accomplish? A single version of doctest that runs under all versions of Python? Then comment out that line and you're done. The generator-future stmt is needed in CVS (only) so that test_generators.py passes (doctest itself doesn't use generators), and the need is due to unresolved general issues spelled out in PEP 236 (see the "Paritally Resolved Problem: Runtime Compilation" section). From sh at ttsoftware.co.uk Tue Jul 24 14:33:43 2001 From: sh at ttsoftware.co.uk (Steve Horne) Date: Tue, 24 Jul 2001 19:33:43 +0100 Subject: Steve Summary of views on the Is-It-Actually-Better? (was re: a use for...) References: <3B5BC73B.2D52E5E2@alcyone.com> <3B5BA29B.E08FEEE9@alcyone.com> Message-ID: On 24 Jul 2001 18:32:08 +1200, Paul Foley wrote: >On Mon, 23 Jul 2001 15:08:16 +0100, Steve Horne wrote: > >> And what do you mean *correctly* - integer division is NOT incorrect, > >It's not division, either. > >> it is the only form of division that is appropriate for integer >> measures. If you are using inherently real measures you should use >> floats - not integers. > >If you want integers, write floor(a,b) [or floor(a/b)], since that's >what you really mean. To address this issues, but also summarise my main objections to many others... Because... 1. The fact that mathematicians have had many views on integers and division, and the one that is in most non-specialist mindsets doesn't meet the pragmatic requirements for several fields of mathematics, is understood. That doesn't make the other definitions from less demanding, more down-to-earth fields invalid. 2. It particularly does not invalidate the practical view which most people can easily understand, which is taught to everyone at a very early age and which also happens to work extremely well for typical programming tasks (not just specialist applications). Doesn't the pro-pep views insistence on the most pragmatic possible definition of discrete integer division seem more than a little inconsistent with their sloppy attitude to the much more fundamental difference between discrete and continuous mathematics? Just because it isn't the unnecessarily pragmatic (for normal programming tasks) field of mathematics that a few people subscribe to, it doesn't make it wrong. It is simply from a less specialised, more basic and more generally useful field that doesn't address the specialist problems of the minority over the general day-to-day practicality of the majority. 3. Practically all programs use discrete integer quantities - indices, subscripts, counters, sizes and more - whereas numerics is a particular specialist field. Making life more awkward for the majority just to suit a few specialist fields is not rational. It's the specialists dealing with specialist fields who should have to deal with awkward special case syntax and semantics - not the everyday user. 4. Discrete measures and continuous measures are not the same thing and should not be arbitrarily confused. Discrete integer division makes perfect sense despite the fact that specialist fields have outlawed it for specialist reasons relating to specialist problems. This is much more fundamental than just switching between different representations of continuous measures. The pro-pep groups arbitrarily application of continuous measure division principles with a discrete integer type is wrong in mathematics, and it is wrong in engineering, and it is wrong in programming. My use of more practical day-to-day discrete principles for discrete integer arithmetic than would be appropriate in field theory - or even 16-year-old pure mathematics, I fully agree - is not the same thing at all. 5. Having established that division on the discrete integer type should work in the only practical way that makes sense while not erroneously confusing the properties of discrete and continuous measures, it makes sense for it to apply a simple everyday convension for rounding direction - wordy and pragmatic systems should be saved for the specialist fields where they are necessary. 6. No-one has yet explained why bugs with misusing discrete integer types in continuous contexts cannot be detected and handled by simple validation. IMO, no-one can consider themselves a professional programmer if they assume the need for validation of externally sourced inputs does not apply to them. If the validation requirements are too fiddly to be practical, then that is a valid reason to consider adding new validation syntax and semantics which could even have wider applications. It is not a valid reason to break the widespread uses of discrete integer division in existing code, nor to make the distinction between discrete and continuous measures even harder to maintain than it already is. 7. People who are really dealing with numerics and who cannot trace down big errors caused by the buggy use of discrete integer types in a continuous context are surely incapable of tracing down the subtle and insidious problems caused by float approximations? 8. If you are worried about the learning curve of newbies and students, then you should be worried about making the learning curve faster and easier - not disguising or hiding it, and not creating a comfort zone where you encourage bad habits while pretending there is no principle that needs to be learned. 9. If you are dealing with 3D graphics, then you are either getting a library or hardware interface to do the rendering for you and MOST (but not all) of what you handle will be continuous measures represented by floats (which obviously should not be confused with discrete integers), or else you will be doing the rendering yourself and you will need to handle a lot of discrete integer mathematics AND continuous floating point mathematics. Pixels are a discrete integer measure and they are handled using algorithms that require discrete integers to behave as discrete integers. Discrete and continuous principles should not be arbitrarily confused, however. 10. Discrete integer division is not fundamentally different to continuous float or rational division - continuous measures simply use logical extensions of the same principles that apply to discrete integers. There is no need for a different notation for division, as mathematitians noticed long ago. The fact that mathematicians have additional notations for floor and ceiling which they use when necessary in specialist fields is irrelevant - we have the capability if we need it but most of the time using a simple convention is more practical. Discrete and continuous types, however, are fundamentally different things and should be kept as cleanly separate and unconfused as possible. That is done by using different data types for discrete and continuous data. If anything is broken, it is in the automatic erroneous 'promotion' of discrete quantities into continuous types in many cases, which should clearly be treated as errors. Such a change would of course cause breakage, but we can set up a transition procedure for that so get with the program. Obviously it is far better to introduce code breaks that are highly visible in that the code aborts through an exception rather than creating insidious hidden bugs in long-time trusted code. That just about covers it. It's pretty irritating the way I worded it as if any alterative opinion is blatantly wrong and stupid, eh - wonder where I learned that trick? This is a self consistent view that explains why the proposed new division handling is clearly rationally debatable and arguably just wrong even in the 20-years-time case, let alone here and now. It isn't the main issue in the here and now, but it remains a serious cause of concern. Adopting some method to minimise the damage at least for many Python users and advocates may be a good thing, but please lets not just assume the change is the right thing. -- Steve Horne Home : steve at lurking.demon.co.uk Work : sh at ttsoftware.co.uk From hnowak at cuci.nl Tue Jul 24 09:10:53 2001 From: hnowak at cuci.nl (hnowak) Date: Tue, 24 Jul 2001 15:10:53 +0200 Subject: Exec and namespaces Message-ID: <3B679067@twigger.nl> >===== Original Message From Aquarius ===== >I've got a CGI which reads a file and then execs its contents. The file >defines a function, and that function can't find itself to call >recursively; it gets a NameError. >def main(): > fp = open("foo.txt") > exec(fp.read()) Replace this by exec fp.read() in {} and it should work fine. The exec() call first creates the bar() function in the local mainspace, i.e. the namespace of main(). So far, so good; calling bar() works too, but the recursive call fails, roughly because of the reasons you already mentioned: bar() is neither in the global nor in the local (in this case, in bar's) namespace, so a NameError is raised. (At least I *think* that's what happens. I'm not a language lawyer. ;-) The Reference Manual says: "In all cases, if the optional parts are omitted, the code is executed in the current scope. If only the first expression after in is specified, it should be a dictionary, which will be used for both the global and the local variables. If two expressions are given, both must be dictionaries and they are used for the global and local variables, respectively." (I'm using Python 2.2a1 docs, Doc/ref/exec.html#l2h-365) Specifying the "in {}" creates a temporary namespace for exec, which is used to define and look up the bar function. HTH, --Hans Nowak From ngps at madcap.dyndns.org Sat Jul 28 11:01:31 2001 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 28 Jul 2001 15:01:31 GMT Subject: Distributed computing using SOAP. What about speed ? References: <48F88F43C9842AD9.1E631B0D03856868.6FDBB21E772A6CB3@lp.airnews.net> <9js18m$n54$1@clematis.singnet.com.sg> Message-ID: <9juk4b$pjh$1@dahlia.singnet.com.sg> According to Cameron Laird : > Ng Pheng Siong wrote: > >There's BEEP, formerly known as BXXP. RFC 3080 and 3081, I think. > > > >A new Internet-draft talks about running SOAP over BEEP. > > > >See www.beepcore.org. > > > >(Python implementation seems to have fallen behind.) > . > The background of the Beepcore principals is in Tcl. Good to see MTR bounce back from First Virtual. (He was with FV, wasn't he? Or was it Nat Borenstein? Whatever happened to NB?) > 'Twill be entertaining to implement the RFCs for Py- > thon, though, no? There is a PyBXXP project on Sourceforge. Seems to have gone defunct. I'm sure it will be fun to do BEEP for Python. Anyone volunteering? ;-) -- Ng Pheng Siong * http://www.post1.com/home/ngps Quidquid latine dictum sit, altum viditur. From grumble at usa.net Fri Jul 13 00:30:04 2001 From: grumble at usa.net (jcm) Date: 13 Jul 2001 04:30:04 GMT Subject: Python speed References: <9ifjjh$1e3$1@news.mathworks.com> <3B4B562F.77C1B79@yahoo.com> <9ifo90$4hh$1@news.mathworks.com> Message-ID: <9iltgc$q2f$1@news.mathworks.com> Greg Copeland wrote: > jcm writes: >> >> Well, I say this because I've written a mud engine in Python and it's >> slow. Using this engine on a PII 266 running RedHat 6.1, 400 >> wandering monsters (with nothing else going on in the mud) will peg >> the cpu. In a production mud, you might want to do something >> intelligent about wandering monsters (like have them stop wandering if >> no players are nearby to save cpu-time), but there will also be lots >> else going on. >> >> There might be some clever optimizations that could be made. Anyway, >> my only point was that computation-speed can become an issue. > Don't take this the wrong way, but you shouldn't expect the language of > choice to make up for what sounds like a poor design. No matter what > language you use, you have to have a sound design that will meet all of > your requirements (speed and scalability included). Once you have a good > design, python makes for an excellent prototype bench. See how well it > runs and profile it. The areas that still don't perform well, many > need to be optimized either via redesign or re-implementation of existing > design. If after all that is done, and you KNOW you have a good design, > but python still isn't up to the task, well then you know that another > scripting language probably wouldn't of fit the bill either. Now, you > have an excellent design and a fast working prototype, so now you are > free to reimplement in another, faster language (C, C++, pascal, etc). I wouldn't assume that something is designed poorly because it runs slowly. We've coded, profiled, optimized, rearchitectured, etc. Things are slow because of the level of generality we wanted. I'm sure that commonly occuring events could be special-cased and speeded up. Anyway, this project isn't one that I'm working on anymore (probably permanently shelved), so I'm really not interested in going into specifics. And since I'm not willing to put the effort into packaging and posting the code (nevermind actually finishing the changes that I have half-complete), it was probably a bad idea to mention anything about the mud at all in a newsgroup. From tim.one at home.com Wed Jul 25 17:37:53 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 25 Jul 2001 17:37:53 -0400 Subject: Version compatibility in division In-Reply-To: Message-ID: [David Bolen] > ... > Then again, the bigger problem with int() is the potential for > rounding that is, at least theoretically, permitted by the > implementation, although as someone else pointed out, it's not clear > that any C libraries actually do that. Guido suggested that "someone" (certainly me) change Python's implementation so that int() and long() always truncate, regardless of what the platform C happens to do. I can do that, no problem. There are no known platforms on which that will make a lick of difference, except to make Python run slower. But that doesn't mean no such platforms exist. And making a particular Python operation run slower can change the behavior of, e.g., threaded apps. It's also the case that platforms certainly vary even now in how int(infinity) and int(NaN) behave (since C89 is silent on those cases), and that they may suffer some different accidental behavior in these cases after the change. So is this a change we should be frightened of? Do we need a from __future__ import int_and_long_guaranteed_to_truncate statement to enable it? I think that would be absurd, but from an implementer's point of view it's the plain truth that no change is without consequences. From laurent.szyster at q-survey.be Tue Jul 24 09:03:26 2001 From: laurent.szyster at q-survey.be (Laurent Szyster) Date: Tue, 24 Jul 2001 15:03:26 +0200 Subject: Advice wanted: asynch I/O on unix References: Message-ID: <3B5D721E.B230D30E@q-survey.be> "Russell E. Owen" wrote: > > I have a unix C library that reads some parallel port cards > (asynchronously), processes the data and writes it files. I want > to be able to call it from Python and would love some advice. > > (...) > > It would be nicest to end up with as little C code as possible (i.e. > move most of this functionality into Python). Some of the processing > would be better done in Python, and it's so much easier to debug and > modify things in Python. > > I think I can rewrite most or all of this directly in Python, but surely > I can do better than simply replicate this code? It looks awfully > complex. Is there A Better Way? Have a look at Medusa sources. It's an asynchronous server that uses the OS select() interface to do multiplexing. Maybe the same technique can be used for serial devices on UNIX. http://www.nightmare.com/medusa Let me know ;-) Laurent Szyster From root at rainerdeyke.com Tue Jul 3 16:28:04 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Tue, 03 Jul 2001 20:28:04 GMT Subject: Eiffel better than Python ? References: Message-ID: "Tomasz Stochmal" wrote in message news:f20ea932.0107030100.6c740683 at posting.google.com... > I have read the following book which gives C/C++ heavy bashing > > http://www.elj.com/cppcv3/ > > Conclusion is to use Java or even better choice is Eiffel The conclusions of those who prefer Java over C++ should not be taken seriously. -- 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 Jul 3 10:57:29 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 3 Jul 2001 16:57:29 +0200 Subject: Augmented Assignement (was: Re: PEP scepticism) References: <20010702145211.M8098@xs4all.nl> <9hq57a0jnd@enews4.newsguy.com> <9hqlel016bl@enews4.newsguy.com> Message-ID: <9hsmgs02aoj@enews1.newsguy.com> "Paul Prescod" wrote in message news:mailman.994112767.3627.python-list at python.org... ... > I shouldn't have said to use proxies instead of mutable integers. I > meant that you should have proxy x holding mutable integer x' and proxy > y holding mutable integer y'. Then when you see x+y you can mutate x > because you claim that you know that there is only ever one reference to > these objects. That doesn't rely on the person using a particular syntax > for adding to x. I may well have other additions to x at other points, that accumulate to other temporary counts -- e.g. at some point I could have: totImportant = mpz(0, mutable=1) for key in importantCases: totImportant += countOf[key] Relying on writing this as "totImportant + countOf[key]" rather than "countOf[key] + totImportant" seems to me far more fragile than relying on +=. And if I ever have this in a python -i and when interactively exploring I write countOf[this}+countOf[that] I definitely do NOT want this to mess up my further explorations -- I shudder at the thought. > How do we "flag" types that have in-place behavior now? How would I > recognize that your integers were mutable based on anything other than > reading the documentation or code? Indeed, while "mutable" vs "immutable" is such a key concept in Python (from well before += was introduced, of course:-), there is no direct introspection for it (maybe there SHOULD be!). If faced with such a need currently, I would try to check if X is hashable (if not, it's probably mutable) and if so if its hash() coincides with its id() (if so, it's probably mutable). But that is hardly as solid or reliable as most Python introspection. But while I can conceive Python growing an ismutable() builtin, I'd hardly imagine an isadvanced() builtin. While not fully pinned down, "mutable" is still a fundamental concept in a way that "advanced" isn't... Alex From anders.eriksson at morateknikutveckling.se Wed Jul 4 04:43:49 2001 From: anders.eriksson at morateknikutveckling.se (Anders M Eriksson) Date: Wed, 04 Jul 2001 10:43:49 +0200 Subject: Writing xbase .dbf files with Python ? References: Message-ID: On Tue, 3 Jul 2001 15:20:01 +0200, Gregor Hoffleit wrote: >Just for confirmation: There is no Python module available that's able >to write/modify xbase .dbf files, right ? > If you can put up some money for Sequiter's CodeBase library, then you can use Mr. Hakki Dougsan's python wrapper. """Wrapper for Sequiter's (www.sequiter.com) dbase api. Win32. Binary Only. CodeBase library is NOT included. Mimics CodeBase C++ Api. Most of the examples are translated to Python. URL: http://home.tr.net/dogusanh/ Platform: Win32 Requires: CodeBase C4DLL.DLL """ There also is the XBase project which has Python on it's ToDo list. http://linux.techass.com/projects/xdb/ // Anders From peter at engcorp.com Fri Jul 13 21:15:19 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 13 Jul 2001 21:15:19 -0400 Subject: How popular is Python, anyway? (was: Long Live Python!) References: Message-ID: <3B4F9D27.CF8DC351@engcorp.com> Rainy wrote: > > On 13 Jul 2001 11:59:09 +0300, Ville Vainio wrote: > > sill at optonline.net (Rainy) writes: > > > >> this and that, and getting hired. I actually did use some python at my > >> previous job (some cgi/image manipulation). I was then asked to redo it > >> in perl :-/." > > > > And that's when you reached for your revolver? > > No, the script was fairly short, maybe a hundred lines. It was also the kind of > script that you write once and never have to extend, so doing it in perl wasn't > a problem. I understand what you mean here, but I'm not sure I believe in the idea that there really are scripts you write once and never have to extend. That's why I value Python's maintainability so much: effectively every program or script we write has to be extended, even if just in the first few months of use. With Python, we regular hand off 100 line programs from one person to another for completion and maintenance, as people are available. I think there's even one each of us has contributed to over the last year. Contrary to what you might imagine, it has become progressively cleaner and easier to understand, rather than growing into its own little tar pit of a program. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From kelleys at ucsu.colorado.edu Wed Jul 25 12:38:53 2001 From: kelleys at ucsu.colorado.edu (Scott Kelley) Date: Wed, 25 Jul 2001 09:38:53 -0700 Subject: Module import problem: _socket References: <3B5C5665.8D41D1F1@tundraware.com> <3B5C749A.59F97320@tundraware.com> Message-ID: <3B5EF61D.363995B2@ucsu.colorado.edu> Hello all, I just installed Python 2.1.1 on a machine running Slackware 3.5 (over Python 1.5.2) and I get the following error while importing some newly installed modules: File "/usr/local/lib/python2.1/socket.py", line 41, in ? from _socket import * ImportError: No module named _socket I can't find this module in the Python lib (naturally). Has anyone out there encountered a similar problem? Thanks for any help you can give me. -Scott ------------------------------------------------------------------------------ Scott T. Kelley, Ph.D. E-mail: Scott.Kelley at Colorado.edu Dept. MCD Biology Phone : 303-735-1808 Campus Box 347 Fax : 303-492-7744 University of Colorado Boulder, CO 80309-0347 U.S.A. From gtalvola at nameconnector.com Tue Jul 24 12:03:47 2001 From: gtalvola at nameconnector.com (Geoff Talvola) Date: Tue, 24 Jul 2001 12:03:47 -0400 Subject: Any Suggestions for an Editor with MS-Windows ? In-Reply-To: References: <92757716C8BFF476.D432477A795DB759.E2FB05E062137965@lp.airnews.net> <3B5BDC16.3A348DF6@oce.nl> Message-ID: <5.1.0.14.0.20010724120105.02666910@infratest1> At 03:43 PM 7/24/01 +0000, Robert Amesz wrote: >SciTE Edit (I believe the URL is something like www.scintilla.org) is >pretty nice for us Pythoneers. If only it could open multiple files... SciTE _can_ open multiple files if you configure it properly! You just have to edit some of the settings in SciTEGlobal.properties. I think I had to make the tabbar visible and increase the number of buffers, or something along those lines. -- - Geoff Talvola gtalvola at NameConnector.com From Tom_Good1 at excite.com Wed Jul 25 16:08:15 2001 From: Tom_Good1 at excite.com (Tom Good) Date: 25 Jul 2001 13:08:15 -0700 Subject: maths in programming References: Message-ID: "Native_MetaL" wrote in message news:... > Hello im new to programming and i have some questions about Maths in > programming > > 1 what type of Maths is used in programming > 2 how good do you have to be at maths to program If you can do simple algebra, there are many kinds of programs that you will be able to write. > 3 dose all programing have complex maths No, not all. Many programs you could write wouldn't involve difficult math at all. > 4 are all programmers Expert's with maths No. > 5 do you need to be an expert with maths to get Employment in programming No, although some *types* of programming will specifically need certain math skills. > 6 in IT firms are there people that do the maths ......... and others that > just do the coding <---- the programmers Not that I know of. I have never worked for a company that had a "staff mathematician" who did all the math while the rest of us just coded. > > i would really like to learn Programming and one day work as a programmer > but i dont have maths skills. With Python, the Python tutorials and documentation, and this newsgroup, you should be able to start learning programming, no calculus classes required :-) From tim at vegeta.ath.cx Thu Jul 19 06:06:19 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Thu, 19 Jul 2001 10:06:19 GMT Subject: OO misconceptions // Learning curve geometry/ References: <9ir1l7$3ja$1@panix2.panix.com> <9irfbc11jaq@enews1.newsguy.com> <3B538E16.65394C9D@engcorp.com> <9j0rko025gf@enews3.newsguy.com> Message-ID: Me parece que rh cassel dijo: > > > Granted, Perl had the longest and steepest learning curve since C++ for > > me. But after grasping the concept of "context" and learning to use > > Perl's m// and s/// operators to my advantage, I find I can just > > accomplish more faster than with most other languages, even (so far) > > with Python. > > Off topic but if one looks at the definition, a "steep" learning curve means > quick and easy to learn. It is an accumulated knowledge versus time > function. The marketing folks have totally corrupted the meaning. > > Here is a nice reference. > http://www.computerworld.com/cwi/stories/0,1199,NAV63-1356_STO61762,00.html I have looked at the definition you mention, but here is _my_ definition, as defended by many I know, at least a couple of which are in this thread. Since we are learning, we start with a knowledge value of zero (on y-axis). As we assume we are just starting to learn, our time value is also 0 (on x-axis). Therefore, our starting point in the graph is (appropriately) the origin (0,0). The more about a given subject we need to learn, the farther up the y-axis we must traverse. As the time we are given is limited (if nothing else, by our lifespans) this leads to a steeper curve than if there were less knowledge to gain. Given the fact that the subject currently is Perl, there are _MANY_ concepts to grasp (curse-characters & what they mean; context; built-in global vars; flexible control structures; et al), giving us a "high" hill to "climb." Since the quicker you learn it, the better certain job prospects might be (if no other motivation exists), this shortens the time span to well under a life span, further squeezing our vector on the x axis. A mostly-joking example: Perl learning curve + ____________/ + / + / + / + / + / + / +/ +---+---+---+---+---+ HTML learning curve + + + + + + + ___________________ +/ +---+---+---+---+---+ In the words of Dennis Miller: "Of course, that's just my opinion. I could be wrong." -- Is there any person in the world who does not dream? Who does not contain within them worlds unimagined? -- Narrator, The Sandman From justin at iago.org Sat Jul 21 12:56:58 2001 From: justin at iago.org (Justin Sheehy) Date: Sat, 21 Jul 2001 12:56:58 -0400 Subject: Language change and code breaks In-Reply-To: (Guido van Rossum's message of "Thu, 19 Jul 2001 23:32:47 GMT") References: <9j7gv8$9mg@dispatch.concentric.net> Message-ID: Guido van Rossum writes: >> I would very much prefer a case *insensitive* language with tools >> that enforce *uniform* case usage. > > And that's of course what I have in mind. The problem here is that you control the language, but you don't control the tools. People use a variety of different editors to work on Python, and adding this type of smarts to all such editors is simply not going to happen. If there is a rule that needs to be enforced, you can't count on the tools to enforce it. Python will either demand uniform case usage, or it won't. It is impractical to assume that everyone will choose editors that enforce this sort of rule. Having only a small number of "approved" editors or IDEs will not work either, as that would alienate a large portion of the professional programmers using Python. Such people are very loyal to their tools. As much as bringing non-programmers into the fold is a major goal, any means used to do so that drives away programmers is questionable. "Bjorn Pettersen" writes: > I don't think anyone would be opposed to an auto-correcting IDE. I beg to differ. There are two problems with this. The first is that many people don't want anything they type to be "autocorrected". I frequently hear about misadventures that people have with Microsoft tools that "autocorrect" their spelling mistakes. This feature often makes correct text incorrect, and even when it is correct it is providing an obnoxious degree of invasiveness which many people find very distracting while they try to work. The second is something that I mentioned above. Attempting to enforce that everyone use such an IDE is a very bad idea. If you can't count on everyone using it, then you cannot count on it enforcing the rules. A language's rules should be enforced by the language implementation itself, not the tools that people use to program in that language. (FWIW, I think that Python's implementions should not allow mixed tabs and spaces, but that is a different argument.) Guido van Rossum writes: > If you use this a lot (message = Message() etc.) your code is less > readable than it should be. Really? People use capitalization semantically all the time, both in programming and in the rest of life. I don't understand at all what makes the above code unreadable. It has been stated a few times that this is "bad style", but I have yet to see why. The lowercase name as instance of uppercase class convention seems to be a valid style, and I don't know of a reason to make it disallowed. > It also makes it harder to discuss code in person or over the phone > -- spoken language is not case-preserving, as anyone who has tried > to give someone a URL over the phone knows. :-) This is a very funny argument in the context of Python. Is spoken language indentation-preserving? Clearly, you should make Python indentation-insensitive in order to make it easier to discuss code over the phone. Besides, we can always just write an IDE that everyone will use that will enforce uniform indentation... Spoken language has very different rules than written natural language, which has different rules than program text. Trying to pretend otherwise leads down a dark and ugly path. I do not see that CP4E can ignore or change this fact. Or that it should try. -Justin From guido at python.org Tue Jul 24 20:26:07 2001 From: guido at python.org (Guido van Rossum) Date: Wed, 25 Jul 2001 00:26:07 GMT Subject: A use for integer quotients References: Message-ID: "Fredrik Lundh" writes: > Guido van Rossum wrote: > > But I also found a likely bug! In colorsys.py, there are two routines > > (rgb_to_hls() and rgb_to_hsv()) that seem to be doing floating point > > math using (r, g, b) inputs and don't take any consistent precaution > > to cast these inputs to floats before dividing them. > > from the docstring: > > "All inputs and outputs are triples of floats in the range [0.0...1.0]. > Inputs outside this range may cause exceptions or invalid outputs." > > Whoops. :-( --Guido van Rossum (home page: http://www.python.org/~guido/) From MarkH at ActiveState.com Mon Jul 2 08:07:19 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Mon, 02 Jul 2001 12:07:19 GMT Subject: Implementation of popen() with timeout References: Message-ID: <3B406415.1060205@ActiveState.com> Tom Harris wrote: > I want to use one of the popen() functions to call an external program and > capture the output, but I would like to have the facility to kill the > external program if it does not complete within a specific time. > Unfortunately I am using NT. Options appear to be to use the Win32 API to > write my own, as the popen source looks fierce code. Any ideas? You probably do need to roll your own. If you use the win32 extensions, you could write it in Python making things smaller, and not providing the multitude of redirection options that popen supports will make it quite a bit simpler. Mark. From tim.one at home.com Sat Jul 7 15:01:47 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 7 Jul 2001 15:01:47 -0400 Subject: Comment on PEP-0238 In-Reply-To: Message-ID: [Guido] > ... > arbitrary exception). In the library itself, only three modules > engaged in integer division during execution of the test suite: > bisect, dumbdbm, and inspect. Of these, bisect and dumbdbm will need > to be converted to using div(); inspect uses 1/0 to raise an > exception. bisect is only dividing by 2; it should use a right-shift instead (like every other binary search algorithm ever written ). inspect (and code like it) should be upgraded to use sys._getframe() directly instead of raising phony exceptions. dumbdbm uses a pattern common to many apps outside the std library: it doesn't really care about integer division per se, it's using an excruciating trick to compute (the mathemetical) ceiling(i/j) (via truncating (i+j-1)/j). This is one-liner disease in action, and subject to spurious OverflowError; it was always better written as def ceiling_of_quotient(i, j): q, r = divmod(i, j) return q + (r != 0) > ... > 1. First we introduce a new function div() and a future statement that > makes integer division return a float result for a specific module. I want to make a pitch for naming it idiv() instead. The "i" should strongly remind that the result is an integer, something "div" says only to former Pascal programmers. Seems a Positive Good to me if, e.g., idiv(5.0, 3.0) returned 1 too; i.e., that idiv(i, j) mathematically return floor(i/j). Alternative: Given the point about dumbdbm above, the missing half is a builtin to return (mathematically) ceiling(i/j) too. A very direct approach to both is to forget div/idiv and introduce two-argument builtins floor(i, j) # return floor of mathematical quotient ceiling(i, j) # return ceiling of mathematical quotient instead. They should also have 1-argument flavors, corresponding to the current math.floor and math.ceil. This would emphasize that the real point to all this stuff is computing floors and ceilings, not really about the numeric types of division arguments (that's always been a red herring!). but-perhaps-some-herrings-are-too-tasty-to-forego-ly y'rs - tim From qrczak at knm.org.pl Mon Jul 23 02:28:48 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 23 Jul 2001 06:28:48 GMT Subject: Future division patch available (PEP 238) References: Message-ID: Mon, 23 Jul 2001 05:34:57 +0100, Stephen Horne pisze: > exp(1/2) is irrational - it cannot be represented as a float or as a > rational - but the float representation can never be more precise than > a rational representation, whereas a rational representation *can* be > more precise than a float representation. Rationals are used in cases when the result is exact, because it can be exact when working with +-*/ and a few more. When I see a rational, I expect that it's exact. Floats are used in cases when the result is not exact, because it can't be exact even for +. When I see a float, I know that there is an inaccuracy. You can't give exact answer to exp(1/2) - Python won't have builtin symbolic computation soon. It must be inexact anyway. Moreover, working with rationals with huge nominators and denominators is ineffective; there are not suited for approximating irrational numbers. If I really wanted to work wirh inexact numbers with a better precision than float, I'd use a custom float-like type with more precision. This is unlikely - in reality the precision of float usually suffices (in cases we allow the result to be approximate at all). > If you argue that integers are just a subset of floats and division > should always return a float if necessary to get the more precise > value, I would not call the difference between 3 and 3.6 "precision". They are results of different operations, difference between these numbers is huge. OTOH the difference between 3.6 and the number closest to 3.6 representable as float is not big. This is precision. >>Too late: it has already lost its precision because input was a float. > > But why throw away the rational arguments precision. > > 1/3 * 2.0 should give 2/3 - not 0.6666666666666 This is a rare case when the float was exact. In general floats are not exact. If you *know* that it's exact, why it's a float in the first place? Convert it to a rational or integer. If one of arguments is inexact, the result is inexact. This is how Lisp behaves BTW. Integer division yields a rational and mixing floats with rationals yields a float. I didn't remember that when I started argouing for it: it's just the most logical way of how it should work. > But if we use your logic for this case, then surely we should consider > that in integer division there's no point giving a float result as the > inputs are already represented as integers and therefore they have > already lost the precision that floats have ;-) Integers are exact!!! That's the point: if numbers represent inexact quantities, they should be expressed as floats. Since working with integers and rationals is predictable and +-*/div,mod give correct (with int/int->rational), they should be used when we want to know the true answer. If it's not possible anyway, use floats and don't waste computation time for the 100th decimal place which is wrong anyway. > But a rational approximation can more accurate than floats - surely > we should choose the *best* approximation. There is no best approximation: there is an infinite sequence of better and better rational approximations. > One major advantage of treating integer division separate from > float division separate from rational division etc etc is simply > that the rules stay the same for each case Why should float division be separate from rational division? > What the hell is a decimal float, and where did they come from! They > only exist, to my knowledge, in the sense of standard form/scientific > notation. Guido was arguing for them :-) > But you can't simply classify floats and rationals as alternatives > like this - by your own logic, floats are a subset of rationals (just > as integers are a subset of floats), No. Integers represent mathematical integers (exactly). Rationals represent mathematical rationals (exactlt). Floats represent mathematical reals (inexactly). -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From jschmitt at vmlabs.com Tue Jul 24 17:32:05 2001 From: jschmitt at vmlabs.com (John Schmitt) Date: Tue, 24 Jul 2001 14:32:05 -0700 Subject: Language change and code breaks Message-ID: <4197FA5DD22AD5118ADE00805F6FA62F3B67BD@eden.vmlabs.com> > -----Original Message----- > From: Guido van Rossum [mailto:guido at python.org] > Sent: Tuesday, July 24, 2001 12:51 PM > To: python-list at python.org > Subject: Re: Language change and code breaks [...] > The language would remain case-sensitive, and you would be free to use > it that way in any tool you chose, but there would be a separate tool > available that enforced case-preserving case-sensitivity for those who > prefer it. [...] There you have it folks. This is the same thing that Guido ended with the last time this issue came up. To summarise: The language will not change to be case-insensitive. Python, the programming language, will remain case-sensitive. Thank you very much, Guido, for stating it. I'm hoping that we can keep this message and quote it as the BDFL proclamation on this issue the next time it arises. Personally, I'm happy to hear that the language will stay case-sensitive and that I can choose to use or ignore a tool that provides case-insensitivity. Hopefully a tool that would provide this isn't tied to something I would like to use. John From paulp at ActiveState.com Sun Jul 8 13:14:57 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sun, 08 Jul 2001 10:14:57 -0700 Subject: Confusion about dictionaries - keys use value or identity? References: Message-ID: <3B489511.19523932@ActiveState.com> Roy Smith wrote: > > I'm kind of confused about exactly what happens when I use a string as a > dictionary key. Section 3.2 of the reference manual seems to imply that > keys are compared by identity: > > > The only types of values not acceptable as keys are values containing > > lists or dictionaries or other mutable types that are compared by value > > rather than by object identity That is confusing! It is saying that the types of objects that case problems are those that a) are mutable AND b) are compared by value rather than by object identity >.. > Is there a way to force the comparison to be by identity? Not on strings! > I'm > contemplating building a cache (using a dictionary), and key comparison by > identity should be significantly faster than by value, because I'm going to > be using rather long strings as keys. Here's one way: >>> class a: ... def __init__(self, val): ... self.val = val ... >>> key1 = a("abc") >>> key2 = a("a"+"b"+"c") >>> dict={key1:5, key2:6} >>> dict[key1] 5 >>> dict[key2] 6 >>> key1.val == key2.val 1 >>> key1 == key2 0 -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From m.faassen at vet.uu.nl Thu Jul 5 09:17:28 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 5 Jul 2001 13:17:28 GMT Subject: PEP: Procedure for Adding New Modules (please comment) References: <9hvqhr$gj2$1@newshost.accu.uu.nl> Message-ID: <9i1pd8$8ei$1@newshost.accu.uu.nl> David Goodger wrote: > Martijn: Good PEP. Comments: >> The library PEP >> differs from a normal standard track PEP in that the reference >> implementation should in this case always already have been >> written before the PEP is to be reviewed; the reference >> implementation _is_ the proposed contribution. > By "to be reviewed" do you mean "to be decided upon by the Integrators"? Or > "to be released to the Python community for comment"? I hope the former. > Please clarify. The former, I shall clarify, thank you. >> In the case where no head maintainer can be found (possibly >> because there are no maintainers left), the integrators will issue >> a call to the community at large asking for new maintainers to >> step forward. If no one does, the integrators can decide to >> declare the contribution deprecated as described in PEP 4. > I agree with Roman that this needs some explanation. When, why, under what > conditions, would the Integrators deprecate a contribution? I think > "maintainerless" is a useful category; after all, most modules do *not* > require much if any maintenance between releases. *all* modules require maintenance, if only to check whether it still works. These maintainers can be PythonLabs or whomever, but there should be a maintainer. Do people really want a maintainerless category? That'd be sort of defeating the point of requiring a maintainer in the first place.. If maintenance is considered trivial, then you or anyone can step forward and become maintainer, after all. Finally, I say 'can decide to declare deprecated', not 'will'. Perhaps I ought to make this actually *stronger*, so that unmaintained contributions never persist for a long time. >> Should there be a list of what criteria integrators use for >> evaluating contributions? > It would be useful. I think it would have to come from the PythonLabs crew > themselves. I think it would be useful to them as well. I'm helping Carlos Ribeiro with this, who is working on such a list of criteria. >> A related question is integration with the Python documentation >> process. Contributions should come with good documentation that >> can be integrated with the Standard Library documentation. Should >> we detail this more in this PEP? > Say exactly that, with a pointer to the "Documenting Python" section of the > Python reference. Okay, sounds good. Thanks, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From steve at lurking.demon.co.uk Mon Jul 23 23:33:48 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Tue, 24 Jul 2001 04:33:48 +0100 Subject: PEP0238 lament References: <11moltg2i6s1ftkpku5dkr0cmifn9f5q1o@4ax.com> Message-ID: On Mon, 23 Jul 2001 17:23:18 -0700, Paul Prescod wrote: >It is very common to pass floats to functions that expect integers and >vice versa without really thinking about it. It is *especially* common >to pass integers to functions that expect floats. And in my mind this is the problem, not division. The traditional solutions to the problem of bad inputs are called *validation* and *documentation*. From martin at strakt.com Mon Jul 9 10:53:18 2001 From: martin at strakt.com (Martin Sjögren) Date: Mon, 9 Jul 2001 16:53:18 +0200 Subject: Writing documentation Message-ID: <20010709165318.A21876@strakt.com> Heya I'd like to document my Python modules in the same way the standard modules are documented, with LaTeX and the Python styles and things. It's not exactly a howto, and it'l look a lot like a mini-library reference, right? So how do I compile it? How do I generate all the nifty HTML? Martin -- Martin Sj?gren martin at strakt.com ICQ : 41245059 Phone: +46 (0)31 405242 Cell: +46 (0)739 169191 GPG key: http://www.strakt.com/~martin/gpg.html From jackyci at sinamail.com Thu Jul 19 12:22:20 2001 From: jackyci at sinamail.com (=?big5?B?amFja3ljaQ==?=) Date: Fri, 20 Jul 2001 00:22:20 +0800 Subject: =?big5?B?W1FdIEZpbGUgT2JqZWN0IC0tIGZ1bmN0aW9uICdyZWFkJw==?= Message-ID: <20010719162220.18332.qmail@sinamail.com> Hi There is a TEXT file named 'test.txt'. --------test.txt------- This is a test.\n test\n test\n ----------------------- In Windows. "\n" equal "\x0d\x0a" But in function "read" of File Object, "\x0d\x0a" equal 1 byte. file = open('test.txt') str = file.read(22) # I want to read the first two line # but str = This is a test\ntest\nte How to solve the problem ? Greetings ================================================================== ?????? 50MB ???? http://www.sinamail.com ???????????? http://bonus.sina.com.tw/adevents/alico/ From thecalm at NOSPAM.btinternet.com Wed Jul 4 18:44:01 2001 From: thecalm at NOSPAM.btinternet.com (G. Willoughby) Date: Wed, 4 Jul 2001 23:44:01 +0100 Subject: Hiding Console? References: <9ht9to$fei$1@neptunium.btinternet.com> Message-ID: <9i065k$gea$1@uranium.btinternet.com> Thanks Carl, that works a treat! Gary. "Carl Fink" wrote in message news:slrn9k4bt2.pjn.carlf at panix2.panix.com... > In article <9ht9to$fei$1 at neptunium.btinternet.com>, G. Willoughby wrote: > > Is there a way in your script to include a command that when run on a > > WinME/32 platform the console does not appear? such as the IDLE ide. I wanna > > write apps with neat little gui's using Tkinter but i dont want the console > > there when there run, any ideas? > > Run the program with pythonw.exe instead of python.exe. > -- > Carl Fink carlf at dm.net From martin.franklin at westerngeco.com Tue Jul 10 10:08:33 2001 From: martin.franklin at westerngeco.com (Martin Franklin) Date: Tue, 10 Jul 2001 15:08:33 +0100 Subject: backslash woes........ References: <9iep6h$gmi$1@plutonium.compulink.co.uk> Message-ID: <3B4B0C61.7193BEF2@westerngeco.com> gbreed at cix.compulink.co.uk wrote: > > In article , > duncan at NOSPAMrcp.co.uk (Duncan Booth) wrote: > > > "Duncan Booth" wrote in > > news:Xns90DA74BD3B968duncanrcpcouk at 127.0.0.1: > > > > > Martin Franklin wrote in > > > news:3B4AC7C2.DD53F6BB at westerngeco.com: > > > > > >> I am having trouble with windows path names (i'm a UNIX'ite) > > > > Another useful tip to remember is that except for the DOS command > > prompt, and some badly behaved applications, Windows actually supports > > both forward slash and backslash as path separators. So in a Python > > program (or most other languages) you can use forward slashes anywhere > > you want to write a pathname. > > So long as you aren't using data given to you by the OS. In this case, I > think the duality is more of a problem than a solution. Here's a function > that I think solves the poster's original problem: > > def getPrefixRelatives(*filenames): > """return the common prefix of the filenames > and each filename relative to that prefix > > """ > # make sure all paths are spelt the same > normalized = map(os.path.normpath, filenames) > prefix = os.path.commonprefix(normalized) > return(prefix, [ > filename[len(prefix):] for filename in normalized]) > > >>> import os > >>> getPrefixRelatives('c:/python/first.py', 'c:\\python\\sub\\second.py') > ('c:\\python\\', ['first.py', 'sub\\second.py']) > > Returning UNIX-style / separated pathnames is left as an exercise for the > reader. > > Graham Bingo! Thanks for this (and all the other sugestions....ofcourse!) It didn't occur to me to use slicing to remove the prefix (simplest is best!) From engsol at teleport.com Fri Jul 27 22:32:19 2001 From: engsol at teleport.com (engsol at teleport.com) Date: Sat, 28 Jul 2001 02:32:19 GMT Subject: Newbie Q: PYTHONPATH_1 vs PYTHONPATH_2? Message-ID: <3b6222b8.1007348@news.onemain.com> I have an "old" copy of Python on my NT machine. I've tailored PYTHONPATH to know about myfiles and mylib, etc. But I've now installed Python 2.1.1 in a different directory, and would like to create PYTHONPATH_2, so as to not have to expand the vanilla PYTHONPATH forever as new versions are available. Is this do-able? Thanks....engsol From guido at python.org Thu Jul 26 17:18:38 2001 From: guido at python.org (Guido van Rossum) Date: Thu, 26 Jul 2001 21:18:38 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <9jnt9p$qhe$1@newsy.ifm.liu.se> Message-ID: [Guido] > >> >The important thing is that i//j will return the same value > >> >regardless if i and j ar ints or floats; ditto for the new i/j. [Grant] > >> If that's important, why won't the other math operators do it??? [Guido] > >Huh? They do (apart from unavoidable round-off errors). 1+2 == 1.0+2.0. [Grant] > They compare equal with the "==" operator, but they are not > the same value: > > >>> 1+2 > 3 > >>> 1.0+2.0 > 3.0 > >>> > > ... unless 3 and 3.0 are "the same value". In which case my > definition of that phrase is merely different than yours. [Guido] Well, they have the same *mathemtical* value, and Python does its darndest to treat them as equal everywhere. For example, a dict with int keys can be indexed with corresponding float or complex values. Exceptions are operations that intrinsically require ints, e.g. list indexing. (This would change under a unified numeric system though, I expect, unless inexact numbers are excluded from being used as sequence indices.) --Guido van Rossum (home page: http://www.python.org/~guido/) From chris.gonnerman at newcenturycomputers.net Mon Jul 9 16:30:26 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Mon, 9 Jul 2001 15:30:26 -0500 Subject: license suggestions? References: <9Bk27.469493$oc7.75721180@news2.rdc2.tx.home.com> Message-ID: <006f01c108b5$ff18c240$0101010a@local> ----- Original Message ----- From: "Rainer Deyke" > "Steve Holden" wrote in message > news:Fij27.24993$F%5.1707320 at e420r-atl2.usenetserver.com... > > And some of us wonder what it is about the GPL that stops your previous, > > liberally-licensed, version from existing? > > Given: software A is released under the BSDL. Somebody creates an improved > version of it (software B) and releases it under the GPL. > > A still exists. But B is better than A, so people will be more likely to > use B than A. A still exists, but A is competing with a better version of > itself. New programmers will be more likely to improve B than A, because > they don't want to duplicate effort. The original author is unable to > incorporate the improvements to A in future software C unless C is released > under the GPL. Granted. Whose fault is that? If the author of A doesn't maintain it, and other programmers prefer the B program *even with the GPL on it* then B must be really superior and deserves to win. Who loses? A's author can't use B to create C unless he/she commits to source code releases forever. If C is to be commercial software with hidden source, and the programmers who created B don't like that, then they chose the right license. On the other hand, if A intended to do that anyway, then there is really no loss to anyone. Sort of a legal armwrestling match. From aleaxit at yahoo.com Tue Jul 3 17:20:42 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 3 Jul 2001 23:20:42 +0200 Subject: MS "bans" GPL References: <7iq1ktcmslo24kbr8qvob2g3hpgleuf025@4ax.com> <9hshbp$oqv$2@216.39.170.247> <9hst9p$oqv$5@216.39.170.247> Message-ID: <9htctp0a0j@enews4.newsguy.com> "David LeBlanc" wrote in message news:9hst9p$oqv$5 at 216.39.170.247... ... > Opinion: It would not be illegal for Microsoft to make it a condition of > use that you not install open source software if you want to use their > OS. It's not restraint of trade since technically, open software is not > traded - there's no _overt_ exchange of value nor is there a "buyer" or a > "seller" who could be harmed monetarily through such a restraint Counter-opinion: where did you get the strange idea that open-source software can't be traded/sold/bought? It's far from unusual for a developer to develop application X for a specific customer (and for plenty of $$$) and put X under the GPL (the developer may have to, if he uses GPL'd stuff in X, or may simply choose to -- maybe he thinks this will help spread X's use and his superior familiarity with X's core sources gives him competitive advantage in bidding for support & enhancement contracts on X once it's widespread, &c). > (besides, you have the freedom to choose another OS according to MS). Remember the US Appeals court did endorse the findings of fact and law in the MS antitrust case -- so MS _is_ officially a monopoly. This subjects them to much stricter restraints (in theory -- what remedies will be decided against their illegal antitrust behavior is another issue of course). Alex From rnd at onego.ru Wed Jul 4 15:02:22 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 4 Jul 2001 23:02:22 +0400 (MSD) Subject: python-mode and py-python-command Message-ID: Hello! How do I tell Emacs to call specific Python interpreter within a certain file with Python code? I know that for this I need to set up py-python-command variable, but how to do it? 1. With set-variable (You know, Lisp is super intuitive ;-) 2. With eval-expression I managed to (setq py-python-command "/usr/bin/python2.1") but it has no effect in the decision which Python to run :-( 3. What is wrong with this (at the end of file)? % Local Variables: % mode: python % py-python-command: \"/usr/bin/python2.1\" % End: (do i need to put some control characters after End: ?) Thank you! Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Wednesday, July 04, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Mediocrity requires aloofness to preserve it's dignity" _/ From nhodgson at bigpond.net.au Tue Jul 17 18:44:57 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Tue, 17 Jul 2001 22:44:57 GMT Subject: PEP: Defining Python Source Code Encodings References: Message-ID: Paul Prescod: > Roman Suzi wrote: > > > > .... > > > > I think non-literal data must be in ASCII. > > I agree. Allowing "funny characters" in names is not something > we have much call for yet and it may break many tools that > have ASCII-only assumptions. Allowing non-ASCII characters in names enhances interoperaility with Java and .NET which allow this. Neil From bsass at freenet.edmonton.ab.ca Wed Jul 11 14:10:43 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Wed, 11 Jul 2001 12:10:43 -0600 (MDT) Subject: Long Live Python! In-Reply-To: Message-ID: On Wed, 11 Jul 2001, phil hunt wrote: > On Tue, 10 Jul 2001 15:31:11 -0700, Paul Prescod wrote: <...> > >Python does not have a niche and is not obviously a niche-friendly > >language. > > Sure it does: python's niche is as a scripting language that's also good > for longer programs. Hehe, you must have missed the recent thread about removing the first line from a text file... I thought it showed that Python is a horrible scripting language, way too verbose, it turned what should be a few lines of script into a program. If I move my notion of a "script" up a level (or two)... Python is great at scripting high level stuff; it is not obvious that could be a niche, and even less obvious that Python fills it. i.e., Python is good at turning what would be "longer programs" in most other languages, into scripts. - Bruce From tim.one at home.com Mon Jul 23 03:26:52 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 23 Jul 2001 03:26:52 -0400 Subject: PEP0238 lament In-Reply-To: <5sdnlt072hm6hp17nluu6f0fqq4bvr6mj8@4ax.com> Message-ID: []Stephen Horne] > ... > And what about the languages web developers are used to, such as > VBScript and JavaScript. Good thing you stopped before mentioning Perl (yes, 1/2 is 0.5 there) -- I'm afraid the "mimic other languages" approach requires picking languages very carefully if you want the illusion of consistency. By the way, 1/2 is also 0.5 in standard JavaScript: http://www.el-mundo.es/internet/ecmascript.html 11.5.2 Applying the / operator The / operator performs division, producing the quotient of its operands. The left operand is the dividend and the right operand is the divisor. ECMAScript does not perform integer division. The operands and result of all division operations are double-precision floating-point numbers. The result of division is determined by the specification of IEEE 754 arithmetic: yadda yadda yadda produce-enough-frantic-arguments-at-random-and-some-are-likely- to-backfire-ly y'rs - tim From R.Brodie at rl.ac.uk Wed Jul 4 09:53:23 2001 From: R.Brodie at rl.ac.uk (Richard Brodie) Date: Wed, 4 Jul 2001 14:53:23 +0100 Subject: Python for air traffic control? References: <9hlfbn$6ok$1@nereid.worldonline.nl> <9hrj3q$cj1@news1.gtech.com> <20010704013238.2DC8A00.NOFFLE@niccolo.ke4.de> Message-ID: <9hv74k$1bts@newton.cc.rl.ac.uk> "Duncan Booth" wrote in message news:Xns90D489E9982B4duncanrcpcouk at 127.0.0.1... > No wonder the compiler gets angry, you can't rename your own types as > 'int'. Also there is no type called 'bool' in C. It's a macro expanding to a type. At least it is, if you include Even when you know a language, someone comes along and changes it... From tim.one at home.com Sun Jul 22 18:17:00 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 22 Jul 2001 18:17:00 -0400 Subject: BURNING EARTHSHAKING Tuple Question In-Reply-To: <9jfe8v$gu4$1@slb6.atl.mindspring.net> Message-ID: [Erik Max Francis] > so perhaps when mathematicians are isolated with other mathematicians > they tend to pronounce it that way. I really don't know. [Tom Bryan] > In both my undergraduate and graduate studies in mathematics in the > U.S., I only remember hearing tuple pronounced so that it rhymes with > goop. Now *that's* an affectation. Where I went to school, it rhymed with goople . > If anyone pronounced it to rhyme with couple, it was rare enough > that I don't remember it. But we also said "pie" for pi and "fee" for > phi. Perfectly sensible. At PythonLabs, I think Fred Drake says tuple-like-couple. I'm a tuple-like-goople guy (i.e., normal). Jeremy hasn't existed for months, and everyone runs away when Barry speaks, so who knows what they say. Guido only barks orders in Dutch, so I'm not sure how he pronounces it either. but-pretty-sure-he-prounounces-"dict"-like-"luxury-yacht"-ly y'rs - tim From peter at engcorp.com Sun Jul 29 01:14:01 2001 From: peter at engcorp.com (Peter Hansen) Date: Sun, 29 Jul 2001 01:14:01 -0400 Subject: Unusual minidom behaviour: Part Deux References: <9jvj7e$96b$1@panix2.panix.com> Message-ID: <3B639B99.E068591E@engcorp.com> Victor Bazarov wrote: > > "Aahz Maruch" wrote... > > You've got a complex problem here, probably resulting from a multi-way > > interaction between Python, Java, and the OS. You're going to get little > > help from us unless you can pare down the problem. > > If I could pare it down, I would have probably found the cause by > now. The problem is that I don't have time to look. The system > that Python is running is a fairly complex one. The Java app that > runs the Python interpreter is also complex. Call it a hunch, call > it an educated guess, but I have a feeling that as soon as I start > paring the problem by removing some [irrelevant] parts of the app > and the Python code, the problem will go into hiding... In another post you wrote: > At this point I frankly care only about one thing: to prevent it > from happening. Is that a temporary solution? You don't have time to find the cause, but you feel confident that if you removed some irrelevant part of the app the problem will go into hiding, and you care only about one thing: preventing it from happening. Problem solved. :-) (I'm sure the real solution is to find the time to narrow down the list of possible causes, because it seems very unlikely this group will be able to solve your problem without more legwork on your part. I know that doesn't sound helpful: sorry.) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From wqh-2 at 263.net Mon Jul 30 21:03:36 2001 From: wqh-2 at 263.net (sdf) Date: Tue, 31 Jul 2001 09:03:36 +0800 (CST) Subject: problem with re.rearch Message-ID: <3B6603E8.13863@mta3> since s=abcd ,then I search 'a' in s the result must be true but why the result is nono >>> a=re.compile(s) >>> b=a.search('a') >>> print b None >>> print s abcd __________________________________________ DVD??????????10?? http://shopping.263.net/category02.htm ?????????????????????? http://shopping.263.net/category10.htm From paulp at ActiveState.com Sun Jul 29 15:37:04 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sun, 29 Jul 2001 12:37:04 -0700 Subject: FEEDBACK WANTED: Type/class unification References: <3B643C58.1C6C94F9@ActiveState.com> <200107291708.NAA07525@cj20424-a.reston1.va.home.com> Message-ID: <3B6465E0.368A104@ActiveState.com> Guido van Rossum wrote: > > ... > > Yes, it's a lot less useful than you seem to think. If you are > interested in documentation, it's better to use something like pydoc > which gives much more details. Major: Pydoc seems only useful for a small subset of types and classes. Major: I use dir() in object browsers and other graphical constructs. I can't use pydoc for that. I don't see an obvious dir-like function in inspect.py. Minor: It returns so much prose information that I might prefer to use dir() to just get the spelling or name of a function. Consider this traceback and you'll see why I still depend on dir() >>> a=urllib.urlopen("file:///c|/autoexec.bat") >>> type(a) >>> dir(a) ['fileno', 'fp', 'headers', 'read', 'readline', 'readlines', 'url'] >>> help(a) Help on instance of addinfourl: > >>> m = re.match("abc","abcdef") >>> type(m) >>> dir(m) ['end', 'expand', 'group', 'groupdict', 'groups', 'span', 'start'] >>> help(m) Help on SRE_Match: > Right now, pydoc doesn't understand the new types yet, but eventually, > before 2.2 final, pydoc (or more likely inspect.py) will be able to > introspect according to PEP 252. Maybe that will be enough to help me for my object-browsing applications. And perhaps pydoc will be reliable enough for me to give up on dir(x). > > .... > Hm, I'd like you to tell me more about how you use dir(). I find > getting the entire list of attributes overwhelming. I use dir(x) as a compressed and somewhat more reliable pydoc that works great for modules and built-in types and works poorly for instances. What do *you* use dir(x) for? When do you want to introspect an instance and you care about instance data but not class data and functions that are instance attributes but not true methods. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From jkraska1 at san.rr.com Sun Jul 1 12:36:57 2001 From: jkraska1 at san.rr.com (Courageous) Date: Sun, 01 Jul 2001 16:36:57 GMT Subject: Augmented Assignment (was: Re: PEP scepticism) References: Message-ID: <8pkujt04pv49fvklj6n8jv61fl177kv6c4@4ax.com> >I don't always have the opportunity to talk to people and explain >confusing things to them. In one class I gave, a guy let out a gasp when >he came to understand the reference rules. He said that that was what >had prevented him from coming to understand Python the first two times >he tried. Now I think we've made life harder for guys like that to save >Numeric Python users from typing a method call for their mutations. >That's a poor trade-off. Sure; I can buy this argument. I'm not a big fan of the ongoing lexical/ grammatical expansion of Python. C// From nwaterworth at lineone.net Wed Jul 18 14:16:21 2001 From: nwaterworth at lineone.net (Neil Waterworth) Date: Wed, 18 Jul 2001 19:16:21 +0100 Subject: All computers in the world MUST sync with ATOMIC clock before 12:00 AM 21 July 2001!!! References: <3B54F839.AC6C11C3@yahoo.com> Message-ID: I have a PC without a modem or network connection. Will it explode, or can someone lend me their Caesium Atomic clock and a serial cable? Ric Werme wrote in message news:sog57.3111$N21.1150208 at typhoon.ne.mediaone.net... > alavoor writes: > > >All computers in the world MUST sync with ATOMIC clock before 12:00 AM > >21 July 2001!!! > > >hello: > >You must sync your PC's date and time with Cesium Atomic clock. > > Garbage! > > >Use this very small and tiny program written in PHP. > > "This won't hurt a bit!" At least you aren't hawking a .EXE virus. > > What wrong with NTP? (Assuming one needs his computers' time to be accurate.) > > -- > Ric Werme | werme at nospam.mediaone.net > http://people.ne.mediaone.net/werme | ^^^^^^^ delete From arnulf at spirea.net Mon Jul 30 04:42:20 2001 From: arnulf at spirea.net (Arnulf Heimsbakk) Date: Mon, 30 Jul 2001 10:42:20 +0200 Subject: Error on mimetools? Message-ID: <9k368v$a8q$1@news.uit.no> I'm trying to decode a mime64 message in python with mimetools. I have tested the "body" with windows winzip. It decodes correctly. When I try to decode it in python, it do not decode correctly. I get a file with slightly increased size. The heading of the file seems the same, but when I test this with a jpg file - the file gets corrupted when decoded with python's mimetools. Is there a error in mimetools? Or is my approach entirly incorrect. My code is below: out = StringIO() mimetools.decode(StringIO(self.body), out, 'base64') return out.getvalue() I preciate any advise or help I can get. --- arnulf heimsbakk system analyst +47 76 14 45 42 spirea.net - http://spirea.net and?ya rocket range - http://www.rocketrange.no From guido at python.org Fri Jul 20 10:39:51 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 20 Jul 2001 14:39:51 GMT Subject: Language change and code breaks References: Message-ID: Mikael Olofsson writes: > On 19-Jul-2001 Guido van Rossum wrote: > > Bruce Sass writes: > > > > > The short of it is... ya got less symbols to work with, therefore it > > > is less ... why is that good for programmers? > > > > You flunked math, right? The number of available identifiers is still > > infinite... > > That comment was not necessary. What Bruce must mean is that the average > length of an identifier will be larger with case insensitiveness than > with case sensitiveness. I am sure you understood that. I apologize for the comment. But I don't find the argument (that case-sensitivity reduces the expressivity or the number of available good identifiers) convincing at all. Given that in current code, case-insensitive name clashes are very rare, I don't believe for a second that the average identifier length will go up. If you use this a lot (message = Message() etc.) your code is less readable than it should be. It also makes it harder to discuss code in person or over the phone -- spoken language is not case-preserving, as anyone who has tried to give someone a URL over the phone knows. :-) --Guido van Rossum (home page: http://www.python.org/~guido/) From bokr at accessone.com Fri Jul 20 13:57:47 2001 From: bokr at accessone.com (Bengt Richter) Date: Fri, 20 Jul 2001 17:57:47 GMT Subject: Language change and code breaks (fwd) References: <3B5505A0.F89ADB86@engcorp.com> <9j79s6$n27$1@panix2.panix.com> <3B578D96.DCE5B63C@engcorp.com> <3B57937B.B4057461@Lugoj.Com> <3B58180A.2264EDCD@engcorp.com> Message-ID: <3b586cc7.2422078454@wa.news.verio.net> On Fri, 20 Jul 2001 07:37:46 -0400, Peter Hansen wrote: >James Logajan wrote: >> >> Peter Hansen wrote: >> > 1. They are inactive in the Python community and are >> > therefore unaware of the upcoming code breakage. >> > >> > 2. Their code is dependent on the existing integer >> > division behaviour, and yet they are not amongst >> > the classes of users identified in this newsgroup >> > as being the most likely to be impacted. >> > >> > 3. They are incapable of maintaining their code, >> > and simultaneously are entirely at the mercy of >> > outside forces who may choose to upgrade them >> > against their will or without their knowledge to >> > the new and incompatible version of Python. >> > >> > Or, they are not at the mercy of outside forces, >> > yet mysteriously cannot *avoid* upgrading their >> > Python installations and thus breaking their >> > own code (which they somehow cannot maintain). >> > >> > 4. Were we to develop and make easily available to >> > them a scanner capable at least of identifying >> > the probability they will suffer code breakage, >> > they would be unable to use it, whether for >> > (1) or (3). >> > >> > Have I missed anything? >> >> I'm sure you could think of many more insults if you just tried harder. Just >> how many years have you been in commercial software development anyway? > >Did you miss the thread up until this point? > >I neither intended the above to be insulting nor, as far as I >can tell, *is* anything in the above insulting. > >Therefore, I agree completely with you. I could *definitely* >think of more insults (than zero) if I tried. > >I've been in commercial software development since roughly 1981. > >(Perhaps you consider something in *this* posting insulting too. >If you do, we clearly have a different definition of insulting. >You, by the way, were obviously trying to insult me, and I honestly >have no idea why.) > Perhaps James meant "insult" in the sense of "insult and injury" to the victims whose injuries you were enumerating. That's the way I took it. I think you are usefully pointing out a real problem. Trying to code in the least-likely-to-be-changed subset of a language is not fun, but that is what you wind up doing. Perhaps the BDFL may want to consider making a never-to-be-changed subset official? Ada went through a no-subset discussion, but I think I might like a very lean official subset, especially if it also meant a very lean embedding option. Isn't it fun trying to make Netscape and IE show the same thing on the screen? ISTM the same could happen between generations of Python. From m.faassen at vet.uu.nl Mon Jul 2 12:22:13 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 2 Jul 2001 16:22:13 GMT Subject: Is Python Dead? References: Message-ID: <9hq73l$i0g$1@newshost.accu.uu.nl> Edward B. Wilson II wrote: > I have been following Python for five years now, and I am still just as > frustrated with it as I was in 1996. And 'is Python dead' will guarantee you people will read your post. > Python still doesn't have good database support, I realize I'm not familiar with Perl's dbi, which I hear is more powerful than Python's database interfacing, but I've happily connected Python to things like Access, MySQL and PostgreSQL. Also from within Zope. What do you consider to be 'good database support'? > nor has it grown to be > useful in the web space as mod_perl. PyApache has been around longer than > mod_php, yet php has far surpassed it as a productivity tool in the web > space. What about Zope, Quixote, WebWare? I mean, really, this is an area which has seen a lot of growth in recent years. http://www.zope.org http://www.mems-exchange.org/software/python/quixote/ http://webware.sourceforge.net/ And then there's this: http://www.vex.net/parnassus where you can find much more web related stuff, in case that wasn't enough. > It would seem Python can do everything, yet nothing. Everyone wants to > write the next killer application with Python, XML parsers, image > manipulators, super computer steering modules, yet no one wants to work on > making Python perform where it matters most. Python is the best language at > eclectic stuff, however, poor at bread and butter tasks. You'll just have to be more specific about this.. > Python needs better leadership in areas of its growth. Python is truly the > best language in use today, except it still isn't very useful for the > largest solution sector, database access, and information presentation (web, > or otherwise). But those areas are exactly what I've been using it for the last couple of years! Surely I would've noticed it if Python was dead. :) Of course, some things could be nicer (relational object integration would be nice), and as have been discussed recently, the Python Standard Library could've seen some more development. Also of course a comprehensive Python Catalog ala CPAN would be nice. But really, either you've managed to miss an amazing amount of developments the last few years (really, had you missed Zope?), or your post here was rather unclear -- what exactly is it that you're missing? Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From ed_tsang at yahoo.com Wed Jul 18 14:29:30 2001 From: ed_tsang at yahoo.com (ed_tsang at yahoo.com) Date: Wed, 18 Jul 2001 18:29:30 -0000 Subject: how to save strings to a temporary buffer? Message-ID: <9j4kia+hmtu@eGroups.com> How can I save string to a tempororay buffer and then write it to a file afterwards? I have a function that output a formatted string each time it is called; but instead of open a file and write it each time; I would like to save these strings to a , may be a tmeporory buffer, and then write it to a file when everythign is completed... how cna I do that? thansk From tdelaney at avaya.com Wed Jul 25 01:41:44 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Wed, 25 Jul 2001 15:41:44 +1000 Subject: A modest PEP0238 suggestion Message-ID: > Actually, adding rationals can be done almost entirely without > breaking code... That is, *if* we adopt PEP-238 now. Changing 1/2 > from returning a float to returning a rational won't have to break > code, since the mathematical value of the result is the same. > Changing it from returning 0 to returning a rational isn't any easier > than changing it from returning 0 to returning a float -- exactly the > same places will have to be changed. > > If you're for rationals, you're for PEP-238. I am entirely for rationals (actually, what I would *really* like is symbolic numerics - I want 100% exact values in all cases, including sqrt(2), and I want them to be *fast*, but I'd settle for rationals ;) I am however leery of the assertion that changing from int/int=>float to int/int=>rational would have no code breakage. There are many cases where int/int=>float will give an inexact result whereas int/int=>rational would give an exact result. In practice, I suspect the cases where the difference would show up are minimal, however just as going from int/int=>int to int/int=>float means you are gaining precision (and possibly losing exactness), the same occurs with going from int/int=>float to int/int=>rational (except you then gain exactness). In any case, as I have stated before, any such changes must be held over until the next major release before they are the default behaviour. Fortunately, the next major release is Python 3.000, which we have always maintained could break existing code. For the record, I intensely dislike the // notation, but I can't articulate why. I would prefer something like ?, but unfortunately, typing that on my keyboard is somewhat difficult. Tim Delaney From claird at starbase.neosoft.com Tue Jul 31 08:38:54 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 31 Jul 2001 07:38:54 -0500 Subject: Tangent on wireless hysteria (was: Language Niches (long)) References: <8beb91f5.0107280407.5a30341d@posting.google.com> <3B65FD2B.39BA0A95@engcorp.com> Message-ID: In article <3B65FD2B.39BA0A95 at engcorp.com>, Peter Hansen wrote: >Cameron Laird wrote: >> >> I've lost count--is WAP essentially >> dead now, or on the verge of utter >> world domination? > >Dead, or at least in stasis waiting for a purpose in life. > >Have you ever tried (or imagined trying) to use a tiny >LCD screen that can't even show your own full name as a >way of accessing something with the degree of rich >information as the Web has? > >(I work in wireless and the topic rarely comes around these >days. I'm quite sure some companies are working full speed >on it, however, and I wish them the best of luck.) . . . I confess I posted a bit disingenuously here. My scant contact with WAP has given me no reason to doubt that it's diving rapidly to extinction, as Andrew Odlyzko describes in . Thanks to a correspondent for offering me this URL. Note that PLENTY of other apparently- knowledgeable people (Clay Shirky, for example), reinforce this judgment. Anyway, my real intent was to expose as delicately as possible my surprise that Paul would use WAP in his illustrations of language growth. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From knight at baldmt.com Thu Jul 12 12:06:44 2001 From: knight at baldmt.com (Steven Knight) Date: Thu, 12 Jul 2001 11:06:44 -0500 (CDT) Subject: ANNOUNCE: SCons (Python build tool) development under way Message-ID: This is to announce that active development of SCons is now underway at: http://scons.sourceforge.net/ SCons is a Python software construction (or software build) tool--that is, a substitute or replacement for Make. SCons is implemented as a Python script around a central set of Python build-engine modules. SCons configuration files are actually executed as Python scripts, allowing you to use full Python functionality to control your build. You use Python functions and methods in the configuration files to tell the central build engine about your input and output files. Other key features: Dependency calculations are done using MD5 signatures, yielding more reliable builds than timestamp-based dependency analysis. Most dependencies are handled automatically. Building multiple targets in parallel (-j) is supported. It's easy to add your own Builder objects and otherwise customize your build. SCons is still on its way to alpha release, so there's no official package available for download at the moment--sorry. Much of the infrastructure has been coded, though, and is available for anonymous CVS checkout, or browsable via the CVS web interface under the SCons project page at SourceForge: http://sourceforge.net/projects/scons/ The usual set of mailing lists (scons-announce, scons-devel, scons-users) has been created. Follow the web site links to subscribe. A small development team (n == 3) is working towards finishing enough documentation and basic functionality for a rapid series of alpha releases in the (hopefully) near future. To help that effort, we'd like to become larger than just a "small" team. If you're interested in contributing, we'd love to hear from you. Check out the developer guidelines on the SCons web site. Yes, SCons is the direct descendant of the ScCons design that won the Software Carpentry build tool competition last year. It's been renamed (dropped the extra 'c') to make it slightly easier to type, and to try to reflect weakly the fact that this project is no longer directly related to Software Carpentry. (Sorry, I don't know the current status of Software Carpentry or the other tools they were planning.) The SCons design is based on the design of the Perl-based Cons software construction tool: http://www.dsmit.com/cons/ SCons improves on the Cons architecture by incorporating several years of practical experience with its strengths and weaknesses. (And, of course, by being written in Python... :-) --SK From boegli at iinet.net.au Sun Jul 15 02:50:42 2001 From: boegli at iinet.net.au (Richard B) Date: Sat, 14 Jul 2001 23:50:42 -0700 Subject: parallel port?!? Message-ID: <3B513D42.933A0445@iinet.net.au> I would like to know how to communicate with the parallel port under python. Is this possible? If so can it be done under all operating systems that support python. I need to interface with the parallel port to send commands to a board connected to it. I have just come to grips with python, it is my first language, so I think this is what I should use to communicate with the parallel port so that I can implement new features latter on. If it is not possible to communicate directly with the parallel port, are there any open source communication programs which work under Windows and Linux which I could communicate to through python. Sorry for long message but this is kind of important. Thanks in advanced. From greg at cosc.canterbury.ac.nz Thu Jul 5 22:39:43 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 06 Jul 2001 14:39:43 +1200 Subject: How to call a method with variing arguments References: Message-ID: <3B4524EF.C33D6F70@cosc.canterbury.ac.nz> Malcolm Tredinnick wrote: > > On Mon, Jul 02, 2001 at 11:40:49PM -0700, Heiko wrote: > > > > If possible, it would be nice, if the sequence of the arguments > > doesn?t matter, and the method realizes which argument is on which > > position (but that is a "nice to have"). > > I don't really know what you mean here, since I don't know how the > function is meant to know which argument belongs where. Heiko, I think you want keyword arguments. Given def foo(a, b, c): ... you can call it like this: foo(b = 1, a = 2, c = 3) If you declare def foo(**kw): ... you can call it with any number of keyword arguments, and kw receives a dictionary where the keys are the keywords you used and the values are the values you passed. You can mix and match all of these, too: def foo(a, b, c, *args, **kw): ... can be called with 3 or more arguments. The first 3 can be passed positionally or by keyword; args receives a tuple of the remaining positional arguments; and kw receives a dictionary of the remaining keyword arguments. -- 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 niemeyer at conectiva.com Tue Jul 31 19:08:32 2001 From: niemeyer at conectiva.com (Gustavo Niemeyer) Date: Tue, 31 Jul 2001 20:08:32 -0300 Subject: 2.2 features In-Reply-To: <3B6727F6.6D43D989@ActiveState.com>; from paulp@ActiveState.com on Tue, Jul 31, 2001 at 02:49:42PM -0700 References: <3B6727F6.6D43D989@ActiveState.com> Message-ID: <20010731200832.L19610@tux.distro.conectiva> > It sounds weird from an English perspective to me. "If Guido in > programmer and Guido in author then". "isa" or even just "a" makes more > sense. or how about "in class" "If Guido in class programmer and Guido > in class author then". What about "If programmer in Guido" ("type in x" instead of "x in type")? -- Gustavo Niemeyer [ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ] From qrczak at knm.org.pl Mon Jul 23 14:42:23 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 23 Jul 2001 18:42:23 GMT Subject: A use for integer quotients References: <3B5BC73B.2D52E5E2@alcyone.com>, <3B5BA29B.E08FEEE9@alcyone.com>, <3B5C5665.8D41D1F1@tundraware.com> Message-ID: 23 Jul 2001 17:00:01 GMT, Tim Daneliuk pisze: > - This is not "incorrect" arithmetic. *It is 3/4 == .75 that is incorrect* > because the precision of the result exceeds the precision of the operands. It doesn't exceed if the result is a rational. Operands and the result are all exact here. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From hoki26 at gmx.de Tue Jul 10 08:14:38 2001 From: hoki26 at gmx.de (Holger Kipp) Date: Tue, 10 Jul 2001 14:14:38 +0200 Subject: Q: mpg123 with Python Message-ID: <9ierhe$c3u$1@sun.rhrk.uni-kl.de> Hi, my professor told me, that i have to realize a "webbased skin for mpg123 with flash and mySQL" so, i installed mpg123 and now i've got the problem to respond that player via Python. Flash and the mySQL-DB are not the problem ... I MUST retrieve ID3-Tags, playtime, etc... from mpg123 and have to control the player like: skip track, seek, pause track, ... and so on. Is there any EASY sourcecode/modules/API for Python? (I'm using Python2.1 on RedHat 7.1) Where can I show useful code-segments? Do you have an better idea? Shouldn't I use mpg123? Please note: easy code is required ;-)) yours sincerely Holger Kipp From mcherm at destiny.com Mon Jul 23 10:02:12 2001 From: mcherm at destiny.com (mcherm at destiny.com) Date: Mon, 23 Jul 2001 09:02:12 -0500 Subject: PEP0238 lament Message-ID: <10ec1ce85.ce8510ec1@destiny.com> One part of Arthur Siegel's posting bears repeating: > I remain convinced that the single most important > factor for Python's acceptance as an educational language is > the growth of its acceptance as a professional language. I have opinions on integer division, case sensitivity, and probably on other issues where CP4E advocates seem to come into conflict with some "professional programmers". But I think I'll just keep quiet about my own opinions (which may NOT be what you think) and let you think a minute on Arthur's words. -- Michael Chermside From peter at engcorp.com Sat Jul 14 09:20:07 2001 From: peter at engcorp.com (Peter Hansen) Date: Sat, 14 Jul 2001 09:20:07 -0400 Subject: Long Live Python! References: <9ip0io010ke@enews4.newsguy.com> Message-ID: <3B504707.86D6ED85@engcorp.com> Alex Martelli wrote: > > "phil hunt" wrote in message > > No it would not. If I say "my car is convenient for journeys <10 miles", > > it doesn't mean it is inconvenient for journeys >10 miles, does it? > > Sure, and if I say "I never strangle British citizens on Saturdays", that > cannot be taken as meaning that you are at risk on other days of the > week, nor that people of other nationalities are at risk today -- however, > depending on context, there is a *fair inference* (in human language > usage, although not in the Aristotelic logic simplification thereof) that > I'm likely to have a specific reason for what would be overqualification > of my sentence IF I never strangled anybody at all on any day of the week. I think you've left the original context behind, Alex. Phil was responding specifically to my parenthetical comment about the phrase "scripting language". I said "(whatever that means)". It was almost independent of anything to do with Python. So he was nicely clarifying a term we were using so that we would be able to agree on a useful definition (which I think we subsequently did). >> Phil Hunt wrote: >> > Peter Hansen wrote: >> >>I tend to think of Python more as an extremely effective and maintainable >> >>general-purpose programming language, which happens also to work >> >>very well when applied as a "scripting language" (whatever that means). >> > >> >To me it means "good for short programs <100 lines". Bear in mind >> >that 100 lines of Python is equivalent to 300 lines of Java or 400 >> >lines of C++. If we rewrite history, what we said was actually this: Peter wrote: > I think of Python as an effective general-purpose language. > Python *also* works very well as a "scripting language". > By the way, can we define what we mean by the term "scripting language". Phil wrote: > The term "scripting language" has the connotation of "good for > short programs, <100 lines". If you think Phil needs to qualify that, I suspect there are many even more critical cases we would need to qualify in half the postings to c.l.p. Of course, maybe we should have added: Peter: > Maybe someone will misinterpret your comment. Just to clarify, > you aren't saying you think Python is *only* good for scripting > according to our agreed definition, are you? You are actually > agreeing with my statement that Python *also* works very well > as a scripting language. Some people might think you meant > something different. Phil: > Yes, Peter. That's exactly what I meant. Good thing we caught > that ambiguity before it developed into a little Usenet noise-fest. Peter: > That's what I thought, too. Thanks, Phil. :-) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From pinard at iro.umontreal.ca Sun Jul 1 01:53:33 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 01 Jul 2001 01:53:33 -0400 Subject: PEP scepticism In-Reply-To: References: Message-ID: [Roman Suzi] > >Examples are: > > - augmented Assigments > > - Lists comprehensions > > - Simple Generators (About recent changes, I would sadly add the fact that join/split are now string methods -- an horrible ugliness that still just cannot tame me!) > I can't see these as bad things which make Python worse! If you do not > want to use them - please do so. Beware the PL/I syndrome. :-) Quite granted that nobody is forced to use a feature. But when a language becomes too featureful, people start programming in the subdialect they like best, later creating difficulties to other wanting to read their programs, who might like other parts better. One of the reason behind Python legibility success, is that there is almost only one way to do one thing (to contrast with Perl, say). We are progressively sliding away of this virtue. The danger is real. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From cjensen at bioeng.ucsd.edu Wed Jul 25 12:28:28 2001 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Wed, 25 Jul 2001 09:28:28 -0700 Subject: Python for Palm OS References: <20010725.4442652@mis.configured.host> Message-ID: <3B5EF3AC.E7627338@bioeng.ucsd.edu> Robert Roberts wrote: > > I have heard several times that there is a version of Python for the palm > os. Have palm version 3.5. Can anyone direct to the proper download? > > Thanks in advance. Is there documentation or a reference manual for pippy? A friend of mine, installed it on his palm, but we couldn't find documetation for it. -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From jeremy at chaos.org.uk Tue Jul 10 13:30:03 2001 From: jeremy at chaos.org.uk (Jeremy Henty) Date: Tue, 10 Jul 2001 17:30:03 GMT Subject: An unspeakable act References: Message-ID: <994786203.24889.0.nnrp-10.d4e48e5c@news.demon.co.uk> In article , Daniel Klein writes: >This person says that dynamically typed languages produce bug-ridden >programs Then this person will be distressed to learn that Java is effectively dynamically typed! See http://www.pragmaticprogrammer.com/cgi-local/pragprog?JavaIsUntyped ! Cheers, Jeremy Henty From philh at comuno.freeserve.co.uk Tue Jul 10 20:00:59 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Wed, 11 Jul 2001 01:00:59 +0100 Subject: Python Idiom Question References: <3B4A4126.7AD3CDD0@tundraware.com> <8Zr27.2394$vA6.115437@e420r-atl1.usenetserver.com> <3B4B2E5E.AB3C94BD@home.net> Message-ID: On Tue, 10 Jul 2001 09:33:34 -0700, Chris Barker wrote: >Steve Holden wrote: > >> > The approved idiom is >> while 1: >> x = raw_input() >> if not x: >> break >> DoSomethingInteresting() > >This is the approved idiom, but I never use it. I always use: > >x = raw_input() >while x: > x = raw_input() > DoSomethingInteresting() > x = raw_input() Do you often find you programs don't work? :-) -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From bill-bell at bill-bell.hamilton.on.ca Fri Jul 6 11:49:01 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Fri, 6 Jul 2001 11:49:01 -0400 Subject: Marking a Python COM server safe for Internet Explorer In-Reply-To: <994426394.405.95578.l7@yahoogroups.com> Message-ID: <3B45A5AD.12631.573C6B@localhost> As a kind of default, Internet Explorer will ask the user's permission before instantiating an ActiveX control. However, one can implement IObjectSafety to inform IE that one's control is safe, thus sparing the user the need to respond to the dialog box. I have a Python COM server that I would like to use with IE. Does someone happen to know if there is an incantation that can be muttered in Python that implements IObjectSafety--or of some alternative way of doing this? (I suppose one could embed the Python in an MSVC server. However, the more I play with Python the more I hate C++. And anyway I have a deadline.) Thanks for any clues or hints!! From mac4-devnull at theory.org Sat Jul 7 14:01:43 2001 From: mac4-devnull at theory.org (Neil Macneale) Date: Sat, 07 Jul 2001 11:01:43 -0700 Subject: Limiting thread intruction count References: <3b46ddb2$0$332$8eec23a@newsreader.tycho.net> <3B4721F3.BA771F79@engcorp.com> Message-ID: <3b474e87$0$322$8eec23a@newsreader.tycho.net> In article <3B4721F3.BA771F79 at engcorp.com>, "Peter Hansen" wrote: > Neil Macneale wrote: >> >> Is there a way to limit the number of instructions executed by a thread >> to a certain number? > > What do you mean by "instructions"? Machine language opcodes? Python > bytecode instructions? Python source instructions ("statements")? > Yes, bytecode intructions. >> The idea is that I have a game where people play there code against >> others, and I would like to have some granularity in the number of >> intructions each thread executes in a given time frame. > > Are you doing this to make the game "fair"? In what sense? > > Would you then need to consider the total amount of processing time used > by a given thread? Or are you trying to see how efficiently (in terms > of source lines of code) your players can code their algorithms, by > putting a limiter on their code at a higher level such as source lines > of code executed per unit time? > I want to give each thread the same amount of processing time. The way the game works is that each player needs to write a program which competes with other programs, or AI some might say. More computation is an advantage, so we want to encourage players who can figure out the most efficient algorythm. In the game, computation will cost a player, in the form of negative points or something. It would also be suitable if there was a way to determine who many instructions were made after there program returns. That may be equally impossible though. > By the way, Python can, depending on the platform, already do some kind > of round-robin style of multithreading (switching threads after a given > number of Python bytecode instructions) which may have an effect similar > to what you are trying to achieve, but I suspect what you are really > looking for can not be found in that way. So round robin scheduling is automatically used? The game is being written strictly for unix; is there a way to find out if the unix version uses round robin scheduling? Neil Macneale -- To reply to me via email, remove the '-devnull' from my address. From duncan at NOSPAMrcp.co.uk Thu Jul 5 03:56:24 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Thu, 5 Jul 2001 07:56:24 +0000 (UTC) Subject: Python for air traffic control? References: <9hlfbn$6ok$1@nereid.worldonline.nl> <9hrj3q$cj1@news1.gtech.com> <20010704013238.2DC8A00.NOFFLE@niccolo.ke4.de> Message-ID: Ralf Muschall wrote in news:u7elrwi0pa.fsf at hpeesof.asc: > No, typedef just creates aliases, *not* types. One might consider > creating something like > > typedef struct { int value; } plane_t; > > instead (and get bitten by the fact that struct tag names are not > local to the struct scope for some versions of C (i.e. adding > > typedef struct { int value; } lane_t; > > would clash)). > At which point you go out and buy yourself a C compiler that manages to get a bit closer to the standard. I think clashing of structure tag names went out of fashion about 20 years ago, certainly it wasn't a problem I encountered even in my days of writing C for Z80s. -- 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 steve at lurking.demon.co.uk Fri Jul 27 04:55:54 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Fri, 27 Jul 2001 09:55:54 +0100 Subject: from __past__ import integerDivision (was Re: A modest PEP0238 suggestion) References: <3b5c6e08.27535083@aplnews> <9jiak1$3s96$3@node21.cwnet.roc.gblx.net> Message-ID: On Wed, 25 Jul 2001 05:06:51 GMT, Guido van Rossum wrote: >missive at frontiernet.net (Lee Harr) writes: > >> I think this is what the PEP is proposing: >> >> // is current / behaviour >> / is new int/int --> fp > >No, a//b would always return floor(a/b). > >> we already have people importing things from the __future__, >> how difficult would it be to let people drag things from the __past__? > >But the problem (as I see it) >is that there will never be a point where we can throw away support >for the past behavior, because there will always be code around that >imports it. Of course there is. You just give an explicit error when the import is disallowed (out-of-range-of-time-machine or some such), and refuse to run the script. This is much better than code that runs incorrectly. It means people know they have a problem, they have a very good clue as to what that problem is, and they can try to find a solution - rather than continuing to trust outputs from previously reliable programs or libraries that have gone bad. From thwapp at hotmail.com Mon Jul 23 20:14:33 2001 From: thwapp at hotmail.com (thwapp at hotmail.com) Date: Tue, 24 Jul 2001 00:14:33 GMT Subject: help with ming and python 2.1 Message-ID: <3b5cbdda.22330511@news.earthlink.net> I have ming-pythonwin32.zip but it was compiled for use with python 1.5.2 and does not work in python 2.1. Does anybody have compiled version for Python2.1 thwapp at hotmail.com From sholden at holdenweb.com Mon Jul 16 09:09:55 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 16 Jul 2001 09:09:55 -0400 Subject: Need help with "global" variables References: Message-ID: "Nick Perkins" wrote in message news:co847.478507$eK2.99254456 at news4.rdc1.on.home.com... > Your modules are going to have to import the globals. You could put them > all in a separate file, call it "my_globals.py", and then in each file > (including the 'main' file), you would have: > from my_globals import * > > This would not be a good idea. Each module would create its own copy of the imported globals, meaning that one module would not see changes made by another because each would be modifying its own copy. And, in fact, this is another good reason why one should avoid from module import * unless one is very sure one knows what one is doing. since-i-frequently-don't-i-avoid-it-like-the-plague-ly y'rs - steve -- http://www.holdenweb.com/ From skip at pobox.com Tue Jul 24 10:37:46 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 24 Jul 2001 09:37:46 -0500 Subject: re bad leadership In-Reply-To: References: <0+yM4IAgmKX7EwIQ@jessikat.fsnet.co.uk> Message-ID: <15197.34874.72036.271448@beluga.mojam.com> Mikael> I've seen BDFL referring to GvR, and I know the interpretation Mikael> of that. Here, obviously, MDFL suddenly referres to the very Mikael> same GvR. What's with that M? Based on the context in which I saw it I assumed it meant "malevolent", but I agree, it's not obvious. I'd never seen that acronym before. Skip From m.faassen at vet.uu.nl Thu Jul 5 09:28:58 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 5 Jul 2001 13:28:58 GMT Subject: PEP: Procedure for Adding New Modules (please comment) References: Message-ID: <9i1q2q$8ei$3@newshost.accu.uu.nl> Bruce Sass wrote: > <...> >> Maintainer(s) >> >> All contributions to the standard library need one or more >> maintainers. This can be an individual, but frequently is a group >> of people such as for instance the XML-SIG. Groups may subdivide >> maintenance tasks among themselves. One ore more maintainers shall >> be the _head maintainer_ (usually this is also the main >> developer). Head maintainers are convenient people the integrators >> can address if they want to resolve specific issues, such as the >> ones detailed later in this document. > With the maintainers of the existing library being the group of core > developers? What happens with the existing library is strictly outside the scope of this PEP, though I could of course broaden it. I'd *like* to say something like that, yes. Perhaps I ought to. [snip] > Will maintainers be given access to the servers, if so then > there should be set procedure to verify who they are (email don't cut > it!) Hm, do I want to get into technical details of how maintainers can be contacted? I think email should be enough; the maintainer should notify the integrators if his or her email address changes! Perhaps there could be a maintainer-SIG or something like that. If a maintainer cannot be contacted easily then that's just a bad job by the maintainer, right? (Perhaps there should be a note that the integrators have the right to reject a maintainer that's inactive and look for another one..?) [snip] >> Should the current standard library be subdivided among such >> maintainers? Many parts already have (informal) maintainers; it >> may be good to make this more explicit. > That would be up to the group currently responsible for them. You mean PythonLabs/python-dev? (along with such other groups like the XML-SIG for the xml modules). >> Perhaps there is a better word for 'contribution'; the word >> 'contribution' may not imply enough that the process (of >> development and maintenance) does not stop after the contribution >> is accepted and integrated into the library. > "contribution" accurately describes the relationship of the work > to the standard library, and as soon as someone starts looking into > contributing the word "maintainer" is gonna smack'em in the forehead. Yes, I think it's okay as well. Thanks for the feedback! Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From peter at engcorp.com Tue Jul 31 01:49:32 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 31 Jul 2001 01:49:32 -0400 Subject: Compile-time type checking (was Re: Typing system vs. Java) References: None <996554015.454155@yabetcha.sttl.drizzle.com> Message-ID: <3B6646EC.37B11428@engcorp.com> Donn Cave wrote: > > If you a type checking compiler, the object would have to agree at > compile time with the programmer's notion of what would be an > appropriate input. Sometimes the programmer's notion of "appropriate input" is a little restrictive. Sometimes it is better not to have type-checking at compile time, but to do it at run time. When a library routine is used for a purpose the original author wouldn't have predicted, maybe. Run-time assertions could check that the inputs have the required characteristics, but those characteristics might not be restricted to the simple notion of "type". (For example, maybe it is better to allow any object which will _act_ as an integer, rather than just integers. If only integers are to be allowed, Python easily supports checking for this, at run-time.) > I don't know if that means Python should have type checking. Its > open typed design works awfully well with OOP, and it would be a > shame to strangle that freedom for the sake of a half-baked concept > of discipline. But some kind of type inference validation could be > applied from a lint utility - that already exists and is reportedly > useful, but I don't know if it actually covers types. The problem with an external checking utility such as lint, or the proposed division scanning utility, is that it only works in a limited set of cases (although perhaps the majority of cases). What it can't do is deal with some cases which are possible because of the dynamic nature of Python. It may be only at run-time that one can determine which inputs are actually being fed to a subroutine, for example. This is where testing comes in. A compiler can only check whether you have followed the rules to which it restricts you. Testing, however, can verify that, whether you followed the rules or not, the code is doing what you think it should. Testing is both necessary and sufficient for Python code. With statically typed languages, testing is still necessary, though probably done less often, while compile-time checking is _not_ sufficient, yet that's all most people use. In the end, whether or not Python suffers because of a lack of compile-time checking is hardly the issue. Anyone relying on such simplistic means to provide them with confidence in their code's correct operation is deluding themselves. Python just doesn't try to delude you: if you want safe code, test. > Anyway, maybe it's an area where a big investment could yield > something real interesting for industrial strength programming. I suppose you could say my group does "industrial strength" programming with Python, since we're in industry :-) and the strength of the code -- without compile-time type checking -- is quite adequate for now. Of all our problems, well under 5% are related to problems caused by Python's syntax, lack of compile-time type checking, division behaviour, and other such things. Adding static types (i.e. _requiring_ them) would cost us significant productivity with next to no practical gain (since they would catch a small fraction of less than 1% of our problems). (Note: these numbers are anecdotal, unscientific, and made up. Hah, some engineer! :-) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From bill-bell at bill-bell.hamilton.on.ca Wed Jul 11 12:54:27 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Wed, 11 Jul 2001 12:54:27 -0400 Subject: Bug in __imul__ In-Reply-To: <994866174.493.60419.l8@yahoogroups.com> Message-ID: <3B4C4C83.18319.3B586F9@localhost> Roman Suzi wrote, in part: > >"Emile van Sebille" wrote in message > >news:9ihg33$irjha$1 at ID-11957.news.dfncis.de... > >> Does it bother anyone that > >> a *= 3 + 4 > >> returns a different value from > >> a = a * 3 + 4 > > By this example I conclude that infix notation is seriously flawed > compared to prefix or postfix (called Polish and inverted Polish). > What? This is inconsistent with math notation? Who cares to know it > these days! You do not need to be rocket scientist (or any scientists > at all) to write simple arithmetics! Good one, Roman! LedOL. All I can say is that you ~belong~ on this list composed mostly of eggheads. :o) Those of us with IQs of 120 (or perhaps somewhat less) just use parens when we find that we're again becoming hopelessly confused. From rmalla1 at lsu.edu Fri Jul 27 01:04:34 2001 From: rmalla1 at lsu.edu (Ratnakar Malla) Date: Fri, 27 Jul 2001 05:04:34 GMT Subject: File Reading , Reverse Direction Message-ID: <3B60F7EC.5275E026@lsu.edu> Hi, I need to read from a very long file. But the only information I am interested is 2 lines at the bottom of the file. 1) Can i read the file in the reverse direction , so that I dont lose time? 2) If so how?? 3) I tried the normal way, but looks like, it is taking lot of time. Thanx, Ratnakar Malla -------------- next part -------------- A non-text attachment was scrubbed... Name: rmalla1.vcf Type: text/x-vcard Size: 294 bytes Desc: Card for Ratnakar Malla URL: From nperkins7 at home.com Wed Jul 11 12:57:38 2001 From: nperkins7 at home.com (Nick Perkins) Date: Wed, 11 Jul 2001 16:57:38 GMT Subject: Language change and code breaks References: Message-ID: <6A%27.454703$eK2.93741234@news4.rdc1.on.home.com> "Guido van Rossum" wrote in message news:cplmlvh6dx.fsf at cj20424-a.reston1.va.home.com... > Very good sumary, Terry. I'm beginning to get second thoughts about > integer division -- maybe it's better to leave well enough alone, and > try to fix areas of the language that could really stand some fixing > (such as subclassing built-in types). > > --Guido van Rossum (home page: http://www.python.org/~guido/) If changing int/int->int to int/int->float is going to break too much code, then why not use another operator? I have seen // suggested as a replacement for int/int->int, ie. int//int->int,.. but why not leave int/int->int alone, and use // for int//int->float. No code breaks, and it is almost as easy for the newbies. 1/2 -> 0 1//2 -> 0.5 That way we still have / = div, % = mod, and we add // = float-divide. No need for a 'div' operator or anything like that. p.s. Would it be possible to allow operators to be used as first-class functions, eg: reduce(+,mylist) instead of: import operator reduce(operator.__add__,mylist) From bsass at freenet.edmonton.ab.ca Thu Jul 26 01:25:54 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Wed, 25 Jul 2001 23:25:54 -0600 (MDT) Subject: int(a), b = divmod(x, y) In-Reply-To: <009901c1156e$6a9c5260$6501a8c0@pacbell.net> Message-ID: Ya, that's pretty much what I figured; well, that or maybe the look-ahead required would involve more than a naive view suggests. It didn't look too weird when I first wrote it, but a second look has me thinking otherwise (Paul and Greg's posts kinda clinch it :). I suppose if I ever get lazy enough to actually want such a thing... it would be easy to do in a preprocessing step. Thanks All. - Bruce -- On Wed, 25 Jul 2001, Ken Seehof wrote: > No, it's just that the syntax makes no sense in python. > > It would also, of course, be invalid to say: > int(a) = 5.2 # hoping for a=5 > > This is not the same as a = int(5.2) and it would seem really wierd to > me if it were. Then again, from a C++ point of view, any syntax that > is currently illegal is a natural candidate for a new syntax feature :-). > But python is not C++, so I'm afraid you'll have to settle for something > less terse and more clear. > > a,b = divmod(x,y) > a = int(a) > > ----- Original Message ----- > From: "Bruce Sass" > > How nasty would it be to allow one to do... > > > > >>> int(a), b = divmod(5.01, 2) > > >>> print a, b > > 2 1.01 > > > > ...instead of the current... > > > > >>> int(a), b = divmod(5.01, 2) > > SyntaxError: can't assign to function call > > > > On the surface, it looks as simple as postponing the function call > > until after the assignment. Would it be a one-time hit when the > > pseudo-ops are generated, a runtime performance issue that would > > affect all function calls, just too hairy to implement, or something > > else? From deblNoNospammy at theworld.com Sun Jul 15 18:47:35 2001 From: deblNoNospammy at theworld.com (David Lees) Date: Sun, 15 Jul 2001 22:47:35 GMT Subject: re Challenge: More Compact? References: Message-ID: <3B521D9B.53E86E68@theworld.com> Because you would also find non-valid IP address. In fact a split would not even require them to be numeric. There is a problem with the original regex approach too because while it does require digits for the quad, it would still accept invalid values such as 999.257.382.433 david lees Roman Suzi wrote: > > On 15 Jul 2001, Tim Daneliuk wrote: > > >The following re is (I think) the description of a legitimate IP addess in > >"quad" format (IPV4). My question is, can it be made even shorter? > > > >ipquad = r"^((\d\d?\d?\.){3}(\d\d?\d?))$" > > ipquad = r"^((\d{1,3}\.){3}(\d{1,3}))$" > > (Why not just split(it, ".") ?) > > Sincerely yours, Roman Suzi > -- > _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ > _/ Sunday, July 15, 2001 _/ Powered by Linux RedHat 6.2 _/ > _/ "This is Borg. is futile is inevitable" _/ From aahz at panix.com Fri Jul 27 16:30:10 2001 From: aahz at panix.com (Aahz Maruch) Date: 27 Jul 2001 13:30:10 -0700 Subject: Language change and code breaks References: <9javdi$bbp$1@panix2.panix.com> Message-ID: <9jsj0i$dom$1@panix2.panix.com> In article , Ben Caradoc-Davies wrote: >On 20 Jul 2001 21:11:30 -0700, Aahz Maruch wrote: >> >>smpt = SMTP() > >That won't be affected. ;-) I caught that just after I posted and decided to wait and see if anyone else noticed. -- --- 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 Fortune cookie: Watch your relations with other people carefully, be reserved. From XQ.Xia at ccsr.cam.ac.uk Wed Jul 11 13:32:22 2001 From: XQ.Xia at ccsr.cam.ac.uk (XiaoQin Xia) Date: Wed, 11 Jul 2001 18:32:22 +0100 Subject: apply for keywords References: <3B4C89BA.DB51C3A7@bioeng.ucsd.edu> Message-ID: <3B4C8DA6.B6F41B8F@ccsr.cam.ac.uk> Why not write as: >>> apply(foo,(),{"bar":1}) Cheers, Xiao-Qin Xia Curtis Jensen wrote: > > Can you use "apply" to pass keywords? If so, what is the syntax? > > ie: > Python 1.5.2 (#4, Sep 5 2000, 10:29:12) [C] on irix646 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> def foo( bar = None ): > ... if bar != None: > ... print 'ok' > ... else: > ... print 'not ok' > ... > >>> apply( foo, [bar = 1] ) > File "", line 1 > apply( foo, [bar = 1] ) > ^ > SyntaxError: invalid syntax > >>> apply( foo, bar = 1 ) > Traceback (innermost last): > File "", line 1, in ? > TypeError: this function takes no keyword arguments > >>> apply(foo, (bar = 1) ) > File "", line 1 > apply(foo, (bar = 1) ) > ^ > SyntaxError: invalid syntax > >>> > > -- > Curtis Jensen > cjensen at bioeng.ucsd.edu > http://www-bioeng.ucsd.edu/~cjensen/ > FAX (425) 740-1451 From nospam at nospam.com Fri Jul 27 02:09:46 2001 From: nospam at nospam.com (Grace) Date: Fri, 27 Jul 2001 15:09:46 +0900 Subject: Is this an Intended behaviour of __getattr__? Message-ID: I'm a bit confused with this: class Node: def __init__(self): self._next=None def __getattr__(self,attr): if attr=='next': if self._next is not None: return self._next else: self._next=Node() return self._next print attr,"was called..." error=3/0 #supposed to raise exception raise AttributeError if __name__=='__main__': f=Node() links=[f.next,f.next,f.next.next,f.next.next] for each in links: print each print f.errorPlz And this yields exactly, __str__ was called... __repr__ was called... <__main__.Node instance at 0081608C> __str__ was called... __repr__ was called... <__main__.Node instance at 0081608C> __str__ was called... __repr__ was called... <__main__.Node instance at 0081601C> __str__ was called... __repr__ was called... <__main__.Node instance at 0081601C> al was called... Traceback (most recent call last): File "...", line 22, in ? print f.al File "...", line 12, in __getattr__ k=3/0 ZeroDivisionError: integer division or modulo by zero Why did it suck up all ZeroDivisionErrors while outputting the "was called..." messages? Special case with magic methods? Is this an intended behaviour? Then what is the exact process/mechanism? Thanks in advance. From tjreedy at home.com Thu Jul 26 13:59:48 2001 From: tjreedy at home.com (Terry Reedy) Date: Thu, 26 Jul 2001 17:59:48 GMT Subject: Use "quotient"? (was Re: proposed language change to int/int==float (was: PEP0238 lament)) References: <52Q77.181728$mG4.85523836@news1.mntp1.il.home.com> Message-ID: "Manoj Plakal" wrote in message news:52Q77.181728$mG4.85523836 at news1.mntp1.il.home.com... > It seems to me that the word "division" is being sorely > overloaded in these threads as well as in PEP 238. Would > it be more precise (mathematically and otherwise) to > reword things like this: > > - currently, the symbol `/' in Python programs signifies > two different operators depending on the arguments: > - the QUOTIENT operator with 2 integer arguments > > - the DIVISION operator with at least 1 float > argument > > - the proposed change is to make '/' always signify the > DIVISION operator and '//' always signify the QUOTIENT > operator > > Seems to be more clear than saying "integer division" > or "truncating division" or "float division". Bravo. This clear and succinct summary of PEP0238 makes its intent and virtues clearer than anything I've read (or written) so far. Guido, please consider something very much like this for the Abstract. Terry J. Reedy From steve at lurking.demon.co.uk Wed Jul 25 04:38:25 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Wed, 25 Jul 2001 09:38:25 +0100 Subject: A use for integer quotients References: <230720010741551768%jwbaxter@spamcop.com> Message-ID: <4h0tltgbrn2b50mueqd2vsgtt3psvkvosv@4ax.com> On Wed, 25 Jul 2001 04:41:49 GMT, Guido van Rossum wrote: >Well, so far the only arguments I've heard come down to > >(1) int/int *ought* to return an int; ... >IMO, argument (1) is misguided. I've heard all the variations many >times by now and none are convincing to me; they are either wrong, >like "that's how mathematicians define it" or "that's how all >right-thinking programming languages define it", or they miss the >point, like "it's easy to explain to newbies that int/int returns >int". Please read my 'Steve Summary' message - it addresses all these and more. If you can prove that the set of mathematicians only includes those who are dealing with the currently interesting discrete-mathematics problems, or you can prove that magically warping discrete measures into continuous measures is useful for typical bread-and-butter programming tasks, I'd be interested to hear it. I define a mathematician as someone who applies mathematics, and who understands the mathematical principles being applied. I don't limit it to people working in field theory or some such, however interesting it may be and however pervasive it may be in current college/university study and specialist application of discrete mathematics. Any narrowing of that definition should be explicit or at least for day-to-day practical reasons. I define practical as the normal case, not the first-day newbies expectations and not specialist fields. From sdm7g at Virginia.EDU Tue Jul 24 12:28:28 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Tue, 24 Jul 2001 12:28:28 -0400 (EDT) Subject: function while true - list function? In-Reply-To: Message-ID: An alternative to the generator class method: Also in 2.2, the 'iter' function has two forms: iter( collection ) & iter( callable, sentinel ) The second form takes a callable object of no args and a sentinal value, and returns an iterator that calls the function until it returns the sentinel value. For example: >>> i = iter( [1,2,3,None,4,5,6] ) >>> j = iter( i.next, None ) >>> for x in j: print x ... 1 2 3 >>> So, if you can curry your function into one that takes no args ( with lambda or by turning it into a class method that keeps state ) or if that's what you've already got, you can just use 'iter( function, None )' . If you need to force eager evaluation of the iterator you can use: [ x for x in iter( function, None ) ] -- Steve Majewski From jim at interet.com Thu Jul 26 09:16:01 2001 From: jim at interet.com (James C. Ahlstrom) Date: Thu, 26 Jul 2001 09:16:01 -0400 Subject: Eliminating upgrade risk References: Message-ID: <3B601811.4B68578B@interet.com> Robin Becker wrote: > If the advice from the Gods is that Python is a 'research' language then > I'll know better what to do. I am afraid I have to agree with Robin here. My company "solved" this problem by staying with Python 1.5.2. I do plan to upgrade when I have the time, but absent any tools to at least flag incompatibilities this may never happen. My new Red Hat 7.1 system reports that its Python version is 1.5.2. Apparently I am not alone. I believe many Python users are at 1.5.2. The problem is that the new Python features, as wonderful as they are, are chosen for Computer Science Purity, not day-to-working-day importance to someone actually trying to write a widely used bullet proof program. The current rate of language change is fine for a student or casual programmer I'm sure, but I don't have that luxury. Jim Ahlstrom From emile at fenx.com Tue Jul 3 10:41:23 2001 From: emile at fenx.com (Emile van Sebille) Date: Tue, 3 Jul 2001 07:41:23 -0700 Subject: Access all classes in a directory, put into an array, and print them out References: <9hsk9c$fl3ec$1@ID-11957.news.dfncis.de> Message-ID: <9hslpr$fl4qm$1@ID-11957.news.dfncis.de> Oops... s/b print file -- Emile van Sebille emile at fenx.com --------- "Emile van Sebille" wrote in message news:9hsk9c$fl3ec$1 at ID-11957.news.dfncis.de... > import os > for file in os.listdir(dirpath): print i > > From skip at pobox.com Wed Jul 4 05:42:18 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 4 Jul 2001 04:42:18 -0500 Subject: Catching Python exceptions from C++ ... In-Reply-To: <3B42847A.E436B1D1@accesswave.ca> References: <3B42847A.E436B1D1@accesswave.ca> Message-ID: <15170.58618.250831.520476@beluga.mojam.com> Sandy> 2. Can I perhaps set stdin, stdout, stderr to my own FILE handles Sandy> and at least dump the output/trace info to something I can Sandy> read later? If so, how? You could wrap the Python code you call in a try/except, then catch and save the exception: import traceback, sys try: ... original code ... except: traceback.print_tb(sys.exc_info()[2], 0, open("/tmp/traceback", "w")) raise The raise call is there so the return value of PyRun_SimpleFileExFlags is the same. It's not strictly necessary. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From simonb at webone.com.au Wed Jul 11 15:44:35 2001 From: simonb at webone.com.au (simonb at webone.com.au) Date: Thu, 12 Jul 2001 05:44:35 +1000 Subject: Tuple Semantics - Rationale'? References: <3B4CA0A8.20B53230@tundraware.com> Message-ID: <3B4CACA3.4010109@webone.com.au> Right, parenthesese usually mean "do this first", as in (1+2)*3. Python is not designed to work out that in something like >>> a=(3) the brackets are redundant and therefore the user really meant that "a" should be a tuple with one element. And im not sure that i'd like such a feature. But (as i just tried), it does work out that if you type >>> a=() you want "a" to be an empty tuple ( (,) does not work ). So to get this structure: (()), (), ((,)) you should do : ((),), (), ((),) Simon Burton Tim Daneliuk wrote: >I'm curious about why python was designed to handle the tuple semantics >described below the way it does. Perhaps one of you language experts >can 'splain it to me. > >I have a data structure that looks like this (each of the elements is a >string): > >ds = ( > ( > (name-1, descrip-1), > ( (argA-1, argB-1), ... (argA-n, argB-n) ) > ), > > ... > > ( > (name-n, descrip-n), > ( (argA-1, argB-1), ... (argA-n, argB-n) ) > ), > ) > > >One of the tuples of ds has a single arg pair. That is, it looks >like this: > > ( > (name-n, descrip-n), > ( (argA-1, argB-1) ) > ), > > >But, at runtime, python sees is as this: > > ( > (name-n, descrip-n), > (argA-1, argB-1) > ), > > >From what I've read, to force the data structure to be maintained correctly, >I have to add a trailing comma to the single arg pair like this: > > ) > (name-n, descrip-n), > ( (argA-1, argB-1), ) > ), > > >And that works fine. But *why* is the trailing comma designed into the >language semantics this way. I've been scratching my head and cannot come >up with a rationale'. It seems to me that the explicit use of the parens >should be telling python that I want the second entry in each data >structure to be a *tuple* of 0 or more tuples. > >Supposed I did want 0 argument pairs in that tuple, but I wanted to prepare >the way for adding some later. Would I use: > > (()), (), ((,)) ??? > >'Just curious... >------------------------------------------------------------------------------ >Tim Daneliuk >tundra at tundraware.com > From erno-news at erno.iki.fi Wed Jul 4 08:12:26 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 04 Jul 2001 15:12:26 +0300 Subject: problem with sending email References: <3B42BD95.D6A0BC30@stroeder.com> Message-ID: In article <3B42BD95.D6A0BC30 at stroeder.com>, Michael Str?der writes: | Now think about systems where sendmail isn't installed at all. every unix mta provides a "sendmail" command afaik. unixes don't function very well without the capability to deliver mail since it's used by cron and whatnot. ok, you may have a box that is configured to only deliver local mail, but not very common and easy to remedy. -- erno From thecalm at NOSPAM.btinternet.com Tue Jul 31 07:40:50 2001 From: thecalm at NOSPAM.btinternet.com (G. Willoughby) Date: Tue, 31 Jul 2001 12:40:50 +0100 Subject: win32api exception names? References: <9k4r84$n85$1@uranium.btinternet.com> Message-ID: <9k65s2$5ao$1@neptunium.btinternet.com> could you please explain the code needed a little better? sorry! if i use something like this: except win32api.api_error, info: win32api.MessageBox(0,"File can not be opened, right double click to open\nthe file's directory.", appName, 0, 0) then i get: AttributeError: 'win32api' module has no attribute 'api_error' any ideas? G. Willoughby "David Bolen" wrote in message news:uhevt6hsy.fsf at ctwd0143.fitlinxx.com... > "G. Willoughby" writes: > > > I'm using this function to open a file listed in a Tkinter Listbox widget, > > but i've run into some problems. First when i double click on .htm files > > listed they work perfectly, opening in Explorer, But when i double click on > > .txt files i get this error: > > > > Exception in Tkinter callback > > Traceback (most recent call last): > > File "c:\program files\python\lib\lib-tk\Tkinter.py", line 1285, in > > __call__ > > return apply(self.func, args) > > File "D:\Backup\Python Programs\PyFind\PyFind.py", line 61, in executeFile > > win32api.ShellExecute(0, "open" , str(resultPane.get(ACTIVE)),"","",1) > > api_error: (31, 'ShellExecute', 'A device attached to the system is not > > functioning.') > > > > i'm trying to handle this exception, but being new to them i dunno what > > exception is being raised, the 'except EnvironmentError:' line really isn't > > getting it. any ideas? > > I can't necessarily address why your code is returning that specific > exception (perhaps a bad path?), but each of the PythonWin modules all > raise an api_error exception for any general Win32 errors. The first > element in the instance data tuple will be the underlying Win32 error > code (31 in this case is ERROR_GEN_FAILURE), then the failing function > call, and finally a textual description. > > So if you want to catch these in your exception handler, you can use: > > except win32api.api_error, info > > and then if necessary, inspect the actual Win32 API error code (in info[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 wtanksle at dolphin.openprojects.net Sun Jul 29 02:43:43 2001 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Sun, 29 Jul 2001 06:43:43 GMT Subject: FEEDBACK WANTED: Type/class unification References: Message-ID: On Sat, 28 Jul 2001 17:14:38 -0700, Paul Prescod wrote: >William Tanksley wrote: >> On Sat, 28 Jul 2001 13:07:32 -0700, Paul Prescod wrote: >> >2. If I have an object that hides its attributes behind an __getattr__, >> >is there any way to tweak the list returned by the API described above? >> Not without the object's cooperation -- it's not even theoretically >> possible to figure out what attributes __getattr__ might support. >I am asking whether there is a way for the object to cooperate. Yes and no. I asked later for input from people who use __getattr__; if most or many of them follow some kind of pattern, then that pattern can be added to the introspection API in some way. However, until they tell us, there is no way for us to predict what that part of the API will look like. For example, I've used getattr once for a little toy project (I shouldn't have; I didn't need it). In short, it created any item you asked for, with some calculated value. We could make that a standard part of the introspection API by possibly making a query function which would answer whether the getattr did that type of action -- the query function could possibly even give some info on how the default value was calculated. >I wasn't being theoretical. I was asking whether there is a function, >method or parameter with those semantics (and obviously a more sane >implementation). I apologise. I wasn't intending to make fun; I was just playing around. I knew you had a good question. I don't think it has a good answer; I think that getattr is by definition too complex to allow introspection. -- -William "Billy" Tanksley From max at alcyone.com Sun Jul 22 20:57:45 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 22 Jul 2001 17:57:45 -0700 Subject: PEP0238 lament References: <3B5B3676.40F39389@alcyone.com>, Message-ID: <3B5B7689.F37B991C@alcyone.com> Moshe Zadka wrote: > Be sure to tell math.cos that...it has been "silently" turning > integers > into floats for years. Sure, but that's something different. The domain of math.cos (and so on) is floats, not ints, so if you pass it an int you very sensibly get coercion to an float, because that's what you must have really meant. That's quite different from the current case, where we're talking about an operation that will return different types depending on the inputs. I don't see any good reason to change the current behavior; / means division over the types that are passed in. If you pass in floats, you want float division. If you pass in ints, you want integer division. > Err.....problem with the URL?. Sorry, lazily pasted something into my .sig database. It was meant to be: http://www.alcyone.com/max/lang/esperanto/ -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ When the solution is simple, God is answering. \__/ Albert Einstein REALpolitik / http://www.realpolitik.com/ Get your own customized newsfeed online in realtime ... for free! From tim.one at home.com Sat Jul 14 16:34:09 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 14 Jul 2001 16:34:09 -0400 Subject: not safe at all In-Reply-To: <9ioonl0jgu@enews4.newsguy.com> Message-ID: [Alex Martelli] > ... > Actually, I wouldn't mind an 'assertion language' that's not even > truly checkable (fast enough to be useful) at runtime -- one where > I could use existential and universal quantifiers, because those are > so often the things I *WANT* to express in a formal, unambiguous > way. Consider the predicate parameter P I can pass to many of > the containers and algorithms in the standard C++ library. What > I often want to assert about the type of P is: for all X, not P(X,X); > for all X and Y, P(X,Y) implies not P(Y,X); for all X, Y and Z, > P(X,Y) and P(Y,Z) imply P(X,Z). I.e., the crucial facts about P's > type is that it's antireflexive, antisymmetric, transitive. What I > _can_ assert that's static-type-checkable is that P accepts two > "foo" arguments and returns a boolean. Pish and tush -- that's > close to saying NOTHING about the known type constraints on P!!! LOL -- "pish and tush" is exactly on-target. ABC (Python's predecessor) had quantified boolean expressions, of the forms 1. each x in s has expression_involving_x 2. no x in s has expression_involving_x 3. some x in s has expression_involving_x The keywords there are "each", "no", "some", "in" and "has". They had a very nice twist: if an expression of form #1 was false, it left x bound to "the first" counterexample (i.e., "the first" x in s that did not satisfy the predicate expression); similarly if #2 was false, it left x bound to the first witness (the first x in s that did satisfy the predicate); and if #3 was true, to the first witness. For example, if some i in xrange(2, int(sqrt(n))+1) has n % i == 0: print n, "isn't prime -- it's divisible by", i or assert no x in xrange(2, int(sqrt(n))+1) has n % i == 0, "n not prime" According to Guido, Lambert Meertens (ABC's chief designer) spent a sabbatical year in New York City working with some of the SETL people, and I speculate that's where this cool little ABC subsystem came from. I would like it in Python too, but it's a lot of new keywords to support one conceptual gimmick. It's still a pleasant pseudo-code notation to use in comments, though. uncommonly-fond-of-constructs-that-capture-common-loops-ly y'rs - tim From guido at python.org Sat Jul 28 11:42:28 2001 From: guido at python.org (Guido van Rossum) Date: Sat, 28 Jul 2001 15:42:28 GMT Subject: Changing the Division Operator -- PEP 238, rev 1.12 References: <9juerr$f3b$1@newsy.ifm.liu.se> Message-ID: paul at svensson.org (Paul Svensson) writes: > Consider an existing > class Foo: > def __div__(self, other): > ... > > With your proposal, this will break as soon as it's called from > a module importing the future division. And that's exactly right, because we don't know if the type is trying to "look like" a float or an int, so we don't know whether to map __floordiv__ to __div__ or __truediv__. This is only a problem when the user of the class uses true or floor division, and I think it's fair that the system shouldn't attempt to guess. --Guido van Rossum (home page: http://www.python.org/~guido/) From mcc at TO.GD-ES.COM Thu Jul 12 11:59:55 2001 From: mcc at TO.GD-ES.COM (mcc at TO.GD-ES.COM) Date: Thu, 12 Jul 2001 08:59:55 -0700 (PDT) Subject: Version incomptabilities, code changes, __future__, etc In-Reply-To: Message-ID: On Thu, 12 Jul 2001 mcherm at destiny.com wrote: > simonb at webone.com.au wrote: > > i don't want to see any more versions of python. > > ITS FINISHED > > AND I LOVE IT RIGHT NOW > > if you want more then make a new language. > > Regretably, Simon, you are out of luck. In order to convince > Microsoft to support Python natively in their .NET initiative, > Guido was forced to make several major concessions. One of those > was to recind the "Open Source" liscense, which allowed anyone > to freely use Python -- using any version they wanted for (pretty > much) any purpose. > > Unfortunately, Python is now released on a more restrictive > liscense, which, in a future version, will require all Python > programs to contact a Microsoft Certification server and > present a Passport certification before executing. In order to > ensure that everyone migrates to the new version of the software > (to be released as soon as Microsoft finishes building the > infrastructure), the migration will be mandatory. This "bon mot" needs more clarification. This implies that Python will only be available to the Windows community. There are environments where Microsoft Certification servers will never exist. If there will now be a component added to Python to only allow its use when authorized by a Microsoft Certification server, then one may need to change or develop a new solution set. I'm not particularly opposed to forking off a "Python for Microsoft Windows Environments" or a "Python for Microsoft Certification Server Environments" as long as there remains a Python for other communities of interest. If the latter is not going to occur, then I need to reconsider whether or not Python is part of a viable solution. Merton Campbell Crockett From ykingma at accessforall.nl Mon Jul 30 05:34:14 2001 From: ykingma at accessforall.nl (Ype Kingma) Date: Mon, 30 Jul 2001 10:34:14 +0100 Subject: Threading in Python References: <9jv2h8$fo1$1@panix2.panix.com> Message-ID: <3B652A0D.D8354D7F@accessforall.nl> Aahz Maruch wrote: > > In article , > Andy wrote: > > > >There seems to be a lot of (arguably) radical changes going on in the > >Python syntax/grammar/language, perhaps the direction should be towards > >improving the internals first? > > > >One thing Java has which Python lacks is transparent support for > >multi-cpu threading. Python has threads, but I believe it is > >internally implemented and has been shown not to take advantage of an > >SMP machine. > > That's about half-true. For more information, see > http://starship.python.net/crew/aahz/ > (Very nice python threading code.) > (New & Improved slideshow coming Real Soon Now (a couple or three days)) > -- Meanwhile you can have the best of both worlds: www.jython.org Some threading features: - jython interpreter threads are Java threads, - java's 'synchronized' is used in the jython interpreter where necessary, - in other words: fine grained locking is used, there is no 'interpreter lock'. Regards, Ype -- email at xs4all.nl From kseehof at neuralintegrator.com Tue Jul 31 19:17:43 2001 From: kseehof at neuralintegrator.com (Ken Seehof) Date: Tue, 31 Jul 2001 16:17:43 -0700 Subject: Large pages using Zope References: <9k766t$dc0$04$1@news.t-online.com> Message-ID: <012c01c11a1f$126371e0$6501a8c0@pacbell.net> From: "Achim Domma" > Hi, > > I just finished the first step : I succeded in introducing Python as our > prefered > scripting language, replacing JScript and VBScript in the future. Now we > need > a way to script webpages with it. I would like to use Zope, but I have to > answer > questions like 'How do we know that it's fast/stable enough ?'. Can anybody > help ? > Are there any big references, which are using Zope ? > > thanks > Achim Hmmm, I was going to refer you to www.zope.org, where there used to be lots of great references. Hey Zope, where's your links to zope users? - Ken From paulp at ActiveState.com Tue Jul 24 08:31:58 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Tue, 24 Jul 2001 05:31:58 -0700 Subject: PEP0238 lament References: <00867F2E.N22121@rsmi.com> Message-ID: <3B5D6ABE.93C05B66@ActiveState.com> Stephen Horne wrote: > >... > > They aren't dynamically typed, they are essentially untyped. That is a > very different thing. And the reason Python users are Python users is > quite often because they hate the choices made by Perl, Javascript... JavaScript is as strongly typed as Python. I don't think anyone ever abandoned Perl specifically for type system reasons. Overall cleanlness is more likely. > There's a marketing term called differentiation. The principle is > simple. You can't compete effectively with another product unless > yours is different somehow. Python is different in a lot of ways. This one is trivial and most people will see both and conclude that Python got it wrong. We wouldn't be talking about this if Guido didn't hear, over and over again, from many people that the other behaviour would be better. Of course that isn't a concensus opinion but I think it is probably a silent majority opinion. > ... Not > a stunningly serious mistake, perhaps, but that hardly counts as a > justification - especially given the much more serious problems with > compatability and credibility. There are ways to handle compatibility (see my posts enocuraging people to take the long view) and credibility is only a function of compatibility. If you put your support behind a plan to stage the change in as gradually as possible, you might have more luck then telling Guido that his language designer instincts are wrong. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From pjakobsen at blueairnetworks.com Fri Jul 13 17:01:38 2001 From: pjakobsen at blueairnetworks.com (Peder Jakobsen) Date: 13 Jul 2001 14:01:38 -0700 Subject: win32net.NetUserGetInfo error Message-ID: <350a368d.0107131301.1bd4d921@posting.google.com> Hi: Hi! I'm running Windows 2000, and I'm calling: import win32api import win32net userName=win32api.GetUserName() info=win32net.NetUserGetInfo(None, userName, 1) I get the following error Traceback (most recent call last): File "", line 1, in ? api_error: (2221, 'NetUserGetInfo', 'The user name could not be found.') Any ideas Many thanks, Peder Jakobsen Python Newbie in Ottawa From qrczak at knm.org.pl Tue Jul 31 05:08:39 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 31 Jul 2001 09:08:39 GMT Subject: [OT] Number theory [Was: A use for integer quotients] References: Message-ID: Tue, 31 Jul 2001 08:56:44 +0200 (MET DST), Mikael Olofsson pisze: > > is needed depending on whether > > n%10 in (2,3,4) and (n//10)%10 != 1 > > or not :-) > > At last, I have reason *not* to learn Polish. :o) It's not that hard after you learn how to change verb forms depending on the subject, adjective forms depending on the noun, noun and adjective forms depending on the preposition, numeral forms depending on the noun and vice versa, the direction of the relationship between numeral and noun depending on the preposition and noun form, what numerals to use with nouns which are already plural when they mean a single object, and how to spell a change at the end of a word written in a foreign orthography depending on how much is changed and whether the final letter was originally mute. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From chrishbarker at home.net Wed Jul 11 15:46:58 2001 From: chrishbarker at home.net (Chris Barker) Date: Wed, 11 Jul 2001 12:46:58 -0700 Subject: BASIC or Python? References: <3d157fa0.0107051904.7ec368b8@posting.google.com> <0t_17.14670$Fk7.131382@news.indigo.ie> <20010711081201.172D211D.NOFFLE@niccolo.ke4.de> Message-ID: <3B4CAD32.20551E64@home.net> Mirko Liss wrote: > Python is often very slow, though. Maybe you should try Perl. > I used logfile analyzers in Perl and Python (radiusreport and > radiuscontext) and the perl program was much faster. > But it used up much memory. When working with large logfiles, > memory quickly got exhausted. The other analyzer needed > less memory. I think that's because Python often copies a > reference and not the actual data. Not wanting to use the > swap partition all the time, I switched to the python code. > Maybe I should have tried and optimized the perl program. Maybe you coudl optimize the Python program, and get the speed and the low memory usage! > This is just an example, not a benchmark. So don't draw > general conclusions. A benchmark is just an example anyway... -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From kp87 at lycos.com Thu Jul 19 16:49:53 2001 From: kp87 at lycos.com (kevin parks) Date: 19 Jul 2001 13:49:53 -0700 Subject: BURNING EARTHSHAKING Tuple Question Message-ID: <5e8bd451.0107191249.3c0d9f21@posting.google.com> By the way is tuple pronounced tOOple (god i hope it is), or is it pronounced like the word "couple". Tuple like "couple" would be too high brow. As a New Yawka i would feel too high brow saying that. I like the blue collar tOOPle. "yeah, joe i gots my freaking tOOples all ****ed up last night, like, you know, i couldn't change 'em or nuttin', jyou you eva heard a such crap? Them tOOples is stuck up, refusin' to change and all, the nerve... **** 'em that's what i say, just use them list things, they always co-operate without havin' to give 'em an attitude adjustment. I wouldn't want to mispronounce it at my next Python cocktail party and be embarrased. inquiring minds want to know From sill at optonline.net Tue Jul 10 15:01:11 2001 From: sill at optonline.net (Rainy) Date: Tue, 10 Jul 2001 19:01:11 GMT Subject: Q: mpg123 with Python References: <9ierhe$c3u$1@sun.rhrk.uni-kl.de> Message-ID: On Tue, 10 Jul 2001 14:14:38 +0200, Holger Kipp wrote: > Hi, > my professor told me, that i have to realize a "webbased skin for mpg123 > with flash and mySQL" > so, i installed mpg123 and now i've got the problem to respond that player > via Python. > Flash and the mySQL-DB are not the problem ... > > I MUST retrieve ID3-Tags, playtime, etc... from mpg123 and have to control > the player > like: skip track, seek, pause track, ... and so on. > > Is there any EASY sourcecode/modules/API for Python? (I'm using Python2.1 > on RedHat 7.1) > Where can I show useful code-segments? Do you have an better idea? Shouldn't > I use mpg123? > Please note: easy code is required ;-)) > > yours sincerely > Holger Kipp > > Look at my sig - it uses mpg123, it skips, but doesn't pause track or seek. I know there's cplay.py that also uses mpg123 as backend and has pausing/ seeking. I don't remember where I got it, so try searching for it.. -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: http://silmarill.org/cymbaline From chrishbarker at home.net Wed Jul 25 12:07:51 2001 From: chrishbarker at home.net (Chris Barker) Date: Wed, 25 Jul 2001 09:07:51 -0700 Subject: re bad leadership References: <0+yM4IAgmKX7EwIQ@jessikat.fsnet.co.uk> <20010724171838.A21770@xs4all.nl> <4crrlt0jbn9ovvkli3qvhqbc5do3lmpg4j@4ax.com> <%kn77.25759$EP6.6204923@news1.rdc2.pa.home.com> <23891c90.0107250216.2f49e2e6@posting.google.com> Message-ID: <3B5EEED7.C9C7117B@home.net> Paul Boddie wrote: > > PEP238 proposes that / be the inverse of *, so that '(a/b) * b = a > > (more or less)' and that 'a // b == floor(a/b)'. If we 'swap the proposed > > meanings of // and /', then we would have a/b == floor(a/b), which would > > break almost all existing floating point code. > > I suspect that the contributor who made the above unattributed > suggestion actually meant that the meanings should be swapped > intelligently in the PEP in such a way that the explanatory text be > altered accordingly. I'm sure that was the intention, but we need to keep in mind that the PEP proposed two types of division, NEITHER of which is the current one, so in order to keep total backward computability, we would need to add two operators, which would really get messy. And, this has been repeated MANY times, but despite the working in the PEP "Rationale" section, there are some very good and compelling reasons to have the proposed division that are relevant to experienced programmers, not just people learning. Guido recently said he will re-write the Rationale section to include this. I have been convinced by those reasons, though I think we need a better way to handle the backward computability issue. -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 gerhard.nospam at bigfoot.de Thu Jul 12 05:55:50 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Thu, 12 Jul 2001 11:55:50 +0200 Subject: MySQLdb - possible without install? References: <3b4d0ea7.11581823@news1.on.sympatico.ca> Message-ID: On Thu, 12 Jul 2001 02:44:29 GMT, Ken wrote: >Just curious. I'm with an ISP that allows running of scripts, and has >MySQL database access. They have a perl API installed, but nothing to >support Python. I was wondering if it was possible to just copy over >the MySQLdb directory from the site-packages area of Python, and just >"import" it into the scripts? Yes, this works. MySQLdb needs a compiled extension module, however. You'll need a compiled version for the platform your provider uses. 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 vincent_a_primavera at netzero.net Wed Jul 11 03:33:11 2001 From: vincent_a_primavera at netzero.net (Vincent A. Primavera) Date: Wed, 11 Jul 2001 07:33:11 +0000 Subject: Apache, CGI, Python... Message-ID: <3B45051300120CE9@mail.san.yahoo.com> (added by postmaster@mail.san.yahoo.com) Hello, Looking for some guidance as to the set up of Apache's httpd.conf for some basic CGI scripting practice in Python... Any suggestions? Thank you, Vincent A. Primavera From hcsgss at texlife.com Wed Jul 18 12:10:48 2001 From: hcsgss at texlife.com (Galen Swint) Date: Wed, 18 Jul 2001 11:10:48 -0500 Subject: Embedded Python 2.1 and AIX Message-ID: <1010718111048.ZM85826@anson.hcs.tl> Hello, I'm embedding Python 2.1 in an AIX 4.3 library and it's crashing every time the embedded Python calls for an import of the 'string' or 'math' module. With a little bit of gdb work I can find that it's crashing with SIGSEGV in the 'initstrop' function (or 'initmath' -- take your pick) when it calls Py_InitModule4. Apparently, when the library is linked the reference to Py_InitModule4 is not resolved. I placed some print statements to print the pointer value of Py_InitModule4 and its fine the four or five times it's called until the library init calls it. I have done the import by running the embedded Python on a file with the import statement on, running the import statement using PyRun_SimpleString, and using PyImport_ImportModule. I do call Py_Initialize, and I can execute code like prints and PyDict functions before the import calls. Some more info -Python configured with ./configure --with-threads --with-gcc --prefix=/opt/local (also, it is loading the library from the correct directory (/opt/local/lib/python2.1/lib-dynload) according to gdb) - The Makefile for the test program is below I suspect there is some linker flag omitted or something of that nature Thanks Galen Swint **Makefile** CC=gcc PYTHONLIB=/opt/local/lib/python2.1/config PYTHONINC=/opt/local/include/python2.1 all: libtest.o test.o test echo Making all. libtest.o: libtest.c gcc -c -g -DAIX -I$(PYTHONINC) libtest.c test.o: gcc -c -g -DAIX test.c test: test.o libtest.o rm -f test $(CC) -o test test.o libtest.o -Wl,-brtl -L$(PYTHONLIB) -lpython2.1 -lpthread -lm From greg at cosc.canterbury.ac.nz Mon Jul 30 01:29:01 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Mon, 30 Jul 2001 17:29:01 +1200 Subject: a break for comprehensions References: <9jpadd$s5k$1@news.duke.edu> Message-ID: <3B64F09D.1D59837F@cosc.canterbury.ac.nz> Kevin Lacker wrote: > > answer = [process(x) for x in my_list while is_good(x)] Looks quite nice. But what should answer = [process(x,y) for x in a for y in b while f(x,y)] do? Should the break terminate the whole comprehension, or just the enclosing for-clause? -- 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 vvainio at karhu.tp.spt.fi Thu Jul 5 09:42:56 2001 From: vvainio at karhu.tp.spt.fi (Ville Vainio) Date: 05 Jul 2001 16:42:56 +0300 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: Mitchell Morris writes: > All in all, it's been a pretty big win for Java. Conventional wisdom and > some non-peer-reviewed studies suggest that Java per se provides very little > leverage over C++, that the average developer doesn't build Java solutions > any faster or more bug-free than they build C++ ones, and that selecting Supposing that garbage collection and abundant reference semantics increase productivity by n percent (as all pythonians know), this would mean that C++ has some areas that improve productivity (and reduce bugs) as much over java. What are they? STL alone doesn't amount to that much, I would believe... -- 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 tim at vegeta.ath.cx Mon Jul 16 16:20:47 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Mon, 16 Jul 2001 20:20:47 GMT Subject: re Challenge: More Compact? References: Message-ID: Me parece que Marcin 'Qrczak' Kowalczyk dijo: > Sun, 15 Jul 2001 21:36:22 -0400, Tim Peters pisze: > > > def valid_ip(ip): > > m = re.match(r'(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$', ip) > > if m: > > elements = map(int, m.groups()) > > return max(elements) < 256 > > return 0 > > Is 0127.0.0.00001 a valid IP? > > If yes, then it should be accepted. If no, what about 127.0.0.001? with : def valid_ip(ip): : m = re.match(r'(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})(?!\n)$', ip) : return (m and max(map(int, m.groups())) < 256) or 0 valid_ip('127.0.0.001') returns 1 valid_ip('0127.0.0.001') returns 0 valid_ip('127.0.0.00001') returns 0 with Mozilla/4.73 [en] (X11; I; Linux 2.2.15-4mdk i686): 0127.0.0.001 fails. 127.0.0.001 succeeds. 127.0.0.00001 succeeds. This is, of course, just what the browser accepts. =) -- C combines all the power of assembly language with all the ease of use of assembly language. -- trad From paulp at ActiveState.com Wed Jul 11 04:45:19 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Wed, 11 Jul 2001 01:45:19 -0700 Subject: Unicode -> String problem References: <92ae279c.0107101751.5348c0a9@posting.google.com> <1103_994830833@jparlar> Message-ID: <3B4C121F.211B1CCD@ActiveState.com> If you don't know the encoding, a bunch of Unicode on a disk is just a bunch of bits. As long as those bits look a lot like ASCII you are safe, but if any of them look like something else you run into trouble. IE probably either a) remembers the encoding of the files or b) uses a single, internal encoding for the cache. You need to know which it is before you can work with the information reliably. Consider the knowledge of the encoding as being almost as important as knowing whether the files are HTML or PDF. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From dale at riverhall.NOSPAMco.uk Tue Jul 31 11:20:54 2001 From: dale at riverhall.NOSPAMco.uk (Dale Strickland-Clark) Date: Tue, 31 Jul 2001 16:20:54 +0100 Subject: Arg decoding with a template? Message-ID: Is there a class that simplifies high-level argument decoding under the control of a template? Such a class would take a string as a template and the arg list and return another list populated with keys, values and switches taken from the args. I've spent the last hour going through the global module list. If it's there, its got a daft name! -- Dale Strickland-Clark Riverhall Systems Ltd From sill at optonline.net Thu Jul 12 15:40:41 2001 From: sill at optonline.net (Rainy) Date: Thu, 12 Jul 2001 19:40:41 GMT Subject: Long Live Python! References: <3B4CC986.A5C8E605@engcorp.com> Message-ID: On Thu, 12 Jul 2001 02:29:21 +0100, phil hunt wrote: > On Wed, 11 Jul 2001 17:47:50 -0400, Peter Hansen wrote: >>I tend to think of Python more as an extremely effective and maintainable >>general-purpose programming language, which happens also to work >>very well when applied as a "scripting language" (whatever that means). > > To me it means "good for short programs <100 lines". Bear in mind > that 100 lines of Python is equivalent to 300 lines of Java or 400 > lines of C++. > > I meant more like sending somewhere my resume saying I know python and did this and that, and getting hired. I actually did use some python at my previous job (some cgi/image manipulation). I was then asked to redo it in perl :-/. -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: http://silmarill.org/cymbaline From bbollenbach at homenospam.com Thu Jul 5 17:31:07 2001 From: bbollenbach at homenospam.com (Brad Bollenbach) Date: Thu, 05 Jul 2001 21:31:07 GMT Subject: There's got to be an easy way to do this References: Message-ID: Consider the underlying problem here before going any further. Generally speaking "data" isn't stored formatted. "Information" is data that has /been/ formatted. In other words, your data model (whether flat file, or database), should store phone numbers as: 1235554444 not (123) 555 - 4444 So by the sounds of it, if you have to do some trickery just to extract _only digits_ out of a stored phone number, you might want to fix your data model before you fix your code. "Lindstrom Greg - glinds" wrote in message news:mailman.994350130.18544.python-list at python.org... > I am reading in a phone number field and would like to throw away everything > except the digits. Being an old C programmer, I know how I would do this. > Even with my limited knowledge of Python, I know how I would do it: > > stripped_phone='' > for c in phone_number: > if c in digits: > stripped_phone += c > > but with all of the data structure support native to Python, I'm sure there > is "an obvious way" to do it (perhaps it's because I'm not Dutch:-). > > Greg Lindstrom > Acxiom Corporation, mail: CWY10011149 > InfoBase Products Development office: (501) 342-1626 > 301 Industrial Blvd, Conway, AR, 72032 fax: (501) 336-3911 > email: Greg.Lindstrom at acxiom.com > > "When the solution is simple, God has spoken" > > Albert Einstein > > > From johnroth at ameritech.net Thu Jul 12 11:54:21 2001 From: johnroth at ameritech.net (John Roth) Date: Thu, 12 Jul 2001 08:54:21 -0700 Subject: Assignement Overloading References: <3b48bd83$0$7113$4d4efb8e@news.be.uu.net> Message-ID: "Pierre Denis" wrote in message news:3b48bd83$0$7113$4d4efb8e at news.be.uu.net... > I am trying to emulate some kind of type checking in Python > (sorry for the heresy). Because of the dynamic typing, my unpretentious > goal is to intercept the assignment statement in order to perform > a consistency check between the variable and the object to assign. > Unfortunately, there is no mechanism in Python to do this; there > is no magic function like __assign__(name,value). The reason > usually invoked about this lack is the fact that Python's assignment > is actually just a name binding, which is very different, for > instance, from C++ assignment. Strong type checking is not a heresy. The subject comes up quite frequently, and the general opinion seems to be that it would be a good idea - as an option. The problem is that nobody has ever proposed an acceptable way of accomplishing it. The difficulty you're running into is that you've fixed on the idea of solving one problem (lack of strong type checking) by using another feature (overriding assignments) that turns out not to be there, either. The only method of doing it is to use the __setattr__ function to intercept all names in the objects you want to protect, and provide a different method of accessing them. > Now I have two questions : > > 1. Why is there no general way to overload the assignment in > Python ? I do not agree with the 'name binding' argument because, to my > humble opinion, __setattr__ allows to overload some assignments, > while performing a name binding (in an object's namespace). So I > think the problem is well stated and the request makes sense. Assignment binds a name to an object. In C++ terms, all names are declared as void *. An overloaded assignment would still have to return an object. If I have an object, "spam", and I try to do this assignment: breakfast = spam what would you expect the spam object's __assign__ method to do with an overload? And how would it do it? Or do you expect the name "breakfast" to have an __assign__ method? Also, you cannot use __setattr__ to influence the name binding of local variables in a function or method. If you can come up with a proposal, I'm sure it will be looked at. See the PEP process for details. However, I know I would object if the proposal stated "type checking" as a reason to do assignment overriding - IMHO, type checking should be dealt with in a different manner. John Roth > > Thanks in advance, > > Pierre Denis > From sholden at holdenweb.com Sun Jul 8 16:08:08 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sun, 8 Jul 2001 16:08:08 -0400 Subject: Tkinter and printf in C ... References: <3B455B5D.544A2EF5@larc.ee.nthu.edu.tw> <9Jh17.38316$he.2456932@e420r-atl1.usenetserver.com> <3B48076E.B16ACF5B@larc.ee.nthu.edu.tw> Message-ID: "Chyr-Pyng Su" wrote in message news:3B48076E.B16ACF5B at larc.ee.nthu.edu.tw... > Steve Holden wrote: > > > > > Sorry, should have read the subject line. Here's a snippet of code that > > write to a PMW scrolled text window, you should be able to do the same in a > > Tkinter text window. > > > > t = Pmw.ScrolledText(self.msgWindow) > > grid(t, row=0, column=0, sticky=N+E+W+S) > > strmes = > > self.index.Message(self.MsgSet[int(self.msgList.curselection()[0])][0]) > > message = mimecntl.MIME_document(strmes) > > for hdr in ("from", "date", "subject", "to", "cc"): > > try: > > hdrline = message[hdr] > > t.insert(END, "%s: %s\n" % > > (string.capitalize(hdr),hdrline)) > > except KeyError: > > pass > > > > It's the insert() method you are looking for, I suspect. > > > > regards > > Steve > > Thanks in advance to help me writing the GUI program.. Actually I intended to > contruct a > buttom so that when I press it, it will trigger a wrapped function originally > written in C. > And capture those dumped message, show them in ScrolledText() widget.. > > Sorry, I can't figure out what the self.index is... besides, where should I > place these codes.. > in the callback function or in top level... :O > OK, I was running a little too fast. The "self" in the code I showed you referred to the object whose class implementation I had extracted the code from, so you all you need to know is that is was the parent of the Pmw.ScrolledText object in which I was rendering text. Suppose that the error message returned by the wrapped C function has been stored in st. To create a Text widget in a separate top-level window and display the message in it, you would do (something like: warning, untested): msgWindow = Toplevel(height=350, width=500) msgWindow.columnconfigure(0, weight=1) msgWindow.rowconfigure(0, weight=1) t = Text(msgWindow) grid(t, row=0, column=0, sticky=N+E+W+S) t.insert(END, st) I have here assumed that like most Tkinter programmers you have used "from Tkinter import *", and that you are using (or are prepared to use) the grid geometry management. Does this make it any clearer? regards Steve -- http://www.holdenweb.com/ From rmalla1 at lsu.edu Fri Jul 27 02:22:43 2001 From: rmalla1 at lsu.edu (Ratnakar Malla) Date: Fri, 27 Jul 2001 06:22:43 GMT Subject: File Reading , Reverse Direction References: <3B60F7EC.5275E026@lsu.edu> <3B6103B4.AF7AE15B@engcorp.com> Message-ID: <3B610A3C.5AF439E4@lsu.edu> Hi, Thanx for the lightning reply. Well , sorry for not speciying my platform. It is a pentium , running Windows 2000. what I really wanted was some sort of "tail " kind of functionality. Unfortunately, there is no "tail" command in Windows. I was just wondering, if there is any better way than reading the entire file into memory. Anyways thanx for your reply. I am sticking with readlines() Cheers, Ratnakar Peter Hansen wrote: > Ratnakar Malla wrote: > > > > Hi, > > I need to read from a very long file. But the only information I am > > interested is > > 2 lines at the bottom of the file. > > > 1) Can i read the file in the reverse direction , so that I dont lose > > time? > > Do you really want to read in "reverse"? To me that implies getting > each byte in reverse order, which would require reversing the lines > again after finding the "first" two... Or do you just want to read > line-by-line, in reverse? > > > 2) If so how?? > > How about this? > > lastTwoLinesAsList = open('somefile').readlines()[-2:] > > > 3) I tried the normal way, but looks like, it is taking lot of time. > > What is "normal"? Maybe your code is not the most efficient > implementation... > > You could also use "seek" to find the end of the file, then > go backwards a few dozen bytes at a time, grabbing blobs of > data until you found the third-last newline (or the second last, > if the file did not end with a newline), then return everything > after that point. This would be awkward, largely unreadable, > bug-prone, and might take a while to develop. > > Or how about calling out to "tail"? > > import os > lastTwoLinesAsString = os.popen('tail -2 somefile').read() > > You might also want to post a sample of your code, and mention > which platform you are on, so feedback might be a little more > relevant to your situation... > > -- > ---------------------- > Peter Hansen, P.Eng. > peter at engcorp.com -------------- next part -------------- A non-text attachment was scrubbed... Name: rmalla1.vcf Type: text/x-vcard Size: 294 bytes Desc: Card for Ratnakar Malla URL: From philh at comuno.freeserve.co.uk Sat Jul 21 16:37:13 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Sat, 21 Jul 2001 21:37:13 +0100 Subject: Language change and code breaks References: <3B585C00.93162A1@Lugoj.Com> Message-ID: On Fri, 20 Jul 2001 09:27:44 -0700, James Logajan wrote: >phil hunt wrote: >[ Elided. ] > >> message = Message() >> >> but this is bad practise anyway, IMO. > >Why is that bad practice? Having two identifiers whose names differ only in case. > What problems do you think this causes? I don't know, I never use this practise :-) Confusion between the 2, I suppose. >I never used that convention much until after I had been exposed to ASN.1, >where it is a common convention to have identifiers differ from type names >only by a change of case in the first letter. In ASN.1 type names start with >upper case and instance names start with lower case. Obviously the ITU >didn't see any problems with that convention. I don't know whether ASN.1 is any good; but i do know (having just looked) the organisation behind it aren't competent to design websites. -- #===== Philip Hunt == philh at comuno.freeserve.co.uk ======# Herbivore: effort-free public key encryption. See: ** First software release coming soon! ** From shane.anglin at mtni.net Sat Jul 14 13:18:31 2001 From: shane.anglin at mtni.net (Shane Anglin) Date: Sat, 14 Jul 2001 13:18:31 -0400 Subject: (no subject) Message-ID: <200107141318.AA116326580@mtni.net> Here's the basics of what I want to do with my new app: Main loop is: 1 - check socket for any incoming data 1a - if no data on socket, go to 2, else get the data and place it into a list 2 - print out list 3 - go to 1 and do it all over again Currently, I can create a TCP socket server app using examples that will sit and wait (idle 99% of the time) and accepts the incoming data just fine, my 'print list' part is not processing at all until I get any new data in... for example, 1-wait on a client connect on socket, when a connection happens, get data, 2- place new data into list, print list, 3 -go to 1 and do it all over again... in this scenario, #1 has the rest of my code 'hostage' until a client connection is made and closed. Thanks a bunch! Shane Anglin shaneanglin at bigfoot.com From alankarmisra at hotmail.com Fri Jul 13 01:04:01 2001 From: alankarmisra at hotmail.com (gods1child) Date: 12 Jul 2001 22:04:01 -0700 Subject: PyZipFile Message-ID: <25b2e0d9.0107122104.50347e10@posting.google.com> Why wont the following code work? Thanx. import zipfile p = zipfile.PyZipFile("c:\\pe\\arc.zip","w",zipfile.ZIP_STORED) p.writepy("c:\\pe") p.close() p = zipfile.PyZipFile("c:\\pe\\arc.zip","r",zipfile.ZIP_STORED) eval(p.read("pe/lang.pyc")) p.close() ---------------------------------------------------- Traceback (most recent call last): File "C:/pe/nest.py", line 6, in ? eval(p.read("pe/lang.pyc")) TypeError: expected string without null bytes From erno-news at erno.iki.fi Tue Jul 17 16:50:55 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 17 Jul 2001 23:50:55 +0300 Subject: Python 2 times slower than Perl References: <8f41cfd.0107171238.6ff33b9b@posting.google.com> Message-ID: In article <8f41cfd.0107171238.6ff33b9b at posting.google.com>, xucs007 at yahoo.com (Xu, C.S.) writes: | #!/usr/bin/env python | i = 2.5; | while i < 1e7: | j = 2.5 * 2.5 | i += 1 | print i, j | The `time` results on my PII 450M is: | python script: 37.93u 0.03s 0:38.03 99.8% | perl script: 15.36u 0.03s 0:15.42 99.8% | java compiled: 1.07u 0.10s 0:01.20 97.5% | C compiled: 0.24u 0.01s 0:00.25 100.0% if you put the code in a function, it will be a fair bit faster since global variable access is slower than local variable access. | Can anybody explain why Python is always about 1 time | slower than Perl? it is not - sometimes it is slower and sometimes faster. -- erno From guido at python.org Thu Jul 26 17:26:26 2001 From: guido at python.org (Guido van Rossum) Date: Thu, 26 Jul 2001 21:26:26 GMT Subject: Toppling the numeric tower References: Message-ID: "Tim Hochberg" writes: > >>> 1e0 << 2e0 > 4 # exact > or > 4e0 # inexact > > Either answer sucks: the first turns two inexact operands into an exact > result, while the second represents the results of bit twiddling, a discrete > operation if ever there was one, as an inexact, floating point number. The > best choice is to insist on exact numbers for integer operations. Agreed. > Note that I don't know that this is the meaning for isintegral meant by PEP > 228, but it is the one that makes sense to me. I don't know why PEP 228 doesn't reference Scheme. It is clearly inspired by Scheme. See http://www.swiss.ai.mit.edu/ftpdir/scheme-reports/r5rs-html/r5rs_8.html#SEC50 --Guido van Rossum (home page: http://www.python.org/~guido/) From tim.one at home.com Wed Jul 25 03:03:28 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 25 Jul 2001 03:03:28 -0400 Subject: Norton AV 2001 + popen + WinMe = crash In-Reply-To: Message-ID: [Kirby Urner] > Wondered if others have this problem: when I try any of the popens > in the os module, and leave NAV 2001 enabled, I get various freeze, > VxD or other errors necessitating hard boot. > > Disabling NAV 2001 ends the problem i.e. popen variants work as > advertized (to the extent of my testing anyway). Running Python 2.1.1. I reported this to Symantec against an earlier version of NAV, and they gave me a runaround stretching over a couple of months. In the end they suggested I purchase NAV 2001 to see whether it still happened(!). I didn't bother, and I'm appalled to hear that it's not fixed. This has nothing to do with Python, BTW: *any* program calling the Microsoft popen() function displays the same symptoms. I gave them a very small (5-line) C program to illustrate that, but try as I might I couldn't get beyond the first two layers of (polite but clueless) tech support to someone who even knew what "a C program" was. BTW, are you running Win98? IIRC, only Win98 systems suffered this problem -- but not *all* Win98 systems (for example, not mine; so why did I spend months on this? because of Guido's Win98 box ). the-virus-stops-here-ly y'rs - tim From claird at NeoSoft.com Mon Jul 30 10:47:17 2001 From: claird at NeoSoft.com (Cameron Laird) Date: 30 Jul 2001 09:47:17 -0500 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Jul 30) Message-ID: <165CDE42C9C74F48.E1CDA2AAFABCA74B.ABA37F87F66F88EE@lp.airnews.net> Quotes of the week: Paul Prescod: Perl users seem remarkably accepting of change considering the installed base of the language. Paul Prescod: Moore's law is slowly making type declarations irrelevant. Stephen: The web just doesn't lend itself to building look-ahead auto-complete fields for names, emails etc. Uwe Zessin releases Python 2.1.1 for OpenVMS http://www.decus.de/~zessin/python2/ Harry George offers example use of setup.py http://groups.google.com/groups?th=18626bc240f7e9e3 June Kim and Dave Brueck present the argument in favor of dynamic typing http://groups.google.com/groups?th=2d17178851b0f98e Thomas Weholt's relatively innocent question about distributed computing technologies leads to deep (if largely Python-free) and even important analyses by Tim Daneliuk, Graham Dumpleton, Galen Swint, and others. Also in the same thread, Ng Pheng Siong provides nice performance boosts for SOAP. http://groups.google.com/groups?th=559ffaccf0ac9907 You can submit a paper for the tenth Python Conference http://www.python10.org/p10-callpapers.html Duncan Grisby provides a fine quick-start tutorial to CORBA use, as well as directions to a public fortune-cookie service http://groups.google.com/groups?th=2244bf713d379f2e Guido launches a lively and important newsgroup thread on the reality of type-class unification (and discloses his own temporal intuition is accurate only to a decimal order-and-a-half of magnitude) http://groups.google.com/groups?th=a8dc15aab8832a6b Front Range Pythoneers energetically dispute the validation theology involved in PyUnit (look for "Doctest" as a subject) http://community.tummy.com/pipermail/frpythoneers/2001-July/thread.html David Mertz teaches that Pippy is a port of Python to PalmOS http://www-106.ibm.com/developerworks/linux/library/l-pippy?open&l=252,t=grl,p=Pyth4PalmOS Now it's called, "Zope Corporation" http://www.zope.com/News/PressReleases/DC2ZC ======================================================================== 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 just at letterror.com Sun Jul 29 03:43:27 2001 From: just at letterror.com (Just van Rossum) Date: Sun, 29 Jul 2001 09:43:27 +0200 Subject: Best practices with import? References: <9jvnoe$om2$1@slb5.atl.mindspring.net> <9jvsio$j4r$1@slb6.atl.mindspring.net> <3B639A2D.83B00CD5@engcorp.com> Message-ID: <3B63BE9C.ED311F4F@letterror.com> Peter Hansen wrote: > > Tom Bryan wrote: > > > > Alex wrote: > > > > > Goodness, without import, python's close to useless. > > > > Well, of course. But where to import? What's the most common idiom? > > At the top, unless you have a specific need to import in a > function. > > Possible reasons to import in a function: > > 1. Readability: if the import is needed in only one > function and that's very unlikely ever to change, > it might be clearer and cleaner to put it there only. > > 2. Startup time: if you don't have the import outside > of the function definitions, it will not execute > when your module is first imported by another, but > only when one of the functions is called. This > delays the overhead of the import (or avoids it > if the functions might never be called). > > 3. There is always one more reason than the ones > we've thought of until now. I know one more: 4. Overhead: if the module imports a lot of modules, and there's a good chance only a few will actually be used. This is similar to the "Startup time" reason, but goes a little further. If a script using your module only uses a small subset of the functionality it can save quite some time, especially if the imports that can be avoided also import a lot of modules. Just From johnroth at ameritech.net Thu Jul 12 11:21:21 2001 From: johnroth at ameritech.net (John Roth) Date: Thu, 12 Jul 2001 08:21:21 -0700 Subject: [Fwd: Comment on PEP-0238] References: <3B474536.DE27A538@3-cities.com> <7ef50c46.0107080945.30bfa5b4@posting.google.com> Message-ID: "Robert J. Harrison" wrote in message news:7ef50c46.0107080945.30bfa5b4 at posting.google.com... > Guido van Rossum wrote in message news:... > > > However, I think that some details of the numerics also need to > > > be clarified before you boldly go. Specifically, > > > > > > - What about long division? A float cannot capture all results. > > > Should it raise a Value/Range error? > > > Should the programmer be forced to use divmod? > > > Should it return a rational? > > > I don't really like the last two choices and the first two choices > > > obviate much of the usefulness of longs. > > > > We'll introduce a new operator or function (e.g. div(x, y)) for > > integer division, which will work for ints and longs. When / is used > > and the result can't be expressed as a C double, we can choose between > > yielding Infinity or raising OverflowError; I think probably the > > latter although with two float arguments this currently returns Inf on > > most platforms. > > I think this design might hold as an interim approach, but I don't > find it satisfactory to have this forced coercion to double make > division by longs sometimes fail ... it's just not in the spirit of > dynamic typing ... if coercion is forced, it should be to make things > "work better", not fail. > > Other thoughts > > - Accelerating the consideration of Rationals. It's inconsistant to have a rational type, and have integer division return a float! Either integer division should return a rational, or we should take PEPs 239 and 240 out and bury them. (In fact, if integer division returns a rational, then there is no need for PEP 240 - 1/2 is perfectly good as a rational literal! If we make integer division return a float now, then we're simply creating another problem when we implment rationals sometime down the path. John Roth From peter at engcorp.com Sat Jul 7 09:48:04 2001 From: peter at engcorp.com (Peter Hansen) Date: Sat, 07 Jul 2001 09:48:04 -0400 Subject: PEP scepticism References: <9hfqb5$dsllb$3@ID-89274.news.dfncis.de> <3dhex01n1m.fsf@ute.cnri.reston.va.us> <9hlcp4$eiphi$2@ID-89274.news.dfncis.de> <9hqc3i$f1dia$2@ID-89274.news.dfncis.de> <6Jd$FLAFotR7EwLP@jessikat.fsnet.co.uk> Message-ID: <3B471314.8B179A92@engcorp.com> Robin Becker wrote: > > The language is evolving as all languages do because of the needs of its > users. Five years ago the leadership said integer division was good, > today it's bad; the audience changed is all. Actually, maybe it's just which audience members are vocal which has changed recently. I happen to use Python frequently (almost exclusively) in situations where it is very valuable to have integer division work the way it does now. Floats are only infrequently used. If I were constantly forced to jump through hoops to make sure my integers divided like integers (as in, like the CPU designers intended... not like CS people believe it should work), I would have a lot more work than I do now. But until now my voice was silent on the matter. Perhaps the reason you think the needs of the users has changed is because Python suits the needs of some users so well that they don't feel the need to constantly whine about the fact. Maybe only those who have a problem with it are going to make their voice heard. (As someone said a few messages back: Well, duh! :-) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From p.vrijlandt at aig.azn.nl Wed Jul 25 09:05:39 2001 From: p.vrijlandt at aig.azn.nl (p.vrijlandt at aig.azn.nl) Date: Wed, 25 Jul 2001 15:05:39 +0200 Subject: size of a file Message-ID: <"vines.+I,8+aLgLvA"@azninfo22.azn.nl> > "Janos Blazi" wrote: > > > How can I find out the length of a file. I have a descriptor fd of the file > > (I am using the os module). import os import stat # file denotes a file-object def fsize(file): return os.stat(file.name)[stat.ST_SIZE] -- Patrick Vrijlandt From kamikaze at kuoi.asui.uidaho.edu Wed Jul 25 16:37:19 2001 From: kamikaze at kuoi.asui.uidaho.edu (Mark 'Kamikaze' Hughes) Date: 25 Jul 2001 20:37:19 GMT Subject: Language change and code breaks References: <9j7gv8$9mg@dispatch.concentric.net> <3B5DF101.9B2E4631@earthlink.net> Message-ID: Wed, 25 Jul 2001 05:29:41 GMT in , Guido van Rossum spake: > But never mind, I'm giving up on making *Python* case-insensitive. > The hostility of the user community is frightening. This baffles me; the division issue is IMO far more terrifying a change, while case-insensitive is a mere quirk. -- 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 nde at comp.leeds.ac.uk Thu Jul 19 08:56:06 2001 From: nde at comp.leeds.ac.uk (Nick Efford) Date: Thu, 19 Jul 2001 12:56:06 GMT Subject: Language change and code breaks References: <9j66an$3bm02@owl.le.ac.uk> Message-ID: On 19 Jul 2001 09:38:47 +0100, Clive Page wrote: > In article , > Guido van Rossum wrote: > > >But it's still open for debate whether the problem here is Windows or > >Unix! All programming languages and file systems used to be > >case-insensitive, until the designers of Unix and C decided that it > >was too much work to write and use a case-insensitive comparison > >routine. It wasn't necessarily intended to be better, just easier to > >implement. But times have changed, and that's a lousy excuse. > > As this thread has shown, nearly everyone has an opinion on this. For what > it's worth, I've been using Unix for nearly 20 years and I still get caught > regularly by its case sensitivity, and I don't like it at all. Of course > my opinion is worth almost nothing, but there are some facts worth noting: > > I'm pretty sure I've seen a study in one of the reputable computer science > journals reporting a trial of two sets of users with two invented computer > languages, identical except that one was case-blind and the other was case > sensitive. It showed that people made significantly more mistakes with a > case-sensitive language. Unfortunately I didn't keep the reference - > maybe someone else remembers it too? To me the results of that study > were pretty conclusive. Interesting. Was the study done with programming novices, or with experienced programmers? If the latter, did they have experience of case-sensitive or case-insensitive languages? I wouldn't want to draw firm conclusions without knowing more... I can appreciate some of the arguments made in favour of a case- insensitive Python, but there are times when we give meaning to case in written English: "python" is the snake, but "Python" is the programming language; "latex" is a material, "LaTeX" is a markup language for document typesetting; "mud" is something you get on your shoes, but a "MUD" is something entirely different. I would much prefer it if Python continued to allow the distinctions we make in written language to be preserved when coding. Also, I'm not entirely convinced by the argument that "foo" and "FOO" are perceived the same way when humans parse source code visually. In pattern recognition terms, they are surely different entities. It is only when natural language processing kicks in that our brains can make the decision to treat the two the same. So it may be that we can grok code quicker in a case-sensitive language. My other worry over case insensitivity is that it creates opportunities for poor style by allowing the inconsistent use of case. This seems a strange path to follow for a language that made the inspired decision to avoid using block delimiters, thereby denying users the "freedoms" of inconsistent or non-existent indentation. Nick From paul at svensson.org Thu Jul 26 22:00:54 2001 From: paul at svensson.org (Paul Svensson) Date: 27 Jul 2001 02:00:54 GMT Subject: Suggestion for impriving list comprehensions References: <3B5F0867.7447E5FB@ccvcorp.com> <9jphkk$rhc$1@newsy.ifm.liu.se> Message-ID: <9jqi0m$5oe$1@newsy.ifm.liu.se> Guido van Rossum writes: >paul at svensson.org (Paul Svensson) writes: > >> I would like to suggest that we add a "while condition" clause >> to list comprehensions, similar to the "if condition" clause, >> but terminating the list comprehension on the first false condition. >> The above example could then be written as >> >> [x for x in fib() while x < 50] > >Neat, but maybe not general enough. How do you request the first N? No need to cover cases that are clearer expressed without involving a list comprehensions at all. fib()[:N], I would assume works. >And fuzzy: does this include or exclude the first x >= 50? No fuzzier than "while x < 50: ..." -- of course it excludes. >How about a library of functions for iterator algebra? E.g. > > def first(n, sq): > it = iter(sq) > for i in range(n): yield it.next() > > def lessthan(n, sq): > for x in sq: > if x >= n: break > yield x Now, there's something I would call "not general enough". /Paul From python_binto at yahoo.com Fri Jul 20 08:16:39 2001 From: python_binto at yahoo.com (binto bient) Date: Fri, 20 Jul 2001 05:16:39 -0700 (PDT) Subject: Python for RADIUS..??? Message-ID: <20010720121639.25111.qmail@web14806.mail.yahoo.com> could Python implemented in RADIUS (Remote Authentication Dial-In User Service )for ISP, everything that related with RADIUS. thnx __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/ From bokr at accessone.com Wed Jul 11 17:38:41 2001 From: bokr at accessone.com (Bengt Richter) Date: Wed, 11 Jul 2001 21:38:41 GMT Subject: Apache, CGI, Python... References: <3B45051300120CE9@mail.san.yahoo.com> (added by postmaster@mail.san.yahoo.com) Message-ID: <3b4cc04f.1657030403@wa.news.verio.net> On Wed, 11 Jul 2001 07:20:50 -0500, "Chris Gonnerman" wrote: > >Check the docs/FAQ at apache.org for CGI guidance. > >Of course, if you have a more specific question feel free to ask. Can a python script be run efficiently and su-exec'd? I.e, Apache can run CGI as a particular account owner (e.g.,for access to private directories etc. that 'nobody' shouldn't see). Naturally it would work if you got a whole instance of the interpreter to yourself, but does modPython take care of su-exec properly? (I guess I should ask at modpython, but I'm here ;-) Also, I'm wondering how widespread Python and/or mod_python is on ISP servers. I have a C++ CGI program with some scriptable aspects, and I ++like Python, so I am considering making the C++ an extension and having the main cgi be pythonic glue and some scriptable stuff (scriptable script ;-). Alternatively, how does embedding python in a C++ CGI program work out? My main concerns are speed, su-exec, and availability. TIA for opinions & advice. From tim.one at home.com Wed Jul 25 00:14:06 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 25 Jul 2001 00:14:06 -0400 Subject: python2.2: type('name') -> ?? In-Reply-To: Message-ID: [Francisco] > I just compiled python2.2a and I'm getting this strange response to the > 'type' command: > > Python 2.2a1 (#2, Jul 24 2001, 12:24:09) > [GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2 > Type "copyright", "credits" or "license" for more information. > >>> type('') > > > while I expected to get . > > Am I missing something or I just messed up with the compilation?? No, that's the way it works (today). Under the type/class unification scheme, type names also work as constructors. Since str() was always the way to build a string in Python, that's a natural name for its type. This name is also different: >>> type(1L) # used to be "long int" >>> Note this cute consequence: >>> x = 1L >>> type(x)(3) 3L >>> That is, type() in 2.2a1 truly returns a constructor, and type(1L)(y) is the same as long(y). Likewise for >>> type("abc")(42) '42' >>> type("abc") is str 1 >>> type(1L) is long 1 >>> I'm not sure the type names will stay this way, but determining that is part of what an alpha release is for. On a scale of 1 to 12, were you merely surprised by the change or truly upset ? From piotrlg at sci.pam.szczecin.pl Tue Jul 24 08:38:46 2001 From: piotrlg at sci.pam.szczecin.pl (Piotr Legiecki) Date: Tue, 24 Jul 2001 14:38:46 +0200 Subject: Debuger for python 2.x Message-ID: <3B5D6C56.A951BDAE@sci.pam.szczecin.pl> Hi I'm new to python and I'm writing my first python program. I'd like to use some nice debugger (like ddd, xgdb etc) but I can't find any for python 2.x. DDD has pydb but only for python 1.5.2. IDLE is not very helpful curently. Aby other choices? I'm using debian/sid. What about pdb? I'v read that this is the python's standard debugger, but on my system there is no such a program. -- Regards Piotr Legiecki From thomas.heller at ion-tof.com Fri Jul 13 03:33:20 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Fri, 13 Jul 2001 09:33:20 +0200 Subject: xml.dom.minidom + py2exe References: <9ilk1r$quo$1@maud.ifi.uio.no> Message-ID: <9im880$jjh8j$1@ID-59885.news.dfncis.de> [posted and mailed] "Trond Gaarder" wrote in message news:9ilk1r$quo$1 at maud.ifi.uio.no... > A small problem concerning py2exe that I hope you can help me with: > > I have a small OpenGL program that reads its scene graph from a XML file. I > use xml.dom.minidom to accomplish this, and everything works fine. But when > I try to compile the script into an .EXE with py2exe I get the following > warnings: > > warning: py2exe: > *************************************************************** > warning: py2exe: * The following modules were not found: > warning: py2exe: * xml.dom.HierarchyRequestErr > warning: py2exe: * riscosenviron > warning: py2exe: * _xmlplus > warning: py2exe: * ic > warning: py2exe: * ce > warning: py2exe: * riscos > warning: py2exe: * SOCKS > warning: py2exe: * rourl2path > warning: py2exe: * riscospath > warning: py2exe: > *************************************************************** > > And when I try to run the program: > > Traceback (most recent call last): > File "", line 381, in ? > File "", line 299, in readScenegraph > File "SceneGraph.pyc", line 187, in fromXML > File "xml\dom\minidom.pyc", line 910, in parse > File "xml\dom\minidom.pyc", line 901, in _doparse > File "xml\dom\pulldom.pyc", line 289, in parse > File "xml\sax\__init__.pyc", line 88, in make_parser > xml.sax._exceptions.SAXReaderNotAvailable: No parsers found > > > It looks like the XML module is using som kind of dynamic loader (like Pmw > does), and these modules naturally escape py2exe. This is indeed the case: C:\sf\py2exe\tests>c:\python20\python.exe Python 2.0 (#8, Apr 25 2001, 22:09:02) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> import xml >>> xml >>> As you can see, 'import xml' actually loads _xmlplus and puts this into sys.modules under the name 'xml'. This can also be done by the packed executable, however, the _xmlplus package must be available for this to work, and the bundling process does not find it. > Do any of you have any > tips on how to work around this problem? Something similar to bundlepmw.py > perhaps? Use the -p command line flag 'python setup.py py2exe -p _xmlplus' to include the whole _xmlplus package into the exe. HTH, Thomas From tjreedy at home.com Wed Jul 18 20:24:17 2001 From: tjreedy at home.com (Terry Reedy) Date: Thu, 19 Jul 2001 00:24:17 GMT Subject: RELEASED: Python 2.2a1 References: Message-ID: "Guido van Rossum" wrote in message news:mailman.995464538.29395.python-list at python.org... ... > I'm writing an introduction to the type/class unification: > > http://www.python.org/2.2/descrintro.html This intro also describes some neat 'by-product' features that I have missed seeing mentioned on the newsgroup: * Static methods (and class methods also): If this does not stop people from asking 'how do I write static class methods', at least now we will be able to say follow 'def f...' with 'f = staticmethod(f)' instead of 'you cannot' and 'here is a kludgy workaround'. * A getset typeclass that allows us to have our cake (the nice instance.attr notation) and eat it too (by having such accesses optionally rerouted to attribute-specific get and set methods instead of all-attribute __get/setattr__). This will end discussions about which now-unnecessary compromise to make. These are nice improvements in the Python class model. There is also an improved base-class lookup rule at least for type-based classes. Terry J. Reedy From aleaxit at yahoo.com Fri Jul 13 11:50:18 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 13 Jul 2001 17:50:18 +0200 Subject: Scripting vs. whatever, again (was Re: Long Live Python!) References: <3B4E5586.82D8ACA8@engcorp.com> <3B4E69D5.5CB278F2@engcorp.com> Message-ID: <9in5bs01mio@enews1.newsguy.com> "Grant Edwards" wrote in message news:H6D37.14720$B7.2683686 at ruti.visi.com... ... > >> I interpret "scripting" as automating a series of operations > >> that would probably be done interactively by a user otherwise. ... > Probably not. To add to my "definition", I guess I would call > it a script if it was done using the same set of "primitives" > that the user would have done had it been done interactively. > Primitives like the "ls" "find" "rm" executables found on Unix > systems. So you wouldn't "call a script" a script scripted in VBScript on the Windows Scripting Host, or a script scripted in JScript or Javascript, residing typically between tags in an HTML page? Because, while they may well be automating a series of operations that would be done interactively by a user, they don't generally do so "using the same set of primitives" the interactive user would interactively use (mostly mouseclics on menuitems, buttons &c, with perhaps a few keystrokes thrown in for good measure)? And yet the names of the languages, of the supporting tools, of the relevant tags, &c, clearly indicate that these things ARE perceived as scripts very widely today. And I concur with the general perception which I think these naming choices indicate. Interactively-used "primitives" today are mostly mouseclics on controls & menuitems, but that doesn't make scripts impossible or inappropriate: on the contrary, scripts are more and more pervasive -- they just use different and more appropriate primitives, organized in "object-models" such as HTML's Document Object Model (DOM), the object-models that WSH exposes for the Windows Shell, filesystem, &c, and so on. Alex From loewis at informatik.hu-berlin.de Mon Jul 30 08:45:18 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 30 Jul 2001 14:45:18 +0200 Subject: Automate telnet? References: Message-ID: "Don Tuttle" writes: > I have a secure Windows telnet client I'd like to automate with a > script. So far my efforts with the popen family haven't worked. Is > this a possible task? Doing popen in Windows is quite involved. Instead, I recommend to try telnetlib directly. Regards, Martin From BPettersen at NAREX.com Wed Jul 18 15:10:59 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Wed, 18 Jul 2001 13:10:59 -0600 Subject: bug in python's scope handling? Message-ID: <6957F6A694B49A4096F7CFD0D900042F27D557@admin56.narex.com> > From: Philipp Weinfurter [mailto:philipprw at gmx.at] > > On Wed, 18 Jul 2001 14:20:49 -0400, Steve Holden > wrote: > > When your Python is compiled into bytecode, the assignment > to a is detected > > during compilation of your function func2(). The name a is > therefore assumed > > to refer to a local variable, hence the ruin-time exception > you observe. > > yes, this is what i thought. but is it correct? > i don't mean to be pedantic, but the rules are that if a variable > is not found in local scope, then the compiler looks up the global > scope and python doesn't follow this rule here. > it doesn't really hurt, since in 99% of all cases the programmer > probably _thinks_ he is referring to a local variable, but still... The rules are a little more complicated: 1. if a variable is assigned to anywhere in a function, then all mentions of the variable in the current function are references to this local. 2. during lookup, if a name can't be found in the local scope, the global scope will be used. therefore it's allready decided before the lookup phase whether the variable is a local or a global. Is it correct? Well, it removes a number of possible errors, so yes. -- bjorn From dirck at pacbell.net Fri Jul 20 01:00:05 2001 From: dirck at pacbell.net (Dirck Blaskey) Date: 19 Jul 2001 22:00:05 -0700 Subject: Language change and code breaks References: <6957F6A694B49A4096F7CFD0D900042F27D55F@admin56.narex.com> Message-ID: <6c8b7eb9.0107192100.5be576a9@posting.google.com> Guido van Rossum wrote in message news:... > ... The programming > environment should be case-preserving, and automatically correct > identifiers to use the same case as used when they were defined. When using this approach, please be a little extra careful: VBA has this feature, and a bug where it remembers some random/first input of a symbol as the 'definition' for things that are actually defined elsewhere. I got stuck with DAte everywhere in one project, because I mis-typed it once, and since Date is a system function, I couldn't ever get it back, it always insists on using DAte no matter what I type. Just some MS-SIlliness to be wary of. d (Not that I expect these kinds of bugs in Python, but you never know.) From sholden at holdenweb.com Tue Jul 17 23:20:20 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 17 Jul 2001 23:20:20 -0400 Subject: Nested List Comprehension References: <9iss5k$2dcd$1@news.idiom.com> <3B529CB7.8030905@T-Online.de> <3B54FAA2.D7E04ECB@cosc.canterbury.ac.nz> Message-ID: "Greg Ewing" wrote in message news:3B54FAA2.D7E04ECB at cosc.canterbury.ac.nz... > Burkhard Kroesen wrote: > > > > Maybe you feel more comfortable with > > multtab = [x*y for x in range(13) for y in range(13)] > > But that doesn't produce what he wanted, which > was for multtab[x][y] to be equal to x*y. > > But if there were such a thing as dictionary > comprehensions, he could use > > multtab = {(x,y):x*y for x in range(13) > for y in range(13)} > > :-) >>> multtab = {} >>> [multtab.update({(x, y): x*y}) for x in range(13) for y in range(13)] [None, None, ..., None] >>> multtab[6,8] 48 If I could think of a way to recycle those Nones I might make money here ;-) regards Steve -- http://www.holdenweb.com/ From web2ed at yahoo.com Wed Jul 11 18:23:57 2001 From: web2ed at yahoo.com (Edward Wilson) Date: 11 Jul 2001 15:23:57 -0700 Subject: Wiring a test harness into a C/C++ application? Message-ID: <5174eed0.0107111423.2c446821@posting.google.com> To use Python for regression testing a C++ application, what is the recommended method for snapping-in Python. 1. Should Python be embedded into the debug/test version of the application? 2. Should an application hook be used as a Python extension? 3. Is there a better way? -- ed From steve at lurking.demon.co.uk Wed Jul 25 03:26:56 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Wed, 25 Jul 2001 08:26:56 +0100 Subject: Future division patch available (PEP 238) References: <9jfjd6$ad4$2@newshost.accu.uu.nl> <7u6nltoqdnqjjdiquu6ngtaruflhvbvdl5@4ax.com> Message-ID: On Tue, 24 Jul 2001 19:44:58 GMT, Guido van Rossum wrote: >Stephen Horne writes: > >> If I take serious damage to my professional reputation because of this >> change and my vocal Python advocacy, I'll more than likely be starting >> up my own competing scripting language. I won't expect success, but it >> will be interesting and I will expect that others will have the same >> thought, so once the breakaway projects start coalescing there might >> well be a *better* alternative in the end. Maybe a bit melodramatic, >> but it's not like it's hard to find a scripting language market these >> days. > >More power to you. Since your new language won't be restricted by >backwards compatibility, you'll find that the better choice for >int/int is to return a float, or perhaps a rational, rather than >following C (whose insistence on closing integers under division, as >that of so many other languages, is inspired by the price of floating >point hardware twenty years ago). And the convenience of integer arithmetic with discrete measures such as array subscripts in a vast number of algorithms. From johann at physics.berkeley.edu Mon Jul 16 17:19:00 2001 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 16 Jul 2001 14:19:00 -0700 Subject: Re-sizing images in Python? References: Message-ID: akhar writes: > Look into PIL(python Imaging library) has all you need. > Stephane Exactly. Here's some sample code I wrote using PIL, just to give you the idea: def resize (filename_in, filename_out, quality=None, size=(400,300)): "Read a file from filename_in, resize, then output to filename_out." im = Image.open (filename_in) out = im.resize (size, Image.BILINEAR) if quality: out.save (filename_out, quality=quality) else: out.save (filename_out) -- Johann Hibschman johann at physics.berkeley.edu From MarkH at ActiveState.com Tue Jul 17 20:23:17 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Wed, 18 Jul 2001 00:23:17 GMT Subject: HELP: Python ASP Bug with traceback information References: Message-ID: <3B54D739.7050601@ActiveState.com> Joe Salmeri wrote: > Can someone please confirm whether this is a known bug using Python with > ASP? It is a known bug with no identified solution. If you do not handle the exception yourself but let the scripting engine handle it, it will work. The problem is that Python is never passed a filename - just a chunk of text that came from "joe.asp" - hence, the traceback module has no way of determining what the original source code was. The script engine hacks around this. Mark. From opengeometry at yahoo.ca Wed Jul 11 11:31:49 2001 From: opengeometry at yahoo.ca (William Park) Date: Wed, 11 Jul 2001 11:31:49 -0400 Subject: Newbie asks(2): How to do this line of C in Py? In-Reply-To: ; from sailwong@alumni.cuhk.edu.hk on Wed, Jul 11, 2001 at 01:50:52AM +0800 References: Message-ID: <20010711113149.A1609@node0.opengeometry.ca> On Wed, Jul 11, 2001 at 01:50:52AM +0800, Steve S.L. Wong wrote: > if sscanf(command,"%c%d",&c,&d) != 2 { > } - isolate the char/number, by cutting at the delimiter(s). See, 'string.split()' - convert ASCII characters into proper char/integer type. See 'int()'. -- William Park, Open Geometry Consulting, 8 CPUs cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc. From ejeandel at ens-lyon.fr Wed Jul 11 15:09:54 2001 From: ejeandel at ens-lyon.fr (Emmanuel Jeandel) Date: 11 Jul 2001 19:09:54 GMT Subject: shortest match regexp operator anyone? References: <3b4c9b7f.8143238@news.hrz.uni-kassel.de> Message-ID: <9ii8a2$hg6$1@macareux.ens-lyon.fr> > > 1) It doesn't solve the intellectual challenge. What about : ([^<]|(<+(A<+)*([^A<]|(A[^<>]))))*<+(A<+)*A>B ? (sorry) Emmanuel From kosh at aesaeion.com Thu Jul 12 21:26:18 2001 From: kosh at aesaeion.com (kosh) Date: Fri, 13 Jul 2001 01:54:18 +0028 Subject: not safe at all References: Message-ID: <9im9fq$gk5$1@apollo.csd.net> Dennis Roark wrote: > For amusement, run this little script which demonstrates a > near ultimate in the lack of type safety in the language. > (Perhaps there is a bit of type safety in that you can't do > this: 4 + "one") But look at what you can do in the > following script: > > x = 3 > x = x + 2 > print "x =", x > x = "now I'm a string" > print x > x = [ 5, x ] > print "and now a list:", x > > If you don't believe it, run it. Should any language allow > x to be such a chameleon, to where it can even be a > different type on two sides of an assignment? > --------------------------------- > Dennis Roark > Dept. of Computer Science > University of Sioux Falls > > Starting Points: http://home.earthlink.net/~denro > --------------------------------- What you have posted has nothing to do with typesafety in the slightest. Not once did you actually mix types. What you have done is just change the assignment. At first you had x equal to an integer of 5, then when you assigned it a value of a string it deleted the old object and made a new one. Then it did the same as a list. What you are really complaining about is that it is easy to reassign a var to point to a new object. If you do id(x) after each assignment you will see x is not the same object. From joonas.paalasmaa at nokia.com Tue Jul 3 08:18:39 2001 From: joonas.paalasmaa at nokia.com (Joonas Paalasmaa) Date: Tue, 03 Jul 2001 12:18:39 GMT Subject: Fetching multiple items from a list Message-ID: <3B41B778.6BD422C1@nokia.com> Why doesn't Python support fetching and setting multiple items at the same time for lists and tuples. For example in the example below multiple fetching would be much better way than the ordinary way. >>> import string >>> mylist = list(string.lowercase) >>> mylist[18],mylist[15],mylist[0],mylist[12] ('s', 'p', 'a', 'm') >>> mylist[18,15,0,12] Traceback (most recent call last): File "", line 1, in ? mylist[18,15,0,12] TypeError: sequence index must be integer >>> From paul at boddie.net Fri Jul 20 05:29:39 2001 From: paul at boddie.net (Paul Boddie) Date: 20 Jul 2001 02:29:39 -0700 Subject: How popular is Python, anyway? (was: Long Live Python!) References: <23891c90.0107170315.36f571e9@posting.google.com> Message-ID: <23891c90.0107200129.13becfc3@posting.google.com> sill at optonline.net (Rainy) wrote in message news:... > On 17 Jul 2001 04:15:40 -0700, Paul Boddie wrote: > > > > to get the job done. A similar kind of idiocy was once imposed on me, > > forcing me to rewrite various CGI-based programs in C++ of all > > horrors. Insane! > > That's just bizarre! Good thing they haven't heard that assembly is > the fastest, they'd have you do CGI stuff in it ;-). These were competent people, though (hello, if you're reading this!), who mostly knew a fair amount about different languages and the different levels of abstraction that they offer. SPARC assembly language wasn't an option. ;-) Still, Perl would have been a better choice than C++ for CGI stuff, although I had "moved on" from Perl long before then and probably would have resented the use of that language too. (But not as much as C++.) From ransen_spam_me_not at nemo.it Wed Jul 25 14:00:43 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Wed, 25 Jul 2001 18:00:43 GMT Subject: control-C not responding, short example program References: <3b5d7220.664033@news.newsguy.com> Message-ID: <3b5f0932.2397984@news.newsguy.com> On 25 Jul 2001 09:52:18 +0300, Ville Vainio wrote: >ransen_spam_me_not at nemo.it (Owen F. Ransen) writes: > > >> halt 500Mhz Windows 98 machine. It simply does not >> respond to control-C. Is there a way of doing this > >What about the good old control-break? Nope don't work. :( -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From sholden at holdenweb.com Mon Jul 16 08:06:55 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 16 Jul 2001 08:06:55 -0400 Subject: More on "with" statement References: <3B4FF355.AFC80981@alcyone.com> Message-ID: "Erik Max Francis" wrote in message news:3B4FF355.AFC80981 at alcyone.com... > Roman Suzi wrote: > > > > That's just plain more efficient. Four additions and one multiply > > > > four? > > Yes, typo. Three, obviously. > > > The same with "with": it could make name-resolving more efficient > > by allowing searching some namespaces ahead of locals() and > > globals()... > > Or you could just make a temporary assignment. Same thing going on, no > need for a new keyword and ambiguous code. > As in: for lvar in [some.horrendous.long.reference[3][12]]: lvar.this = 17 lvar.that = 21 which, IIRC, was pointed out bu the timbot about three months ago. But a lot of this thread has ignored the fact that Python's dynamic nature makes a "with"-type construct impossible to compile with any efficiency, since the contents of the namespace cannot be predicted purely as a result of static program analysis. regards STeve -- http://www.holdenweb.com/ From new_name at mit.edu Sat Jul 28 12:50:42 2001 From: new_name at mit.edu (Alex) Date: 28 Jul 2001 12:50:42 -0400 Subject: I want to do something: References: <9E498636EBFC006C.0B20514C36C78E95.408432537CAD3767@lp.airnews.net> Message-ID: Thanks for pointing that out. Alex. From opengeometry at yahoo.ca Thu Jul 5 18:01:54 2001 From: opengeometry at yahoo.ca (William Park) Date: Thu, 5 Jul 2001 18:01:54 -0400 Subject: There's got to be an easy way to do this (fwd) In-Reply-To: ; from mertz@gnosis.cx on Thu, Jul 05, 2001 at 05:42:00PM -0400 References: Message-ID: <20010705180154.A2143@node0.opengeometry.ca> On Thu, Jul 05, 2001 at 05:42:00PM -0400, Lulu of the Lotus-Eaters wrote: > def traditional(iters): > for i in iters: > result = "" > for c in '(123)/456-7890': > if c in digits: > result = result + c Sorry to jump in the middle of thread (can't access newgroup at the moment). Have you tried this one. def traditional(iters): for i in iters: result = [] for c in '(123)/456-7890': if c in digits: result.append(c) "".join(result) -- William Park, Open Geometry Consulting, 8 CPUs cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc. From aleaxit at yahoo.com Tue Jul 3 12:08:01 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 3 Jul 2001 18:08:01 +0200 Subject: Access all classes in a directory, put into an array, and print them out References: Message-ID: <9hsql302ghk@enews1.newsguy.com> "Kemp Randy-W18971" wrote in message news:mailman.994168205.8845.python-list at python.org... > Can anyone share a short code example of how to access all the programs in a > Unix directory, put them into an array, and print them out in Python? Here > is the code I have to do it in Perl (please forgive the harsh language). > > #!/usr/bin/perl -w > #use Net::FTP; > opendir (TEMP, '/usr2/ecadtesting/javaprograms') > or die "Can't open current directory."; > @files=join(',',grep(!/^\.\.?$/, readdir TEMP)); > closedir TEMP; > print "\n"; > print @files; > print "\n"; #!/usr/bin/python import os print os.listdir('/usr2/ecadtesting/javaprograms') Makes you wonder where Perl got its reputation for conciseness, doesn't it?-) [Note the . and .. entries are automatically removed by the listdir function]. Alex From JoeSalmeri at home.com Tue Jul 17 18:40:56 2001 From: JoeSalmeri at home.com (Joe Salmeri) Date: Tue, 17 Jul 2001 22:40:56 GMT Subject: HELP: Python ASP Bug with traceback information Message-ID: Can someone please confirm whether this is a known bug using Python with ASP? Web Server is IIS 5.0 OS is Windows 2000 SP2 Python is BeOpen Python 2.0 Win32All is build 138 When an exception occurs in a script under ASP the contents of the line that the traceback occurred on do not appear to exist in the traceback. I have tried most of the functions available in the traceback module but in all cases the contents of the line that normally appears in the traceback is lost when using ASP. When using CGI/Python there are no problems. I have narrowed down my problem to the simple test scripts listed below: Have I found a new bug? Is there a workaround available? **** File 1: joe.py **** print 'Content-Type: text/html' print import StringIO import sys import traceback try: 1/0 except: e = sys.exc_info() f = StringIO.StringIO() traceback.print_exception(e[0], e[1], e[2], file=f) print f.getvalue() **** File 2: joe.asp **** <%@language="Python"%> <% import StringIO import sys import traceback try: 1/0 except: e = sys.exc_info() f = StringIO.StringIO() traceback.print_exception(e[0], e[1], e[2], file=f) Response.Write(f.getvalue()) %> **** joe.py output **** Traceback (most recent call last): File "P:\Home\Joe\Web\Rolo\j.py", line 10, in ? 1/0 ZeroDivisionError: integer division or modulo **** joe.asp output **** (NOTE: you must view source of the asp page because I did not Encode the ASP output) Traceback (most recent call last): File " You can't mix HTML in code blocks. <%if 1:%> <%else:%> This doesn't work for obvious reasons. Check out HTMLgen for some easy alternatives. And there's a bunch more I can't think of right now, but go check through the c.l.py archives for ASP and lots of good info will emerge. From bokr at accessone.com Tue Jul 17 16:31:27 2001 From: bokr at accessone.com (Bengt Richter) Date: Tue, 17 Jul 2001 20:31:27 GMT Subject: Regex for strings utility References: <1103_995396879@pan> Message-ID: <3b549ec9.2172736409@wa.news.verio.net> On Tue, 17 Jul 2001 14:25:52 -0500, Skip Montanaro wrote: > > rhys> I'm trying to write a script which operates like the Unix > rhys> 'strings' utility but I'm having difficulties with the regex. > ... > rhys> I'm getting a Syntax Error: Invalid Token at the closing brace to > rhys> the pattern. > >You have a couple problems. First, the pattern needs to be a string, so it >has to be enclosed in quotes. Second, the terminating character for the for >loop needs to be a colon. Third, based upon the way you imported re, you >need to refer to the findall function as re.findall. > >Here's a slightly revised version of your script: > > #!/usr/bin/env python > > # strings program > > import sys, re > > f = open(sys.argv[1]) > line = f.readline() > pattern = re.compile("[\040-\126\s]{4,}") Fourth ... ;-) I don't think he means \126 since >>> "\126 is not \176" 'V is not ~' and since he's got \s covered, it would be clearer as pattern = re.compile("[!-~\s]{4,}") > > while line: > # regular expression to match strings >=4 chars goes here > matches = re.findall(pattern, line) > for match in matches: > print match > line = f.readline() > From robin at jessikat.fsnet.co.uk Tue Jul 24 06:24:29 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Tue, 24 Jul 2001 11:24:29 +0100 Subject: A way to accommodate laguage changes References: <3B5CB83B.F3B7D51@home.net> <3B5CC345.D18FEEE8@Lugoj.Com> Message-ID: In article <3B5CC345.D18FEEE8 at Lugoj.Com>, James Logajan writes ... > >I effectively stopped considering Python for new projects as of last night. >I can't read Guido's mind, I don't know what other code-breaking changes he >might be considering. I'm not sure he even knows. Where else is he going to >be convinced that "evil" lies in the language and needs to be exorcised? I'm afraid that's the real problem that became apparent during this discussion. All the fury and arguments mean nothing when the mdfl has decided to change the language. The PEP process is a rubber stamping mechanism for the great leader's diktat. -- Robin Becker From hinsen at cnrs-orleans.fr Tue Jul 3 11:17:11 2001 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 03 Jul 2001 17:17:11 +0200 Subject: Calculus Module (Michael Hudson) References: Message-ID: Andrew Todd writes: > Not necessarily, but that would be nice. I'm more > interested in lower level Calculus at the moment. > Really I just want to see how a math module should be > designed. Math is still a bit general. Perhaps you should look at Numerical Python (numpy.sourceforge.net) and ScientificPython (dirac.cnrs-orleans.fr/programs/scientific.html) to get an idea of what has already been done in this field. -- ------------------------------------------------------------------------------- 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 dirck at pacbell.net Sat Jul 28 23:28:28 2001 From: dirck at pacbell.net (Dirck Blaskey) Date: Sat, 28 Jul 2001 20:28:28 -0700 Subject: Deposing Dictators References: <9jmjne$q54$1@wisteria.csv.warwick.ac.uk> Message-ID: "Steve Horne" wrote in message news:n0r2mto4fv52lhqh4i2u8dl9ja44ad3uog at 4ax.com... > ... > 1. A lot of the ideas turn out not to be for a programming language > as such at all. Rather, it combines the ideas of literate programming > with a kind of replacement for make. An XML notation would allow > source code in a range of languages to be packaged in a linked set of > XML files with documentation, detailed specification of the build > process and explicit requirements for the run-time and build-time > environment. It would allow you to specify, for instance, that the > source code for this C++ module contains a constant structure derived > according to xxx principles (for the documentation) and can be > generated by running yyy script in zzz version of Python (or > whatever). > > Definitely a case of going off at a tangent! > ... Unless you have compelling reasons for using XML, I would suggest the alternative of using Python itself as the meta-language. Maybe I don't fully understand your intended use of XML, but it gives me a good opportunity to go off on a tangent, as well. (Hmm... Maybe it's time to change the subject: line?) XML is a bit hard on the eyes (quite unlike Python). I've been using Python as a meta-language, and it's kind of a neat twist. For example, here is a piece of a script defining a database structure: #################### from dbmodel import DBD db = DBD('cmsmain') table = db.table('Active Clients') table.field('ClientID', 'COUNTER', nulls=1) table.field('ClientName1', 'VARCHAR', size=50) table.field('Address1', 'VARCHAR', size=50, nulls=1) table.field('City', 'VARCHAR', size=25, nulls=1) table.field('State', 'VARCHAR', size=2, nulls=1) table.field('SalesPersonID', 'INTEGER', nulls=1) table.primary('ClientID') table.unique('ClientName1', name='ClientName1') table.index('SalesPersonID', name='SalesID') table = db.table('Active Contracts') table.field('ContractID', 'COUNTER', nulls=1) table.field('ContractNo', 'VARCHAR', size=15) table.field('ClientID', 'INTEGER') table.field('IntRate', 'FLOAT', nulls=1) table.primary('ContractID') table.unique('ContractNo', name='Active ContractsContractNo') table.index('ClientID', name='ClientID') db.onetomany('Active Clients', 'ClientID', 'Active Contracts', 'ClientID', enforce=1, cascadeUpdates=1, cascadeDeletes=0) #################### Python modules can load this and generate the appropriate CREATE TABLE statements for the target platform (it seems like all SQLs are different), or alternatively, query a platform, and generate this Python code from an existing SQL database, which can then in turn be loaded and the structure reproduced on a different platform. Maybe the point here is subtle, and I'm not sure exactly how to express it. The code above isn't quite like normal code, exactly, because the code itself is essentially the persistent data structure. dbmodel doesn't _do_ anything, all the dbmodel classes can do are be created, be queried for their structure, and write themselves out, as Python code. A dbmodel might be used somewhat like this: ==================== import dbmodel db = dbmodel.Load("modelfile") for table in db: print table, for field in table: print field, print ==================== It occurred to me that it would be cool if they could also call into another DBD-like class exactly as above, in essence, reproduce, or reflect their structure onto another implementation, which might have different purposes. Something like this: ==================== import dbmodel import dbgen g = dbgen.thingie() db = dbmodel.Load("modelfile") db.renderOn(g) ==================== which is subtly different from this: ==================== import dbmodel import dbgen g = dbgen.thingie() db = dbmodel.Load("modelfile") g.buildFrom(db) ==================== Another example, from a Python build system (for C/C++) I use instead of make (it has #include searches and dependency checking.) Here's an example recipe '.bld' file: ######################## TARGET="application.exe" # our target executable BUILD=["../lib/framework.bld"] # required subprojects: we're using this lib SOURCES=["../util/*.cpp", # sources to build and link "/thirdParty/xsrc/*.c", "main.cpp",] DEFINES=["DEBUG_FRIPPERY", "NO_WIDGET_CHECKS"] # some switches INCLUDES=[".", "../util", "/thirdParty/stuff"] # where to look for includes LIBRARIES=["../lib/framework.lib"] # libraries to link ########################## So instead of futzing with Make rules and yet-another-obscure-syntax, all I do is write little Python declarations for what I want. You could also put conditionals in the recipe based on configuration options. Another example, a deliver recipe, from a tool that just copies files about: ########################## SOURCE="../lts/cdoc/src" TARGET='../ship/cdoc/src' files=FileSet(base=SOURCE, files=['*/*', '*/*/*'], exclude=['*.obj', '*.exe', '*.pdb','*.idb','*.ilk' 'tools/*']) files.copy(TARGET) ########################## I've been thinking about another Python-Code-Model-Representation for vector graphics documents. Maybe something like this: ########################## from picmodel import * pic = PICTURE() pic.dpi(72) pic.extents(0,0,8.5*72,11.5*72) pic.fill_color(red) pic.frame_color(blue) pic.frame_width(1) pic.rectangle(0,0,100,100) shape = pic.shape() shape.line(10,10) shape.line(15,0) shape.line(20,10) shape.arc2((15,15),(10,10)) pic.shape_fill(shape, (100,100)) ########################## Then you could do this: ===================== import picmodel import pslib import pdflib ps = pslib.target("file.ps") pic = picmodel.Load("picturefile") pic.renderOn(ps) pdf = pdflib.target("file.pdf") pic.renderOn(pdf) ===================== Still thinking about that one. Graphic models get pretty horrendous. Hopefully this isn't too obscure, and maybe gives you some more ideas. -off-on-still-yet-another-tangent- d From missive at frontiernet.net Mon Jul 23 20:09:17 2001 From: missive at frontiernet.net (Lee Harr) Date: Tue, 24 Jul 2001 00:09:17 +0000 (UTC) Subject: from __past__ import integerDivision (was Re: A modest PEP0238 suggestion) References: <3b5c6e08.27535083@aplnews> <9jiak1$3s96$3@node21.cwnet.roc.gblx.net> Message-ID: <9jiebd$poi$1@node21.cwnet.roc.gblx.net> On Mon, 23 Jul 2001 16:13:59 -0700, David Eppstein wrote: > In article <9jiak1$3s96$3 at node21.cwnet.roc.gblx.net>, > missive at frontiernet.net (Lee Harr) wrote: > >> we already have people importing things from the __future__, >> how difficult would it be to let people drag things from the __past__? > > Doesn't do anything for the people who are running precompiled scripts > acquired from somewhere else, or who have warnings redirected to where they > won't be seen. I have not used it, but I think you can define a script that runs every time python starts up. Or is that only for the interactive mode? From Pierre-et-Liliane.DENIS at village.uunet.be Sun Jul 8 16:26:59 2001 From: Pierre-et-Liliane.DENIS at village.uunet.be (Pierre Denis) Date: Sun, 8 Jul 2001 22:26:59 +0200 Subject: Assignement Overloading Message-ID: <3b48bd83$0$7113$4d4efb8e@news.be.uu.net> I am trying to emulate some kind of type checking in Python (sorry for the heresy). Because of the dynamic typing, my unpretentious goal is to intercept the assignment statement in order to perform a consistency check between the variable and the object to assign. Unfortunately, there is no mechanism in Python to do this; there is no magic function like __assign__(name,value). The reason usually invoked about this lack is the fact that Python's assignment is actually just a name binding, which is very different, for instance, from C++ assignment. However, there exists a concept very similar in Python, although less general : the __setattr__ method. For a given class instance, it is invoked whenever an attribute assignment is attempted. This allows to make a step towards a solution to my problem. Consider the following example where an attribute's type checking is emulated, basing on Python's type() function (this example has no other pretension than showing a 'pattern' to fake assignment overloading) : -------------------------------------------------------------------------------- ''' file typechecker.py ''' class TypedNamespace: def __setattr__(self,name,value): if self.__dict__.has_key(name): targetType, valueType = type(self.__dict__[name]), type(value) if targetType != valueType: print "Error : cannot assign %s value to %s variable '%s'." \ % (valueType.__name__, targetType.__name__, name) return self.__dict__[name] = value t = TypedNamespace() -------------------------------------------------------------------------------- >>> from typechecker import t >>> t.name = 'To infinity and beyond' >>> t.name = 20 Error : cannot assign int value to string variable 'name'. >>> t.name 'To infinity and beyond' >>> t.name = ['Hello','Dolly'] Error : cannot assign list value to string variable 'name'. >>> t.height = 15 >>> t.height = t.name Error : cannot assign string value to int variable 'height'. >>> -------------------------------------------------------------------------------- This works fine, but the (expensive) price to pay is the fact that you can not work with true variables : the prefix 't.' is an artifact to get true attributes in order to take advantage of the __setattr__ method. Now I have two questions : 1. Why is there no general way to overload the assignment in Python ? I do not agree with the 'name binding' argument because, to my humble opinion, __setattr__ allows to overload some assignments, while performing a name binding (in an object's namespace). So I think the problem is well stated and the request makes sense. 2. Is there other features in Python I can use to emulate assignment overloading (simpler than the technique given in my example) ? Thanks in advance, Pierre Denis From guido at python.org Sat Jul 7 09:20:00 2001 From: guido at python.org (Guido van Rossum) Date: Sat, 07 Jul 2001 13:20:00 GMT Subject: Comment on PEP-0238 References: <3dd77drkea.fsf@ute.cnri.reston.va.us> <9i5guj$7kg$1@panix6.panix.com> Message-ID: aahz at panix.com (Aahz Maruch) writes: > I'm in agreement with Guido that at least two releases are necessary > (I also agree that it could be two warning releases). But I think > Guido's step 3 (if used) should be changed to the semantically equivalent > > In Python 2.4, integer division with the '/' operator raises an > exception. This exception can be caught as usual, but the > programmer should prepare for the next release of Python by either > using the div() function or by using the future directive to get > floating point division. Oh, Aazh! I wasn't writing a formal specification, I was sketching a plan. In that context, using "make it an error" is the right level of detail. Everybody can fill in for themselves that that means it's an exception, since that's how we typically signal errors in Python. > (Calling it an error is technically imprecise; an exception isn't > *necessarily* an error.) No, I meant it to be an error. --Guido van Rossum (home page: http://www.python.org/~guido/) From philh at comuno.freeserve.co.uk Sun Jul 15 12:07:18 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Sun, 15 Jul 2001 17:07:18 +0100 Subject: do .. while loops ? References: Message-ID: On Sun, 15 Jul 2001 14:00:31 +1000, Paul Andreassen wrote: > >Could someone please tell me why "do .. while" loops are not part of the >python language? Because they complicate the language, probably. Also, doing else: continuations with them would look a bit ugly, IMO: do: ...code... if x: break ...more code... while a>b else: ...stuff if we didn't break... Personally, if i was designing a Pytohn-like lang, it'd have "loop" which does the same as "while" but "loop:" would mean "while 1:" loop: fun1() if x: break fun2() etc. -- #===== Philip Hunt == philh at comuno.freeserve.co.uk ======# Herbivore: effort-free public key encryption. See: ** First software release coming soon! ** From bsass at freenet.edmonton.ab.ca Wed Jul 4 17:30:53 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Wed, 4 Jul 2001 15:30:53 -0600 (MDT) Subject: Not enough Python library development [was PEP scepticism] In-Reply-To: Message-ID: On 4 Jul 2001, Ralf Muschall wrote: > Grant Griffin writes: > > concept seemed to encourage large interdependencies between modules. > > Unfortunately, the logical alternative to interdependencies is > duplication of code (or, at least, of functionality). > > > "application-targeted" distributions. For example, someone could make a > > "Numeric" bundle of Python, including NumPy and related modules; > > likewise, there could be a "webmaster" bundle. Of course, this takes a > > This does not remove the need to keep them mutually compatible. Stuff would _need_ to be packaged in terms of the smallest replaceable unit if you want to eliminate duplication, and if you do not eliminate duplication you can end up with packages conflicting because they require different versions of the same software. One result of this is that packages which make it into the archive, and depend on other stuff in the archive, will either get maintained or dropped when the dependencies can not be met anymore. The bug tracking system is what tells the pkg's maintainer there is a problem, but if the maintainers are not around because you didn't make them jump through some hoops to ensure they are serious -- it all falls apart and becomes easier for the user to just go get the source. I think this needs a PEP from the core Python developers, for four reasons: 1) anything less is "just" third-party (no matter how well done) 2) to end up with an archive that is not crufty, inconsistent, or full of duplication -- Python itself must be in the archive [(co)authoring a PEP is tacit approval] and 3) having a repackaged version of Python in the archive is potentially starting down the road to having multiple, incompatible, archives (who decides the right way to break Python down into packages, and what happens when PyPAN and ActiveState (or whoever) diagree) -- this pretty much necessitates the core developers involvement 4) this is a complex undertaking, the result of which can affect the stability and security of systems that use it - Bruce From aleaxit at yahoo.com Thu Jul 5 08:28:35 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 5 Jul 2001 14:28:35 +0200 Subject: reading sockets References: Message-ID: <9i1mhk02fhu@enews1.newsguy.com> "Ken Mugrage" wrote in message news:FGN07.153841$%i7.102425274 at news1.rdc1.sfba.home.com... ... > In perl, I would do something like > > while() { > print $_; > } > > and it would print everything as it is sent, one line at a time. > > In Python, I have something like > > while 1: > data = mysocket.recv(1024) > print data > > which of course print everything in 1024 byte blocks. from xreadlines import xreadlines ... for line in xreadlines(sock.makefile()): print line, should be what you want. sock.makefile() gives you a file-like object that reads data from the socket, and the xreadlines() wrapper makes it easy and efficient to loop on it line by line. Alex From jacy at poczta.onet.pl Mon Jul 23 02:50:41 2001 From: jacy at poczta.onet.pl (jacek czerwinski) Date: Mon, 23 Jul 2001 08:50:41 +0200 Subject: light GUI Message-ID: <3B5BC941.C7B77575@poczta.onet.pl> I need simple light GUI for python embeded into bigger windows application. Some proposal ? -- Skalowalny, bezpieczny, serwer dedykowany, http://www.wdc.pl From ddublanc at free.fr Wed Jul 4 18:03:43 2001 From: ddublanc at free.fr (Dublanc, David) Date: Wed, 04 Jul 2001 22:03:43 GMT Subject: Dynamic call of a method : error Message-ID: <3pM07.8236$Yq2.6098008@nnrp5.proxad.net> Hello, when I execute the module : *************** L = [] for method in dir(L): "dynamic call" print L.method.__doc__ **************** I have the following error : 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 "f:\python21\pythonwin\pywin\framework\scriptutils.py", line 301, in RunScript exec codeObject in __main__.__dict__ File "G:\script python\test concat?nation.py", line 5, in ? print L.method.__doc__ AttributeError: method How can I call a method dynamically ? Thanks. Regards, -- David From phillip at transwitch.co.za Mon Jul 23 04:39:54 2001 From: phillip at transwitch.co.za (phillip) Date: 23 Jul 2001 01:39:54 -0700 Subject: Packing of Frames Message-ID: <74cc9702.0107230039.195d1546@posting.google.com> Hi, I have two frames(left & right) into which I place names (left) and vlaues (right). The left Frame adheres to my constraints but the right expands vertically beyond my constraints. I do it thus: root = Tk() root.geometry('350x300') root.leftFrame = Frame(width=150, height=300, bg='gray50', relief=RAISED, bd=4) root.rightFrame = Frame(width=200, height=300, bg='gray50', relief=RAISED, bd=4) root.setup = ui.getSetupValues() root.rightFrame.pack(fill=X, side=RIGHT) root.rightFrame.pack_propagate(0) root.leftFrame.pack(fill=BOTH) root.leftFrame.pack_propagate(0) myRow = 0 for eachKey in root.setup.keys(): l = Label(root.leftFrame, text=string.strip(eachKey), bg='gray50',anchor=E, justify=RIGHT) r = Entry(root.rightFrame, bg='gray100', width=200, relief=GROOVE) l.grid(row=myRow, sticky=E+W ) r.insert(INSERT, string.strip(root.setup[eachKey])) r.pack() root.mainloop() any ideas? Phill From paulp at ActiveState.com Tue Jul 17 12:33:43 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Tue, 17 Jul 2001 09:33:43 -0700 Subject: [Python-Dev] Re: PEP: Defining Unicode Literal Encodings (revision 1.1) References: <3B50C1FF.7E73739B@ActiveState.com> <200107150126.VAA23781@cj20424-a.reston1.va.home.com> <3B51CFB0.ACE9070D@ActiveState.com> <200107151729.NAA00455@cj20424-a.reston1.va.home.com> Message-ID: <3B5468E7.F534E5D2@ActiveState.com> David Eppstein wrote: > >... > > I tend to think putting anything at all in the text of the file is a hack > and not a clean design -- this is meta-information rather than content, > right? What is the practical problem with mixing "meta-information" and "content"? > ... But maybe as long as you're going to do that you should go all the > way and have some kind of "meta" directive that allows MIME directives > beyond just charset=... What other ones make sense? -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From mal at lemburg.com Thu Jul 19 05:14:35 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Thu, 19 Jul 2001 11:14:35 +0200 Subject: PEP: Defining Python Source Code Encodings References: Message-ID: <3B56A4FB.104CBCBB@lemburg.com> Roman Suzi wrote: > > On Wed, 18 Jul 2001, M.-A. Lemburg wrote: > > > This PEP proposes to introduce a syntax to declare the encoding of > > a Python source file. The encoding information is then used by the > > Python parser to interpret the file using the given encoding. Most > > notably this enhances the interpretation of Unicode literals in > > the source code and makes it possible to write Unicode literals > > using e.g. UTF-8 directly in an Unicode aware editor. > > I have not understood: will Unicode encoding be directly allowed or only > ASCII-compatible encodings (like UTF-8)? Only ASCII supersets -- detecting UTF-16 or UTF-32 would be hard since Python's source files do not provide a usable file magic (at least not to my knowledge) and prepending BOM marks or similar identifiers will likely break executability of Python scrips on Unix (due to the #! logic). > >Problem > > > > In Python 2.1, Unicode literals can only be written using the > > Latin-1 based encoding "unicode-escape". This makes the > > programming environment rather unfriendly to Python users who live > > and work in non-Latin-1 locales such as many of the Asian > > countries. Programmers can write their 8-bit strings using the > > favourite encoding, but are bound to the "unicode-escape" encoding > > for Unicode literals. > > Isn't it time for better gettext support in Python? Then for i18n-enabled > programs, encodings will belong to .mo, .po or whatever called files... We already have good gettext support in Python (see the Tools/i18n directory). AFAIK, gettext uses UTF-8 as only encoding for its l10n files. > >Scope > > > > This PEP only affects Python source code which makes use of the > > proposed magic comment. > > > Without the magic comment in the proposed > > position, Python will treat the source file as it does currently > > to maintain backwards compatibility. > > This is what I like most. Will optimization be mentioned here? If the performance hit is noticable, we could look into optimizing the setup for files which don't use the magic comment. I'd rather leave this to after the implemenation. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From barry at digicool.com Mon Jul 23 11:19:15 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Mon, 23 Jul 2001 11:19:15 -0400 Subject: emacs python mode References: <3B5BF5C7.3070707@herts.ac.uk> Message-ID: <15196.16499.637362.583213@anthem.wooz.org> >>>>> "MR" == Mark Robinson writes: MR> trivial question I suppose, but it is bugging me, so here MR> goes. I have just installed the python.el file (and byte MR> compiled it) and emacs is happily switching to python mode MR> when I open a *.py file, but I don't get any pretty colors at MR> all. Is there anything I need to be doing, I thought that MR> should be automatic? You need to turn on font-lock mode. -Barry From grayson-wilson at home.com Wed Jul 11 23:27:21 2001 From: grayson-wilson at home.com (EricIDLE) Date: Thu, 12 Jul 2001 03:27:21 GMT Subject: LAMBDA IS IT USELESS? Message-ID: Ok well I dont quite grasp the Lambda concept heres an example. def mult(x,y): return x * y f = reduce(lambda x,y: x*y,n) print f *NOTE The varible N is defined in the code before this excerpt. Anyways back to the point the book says this is easier!?!? But comon sense tells me this is easier. def mult(x,y): return x * y f = reduce(mult,n) print f Isnt that easier?? Or do I not get lambda? *NOTE ... I think its just a way to complicate things OR just a way to avoid typing the function name beacuse.... I dont know they are scared of the names they give them. From bhahn at spam-spam.g0-away.com Mon Jul 30 23:32:18 2001 From: bhahn at spam-spam.g0-away.com (Brendan Hahn) Date: Mon, 30 Jul 2001 20:32:18 -0700 Subject: "Systems programming" (was: Language Niches (long)) References: <8beb91f5.0107280407.5a30341d@posting.google.com> <4E215400D01D7374.0068C51FD6502BE8.99D4E013ECF0FDFB@lp.airnews.net> Message-ID: claird at starbase.neosoft.com (Cameron Laird) wrote: >Grant Edwards wrote: > . >>AFAIK, all Unix system programming is still done in C. (At least >>that's true for the Unices I'm familiar with (SCO, Solaris, >>BSD, Linux). >Perlites occasionally make a serious pitch for this role. >Java, Forth, and C++ have all briefly flared as possibili- >ties. You can do kernel stuff in C++ on a lot of systems, but it's often more trouble than it's worth...kernel versions of the C++ runtime can be very quirky. NT is actually pretty nice for doing C++ drivers. You could use Objective-C on the old NeXT systems -- Apple has switched to a C++ IO system, for better performance, but using a restricted subset of the language. Haven't tried it yet but I think it'll be nice. Forth is actually in very wide use, but at the sub-OS level -- any Open Firmware system starts up running Forth, and if you want a boot driver for a new storage adapter, say, you write it in Forth and put it in ROM on the card. bhahn at transoft.mmangle.net <-- unmangle address to reply From skip at pobox.com Mon Jul 2 08:31:54 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 2 Jul 2001 07:31:54 -0500 Subject: New PEP: Quality Guidelines For Standard Modules In-Reply-To: <5.0.2.1.0.20010701213736.0277d700@mail.inet.com.br> References: <5.0.2.1.0.20010701213736.0277d700@mail.inet.com.br> Message-ID: <15168.27066.773689.676765@beluga.mojam.com> Carlos, Good start on the PEP. A couple comments. In the final PEP I think you will need to have code examples or point to specific compliant modules as examples. That will make it easier for people who won't bother to read and understand the entire PEP to write compliant code the first time. For example, you wrote: 4. Class names SHOULD be written in mixed case. This could be either missed or interpreted by lazy programmers as any of mixedCaseClass MixedCaseClass mIxEdCaseCLASS Mixed_Case_Class or any of a zillion other possibilities. I suspect you only meant the second case. Also, in the References section you should refer to Guido's style guide: http://www.python.org/doc/essays/styleguide.html In fact, you may want to pilfer some content... -- Skip Montanaro (skip at pobox.com) (847)971-7098 From cribeiro at mail.inet.com.br Thu Jul 5 22:22:20 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Thu, 05 Jul 2001 23:22:20 -0300 Subject: Warning: Quality Guidelines For Standard Modules Message-ID: <5.0.2.1.0.20010705231135.0279fba0@mail.inet.com.br> As I promised, I'm revising my draft PEP - Quality Guidelines For Standard Modules. However, due to external reasons (read "real job pressures") I'm only going to be able to work on it over the weekend. I expected to be able to make it over the past two days but it was simply impossible. I need to take some time to re-read carefully all the answers that I got both privately and through the newsgroup before issuing a revision. I would like to ask all the people that contributed to wait a few more days, and to keep sending contributions and revisions. I apologize if this is inconvenient to anyone, specially to Martijn Faassen that is working on a related PEP. I'm working to make this delay as small as possible. Thanks in advance, Carlos Ribeiro From alf at leo.logilab.fr Tue Jul 10 10:54:26 2001 From: alf at leo.logilab.fr (Alexandre Fayolle) Date: Tue, 10 Jul 2001 14:54:26 +0000 (UTC) Subject: Profiler question Message-ID: Hello, I'm using the profile module to try to see where I could get some speedups in an application, I'm getting troubles interpretting the results, especially the cumulative times. Is there a known problem with profile and multithreaded applications? Alexandre Fayolle -- LOGILAB, Paris (France). http://www.logilab.com http://www.logilab.fr http://www.logilab.org Narval, the first software agent available as free software (GPL). From skip at pobox.com Sun Jul 8 09:30:28 2001 From: skip at pobox.com (Skip Montanaro) Date: Sun, 8 Jul 2001 08:30:28 -0500 Subject: Comment on PEP-0238 In-Reply-To: References: Message-ID: <15176.24692.194746.775712@beluga.mojam.com> Tim> inspect (and code like it) should be upgraded to use Tim> sys._getframe() directly instead of raising phony exceptions. Inspect tries to be 1.5-compatible I believe, so it can't call sys._getframe. It could raise a different exception, however... Skip From rnd at onego.ru Thu Jul 19 05:37:26 2001 From: rnd at onego.ru (Roman Suzi) Date: Thu, 19 Jul 2001 13:37:26 +0400 (MSD) Subject: Python 2 times slower than Perl In-Reply-To: Message-ID: On Thu, 19 Jul 2001, Greg Jorgensen wrote: > "Alex Martelli" wrote in message > news:9j4af20d2o at enews4.newsguy.com... > > > Perl and Python ruled the roost in Prechelt's tests (from the POV > > of development speed), indistinguishable from each other. C and C++ > > made the fastest executables on average. Java was bad on both > > scores -- very slow programs taking a long time to develop. Other > > scripting languages (Tcl, Rexx) gave intermediate development times > > but extremely slow results. Somebody else claims to have rerun the > > same experiment with Common Lisp, getting runtimes competitive with > > C and C++ and development speed competitive with Perl and Python. > > > > We could definitely do with more such tests...!!! > > With all respect, why? Other than Usenet fodder what good are these tests? Posting tests showing performance weakness in some typical situations is needed to make Python better. Maybe, not such trivial and useless as with cycling 2.5 * 2.5, but others which come from real programmer's practice. For example, Oleg Broytman was concerned with Python's re performance, because their application became 5 time slower. We need watch Python performance and it is not nice to discourage posting tests here which indicate problams. > I know who the audience is for these timing tests: In the cubicle next to > mine is a junior programmer (fresh from Sun Java training classes, his first > language) who frequently gets into long discussions with other programmers > about language trivia and "performance." His projects are always late > because he over-designs and ends up with unusable class structures. Over the > course of the last few months he has wasted hundreds of hours of his own > time, and incessantly interrupted other people, because he doesn't > understand Excel or SQL. He's writing a set of functions--he calls it a > class library--to calculate vacation time for various types of employees. > His code is supposed to replace a perfectly good spreadsheet that everyone > understands. I do not know your concrete case, but sometimes simple CGI script is better than XLS file, because only browser is needed to use it. It's much more inconvenient to send XLS to anybody. SQL is also overkill when not used on the regular basis with real databases. And also those "wasted hundreds of hours" are not wasted in vein, because juniors need to learn. As for over-designs, I agree. I am too tending to over-design (I am not into XP!). This could be explained by inexperience. When experienced programmer makes the same, it is not called "over-design", because he includes things which make easier to extend system in directions he foresee. For example, when I was writing my ISP tarification program, I always tried to put our domain name in a variable (while it was easier to put "onego.ru" everywhere is source!). Now we can accept different domains without much refactoring. > Sign me, cynical and sick of worthless benchmarks. These benchmarks also show how good someones Python is compiled. For exaple, I saw that my AMD K6 225 makes almost same results as somebody elses Celeron 450 ;-) > Greg Jorgensen > PDXperts LLC > Portland, Oregon, USA Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From brian_zhou at NOSPAMtechie.com Mon Jul 30 01:45:09 2001 From: brian_zhou at NOSPAMtechie.com (Brian Zhou) Date: Sun, 29 Jul 2001 22:45:09 -0700 Subject: PythonPath for ASP Message-ID: <996471911.551564@emperor.labs.agilent.com> Hello group, Currently on command line, sys.path is ['', 'c:\\python21\\pil', 'c:\\python21\\pythonwin', 'c:\\python21\\win32', 'c:\\python21\\win32\\lib', 'c:\\python21', 'c:\\python21\\dlls', 'c:\\python21\\lib', 'c:\\python21\\lib\\plat-win', 'c:\\python21\\lib\\lib-tk', 'c:\\python21\\numeric', 'c:\\python21\\ppm'] But from ASP Python script: [c:\python21\pythonwin c:\python21\win32 c:\python21\win32\lib c:\python21 c:\python21\lib\plat-win c:\python21\lib c:\python21\dlls c:\python21\lib\lib-tk c:\windows\system32] You can see 'c:\\python21\\pil' is not in the path. So from ASP scripts, I have to do import PIL.Image instead of import Image Is there a place I can set that makes C:\Python21\PIL in PythonPath? Thanks for any help, -Brian From m.faassen at vet.uu.nl Mon Jul 23 06:48:44 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 23 Jul 2001 10:48:44 GMT Subject: PEP0238 lament References: Message-ID: <9jgvec$dos$2@newshost.accu.uu.nl> Moshe Zadka wrote: > On Sun, 22 Jul 2001 16:27:32 -0700, David Eppstein wrote: >> My intuition is that the users who will be surprised that 1/2 = 0 are the >> same ones who would be bitten by roundoff-error bugs if 1/2 = 0.5. >> Result: buggier code since the errors are less obvious. > The thing is, making 1/2=0.5 won't make the problem *worse*. Because > after two days of being baffled by 1/2=0, these newbies will eventually > figure out the solution float(1)/2. So, I'm just getting to show them > the buggy roundoff-error code *faster*, instead of making them suffer > for it. You want to fix *that* problem, you have to give easy to access > rationals. Will you introduce a special 'rational division' operator for that? Or change the semantics of '/' again? :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From franck.delarue at rd.francetelecom.com Tue Jul 31 05:33:46 2001 From: franck.delarue at rd.francetelecom.com (franck delarue) Date: Tue, 31 Jul 2001 11:33:46 +0200 Subject: portability Message-ID: <9k5u2c$p542@news.rd.francetelecom.fr> hello everyone, i'm working on python on linux red hat and i'm wandering if all the code that i've written would be portable to unix or windows (except the system calls of course). I know that python works a little like java ( on a virtual machine), but is Python as portable as java ? thanks in advance. From grante at visi.com Sun Jul 29 20:22:05 2001 From: grante at visi.com (Grant Edwards) Date: Mon, 30 Jul 2001 00:22:05 GMT Subject: Language Niches (long) References: <3B6481DB.C5AEA46@ActiveState.com> Message-ID: On Mon, 30 Jul 2001 00:37:18 +0100, Robin Becker wrote: >I hesitated to mention ADA One nit: It's "Ada" not "ADA". The former is a programming language; the latter is the American Dental Association (among other things). -- Grant Edwards grante Yow! I'd like some JUNK at FOOD... and then I want to visi.com be ALONE -- From tchur at optushome.com.au Fri Jul 6 18:39:34 2001 From: tchur at optushome.com.au (Tim Churches) Date: Sat, 07 Jul 2001 08:39:34 +1000 Subject: Sybase module (was Re: Postgres support) References: <5174eed0.0107061058.5446dac9@posting.google.com> <15174.5497.55793.936749@beluga.mojam.com> Message-ID: <3B463E26.582642E0@optushome.com.au> Skip Montanaro wrote: > > Edward> Python needs a ready to use cross database module which handles > Edward> Oracle, DB2, SQL-Server, Sybase, and Informix. If it handles > > "Python Sybase" netted this: > > http://www.stecf.org/~npirzkal/python/sybase/ I think the Python<->Sybase module of choice would have to be the Sybase module (alpha status notwithstanding) being developed by Object Craft, who are based in Melbourne, Australia. See http://www.object-craft.com.au Ava Gardner quipped that Melbourne was a good place to make a movie about the end of the world when she was filming the cinema version of Neville Shute's "On the Beach" (in which the Northern Hemisphere obliterates itself in a bout of mutually assured thermonuclear destruction, with the Southern Hemisphere eventually succumbing to radioactive fallout, but only after plenty of soul-searching, a few bottles of Scotch and a brief but passionate love affairs). Melbourne also appears to be a good place to write Python modules. Cheers, Tim C Sydney, Australia From philh at comuno.freeserve.co.uk Wed Jul 11 09:19:34 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Wed, 11 Jul 2001 14:19:34 +0100 Subject: Long Live Python! References: Message-ID: On Tue, 10 Jul 2001 15:31:11 -0700, Paul Prescod wrote: >Kemp Randy-W18971 wrote: >> >> So an interesting question is raised. If PHP and Ruby are gaining >> acceptance because they address business needs, what needs to be done to >> carry Python in that direction? And while Java may be slow, Sun pushing it >> for business solutions also gives that language acceptance. How can Python >> become as popular as Perl, Java, or PHP? > >Perl, Java and PHP all grew popular by solving a particular problem at a >particular time, better than any other language. (I'm thinking of system >administration/CGI, Applets and web page generation). Perl and Java grew >into general purpose languages over time. The jury is still out on PHP. > >Python does not have a niche and is not obviously a niche-friendly >language. Sure it does: python's niche is as a scripting language that's also good for longer programs. > That means that it has a harder slog to gain adherents. On the >other hand, Python is not as dependent on its niche. I think that Python >is probably growing faster than Perl and PHP now that those two >languages have basically dominated their niches. I've heard there is a Python Server Pages program that lets you use Python in the same way you would with PHP or JSP. Has anyone used this? Is it any good? Of course, there is also Zope, which is another Python-to-web interface. >Consider the status of >Tcl which is not growing much since other languages invaded the "easy >GUI development" niche. Including Python. >Java has of course outgrown its initial niche but it is hardly fair to >compare Python to a language backed by Sun, IBM, etc. If Python had that >kind of backing it would be as big or bigger than Java too. Indeed. -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From qrczak at knm.org.pl Mon Jul 9 06:25:55 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 9 Jul 2001 10:25:55 GMT Subject: Comment on PEP-0238 References: Message-ID: Sun, 8 Jul 2001 18:19:01 -0400, Tim Peters pisze: > BTW, state-of-the-art rational support also requires context, to determine > whether results should be reduced to lowest terms (some programs run 1000s > of times faster if you don't, others 1000s of times faster if you do, and > only the algorithm author can know which is better). If such context affects only performance, then maybe it's acceptable, but if it affects essential semantics, I'm worried that it's a bad idea to introduce global state where it doesn't exist in the problem domain. The more global settings affect the meaning of a piece of code, the harder is to use independent modules together and to understand code in isolation. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From new_name at mit.edu Mon Jul 16 11:09:49 2001 From: new_name at mit.edu (Alex) Date: 16 Jul 2001 11:09:49 -0400 Subject: Most efficient solution? References: <20010716132133.DIZO21397.femail2.rdc1.on.home.com@jparlar> Message-ID: > map(A.remove, B) That'll throw an error on elements of B that aren't in A, and if elt occurs twice in A and once in B, map(A.remove, B) will still have a copy of elt in it, even if no error is thrown. Alex. From spam at melkor.dnp.fmph.uniba.sk Tue Jul 24 03:11:18 2001 From: spam at melkor.dnp.fmph.uniba.sk (Radovan Garabik) Date: Tue, 24 Jul 2001 09:11:18 +0200 Subject: user level can't bind socket address & port References: Message-ID: "??????" wrote: : hi, all : as the title user level can't bind socket address & port : for example, : sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) : sock.bind((iface, port)) : if i login user level, python interpreter generate error message like that : " sock.bind((iface, port)) : socket.error: (13, 'Permission denied') " : How can I bind socket user level. : please send comment...... 1) what OS are you using? 2) by any chance, is your port < 1024 ? If the answer to 1) is UNIX-like, and the answer to 2) yes, then what you experience is the expected behaviour. Either run the script as superuser (ewww...), or use authbind (http://packages.debian.org/authbind), or some relevant kernel modification. -- ----------------------------------------------------------- | 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 mlh at idi.ntnu.no Wed Jul 25 14:56:45 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Wed, 25 Jul 2001 20:56:45 +0200 Subject: Numeric methods again References: <9jmelr$m2g$1@tyfon.itea.ntnu.no> Message-ID: <9jn4pe$2ov$1@tyfon.itea.ntnu.no> "Martin von Loewis" wrote in message news:j4ofq8hp0w.fsf at informatik.hu-berlin.de... > "Magnus Lie Hetland" writes: > > > in front of the reference dot... For a simple parser > > it might be difficult to know whether 5. was a float > > or the beginning of a reference, but with a bit of > > lookahead that can't be too hard? > > If you want to allow "5.foo", you certainly also need to allow > "5. foo", as you can also write "a. foo". So it requires arbitrary > look-ahead. I'm sure you didn't think I meant that "5. foo" should be outlawed? I'm just surprised that it should be _required_. And it would only require one token lookahead, as long as the scanner compresses the whitespace... But, as I said, that's not the issue. > > Can a number ever be directly followed by an identifier? > > Yes, certainly: "5.e17" could be either 5*10**17, or the e17 attribute > of 5. Right. I guess that's the problem, then. But since all the methods of numeric constants begin with an underscore, that really ought not to be a problem... Right? > Regards, > Martin - Magnus, still wondering what the _real_ problem is... -- 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 sholden at holdenweb.com Tue Jul 31 19:30:35 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 31 Jul 2001 19:30:35 -0400 Subject: Question... References: <3B6737BE.2CCC0A1A@telocity.com> Message-ID: <%8H97.15003$WD1.668162@e420r-atl2.usenetserver.com> "Adonis Vargas" wrote in message news:3B6737BE.2CCC0A1A at telocity.com... > how come this code does not seem to popup on any broswer i attempt to > send HTML data to: > > (c, a) = s.accept() > c.send('HTTP 200 OK\n') Strictly according to the protocol that should be "HTTP/1.0 200 OK" or some other string including a version. > c.send('Content-Type: text/html\n') > c.send('') > print RED + "CONNECT->%s"%a[0] + RESET > > d = c.recv(256) At the moment the browser has the HTTP headers winging their way towards it, with no terminating blank line. What are you expecting to receive? Since the browser won't close the socket either (it's still waiting for the termination of the headers) it won't close its end of the socket either, so your program stops here. Only for an hour or two while the connection times out, though 8-) > c.send(""" > > > Redirecting... > > > > > \n > """) > c.close() > > *basic idea to redirect a broswer. > > any help would greatly be appreciated. > Does this help? regards Steve -- http://www.holdenweb.com/ From James_Althoff at i2.com Fri Jul 13 15:44:46 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Fri, 13 Jul 2001 12:44:46 -0700 Subject: Scripting vs. whatever, again (was Re: Long Live Python!) Message-ID: Peter Hansen wrote: >Interesting (?) special case: what do Jython programmers >use to refer to their source. Do you call it, as you likely >do for Python, a script, or do you think of it as a program? >(And I don't know the nature of the compilation stage: >is it automated as with Python, or manual as with Java?) Jython has the same "auto-compile and run" mechanism as CPython. In terms of what we call our Jython code, it depends on the context. I generally use the phrase "scripting capabilities" as opposed to "scripting language". For me it makes more sense to characterize certain capabilities: "write and run", "very high-level, built-in, domain-specific functionality", "embedded in a particular framework", etc. as "scripting-like" capabilities. Then I can say that Python is a full-fledged, high-level language that also has "scripting capabilities" and avoid the debate of whether Python is a "scripting" language OR a "programming" language -- because it's both. :-) So getting back to the question at hand, if I write a 10,000 line business application in Jython, I call it a "program". If I include in that program the ability for customers to add extra buttons to the UI along with a few lines of Python that act handlers for those added buttons, I call those handlers "script". The "script" in this case is not script *because* it is written in Python. It is "script" because it is code that has "script" -like capabilites and is being used in a "script"-like role (it is embedded in the framework of my application, you can write a few lines of code in a configuratio file and not have to compile it and link it, etc.). Jim From guido at python.org Sun Jul 8 08:21:28 2001 From: guido at python.org (Guido van Rossum) Date: Sun, 08 Jul 2001 12:21:28 GMT Subject: Comment on PEP-0238 References: <7ef50c46.0107070905.4f9fa92@posting.google.com> Message-ID: Timothy Grant writes: > I'm not the most gifted programmer on the planet, but I have had no > problem with the concept of integer division, in fact, when I need a > calculator I usually open the Python interpreter and do my math on > the command line. I've never had a problem remembering that if I > want a float result I need to make one of the numbers a float. Easy for you to say, since you seem to think mostly in terms of integers. For other people, and in other application domains, where floating point is the only type that makes sense, it's very easy to forget adding a decimal point to every constant you use. A typical example goes as follows: def velocity(distance, time): return distance / time The author of this function clearly assumes that the arguments are floats. But a user, thinking that ints are automatically converted to floats, it's totally necessary to write velocity(50000, 3600) # 50 km/h and get a result that is plausible but incorrect. Now imagine that this is part of a much large program doing physical calculations. Either we'd have to place a total ban on integer constants (a big pain), or we'd have to place float() casts around the arguments of function everwhere (an even bigger pain). > # It looks ugly but it really isn't. A couple of really nice > # Pythonisms > # make it work right. The first is list insertion, and the > # second is integer > # division. > > I guess I need to revise the comments in my code now... The *concept* of integer division won't go away. It will just be spelled differently (as div(x,y) or x div y). There's no need to update your comment. :-) --Guido van Rossum (home page: http://www.python.org/~guido/) From steve at lurking.demon.co.uk Tue Jul 24 03:42:28 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Tue, 24 Jul 2001 08:42:28 +0100 Subject: Hello, References: <9jeafl$46q$1@nntp9.atl.mindspring.net> Message-ID: On 22 Jul 2001 20:06:34 GMT, quinn at yak.ugcs.caltech.edu (Quinn Dunkan) wrote: >On Sun, 22 Jul 2001 06:43:18 +0500, Tom Bryan wrote: >>Alex wrote: >> >>> Not really. There are some ways you could speed up the python code: >> >>I'm also not really sure why one would want to do this, but... >> >>> There's the additional problem that >>> opening "err" will truncate the log file, and if an error occurs while >>> you're writing the new version back, you could lose messages. >> >>here's a version that makes a copy of the file before prepending a >>new message to avoid that problem. It also uses seek to avoid having > >I suggest appending the normal way, but viewing it with 'tac' :) Another possible alternative... In initialisation, read the main file, invert the order of the lines and save to a second temporary file... f = open ("file.log", "r") text = f.readlines ().reverse () f = open ("temp.log", "w") for i in text : f.write (i) While the program runs, log at the end of the temporary log file. Then on completion, reverse what you did at the start... f = open ("temp.log", "r") text = f.readlines ().reverse () f = open ("file.log", "w") for i in text : f.write (i) If the program ran for a while, this might be the better approach. You could also use the same general approach to print a normal-order log file in last-error-first order - remember to slice off the newline character at the end of each line before calling print though. Another approach is to save all your errors into a list of strings in memory and dump them out to err at the end - a risky one, though, if you get a bug that stops the log getting saved. From guido at python.org Fri Jul 27 16:01:04 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 27 Jul 2001 20:01:04 GMT Subject: 2.2 features References: Message-ID: John Schmitt writes: > Why do we have to wait for 2.2? You can do this already. > >>> import types > >>> types.IntType > > >>> assert isinstance(0,types.IntType) [me, earlier] > > assert isinstance(num, int) > > assert isinstance(msg, str) In 2.2 you don't have to import types. --Guido van Rossum (home page: http://www.python.org/~guido/) From bokr at accessone.com Sun Jul 8 18:14:51 2001 From: bokr at accessone.com (Bengt Richter) Date: Sun, 08 Jul 2001 22:14:51 GMT Subject: I'm Sure There's A Better Way References: <3B465858.CB7F38E8@tundraware.com> <9i6e5502d9g@enews4.newsguy.com> <3b478576.1314346961@wa.news.verio.net> <9i92mb02pnp@enews3.newsguy.com> Message-ID: <3b48d5b9.1400429941@wa.news.verio.net> On Sun, 8 Jul 2001 09:40:21 +0200, "Alex Martelli" wrote: >"Bengt Richter" wrote in message >news:3b478576.1314346961 at wa.news.verio.net... > ... >> >> dollar amount. Which means it follows these rules: >> >> >> >> First character is numeric or "-" > ... >> >This is very easy to express as a Regular Expression: >> > r'-?\d+(\.\d\d)?$' >> or >> r'^-?(\d*\.\d\d|\d+)$' >> if you want to allow .12 (or -.00), see below ;-) > >Yes, but that follows a very different spec from the one >given by the original poster, where the first rule was, as >above quoted, 'first character is numeric or "-"'. > >Getting the specs 'right' for a fuzzily defined domain is >challenging, I was just trying to help implement the >specs the poster thought were right:-). > > Well, ok, but did either of us really nail that? ;-) """ First character is numeric or "-" At most, one "." is allowed and, if present, is followed by exactly two digits All the remaining characters must be in the range "0" - "9" """ I missed because I allowed \.\d\d by itself, which has first character '.' not equal to '-' or digit. But according to the rules, ISTM you missed too, since you don't allow -\.\d\d, which has an ok first character. The rules don't say whether any digits must precede a '.' In fact, we probably both missed by not letting '-' by itself be legal ;-) Perhaps r'(-|\d)\d*(\.\d\d)?$' ? From sholden at holdenweb.com Wed Jul 18 15:42:39 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 18 Jul 2001 15:42:39 -0400 Subject: How to set a timeout? References: <9j446n$lom9k$1@fu-berlin.de> <9j4ntg$m8l0k$1@fu-berlin.de> Message-ID: "Matthias Huening" wrote in message news:9j4ntg$m8l0k$1 at fu-berlin.de... > Thanks, Marco, for pointing me to the signal-module. > > And, Steve, thank you very much for your 'other suggestion'. > I have to admit that I don't understand how it works but - it works!! > The asyncore-module is really great! Exactly what I was looking for. > > One question: while playing around with your example I noticed that there > seems to be a problem with virtual servers. Your http_client-class seems to > ignore virtual servers. E.g. the page: > http://www.niederlandistik.fu-berlin.de/mitarbeiter.html > is not found (but it exists...). > Any ideas? You might find you need to examine the HTTP response headers and access another page. I think that httplib does that for you, but you will have to code it yourself with asyncore. Here's a trace from a proxy trying to access that page on my browser's behalf. Did I get anything wrong? I cam certainly access the page in IE. In this case the server might not have liked the apparently-spoofed "Host:" header which the proxy just dumbly echoes out. By the way, the proxy is another Rushing-inspired tool! D:\Book1\Code\Ch7>python proxysample.py www.niederlandistik.fu-berlin.de 80 <==(0) 'GET /mitarbeiter.html HTTP/1.0\015' <==(0) 'Accept: application/vnd.ms-excel, application/msword, application/vnd.ms-powerpoint, image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*\015' <==(0) 'Accept-Language: en-us\015' <==(0) 'User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; MSNIA; Windows 98)\015' <==(0) 'Host: 127.0.0.1:8080\015' <==(0) 'Connection: Keep-Alive\015' <==(0) '\015' Connected ==>(0) 'HTTP/1.1 404 Not Found\015' ==>(0) 'Date: Wed, 18 Jul 2001 19:38:16 GMT\015' ==>(0) 'Server: Apache/1.3.9 (Unix) Debian/GNU PHP/4.0.3pl1 mod_ssl/2.4.10 OpenSSL/0.9.4\015' ==>(0) 'Connection: close\015' ==>(0) 'Content-Type: text/html; charset=iso-8859-1\015' ==>(0) '\015' ==>(0) '' ==>(0) '' ==>(0) '404 Not Found' ==>(0) '' ==>(0) '

Not Found

' ==>(0) 'The requested URL /mitarbeiter.html was not found on this server.

' ==>(0) '' regards Steve -- http://www.holdenweb.com/ From db3l at fitlinxx.com Wed Jul 25 15:59:26 2001 From: db3l at fitlinxx.com (David Bolen) Date: 25 Jul 2001 15:59:26 -0400 Subject: proposed language change to int/int==float (was: PEP0238 lament) References: Message-ID: "Terry Reedy" writes: > (IMO -- and attempting to be helpful again) This (and similar > statements) is rhetorically wrong and counter-productive. In PEP238, > you are NOT proposing to delete integer division (and I hope/presume > you never will), you are NOT proposing to switch it to C's version > (ditto), nor are you proposing any other substantive change (ditto). > From a technical viewpoint, you are merely, in Tim's words, proposing > to change it's spelling, so that future i//j == current i/j, down to > the very last bit. (...) Just for clarification, I don't think that's quite right. // is being proposed for integer division only. That is, unlike todays /, using // with two floats, while still yielding a float, would yield the floor() of what today's / would have yielded, and thus not the same "down to the very last bit" -- -- 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 gmcm at hypernet.com Mon Jul 2 09:51:44 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 02 Jul 2001 13:51:44 GMT Subject: New PEP: Quality Guidelines For Standard Modules References: Message-ID: <90D26BA98gmcmhypernetcom@199.171.54.194> Carlos Ribeiro wrote: [snip example of module global being misused] >... Also, if the state variable >is declared as a global, even reimporting the module will fail. This is untrue. I'm guessing you mean that given: from module import module_global reload(module) doesn't do what you want, but that's the fault of using "from ... import", not module's use of a global. - Gordon From ramsa at swva.net Sun Jul 29 21:56:08 2001 From: ramsa at swva.net (Patricia A. Shaffer) Date: Mon, 30 Jul 2001 01:56:08 GMT Subject: Try floating the Back Orifice's dumb PGP and Willy will recycle you! References: Message-ID: On Sun, 29 Jul 2001 22:27:33 GMT, "Nick Perkins" wrote: >I laughed at the first one of these I read, >thinking it might be the result of a python program, >but now I have noticed that they are popping up >on other newsgroups, too, all from different names. >Once is funny. Twice is spam. >I have seen four or five today. Poor dear, you've missed out on all the fun! C'mon over to nanae (news.admin.net-abuse.email) and join the party! Patricia ramsa at swva.net Proud Citizen of the Commonwealth of Virginia "Anti-spammers are the immune system of the Internet." CDR M. Dobson "The issue is consent, not content." Crosscut Help Outlaw spam! - From db3l at fitlinxx.com Tue Jul 31 19:49:01 2001 From: db3l at fitlinxx.com (David Bolen) Date: 31 Jul 2001 19:49:01 -0400 Subject: Arg decoding with a template? References: <4oA97.5883$9i1.519137@e420r-atl1.usenetserver.com> Message-ID: Dale Strickland-Clark writes: > I guess what I had in mind was a simple but effective equivelent > that I used to use with BCPL. A function called rdargs, which I > think also became part of AmigaDOS If you do get a moment to point to any reference or just write up a quick summary, I'm sure there would be some implementation suggestions available. Presumably any parsing template still has to deal with issues such as flagging options (optional pieces) versus standard arguments, delimiters and quoting them, etc... But there's obviously also multiple ways to make choices about each of those issues. -- -- 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 robin at jessikat.fsnet.co.uk Wed Jul 11 11:58:55 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Wed, 11 Jul 2001 16:58:55 +0100 Subject: Win2k Tkinter checkbuttons Message-ID: I'm having problems with menu checkbuttons under python2.1 running under win2k sp2. When I pop up a menu containing a ticked item I don't see all of the tick. When the mouse passes over the checkbutton the tick suddenly gets fully displayed. I have other Tk apps which seem to be able to do this eg tkCon, but stuff I build with Tkinter doesn't seem able to get this quite right. Anyone else seen/fixed this? -- Robin Becker From greg at cosc.canterbury.ac.nz Wed Jul 11 02:35:49 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 11 Jul 2001 18:35:49 +1200 Subject: Comment on PEP-0238 References: Message-ID: <3B4BF3C5.419FEC0D@cosc.canterbury.ac.nz> Tim Peters wrote: > > If you want to turn every + - * / etc into a long-winded function call No, I don't want to do that, obviously. But I also wouldn't like to see a piece of implicit state controlling the number of digits I get out of arithmetic operations. I've had experiences with that in Hypertalk, all of them bad. -- 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 Mon Jul 23 11:26:34 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Mon, 23 Jul 2001 16:26:34 +0100 Subject: python for AS400 ? Message-ID: <31575A892FF6D1118F5800600846864D78BEDF@intrepid> > From: dedalus at yifan.net [SMTP:dedalus at yifan.net] > is there a python version for AS400 ? See for Per Gummedal's port. 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 laurent.szyster at q-survey.be Sat Jul 7 02:30:12 2001 From: laurent.szyster at q-survey.be (Laurent Szyster) Date: Sat, 07 Jul 2001 08:30:12 +0200 Subject: openssl-python References: Message-ID: <3B46AC74.717BF64D@q-survey.be> phil hunt wrote: > > There's a package, openssl-python that lets you write python > programs that call functions in the OpenSSL library. > > Unfortunately i cannot find a homepage for it. All there > is that gets retuerned by Google is pages that link to RPMs > for it. Search for "M2Crypto". Laurent Szyster From aetodd at wm.edu Tue Jul 10 10:39:40 2001 From: aetodd at wm.edu (Andrew Todd) Date: Tue, 10 Jul 2001 10:39:40 -0400 (EDT) Subject: getpass() problems.. In-Reply-To: References: Message-ID: <994775980.3b4b13acc356e@webmail1.wm.edu> Hey, getpass() seems to be crashing my WinNT system. Is there some way I can manually change the echo to aterisks or something? I'm writing a _really_ simple program that just encrypts text files past in on the command line using the rotor module. I'm using getpass to get the key... is this a bad idea? Is there a better way? Andrew ~ elecfsh aetodd at wm.edu From martin at strakt.com Wed Jul 4 02:38:48 2001 From: martin at strakt.com (Martin Sjögren) Date: Wed, 4 Jul 2001 08:38:48 +0200 Subject: Problems with thread state In-Reply-To: <994174327.655299@yabetcha.drizzle.com> References: <994174327.655299@yabetcha.drizzle.com> Message-ID: <20010704083848.A595@strakt.com> On Tue, Jul 03, 2001 at 03:32:08PM -0000, Donn Cave wrote: > Quoth Martin Sjgren : > > | Seeing as a call to SSL_connect() might block, I surrounded the call to it > | by Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS. I also have a wrapper > | callback for verification (i.e. I plug my callback into OpenSSL and it > | calls a Python callback residing in a Context object)... Here's my > | problem: When I call PyEval_CallObject() in my wrapper callback, python > | segfaults! Some poking around with gdb shows that somewhere, before > | PyFrame_New() is called to execute the Python callback in, > | PyThreadState_Get() returns NULL! > > Prior to PyEval_CallObject(), you need to get back in line for the > Python thread you released with Py_BEGIN_ALLOW_THREADS. I do that > with PyEval_AcquireThread(PyThreadState *), and then after the > callback, PyEval_ReleaseThread(PyThreadState *). How do you get > the thread state? Not the way I do, I reckon, so I will leave > that to you. This is how I do it, in my MySSL_Connection_connect() if (PySocketSock_connect(self->socket, args) == NULL) return NULL; setup_ssl(self); // creates a BIO and some stuff Py_BEGIN_ALLOW_THREADS ret = SSL_connect(self->ssl); Py_END_ALLOW_THREADS // handle ret, etc But... SSL_connect may call a callback I've set, for verification purposes. This function looks somewhat like this: // find context and certificate and stuff argv = Py_BuildValue(...); ret = PyEval_CallObject(ctx->verify_callback, argv); Py_DECREF(argv); // handle ret, etc and this is where it crashes... Should I put in a PyThreadState pointer in my ctx objects that I set instead of using BEGIN_ALLOW_THREADS, so I can release and re-acquire around the CallObject? Thanks a lot for your help -- Martin Sj?gren martin at strakt.com ICQ : 41245059 Phone: +46 (0)31 405242 Cell: +46 (0)739 169191 GPG key: http://www.strakt.com/~martin/gpg.html -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 248 bytes Desc: not available URL: From tjreedy at home.com Thu Jul 26 15:35:57 2001 From: tjreedy at home.com (Terry Reedy) Date: Thu, 26 Jul 2001 19:35:57 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <9jnt9p$qhe$1@newsy.ifm.liu.se> Message-ID: I believe that 5.0//2.0 will be 2.0, not 2 TJR From tjreedy at home.com Thu Jul 12 14:25:24 2001 From: tjreedy at home.com (Terry Reedy) Date: Thu, 12 Jul 2001 18:25:24 GMT Subject: pythonista.com References: Message-ID: > If an open source(ish) project doesn't come forward for it let me know > bosahv at netscape.net. Like I said I don't know what I'd do with it but I > think I'll pay whatever transfer stuff to keep it 'in the family' so to > speak. Probably easiest and cheapest to let it expire and reregister the next day. From simonb at webone.com.au Sun Jul 15 10:07:18 2001 From: simonb at webone.com.au (simonb at webone.com.au) Date: Mon, 16 Jul 2001 00:07:18 +1000 Subject: How to add type "int" to string ? References: <692684d4.0107150512.5b7d9ccd@posting.google.com> Message-ID: <3B51A396.4020302@webone.com.au> >>> "hello world"+chr(0x00) 'hello world\000' is that what you wanted? shuibo wrote: >Hello all : >in my program I want to give a char variable a Hex value , for example : >a = "Hello World" >a = a + 0x00 >but it display "cannot add type int to string" >what can I do ? >thanks very very much ! > From dsh8290 at rit.edu Tue Jul 3 13:18:40 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 3 Jul 2001 13:18:40 -0400 Subject: Calling a user-defined Exception from within a function. Need Help. In-Reply-To: <9hsmbn+781@eGroups.com>; from jestes39@yahoo.com on Tue, Jul 03, 2001 at 02:54:47PM +0000 References: <9hsmbn+781@eGroups.com> Message-ID: <20010703131840.F22543@arizona.cs.rit.edu> On Tue, Jul 03, 2001 at 02:54:47PM +0000, jestes39 at yahoo.com wrote: | I am still learning Python basics. I am trying to raise exceptions | within a function. The problem is that my named exceptions aren't | being recognized. They were working before I split the code up into | modules. I just need to know where I need to define the exceptions or | if I have to do something special to get them to work. Here's the | basic shell of the code: | | import sys | import telnetlib | import dbi,odbc | import exceptions | | class database_error(exceptions.Exception): ... | class other(exceptions.Exception): ... | def parse(record): | try: | #Parse the row into the variables that will be used to | # populate the receiving fields | ..... | ..... | return 'TRUE' | except: | return 'FALSE' IMO it is better to raise an exception than to catch all of them and return a boolean. This is Python, not C, after all :-). | def receipt(record): ... | if parse(record) == 'FALSE': For example, here, you could just let the exception from 'parse' propagate upwards, rather than checking the return value and then raising a new exception. | raise other I think this line is wrong, but I could be wrong. Can classes be raised, or just instances? I think you mean to raise an instance anyways so change it to raise other() | except database_error: | dbc = None | crsr = None | tn.close() | print 'we made it to the database exception' | except other: | dbc = None | crsr = None | tn.close() | print 'unidentified error' | except: | dbc = None | crsr = None | tn.close() | print 'unhandled exception' The first 2 except clauses can be simplified down to : except (database_error , other ) err : dbc = None crsr = None tn.close() print err # let the exception itself define what a useful # message will be The only difference here is that unexpected exceptions are caught (such as SystemExit, as Steve mentioned). Alternatively, if you want the error (exception) to propagate upwards, you can use a 'finally' clause : finally : dbc = None crsr = None tn.close() print sys.exc_info() # this gives you access to the # exception, but check the spelling as # I'm not 100% certain Which one you should use depends on the exact semantics you want in your program. -D From salnikov at inp.nsk.su Sun Jul 22 23:42:10 2001 From: salnikov at inp.nsk.su (Andy Salnikov) Date: Mon, 23 Jul 2001 10:42:10 +0700 Subject: PEP0238 lament References: <3B5B3676.40F39389@alcyone.com> Message-ID: <9jg6ei$ges7$1@sky.inp.nsk.su> "Robin Becker" wrote in message news:vyIKbWAP62W7EwC+ at jessikat.fsnet.co.uk... > > I think that is wrong, but I use python in a professional capacity. I > think languages succeed or fail because they work for programmers. Yeah, completely agree. Personaly, if this change happens, it will be a big revolt from Python for me. Not only for aesthetic reasons, simply because I cannot rely on the language which dares to change the meaning of existing operators. What do you think will be next? Change assignment to work like a copy, because there are many people confused with the reference semantic? I almost hear how manager staff saying: "Do you talk about that sh**ty snake language which changes its rules every year? Don't even think about it in our project!" Guys, if you really need something returning floats for division, make it new operator, I guess everyone could be made happy with 1/2 == 0 and 1//2 == 0.5. Cheers, Andy. From nperkins7 at home.com Mon Jul 23 14:22:02 2001 From: nperkins7 at home.com (Nick Perkins) Date: Mon, 23 Jul 2001 18:22:02 GMT Subject: incrementing characters References: <9jhojp$t7h$1@solaria.cc.gatech.edu> Message-ID: "Holland King" wrote in message news:9jhojp$t7h$1 at solaria.cc.gatech.edu... > how do you interate a letter or string? for instance: > a + 1 = b > or > aa + 1 = ab > etc. in c it is similar to above and i am guessing there is an equally > simple way to do it in python, i just can't figure it out. thank you > for your time and help. > > -- > --- > 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 I think you mean "increment"... For one character, it's simple: >>> ord('A') 65 >>> chr(65) 'A' >>> chr(66) 'B' For a string, you will have to mess around a bit. Remember, strings are immutable, so you will have to construct a new string. def inc_char(ch): return chr(ord(ch)+1) def inc_string(s): return s[:-1] + inc_char(s[-1]) ..add you own error checking, etc... From tanzer at swing.co.at Fri Jul 27 04:39:30 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Fri, 27 Jul 2001 10:39:30 +0200 Subject: PEP238 and zope In-Reply-To: Your message of "Wed, 25 Jul 2001 12:45:35 EDT." <15198.63407.158009.6372@anthem.wooz.org> Message-ID: barry at zope.com (Barry A. Warsaw) wrote: > >>>>> "CT" == Christian Tanzer writes: > > >> really-portable-code-is-always-ugly-anyway-ly y'rs, > > CT> So-lets-make-it-even-uglier-?-ly y'rs, > > I don't consider int(math.floor(a / b)) to be ugly. In fact, it's > arguably much more Pythonic: Explicit is better than implicit. > There's no ambiguity in intention with that idiom, like there is with > bare a / b. As they say (at least in german): `tastes vary`. If `a` and `b` are integer numbers, I consider int(math.floor(a / b)) to be considerably uglier than int(a / b) Both are explicit, but use of a floating point function like floor in a pure integer context is less than obvious. Besides, the quotient operation might be part of a bigger expression -- even the use of a single function call might reduce readability there. -- 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 James_Althoff at i2.com Mon Jul 9 15:06:51 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Mon, 9 Jul 2001 12:06:51 -0700 Subject: Comment on PEP-0238 Message-ID: Tim Peters wrote: >The last time we solved a "it's *hard* to make sure temporary context >changes get undone!" problem in Python was via adding ">>" to "print" <0.8 >wink>. Python may want a more general approach to this kind of thing. I'm hoping for the possibility of Python someday supporting "unnamed, in-place (and fully functional)" code blocks as a possible "more general approach" (a la Smalltalk and Ruby). context.withPrecisionDo(max(8, oldp + 3)): do stuff return roundtoprecision(result, oldp) lock.whileAcquiredDo(): do stuff mySideEffectObjectDo(args): do stuff myFunkyCursor.showDuring(): do stuff myFile.whileOpenDo(): do stuff etc. (Ignoring vexing details of syntax, semantics, etc. :-) Jim From Randy.L.Kemp at motorola.com Wed Jul 11 16:35:44 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Wed, 11 Jul 2001 15:35:44 -0500 Subject: Is Python Dead? Long Live Python! Message-ID: I really can't speak for Ruby or PHP, as I can only work on the assumption that the gentleman that wrote the original work has accurate information. But I also wonder about that. How does PHP compare, in comparison to ASP, JSP, and Cold Fusion? JSP is free if you run Tomcat, PHP is free, and APS is free if you run Windows and IIS. The only one I question is Cold Fusion, which costs a few thousand. And as far as Ruby goes, how many of those business needs lie outside Japan? And Sun has picked up other big names (has anyone heard of IBM and Oracle?) on the J2EE bandwagon. To set the record straight, I am pro Python. But it is hard to get others at my company on that bandwagon. I have a hard enough time selling Perl. -----Original Message----- From: "J?rgen A. Erhard" [mailto:juergen.erhard at gmx.net] Sent: Wednesday, July 11, 2001 2:41 PM To: Kemp Randy-W18971 Cc: python-list at python.org Subject: Re: Is Python Dead? Long Live Python! >>>>> "Kemp" == Kemp Randy-W18971 writes: Kemp> So an interesting question is raised. Is it? Kemp> If PHP and Ruby are gaining acceptance because they address Kemp> business needs, what needs to be done to carry Python in Kemp> that direction? *If*! We can debate to no end whether PHP and Ruby are gaining acceptance, in business circles. And PHP and Ruby are quite different beasts. I'm looking on my Debian system... and lo and behold, I don't see any significant app or tool written in Ruby. Okay, that might not mean too much... I can find tons of *important* stuff using Python, however (apt-cache showpkg python-base scrolls off the screen... a 60 line screen. The same for ruby fits nicely) Kemp> And while Java may be slow, Sun pushing it for business Kemp> solutions also gives that language acceptance. How can Kemp> Python become as popular as Perl, Java, or PHP? What Paul said... especially concerning Java. Just Sun alone probably has a marketing budget for Java that no company in the Python camp can match. Bye, J PS: This will really (yeah, sure ;-) be the last from me in this thread. -- J?rgen A. Erhard (juergen.erhard at gmx.net, jae at users.sourceforge.net) MARS: http://members.tripod.com/Juergen_Erhard/mars_index.html GNU Privacy Guard (http://www.gnupg.org) I have a firm grip on reality, now I can strangle it. From skip at pobox.com Fri Jul 13 19:50:21 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 13 Jul 2001 18:50:21 -0500 Subject: PEP: Defining Unicode Literal Encodings (revision 1.1) In-Reply-To: <3B4F746C.827BD177@lemburg.com> References: <3B4F6E98.733B90DC@lemburg.com> <004c01c10be8$af2face0$4ffa42d5@hagrid> <3B4F746C.827BD177@lemburg.com> Message-ID: <15183.35133.264728.399408@beluga.mojam.com> mal> Here's an updated version which clarifies some issues... ... mal> I propose to make the Unicode literal encodings (both standard mal> and raw) a per-source file option which can be set using the mal> "directive" statement proposed in PEP 244 in a slightly mal> extended form (by adding the '=' between the directive name and mal> it's value). I think you need to motivate the need for a different syntax than is defined in PEP 244. I didn't see any obvious reason why the '=' is required. Also, how do you propose to address /F's objections, particularly that the directive can't syntactically appear before the module's docstring (where it makes sense that the module author would logically want to use a non-default encoding)? Skip From XQ.Xia at ccsr.cam.ac.uk Wed Jul 18 09:26:30 2001 From: XQ.Xia at ccsr.cam.ac.uk (XiaoQin Xia) Date: Wed, 18 Jul 2001 14:26:30 +0100 Subject: Stop a duty in a Tkinter program Message-ID: <3B558E86.1E7441C4@ccsr.cam.ac.uk> Hi, everybody, I am programming with Tkinter. After the user click "Go" button or menu, my program will carry out some operation which won't stop until the end time (which is set by user) reach. In order to let user interupt the operation, a "Stop" button is present. But during the period of the operation, my program is not able to respond to any click at all, it seems dead before the operation finished. How can I terminate the operation without exit the program? Any help is welcome. Cheers, Xiao-Qin Xia From duncan at NOSPAMrcp.co.uk Wed Jul 25 03:59:07 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Wed, 25 Jul 2001 07:59:07 +0000 (UTC) Subject: PEP0238 lament References: <9jhbfj$79s$1@pea.uk.research.att.com> <9jjfts$9k2$1@pea.uk.research.att.com> <3B5DBAC8.4B89E271@alcyone.com> Message-ID: Erik Max Francis wrote in news:3B5DBAC8.4B89E271 at alcyone.com: > I find it pretty horrifying that this change is even being seriously > considered much less is evidently going forward. That I find the > benefits (namely, making the language easier for novices to understand; > integer division is not very hard to understand and have not known > anybody learning programmer for which this was absolutely a deal breaker > and totally inhibited their ability to learn a language) to be of > dubious value only makes it more disturbing. When it comes down to it, real beginners (5 to 7 years old?) will have been told that if you divide 9 by 2 you get 4 with 1 left over. Which is EXACTLY what you get at present. Floating point is a MUCH more sophisticated concept which, as has been shown repeatedly on this newsgroup, is hard even for most programming professionals. -- 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 ben.hutchings at roundpoint.com Wed Jul 4 07:38:24 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 04 Jul 2001 04:38:24 -0700 Subject: Interpreter hangs after calling my extension References: Message-ID: Martin von Loewis writes: > Ben Hutchings writes: > > > 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. > > Your code looks fine to me. Are you running it from IDLE or PythonWin? > If so, don't be surprised that nothing is displayed immediately; you > may need to trigger a repaint. So I recommend to run it in the console > version first. I was running it in the console. In PythonWin these problems don't occur. So perhaps the CVS DLL does something strange to the console. In any case, I think that's where I should be looking now. Thanks for looking over my code. > Next, you probably have to start debugging through the Python code, as > well. You'll need the debug version of Python for that so VC++ can > locate the source code properly. Right. From skip at pobox.com Tue Jul 17 18:23:39 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 17 Jul 2001 17:23:39 -0500 Subject: Python 2 times slower than Perl In-Reply-To: <87itgrmf9k.fsf@elbereth.ccraig.org> References: <8f41cfd.0107171238.6ff33b9b@posting.google.com> <87itgrmf9k.fsf@elbereth.ccraig.org> Message-ID: <15188.47851.965197.196645@beluga.mojam.com> Christopher> This is, in this case, incorrect. Unless I am horribly Christopher> mistaken, the higher cost of dealing with globals is that Christopher> you first have to do a failed lookup in the local Christopher> dictionary. (Plus failed lookups are more expensive than Christopher> successful ones) (Note: I trimmed the endpoint from 1e7 to 1e6): simple1.py: i = 2.5 while i < 1e6: j = 2.5 * 2.5 i += 1 print i, j simple2.py: def func(): i = 2.5 while i < 1e6: j = 2.5 * 2.5 i += 1 print i, j func() Result: % time python simple1.py 1000000.5 6.25 4.04user 0.00system 0:04.13elapsed 97%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (323major+138minor)pagefaults 0swaps % time python simple2.py 1000000.5 6.25 3.00user 0.00system 0:03.06elapsed 97%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (323major+138minor)pagefaults 0swaps QED. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From db3l at fitlinxx.com Fri Jul 27 02:11:46 2001 From: db3l at fitlinxx.com (David Bolen) Date: 27 Jul 2001 02:11:46 -0400 Subject: PEP 238 (revised) References: Message-ID: "Terry Reedy" writes: > "David Bolen" wrote in message > news:upuanumtb.fsf at ctwd0143.fitlinxx.com... > > > Is the polymorphic argument really true here? > > I think so, even though Guido made it look asymetric in the first > paragraph. I can easily imagine that I would want a formula like > (n-1)//k to give the same numerical value regardless of whether n > enters as 20 or 20.0 -- the same as (n-1)*k does. Why should one work > polymorphically and the other not? I'm not sure I follow - the section is discussing an alternative where // does the true division, so the new // functionality would be polymorphic for true division? The "argument" I'm not sure about is that leaving / alone still leaves a problem case when trying to use it (e.g., the existing classic function with /) in some other polymorphic case. I'm just not sure what that case is. If in the above, you meant / rather than //, then either you want an integer result polymorphically (in which case I'd think int(expr) would work), or you want a float result polymorphically (in which case you'd use // for true division instead). Yes, the existing classic operator on its own might not give you the integer polymorphic result, but it's not "hard" to write as specified here. -- -- 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 rnd at onego.ru Sun Jul 15 01:46:34 2001 From: rnd at onego.ru (Roman Suzi) Date: Sun, 15 Jul 2001 09:46:34 +0400 (MSD) Subject: Need help with "global" variables In-Reply-To: Message-ID: On Sun, 15 Jul 2001, Nick Perkins wrote: >Your modules are going to have to import the globals. You could put them >all in a separate file, call it "my_globals.py", and then in each file >(including the 'main' file), you would have: >from my_globals import * This assumes globals are constants. If you want them to change, you can put them to class/object: class Dummy: pass globs = Dummy() globs.var1 = 1.23 globs.var2 = 2.34 ... BTW, globals and object attributes take more time to get than locals. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Sunday, July 15, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "This is Borg. is futile is inevitable" _/ From peter.zettler at gmx.net Wed Jul 4 03:53:39 2001 From: peter.zettler at gmx.net (Peter Zettler) Date: Wed, 04 Jul 2001 07:53:39 GMT Subject: Binding for Open Cascade Message-ID: <1103_994233219@creepy-pz> Hey there, does anybody know if someone is working on a Open Cascade binding for Python? For Open Cascade see www.opencascade.org Regards, Peter Zettler From sholden at holdenweb.com Mon Jul 30 10:07:34 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 30 Jul 2001 10:07:34 -0400 Subject: Loaded module list and attributes References: Message-ID: "Dale Strickland-Clark" wrote in message news:o2mamt4qtis8r77maqnsmjg7h193aa80t4 at 4ax.com... > How do I itterate through all the loaded modules and find the name of the module and a value of a > local attribute (__version__ in this case)? > > I'm writing a small debugging routine and Python internals are still a bit of a black box to me. > > Thanks. Probably you want to iterate over sys.modules -- one way to do this is: for k in sys.modules.keys(): module = sys.modules[k] print module.__version__ However you will need to ensure that a particular module HAS a __version__ attribute before referencing it, or trap the AttributeError exception which will result when it doesn't. regards STeve -- http://www.holdenweb.com/ From tanzer at swing.co.at Fri Jul 27 04:55:37 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Fri, 27 Jul 2001 10:55:37 +0200 Subject: Version compatibility in division In-Reply-To: Your message of "Wed, 25 Jul 2001 17:37:53 EDT." Message-ID: "Tim Peters" wrote: > [David Bolen] > > ... > > Then again, the bigger problem with int() is the potential for > > rounding that is, at least theoretically, permitted by the > > implementation, although as someone else pointed out, it's not clear > > that any C libraries actually do that. > > Guido suggested that "someone" (certainly me) change Python's implementation > so that int() and long() always truncate, regardless of what the platform C > happens to do. I can do that, no problem. > > There are no known platforms on which that will make a lick of difference, > except to make Python run slower. But that doesn't mean no such platforms > exist. And making a particular Python operation run slower can change the > behavior of, e.g., threaded apps. It's also the case that platforms > certainly vary even now in how int(infinity) and int(NaN) behave (since C89 > is silent on those cases), and that they may suffer some different > accidental behavior in these cases after the change. Judging by your many other posts, I think you'll be able to avoid any performance hit for all the platforms where C does the right thing anyway. I don't see how changing previously undefined behavior to platform-indpendent behavior makes you worry, though. As far as I understood one of your previous posts about this topic, moving to a C99(?) compiler would have the same effect anyway. For sure you aren't planning on introducing `from __future__ import C99_semantics` for when Python migrates to one of these new-fangled compilers ? > So is this a change we should be frightened of? Do we need a > > from __future__ import int_and_long_guaranteed_to_truncate > > statement to enable it? > > I think that would be absurd, but from an implementer's point of view it's > the plain truth that no change is without consequences. So it is. That's-what-pragmatism-was-invented-for-y'rs, Christian -- 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 chris.gonnerman at newcenturycomputers.net Fri Jul 27 08:40:31 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Fri, 27 Jul 2001 07:40:31 -0500 Subject: web sessions support References: <3B5BE6CC.9B71B87E@stroeder.com> <015001c1165c$8106e6c0$0101010a@local> <3B611DB7.480D5FA5@stroeder.com> Message-ID: <000d01c11699$5793dcc0$0101010a@local> Oooooops... that'll teach me to post after Midnight... :-0 ----- Original Message ----- From: "Michael Str?der" > Chris Gonnerman wrote: > > > > What I'd like to see is a working example of *using* one or more of > > the given session managers... I'm afraid that just reading the source > > is not helping me. > > Did you check out the cgi-bin/test-session.py shipped > in PyWebLib's tar.gz file ? > > Ciao, Michael. From skip at pobox.com Sat Jul 21 18:54:09 2001 From: skip at pobox.com (Skip Montanaro) Date: Sat, 21 Jul 2001 17:54:09 -0500 Subject: Language change and code breaks (fwd) In-Reply-To: <9jbp9l$90f$1@apollo.csd.net> References: <3b5873ba.2423857703@wa.news.verio.net> <9jbp9l$90f$1@apollo.csd.net> Message-ID: <15194.2065.803389.649592@beluga.mojam.com> >> That does bring up the subject of machine-generated symbols though. >> And case sensitivity in dictionaries. I use base52 [A-Za-z] encoded >> md5's in certain contexts. If I use those as keys, will it break? kosh> Losing case sensitivity in dictionaries would screw me pretty kosh> badly also. I think case-sensitivity as we are discussing in this thread runs only to identifier and attribute names, not the contents of strings, so while date = 1 DATE += 1 print Date should print "2" by my understanding, dict = {"date": 1, "DATE": 2, "Date": 3} would create a dictionary of length 3. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From larryd at musicalheritage.org Fri Jul 13 17:07:02 2001 From: larryd at musicalheritage.org (Lawrence D) Date: 13 Jul 2001 14:07:02 -0700 Subject: dependencies question on 2.1-5 References: Message-ID: thank you. From aleaxit at yahoo.com Sat Jul 14 03:24:00 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 14 Jul 2001 09:24:00 +0200 Subject: How to run codeobjects in Python? References: <9imphr015u5@enews1.newsguy.com> <3B4FBBD8.45F56742@engcorp.com> Message-ID: <9iorv60pj2@enews4.newsguy.com> "Peter Hansen" wrote in message news:3B4FBBD8.45F56742 at engcorp.com... ... > Alex, please consider moving closer to the Eastern Standard timezone > so that you may answer my questions more quickly. What's so special > about Italy anyway? Pasta, of course. You guys can claim your pizza is as good as Italy's (I'd disagree, but there IS space for debate), but our pasta is still nonpareil -- people who decry spaghetti coding don't know what they're blabbering about! Alex From guido at python.org Tue Jul 17 09:29:11 2001 From: guido at python.org (Guido van Rossum) Date: Tue, 17 Jul 2001 13:29:11 GMT Subject: memory leak with dynamically defined functions? References: Message-ID: zooko at zooko.com writes: > But if I allocate memory and store a reference to it in a default argument to > an inner function, like this: > > >>> def silliest_func(): > >>> x = [0] * (2**10) > >>> def inner_silliest_func(x=x): > >>> pass > >>> return inner_silliest_func > >>> > >>> blarg = {} > >>> for i in range(2**13): > >>> blarg[i] = silliest_func() > > and then remove the references to this memory, like this: > > >>> del blarg > > none of the memory is freed up! Hi Zooko, How do you know that the memory isn't feed up? I've tried this with 2.0 and with the current CVS, and it doesn't leak. If you're looking at process size, there are lots of good reasons why the process size doesn't go down -- but if you do this in a loop, you'll see it doesn't grow: >>> def ps(flags = "-l"): import os os.system("ps -p %d %s" % (os.getpid(), flags)) >>> def f(): x = [0]*2**10 def g(x=x): return x return g >>> while 1: ps() b = {} for i in range(2**13): b[i] = f() Could it be that the real code that does blow up have more intricate behavior that isn't captured by your example? What Python version are you using where you have observed this in your server? --Guido van Rossum (home page: http://www.python.org/~guido/) From cribeiro at mail.inet.com.br Tue Jul 3 07:07:27 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Tue, 03 Jul 2001 08:07:27 -0300 Subject: New PEP: Quality Guidelines For Standard Modules Message-ID: <5.0.2.1.0.20010703080216.026f3ab0@mail.inet.com.br> I've got some very good comments on my PEP-to-be. The main concerns are: - we need to reference the style guide - the use of tools such as PyCheck should be encouraged - and yes, my english needs some quality checking also :-) I'm going to work on it tonight. Too bad I have a day job . As of now, I'm still waiting for Martin's proposed PEP2 text - it seems that he still needs to get either Barry Warsaw or ESR approval on this, mainly because he's taking over an existing but unfinished PEP. I feel that we're talking about complementary issues, and it would be very important to be working together. Carlos Ribeiro From GADGILP at INFOTECH.ICICI.com Wed Jul 4 07:32:10 2001 From: GADGILP at INFOTECH.ICICI.com (GADGIL PRASAD /INFRA/INFOTECH) Date: Wed, 4 Jul 2001 17:02:10 +0530 Subject: Is there a K&R on Python? Message-ID: hi, I think the "python tutorial" + "language reference" provided by the python standard distro is something that comes close. Small tutorial plus a neat language reference and both provided by the same ppl that designed the language. I have not yet purchased a python book, and using the above. I too, wanted a smallest and best book for it like K&R :) /prasad -----Original Message----- From: Simon Brunning [mailto:SBrunning at trisystems.co.uk] Sent: Wednesday, July 04, 2001 4:17 PM To: python-list at python.org Cc: 'Nicola.Musatti at ObjectWay.it' Subject: RE: Is there a K&R on Python? > From: Nicola Musatti [SMTP:objectway at divalsim.it] > I'm looking for a Python book to use as a desktop reference on the core > language (rather than the library, available modules, third party > toolkits, etc), neither a tutorial nor something meant for language > lawyers only. Something analogous in style to Kernighan & Ritchie's "The > C Programming Language" would be perfect. Any suggestions? Hmmm. I thought K&R *was* a tutorial. Anyway, there are two books which nearly fit the bill. The first is Mark Lutz's 'Python Pocket Reference' (O'Reilly). This is *very* similar in style and content to the on-line quick reference (see ). It covers Python 1.5.1 - I don't know if a 2.1 version is planned. The other is David Beazley's 'Python Essential Reference' (New Riders). This is rather larger, and covers both the core language and most of the Standard Library. The 2nd edition was published recently, and covers Python 2.1. To me, this really *is* essential. YYMV. 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. -- http://mail.python.org/mailman/listinfo/python-list . -------------- next part -------------- An HTML attachment was scrubbed... URL: From tim.one at home.com Sun Jul 8 23:24:06 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 8 Jul 2001 23:24:06 -0400 Subject: Confusion about dictionaries - keys use value or identity? In-Reply-To: Message-ID: [Roy Smith] > ... > I'm writing a parser for a kind of text file we use a lot. The main > loop of the parser is a state machine. In each state, the current > input line is tested to see if it matches one or more regular > expressions, and based on which (if any) it matches, you do some > processing and advance to the next state. Something like: > > state = "cvsid" > for line in inputfile.readlines(): > if state == "cvsid": > if re.match ("^\s*$\s*Id:([^$]*)$\s*$", line): Always use r-strings for regexps! You're going to get "mysterious failures" if you don't, as time goes on and you change the regexps. For example, add a \b to the above to match at a word boundary, and it's actually going to insist on matching a backspace character instead. It's just an accident that "\s" yields a two-character string and leaves the backslash intact, while "\b" yields chr(8). r-strings are WYSIWYG in all cases. > state = "header" > elif state == "header": > if re.match ("big ugly pattern", line): > do some stuff > state = "what comes after the header" > > and so on. I'll end up with about a dozen different states, with > perhaps 2 dozen different regex's. Here's the dilema. If I write > it as I did above, the regex's will get compiled each time they're > evaluated, which is clearly inefficient in the extreme. The good news is that this part isn't true: all versions of Python have always maintained an internal compiled-regexp cache, mapping regexp strings to their compiled forms, much like the one you sketched building "by hand" later. Current Python maintains a cache of 100 pairs. The bad news is that I recommend the alternative anyway: > The alternative would be to re.compile() all the regex's once, at the > top, then use the stored programs, The great *advantage* to this is that you wouldn't be so reluctant to exploit re.VERBOSE mode if the regexps were compiled at module level. The clarity added by using whitespace and inline comments to document the *intent* of regexp gibberish is of overwhelming maintenance value. > something like this: > > cvsPattern = re.compile ("^\s*$\s*Id:([^$]*)$\s*$") > [...] > if cvsPattern.match (line): > state = header > > and so on. This would certainly work, but it moves the regex's away > from where they are used, making (IMHO) the program more difficult to > read and understand. re.VERBOSE mode regexps can be much easier to read and understand; so long as you leave them inline, you're going to tend (as your examples *do*) to squash them into as little space as possible with no explanation at all. > It reminds me of the bad old days when we would collect all > our FORTRAN format statements at the back of the deck. See > http://www.python.org/doc/Humor.html#habits for why I don't want > to do that any more :-) There's one huge difference: FORMAT statements were identified by meaningless integers, but you can give compiled regexp objects descriptive names instead. BTW, abstract away a little more, and you can likely build an entirely table-driven state machine for this task, with simple and uniform code that merely walks the table. Nested dicts make great state-machine tables. From martin at strakt.com Mon Jul 9 03:19:43 2001 From: martin at strakt.com (Martin Sjögren) Date: Mon, 9 Jul 2001 09:19:43 +0200 Subject: socket module Message-ID: <20010709091943.A18359@strakt.com> Is there ANY way to use the socket module from a Python module written in C? I mean, sure I could use BSD sockets right away, but that's really reinventing the wheel since the Python socket module is a good, portable module (AFAIK). So, is there any way short of doing a s/static//g in socketmodule.c? Martin -- Martin Sj?gren martin at strakt.com ICQ : 41245059 Phone: +46 (0)31 405242 Cell: +46 (0)739 169191 GPG key: http://www.strakt.com/~martin/gpg.html From nperkins7 at home.com Wed Jul 11 17:40:52 2001 From: nperkins7 at home.com (Nick Perkins) Date: Wed, 11 Jul 2001 21:40:52 GMT Subject: Tuple Semantics - Rationale'? References: <3B4CA0A8.20B53230@tundraware.com> Message-ID: "Quinn Dunkan" wrote in message """ Large complicated data structures of nested tuples might be a mistake. Tuples and python's simple pattern matching can be handy for small ad hoc types, but don't forget about classes. """ Yes, ...but I have found one good use for such 'tuple gymnastics'. ( perhaps this is what you mean by 'pattern matching' ) When you want to have a dictionary that uses some type of object as a key, but you want 'identical' objects to considered 'the same', you can pack the relevant bits of an instance's data into a tuple, and use it as the dict key. example: Suppose you want to keep track of the color any given x,y point... >>> class point: ... def __init__(self,x,y): ... self.x = x ... self.y = y ... def as_tuple(self): ... return (self.x,self.y) ... >>> p1 = point(3,4) >>> p2 = point(3,4) >>> color = {} >>> color[p1]='red' >>> color[p2] Traceback (most recent call last): File "", line 1, in ? KeyError: <__main__.point instance at 01373A6C> # not the same instance >>> color[p1.as_tuple()]='red' >>> color[p2.as_tuple()] 'red' >>> # ..but the generated tuples are considered the same This example is trivial, but I have used the same technique for much more complicated objects, often generating a 'stucture of tuples', much like the original poster was using. Such a structure is, of course, unweildy, but it makes a great dictionary key! You can pick and choose which bits of instance data to include, depending on your needs. I have used this to detect the (unwanted) generation of multiple, similar objects. And the good news is that you never have to manually extract info from the tuple, at all. Another variation is to keep a dict which maps the tuple back to the object itself, if that suits your needs. From qrczak at knm.org.pl Fri Jul 27 11:49:05 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 27 Jul 2001 15:49:05 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: Message-ID: 28 Jul 2001 02:17:57 +1200, Paul Foley pisze: > Paul> The most obvious problem is that it implies that every rational > Paul> can be represented as a float -- this is *severe* brokenness you > Paul> don't need. [I think it also implies that floats with integral > Paul> values (1.0, etc.) should turn into integers.] > >> You can't do that. Suppose that value you think is 1.0 really got truncated > > Yeah; that's exactly my point! But my model never treats a float as an integer, even if it's equal to 1.0. Where does it give a wrong answer? It doesn't claim that rationals are exactly representable as floats and doesn't implicitly turn floats into rationals. What's wrong with it? -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From pmoscatt at iprimus.com.au Wed Jul 18 23:48:12 2001 From: pmoscatt at iprimus.com.au (Peter Moscatt) Date: Thu, 19 Jul 2001 13:48:12 +1000 Subject: Retreiving a single number from a list of numbers ? Message-ID: <3b565953@news.iprimus.com.au> I am trying to extract a value from a variable that contains more than one value. For example: If I assigned the result of wxGetClientDisplayRect() to the var 'a' like: a = wxGetClientDisplayRect() the 'a' would return something like (0, 0, 800. 540) How then would I assign the 800 from 'a' and give it to a var called 'b' ?? Regards Pete From chris at voodooland.net Sun Jul 8 18:39:45 2001 From: chris at voodooland.net (Chris Watson) Date: Sun, 8 Jul 2001 17:39:45 -0500 (CDT) Subject: license suggestions? In-Reply-To: <3b477513$0$322$8eec23a@newsreader.tycho.net> Message-ID: <20010708173310.D92972-100000@open-systems.net> On Sat, 7 Jul 2001, Neil Macneale wrote: > I am wondering if there is a straight forward license which I can use for > python code I plan to distribute. Is there a standard header, or > possibly a link that can be placed in a header which basically says that > people use the code at there own risk, and that they are free to change > it? I ask here because I know there has been conflict between python and > GPL. Is there some vanilla header that people in this group use? This is what I use. A standard 2 clause (clause 1 and 2) FreeBSD style copyright but with my own clause 3 to PREVENT people from GPL'ing my code and thereby RESTRICTING its useage. I call it the static BSD License. Once it's BSDL'ed it can't be made any less free. It's the closest thing to public domain you can get yet still cover you A$$ from liability, and the like. It keeps the code BSDL'ed and prevents someone from GPL'ing it basically. If a company wanted to license it differently I would have ZERO problem letting them license it for their own needs whatever that may be. I just REFUSE to let the code be GPL'ed. Hence clause 3. # Copyright 2001 Chris Watson (scanner at jurai.net). All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer. # 3. No changes are made to this license and/or additional terms of use # are placed without prior written permission from Chris Watson. # # THIS SOFTWARE IS PROVIDED BY CHRIS WATSON ``AS IS'' AND ANY # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CHRIS WATSON OR CONTRIBUTORS # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF # THE POSSIBILITY OF SUCH DAMAGE. From bh at intevation.de Thu Jul 12 13:41:28 2001 From: bh at intevation.de (Bernhard Herzog) Date: 12 Jul 2001 19:41:28 +0200 Subject: Can anyone offer a suggestion? References: <9ikgpq$j1cff$1@ID-11957.news.dfncis.de> Message-ID: <6qsng2rqnr.fsf@abnoba.intevation.de> "Emile van Sebille" writes: > I've been writing a business math class that allows for multiple precision > accuracy, and in testing stumbled on this behavior: > > >>> from BNum import BNum as bn > > >>> ab = bn('1.2340000') > >>> cb = bn('123.45') > >>> ab > 1.2340000 > >>> ab * cb > 152.3373000 > >>> (ab*cb).disp(2) > '152.34' > >>> print '%8.2f' % ab*cb > 151.84 > +++++++++++++++++++++??????! This is equivalent to print ('%8.2f' % ab) * cb :-) And since >>> 1.23 * 123.45 151.84350000000001 the output 151.84 seems reasonable to me. Bernhard -- Intevation GmbH http://intevation.de/ Sketch http://sketch.sourceforge.net/ MapIt! http://mapit.de/ From fig at localhost.localdomain Tue Jul 31 11:22:27 2001 From: fig at localhost.localdomain (Stephen R. Figgins) Date: Tue, 31 Jul 2001 15:22:27 -0000 Subject: Frank Willison References: Message-ID: I am reeling from this news. Frank was my manager for four years at O'Reilly & Associates. We worked on different coasts, but I got to meet with him a few times a year. Frank was very witty, well read, intelligent, I loved talking with him. His emails often made me smile. Frank was my hero when it came to wit and choice of words. Frank was at the very heart of O'Reilly & Associates. Tim is the visionary, but Frank made the vision real. What a sad day. O'Reilly & Associates has lost its strongest and best loved knight. -Stephen From michael at rcp.co.uk Mon Jul 30 03:38:47 2001 From: michael at rcp.co.uk (Michael Abbott) Date: Mon, 30 Jul 2001 07:38:47 +0000 (UTC) Subject: PEP0238 lament References: <3B5B3676.40F39389@alcyone.com> <9jg6ei$ges7$1@sky.inp.nsk.su> <23891c90.0107230118.752e3f00@posting.google.com> Message-ID: Paul Foley wrote in news:m2y9pc5ljc.fsf at mycroft.actrix.gen.nz: > On 25 Jul 2001 10:23:14 -0700, Johann Hibschman wrote: > > ... The printed representation of > > a > / \ > b c > > as (a b c) is just an easier-to-deal-with form of "marshal" output. > Nothing says you have to use that particular print representation, > though everybody does. I would have thought that a(b,c) was a slightly more familiar print representation of the structure above! Of course, sometimes it's nice to write b `a` c (stealing infix notation from Haskell here) for the same expression. From philh at comuno.freeserve.co.uk Wed Jul 11 18:32:19 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Wed, 11 Jul 2001 23:32:19 +0100 Subject: Long Live Python! References: Message-ID: On Wed, 11 Jul 2001 12:10:43 -0600 (MDT), Bruce Sass wrote: >On Wed, 11 Jul 2001, phil hunt wrote: >> On Tue, 10 Jul 2001 15:31:11 -0700, Paul Prescod wrote: ><...> >> >Python does not have a niche and is not obviously a niche-friendly >> >language. >> >> Sure it does: python's niche is as a scripting language that's also good >> for longer programs. > >Hehe, you must have missed the recent thread about removing the first >line from a text file... Yes, I did. How about: stdin.readline() #throw away first line stdout.write(stdin.read()) #send the rest to stdout or: stdin.readline() #throw away first line while 1: l = stdin.readline() if l == "": break stdout.write(stdin.readline()) -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From chris.gonnerman at newcenturycomputers.net Thu Jul 26 01:53:46 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Thu, 26 Jul 2001 00:53:46 -0500 Subject: from __numerics__ import rational References: <3b5c6e08.27535083@aplnews> <9jiak1$3s96$3@node21.cwnet.roc.gblx.net> Message-ID: <01c101c11597$56a23300$0101010a@local> Guido recently shot down my proposal for a magic __numerics__ module, based largely on the idea that the old semantics could never be removed. In another posting I state that you *can* remove the original semantics, producing (for instance) a DeprecationError exception so that the user knows as soon as the module compiles that it isn't going to work. I have an ulterior motive for this proposal. I don't like rationals, for the very pragmatic reason that even Guido mentions the "mysterious inefficiencies" of programs using rational numbers. On the other hand, there are some strong supporters of rational numbers who have just as much right to their opinions as I do. My proposal gives a mechanism for specifying that a given module needs (for instance) support for automatic rational arithmetic, which could then be off by default. It would also be straightforward to add support for fixedpoints and/or decimal floats, which I would very much like to have but which the rational guys could care less about. My proposal is certainly not the only way to support numeric operation control; I don't even care if Guido et al use it. I just want to be sure that the needs of the rational crew aren't allowed to harm the rest of us, and likewise our disinterest in rationals doesn't harm them. I don't mind int/int => float; I'll probably avoid using the / operator with integers from now on anyway. I just don't want to accidentally get a rational number when I don't want one. I guess that makes me irrational... ;) From aahz at panix.com Tue Jul 31 09:56:28 2001 From: aahz at panix.com (Aahz Maruch) Date: 31 Jul 2001 06:56:28 -0700 Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <9jnt9p$qhe$1@newsy.ifm.liu.se> Message-ID: <9k6dec$nbr$1@panix2.panix.com> In article , Marcin 'Qrczak' Kowalczyk wrote: >28 Jul 2001 23:14:01 -0400, Lloyd Zusman pisze: >> >> Agreed: rationals with a fixed denominator for calculation results, >> such as 100 in the U.S. where we have dollars and cents. > >No, plain rationals will suffice. No arithmetic operation except >division introduces a denominator which represents fractional cents. Huh? What about sales tax? -- --- 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 "activist for accuracy" --SJM From jparlar at home.com Mon Jul 16 09:19:09 2001 From: jparlar at home.com (Jay Parlar) Date: Mon, 16 Jul 2001 09:19:09 -0400 Subject: Most efficient solution? Message-ID: <20010716132133.DIZO21397.femail2.rdc1.on.home.com@jparlar> I have a simple problem, but one that, without some optimization, might hurt the performance of my project. To sum it up, I have two lists, we'll call them list A and list B, both lists contain only one-word strings (ie. both were generated by string.split() performed on a large amount of text) List B consists of my "stopwords", meaning, the words I don't want included in my final version of list A. So what I need to do is check every item in list A, and if it occurs in list B, then I want to remove it from the final version of A. My first thought would be: for eachItem in A: if eachItem in B: A.remove(eachItem) Now, this will work fine, however, the size of list A varies, and while list B is constant, it is quite large (more than 750 items). List A can also, should the situation warrant, become quite huge as well. The main problem is that I have no idea of the efficiency of "in" for large lists like this. Can anyone think of a possibly quicker way, or is this the best? One other note: List A may (and usually does) contain duplicate words. If those duplicate words appear in list B, then I want them both removed, but if they don't appear in list B, then I want them to remain separate (ie. if the word "Python" shows up five times in A, then I want the final version of A to still contain five occurrences of "Python") I really don't know if this can be made any quicker, but any insight would be appreciated. For the cases I've been running, it's been quick enough so far, but there's a good chance that the amount of data in list A will be getting much larger, and I'll have to perform this entire operation (for different versions of list A) multiple times in one program execution. Jay Parlar ---------------------------------------------------------------- Software Engineering III McMaster University Hamilton, Ontario, Canada "Though there are many paths At the foot of the mountain All those who reach the top See the same moon." From fluxent at yahoo.com Mon Jul 2 13:21:31 2001 From: fluxent at yahoo.com (Bill Seitz) Date: 2 Jul 2001 10:21:31 -0700 Subject: SQL-SELECT against View via ODBC? References: <2l%Z6.22470$g4.740189@e420r-atl2.usenetserver.com> Message-ID: I established that the "cause" of the problem is that one of the tables in my view has a Text field. It's the last field in the base table, so those queries always worked fine. When I built the view, it was no longer the last field, so the error reared it's ugly head. Does anyone know whether mxODBC has this bug? The person who led me on this discovery thought so, but wasn't too sure... Also, I'm not clear on what qualifies as "commercial" use triggering the non-free status of mxODBC? Is it limited to using the API within a product for sale, or does any internal use by a corporate trigger it? "Steve Holden" wrote in message news:<2l%Z6.22470$g4.740189 at 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). From skip at pobox.com Wed Jul 11 16:38:58 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 11 Jul 2001 15:38:58 -0500 Subject: Language change and code breaks In-Reply-To: References: <6A%27.454703$eK2.93741234@news4.rdc1.on.home.com> Message-ID: <15180.47458.789719.733845@beluga.mojam.com> Konrad> And a//b definitely beats (a+0.)/b, which does the trick, but is Konrad> not at all evident. I'm not sure that the purpose of a//b would be all that evident to a new Python programmer, especially one whose first programming language is Python. I've never seen // used as an operator before other than to introduce comments in C++ and that ilk. I suppose it means something in APL, and I wouldn't be that surprised if it had some meaning in Perl. ;-) At the very least C, C++ and Java programmers should be familiar with the purpose of (a+0.0)/b or float(a)/b -- Skip Montanaro (skip at pobox.com) (847)971-7098 From piet at cs.uu.nl Tue Jul 3 07:36:22 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 03 Jul 2001 13:36:22 +0200 Subject: Augmented Assignement (was: Re: PEP scepticism) References: <6qn16r7i69.fsf@abnoba.intevation.de> <9hhu6701d5j@enews2.newsguy.com> <6qae2r71hd.fsf@abnoba.intevation.de> <3B3CECEA.5D02A66E@Lugoj.Com> Message-ID: >>>>> Marcin 'Qrczak' Kowalczyk (MK) writes: MK> 02 Jul 2001 20:18:50 +0200, Piet van Oostrum pisze: SH> I've always liked having a colon on my assignment operator - I think SH> the single = for assignment was a mistake. If we had := for SH> assignment, then augmented assignments would be more clearly distinct SH> from other operators - :+=, :-=, :*= etc etc. >> >> Should be +:=, like in Algol 68. MK> Or :+, like in Comal AFAIR. "x :+ y" is composed of two substrings of MK> "x := x + y"; "x +:= y" is not. It *is*, just in a different order. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From s713221 at student.gu.edu.au Sat Jul 21 21:04:02 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Sun, 22 Jul 2001 11:04:02 +1000 Subject: Language change and code breaks References: <9j9i19$p96$1@panix2.panix.com> <3B596D95.C87DFFCD@mac.com> <3B5A12D9.7836217E@yahoo.com> Message-ID: <3B5A2682.E1A8A4D0@student.gu.edu.au> SteveN wrote: > > jorjun wrote: > > > > Aahz Maruch wrote: > > > i'M aFraId i doN't UnDerStaNd wHy YoU THinK caSE-InsENsitIvitY miGhT bE > > > A gOoD idEA. > > > -- > > Currently if I import a module and the identifiers lOoK_lIkE_ThIs > > then I have to precisely follow the ugly conventions in my own code. > > Or import uGlY_mOdUlE as pretty_module > > -SteveN- Or 1. politely mention it to the original coder. 2. recode it for yourself with pretty names. :) -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From rnd at onego.ru Sat Jul 7 17:16:42 2001 From: rnd at onego.ru (Roman Suzi) Date: Sun, 8 Jul 2001 01:16:42 +0400 (MSD) Subject: "has" Operator In-Reply-To: <3B4777CD.A6EBEA7F@home.com> Message-ID: On Sat, 7 Jul 2001, Paul Sidorsky wrote: > >I was thinking that Python might benefit from a "has" operator that >would allow you to type something like this: > >if myobject has someattribute: > foo() >else: > bar() if hasattr(myobject, "someattribute"): foo() else: bar() is clean enough, IMHO... Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Saturday, July 07, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "OK, I'm weird! But I'm saving up to become eccentric." _/ From kirschh at lionbioscience.com Fri Jul 20 02:54:56 2001 From: kirschh at lionbioscience.com (Harald Kirsch) Date: 20 Jul 2001 08:54:56 +0200 Subject: Parsing TCL? References: Message-ID: Skip Montanaro writes: > Roy> I know this is probably a strange request, but does anybody know of > Roy> a python module which parses TCL files? > > No, but isn't Tcl essentially just > > command arg arg arg arg > Except that arg may be "arg" or {arg} or [arg] or $arg and those special characters as well as backslash and some others have to be treated within. In fact even command may be "command" or [command] or {command} or $command, but this is not for beginners:-) > ? I thought it was designed to be extremely easy to parse. Shouldn't be > hard to write a parser for it I wouldn't think. Nevertheless you are right. The whole syntax *plus evaluation semantics* is described in 11 points in a man-page of 208 lines. Harald Kirsch -- ----------------+------------------------------------------------------ Harald Kirsch | kirschh at lionbioscience.com | "How old is the epsilon?" LION bioscience | +49 6221 4038 172 | -- Paul Erd?s *** Please do not send me copies of your posts. *** From akuchlin at mems-exchange.org Wed Jul 11 15:07:39 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 11 Jul 2001 15:07:39 -0400 Subject: shortest match regexp operator anyone? References: Message-ID: <3d66czqo78.fsf@ute.cnri.reston.va.us> Harald Kirsch writes: > With non-greedy matching, another approximation is '^.*?B', however > this matches 'xxyB', although it should not. It sounds like you want something similar to the (?> ...) in Perl 5.6. Neither SRE nor the current version of PCRE support this, though. Personally I'd just code it explicitly, as 'index = s.find('') ; if index != -1: # check for B ...'. Wordier, but doesn't require regex arcana. --amk From gaul at spam.utexas.edu Sun Jul 8 15:09:34 2001 From: gaul at spam.utexas.edu (Andrew Gaul) Date: Sun, 8 Jul 2001 19:09:34 +0000 (UTC) Subject: ICFP 2001 contest - Python team, anyone? References: Message-ID: In article , Nick Perkins wrote: > "Gerhard H?ring" wrote in message > news:slrn9k9hbd.8uh.gerhard.nospam at lilith.hqd-internal... >> The International Functional Programming Contest was announced. I'd >> like to join this year. If you are a Python hacker and want to have >> all the fun and glory, please contact me :-) >> >> http://cristal.inria.fr/ICFP2001/prog-contest/ > > ..reading contest rules... > so, we would have to write for Python 1.52?? > ..and this is for a functional programming contest? > > 2.1 would be better, with nested scopes and list comprehensions, etc. According to the machine configuration page (http://cristal.inria.fr/ICFP2001/prog-contest/machine.html), both Python 1.5.2 and 2.1 will be supported. This year's Python effort: http://www.twistedmatrix.com/users/jh.twistd/python/moin.cgi/IcfpPythonTeam and last year's: http://www.crepuscule.com/icfp/ -- | a | n | d | r | e | w | @ | g | a | u | l | . | o | r | g | White trash. Loser. Geek. From jm7potter at hotmail.com Wed Jul 11 10:03:50 2001 From: jm7potter at hotmail.com (Joe Potter) Date: Wed, 11 Jul 2001 10:03:50 -0400 Subject: MySQL-python-0.9.0 setup problems under windows98 References: <3B4C5A47.50D8E366@nokia.com> Message-ID: <42noktok3h9cbo3757kg8hoavhnjjsc478@4ax.com> On Wed, 11 Jul 2001 13:50:39 GMT, Joonas Paalasmaa wrote: >Joe Potter wrote: >> >> Hello all, >> >> I have MySQL running on a win98 box. All systems are go with the package. >> >> Now, I would like to use the system from within python. So far I have downloaded the >> module that does this job. The one listed above is supposed to be the windows >> version. >> >> However, I can not seem to understand how to install the module and get it imported >> so as to start using MySQL. > >Download MySQL-Python Windows installer from http://highqualdev.com/ >It is very easy to use. > I must be very dense. I downloaded "MySQL-python-0.9.0-win32-2.zip (this archive is for Python 1.5.2/2.0/2.1)" from that very url. Now what? Regards, Joe From tim.one at home.com Thu Jul 26 23:39:10 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 26 Jul 2001 23:39:10 -0400 Subject: Suggestion for impriving list comprehensions In-Reply-To: Message-ID: [Steven D. Majewski] > ... > [ But maybe the generator versions above are better. > I'm still getting used to this new stuff. > Sometimes the syntax seems a bit awkward. > I hope that this __future__ stuff is not cast in stone until > we've had time to see how it works. ] Nothing is frozen until at earliest the first 2.2 beta release; indeed, generators may go away entirely before 2.2 final. There's something at least a *little* off with the dance between generators and iterators, but I'm not clear on exactly what and haven't had more time to consider it. Part of it seems to be that for x in whatever: magically applies iter() to whatever under the covers (nothing off there), but if "whatever" is a generator(-function), iter(whatever) is an error. I don't know *why* that seems a little bit off, because it makes perfect sense . But play with it long enough and I wouldn't be surprised if you thought so too. if-so-it's-in-need-of-articulation-ly y'rs - tim From philh at comuno.freeserve.co.uk Tue Jul 10 07:31:24 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Tue, 10 Jul 2001 12:31:24 +0100 Subject: BASIC or Python? References: <3d157fa0.0107051904.7ec368b8@posting.google.com> <0t_17.14670$Fk7.131382@news.indigo.ie> Message-ID: On Tue, 10 Jul 2001 02:17:31 GMT, Gerry Quinn wrote: > >In case anyone is fooled, here's an example from the tutorial at >www.python.org, which also has a FAQ on what Python is for: > >>>> for n in range(2, 10): >.. for x in range(2, n): >.. if n % x == 0: >.. print n, 'equals', x, '*', n/x >.. break >.. else: >.. print n, 'is a prime number' >.. > >Now some people may very well find that lovable, but I certainly don't. >Note how the clever language design means that the 'else' must be >level-indented with the 'for'. No doubt longer programs are even more >fun. The FAQ on increasing speed helpfully notes that function calls >are expensive... > >The second print statement is one character offset from the 'if' - I >don't know whether that is necessary or not. It is unlikely that I will >ever wish to know. I don't wish you to know either. Python is far too sensible a language for the likes of you to be using it. -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From sholden at holdenweb.com Fri Jul 6 20:47:11 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 6 Jul 2001 20:47:11 -0400 Subject: Marking a Python COM server safe for Internet Explorer References: Message-ID: "Bill Bell" wrote in message news:mailman.994455192.30495.python-list at python.org... > > "Steve Holden" wrote: > > "Bill Bell" wrote in ... > > > > > > As a kind of default, Internet Explorer will ask the user's > > > permission before instantiating an ActiveX control. However, one can > > > implement IObjectSafety to inform IE that one's control is safe, > > > thus sparing the user the need to respond to the dialog box. > > > > > I must have misunderstood. Are you telling me that IE has a security > > system to detect potentially unsafe downloaded content, but that it > > won't use this system if the downloaded content tells it there's no > > need? > > > > How very Microsoft. I must have missed something. > > Steve, > > This may not be as bad as it might have sounded. In order for IE to > successfully query for IObjectSafety the ActiveX has to have been > registered, right? And it couldn't be registered until it had been > downloaded. And that couldn't happen unless the user agreed-- > assuming that his/her IE is properly secured. > > Do I discern perhaps that your trust in, and admiration for, MS > products are bounded? > Good heavens, whatever gave you that impression. If the rest of the worl did as fine a job as Microsoft does then we'd be ... up shit creek without a paddle, I guess. Seriously, I think there is value in much of what Microsoft has done, but they have on occasion really pissed me off. For example, the long period during which they refused to admit that any security problems existed in their product. The lying about the differences between NT Server and Workstation, until O'Reilly clearly demonstrated that WS would operate as Server (and even had a special thread to reverse registry changes designed to make it do so). not to mention their "let's start introducing propruetary features into standard protocols to defeat the open Source world" [Halloween]. Because they are the largest software company in the world, by the nature of things they come in for a bashing now and then. I hand out my share, mostly in fun, but sometimes with a real point. In this case, as you and another poster have pointed out, it was my misunderstanding. Thanks for the enlightenment. but-i'll-never-click-the-trust-all-downloads-from-redmond-box-ly y'rs - steve -- http://www.holdenweb.com/ From francois.senequier at voila.fr Tue Jul 24 05:12:31 2001 From: francois.senequier at voila.fr (SENEQUIER) Date: Tue, 24 Jul 2001 11:12:31 +0200 Subject: Using TKINTER Message-ID: <9jjehn$9mb$1@s1.read.news.oleane.net> Hi, I simply open a window using the TKINTER root widget. I know how to put a button in the window in order to close the window but I don't know how to close the window when the exit button of the bar menu (X) is clicked ? Someone could help me ? Thanks From m.mariani at imola.nettuno.it Mon Jul 23 07:52:07 2001 From: m.mariani at imola.nettuno.it (Marco Mariani) Date: Mon, 23 Jul 2001 13:52:07 +0200 Subject: Future division patch available (PEP 238) In-Reply-To: <23891c90.0107230204.4e26d5e8@posting.google.com> Message-ID: <20010723135207.A25465@zoidberg> On Mon, Jul 23, 2001 at 03:04:22AM -0700, Paul Boddie wrote: > > Python would be a laughing stock without a division operator, and it > > will certainly be a laughing stock if we can't rely on it to do the > > same thing from one release to the next. It's a far to fundamental > > change just to please people with a particular mindset. I am quite frightened by this patch too. > I get the feeling that those people who follow the Python development > list tend to work their way to what they believe to be sensible > conclusions, but run the risk of becoming out of touch with everyone > else. The big danger for Python is that they become so out of touch > that half the Python community decide to "fork off". And I want to be on the half whose programs keep working :-) From shriek at gmx.co.uk Fri Jul 27 02:10:53 2001 From: shriek at gmx.co.uk (Stephen) Date: 26 Jul 2001 23:10:53 -0700 Subject: Going from webscripting to server-client software. References: <6572890e.0107251014.47e07810@posting.google.com> <9jop6k$l2d$2@pea.uk.research.att.com> Message-ID: <97ae44ee.0107262210.795d3e0e@posting.google.com> > [...] > >I know there's lots to learn here and would prefer to go read up > >rather than trouble you so any helpful resources will see me on my way. > >Should I be looking at SOAP/.Net or Visual Basic or Java/CORBA instead > >or is Python up to it? What other caveats are there ? > > This is the ideal kind of application for CORBA. You could model both > the booking server and each of your client applications as CORBA > objects. They would then easily communicate with each other so > everything is kept up-to-date. > > Python is the easiest language in which to develop CORBA applications, > and there are a number of CORBA implementations available. This page > has a list of them: > > http://www.faqts.com/knowledge_base/view.phtml/aid/4930 Thank you very much, Duncan. After looking around for a couple of days (hence my late followup. sorry), it does seem like my options are (a) CORBA (b) SOAP (c) XMLRPC (d) Pyro CORBA has always been intimidating. So much work just to do "hello world", let along build a full app. Then again, I suppose it's less work than trying to manage communications between all the distributed clients which is what I understand CORBA takes care of for me. Interesting that you say Python is the easiest language in which to develop CORBA apps because I thought that that was Java's EJB selling point, that it takes care of CORBA for you. SOAP is interesting because of .Net I was very excited by John Udell's article http://www.byte.com/documents/s=804/byt20010712s0002/ where he mentions that in J2EE, the platform is the Java language but .Net really does look language and maybe platform independent. Same advantages of CORBA of course. XMLRPC seems to have been superceded by SOAP and certainly doesn't seem any faster. CORBA will be more appealing to me than SOAP or XMLRPC from a speed and scalability point of view because I'd like to build my booking application to be reused for other, larger companies and not just my current client. Pyro looks dead easy. Main problem being that if somebody else wants to work with the system, to extend it etc, they have to use Python. I try to provide clients with as many options as possible for future development and not lock them into Python. Also, it's safer to go with a standard thing like CORBA,XMLRPC,SOAP. However, well done to Irmen for creating something so simple that works like CORBA. > I won't recommend one. I wrote omniORBpy so I'm biased. I've heard good things about that. Will check it out. Most importantly, lots of documentation and win 2000 binaries (I like to reduce the number of things that can go wrong) :) Thanks again. S. From rnd at onego.ru Thu Jul 19 16:26:01 2001 From: rnd at onego.ru (Roman Suzi) Date: Fri, 20 Jul 2001 00:26:01 +0400 (MSD) Subject: wow! Message-ID: >>> def a(): ... for i in range(5): ... yield i :3: Warning: 'yield' will become a reserved keyword in the future File "", line 3 yield i ^ SyntaxError: invalid syntax >>> # let's guess: >>> from __future__ import generators >>> def a(): ... for i in range(5): ... yield i ... >>> for k in a(): print k ... 0 1 2 3 4 >>> Wow! So I think letting know what I need from the __future__ could help: :3: Warning: 'yield' will become a reserved keyword in the future (try: from __future__ import generators to use it) Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Thursday, July 19, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "The bigger they are, the harder they hit you." _/ From denro at earthlink.net Fri Jul 13 12:00:22 2001 From: denro at earthlink.net (Dennis Roark) Date: Fri, 13 Jul 2001 16:00:22 GMT Subject: not safe at all References: Message-ID: I appreciate those who replied, particularly Nick's informative reply. I would still argue that "dynamic" typing is a weaker and less safe sort of typing than the static typing of C++. Nick brings up the C++ example of using pointers to void and then casting them as needed or recasting them to allow the variable to point to different objects not involved in an inheritance relationship. But C++ is also often criticized for this because void pointers do allow for unsafe coding, relaxation of type safety and should be avoided if possible. Python is an attractive language. But for a large program I would still rather be forced to declare the name of a variable (and its type) rather than risk misspelling or misuse 500 lines later in the program. My original note was not intended to be an indictment of Python, but only to bring up some reasons that for me make more strongly typed languages like C++ or Object Pascal better at coding very large projects. 9nick9m at alum.mit.edu (Nick Mathewson) wrote: >On Fri, 13 Jul 2001 07:32:28 GMT, Dennis Roark wrote: >>For amusement, run this little script which demonstrates a >>near ultimate in the lack of type safety in the language. >>(Perhaps there is a bit of type safety in that you can't do >>this: 4 + "one") But look at what you can do in the >>following script: >> >>x = 3 >>x = x + 2 >>print "x =", x >>x = "now I'm a string" >>print x >>x = [ 5, x ] >>print "and now a list:", x >> >>If you don't believe it, run it. > >I believe it, but it doesn't demonstrate a thing about type safety. >You've just discovered dynamic typing. You see, your implied view of >typing seems to come from a statically typed language, where every >*variable* has a type of its own. > >In Python, types are associated with *objects*, not with *variables*. >IOW, all variables are of the same type: reference-to-object. >... > >Or even C++: > // Watch out! My C++ is rusty. > class Integer { int val; > public: Integer(int v) : val(v) {} > operator int() { return val; } } > void* x = new Integer(3); > x = new Integer(2 + *(Integer*)x); >... --------------------------------- Dennis Roark Dept. of Computer Science University of Sioux Falls Starting Points: http://home.earthlink.net/~denro --------------------------------- From mjsilva at jps.net Fri Jul 6 00:27:19 2001 From: mjsilva at jps.net (Mike Silva) Date: 5 Jul 2001 21:27:19 -0700 Subject: Python for air traffic control? References: <9hlfbn$6ok$1@nereid.worldonline.nl> <9hrj3q$cj1@news1.gtech.com> <9htebs$ck2@news1.gtech.com> <9i0cjt$ck9@news1.gtech.com> Message-ID: <5267be60.0107052027.76afbb39@posting.google.com> "Peter Milliken" wrote in message news:<9i0cjt$ck9 at news1.gtech.com>... > Strong type checking means that when you tell a compiler that a function > will return a value then the compiler will not allow a program to compile > that doesn't have that return value assigned to *something* (of the > appropriate type, as well :-)) i.e. a program variable or just used in a > test case e.g if statement. The language that I have in mind is Ada - it is > used primarily in the defence industry and therefore has the stigma of being > a "defence language" and therefore not worth considering in the "real world" > of commercial programming :-) (their loss :-)). It was designed to/using > some strict computer science principles (please, no boffins jumping in here > with corrections thanks :-)) of the day and encourages, through the language > definition and operation of the compiler some very handy heuristics. It is a > very "readable" language (uses keywords in the same style as Pascal and > Modula). By default (you can turn it off when generating binaries for the > live system), it generates automatic run-time checking of code i.e. if you > define a data type that should only ever have a range of values of 0 - 255 > then if you try and assign 256 to a variable of that type then it will raise > an exception at runt-ime (this assumes that the compiler wasn't able to > detect that at compile time though! a statement line like byte_var := 256; > would raise an error from the compiler) - the application will either handle > the exception via an exception handler (has to be programmed though, just > like Python :-)) or it will abort the program and display diagnostic data > (just like Python :-)). > > Many programmers, when they first meet a strongly typed language (such as > Ada, but there are others) have a great deal of difficulty, because they are > used to having a lot more "freedom" from the languages they are used to. But > once you get past the barrier of producing correct code then it offers a > great freedom - 90% of your "typical" bugs are found by the compiler at > compile time rather than during unit testing :-). In my experience (I wrote > code using Ada for about 4-5 years, I have about 10-12 years of coding in C, > I have used C++ but not any any extent worth mentioning), the only bugs left > after a successful compile are "algorithimic" - a truly great aid to > productivity! :-). Most programmers can't get past that first hurdle though, > they "hate" the language because it "won't let them do what they want" - but > if they examined their code, they are always forced to admit that what they > "wanted" wasn't "correct" :-). > > But Ada is like C or C++ - it doesn't "shine" in the areas of data > manipulation that Python does. It doesn't have a huge array of support > libraries, like Python, Perl and Java do etc. So productivity can be down > purely because you have to write a lot of basic things from the ground up. > Again, different languages have different applications areas. Python is not > my choice for an ATC (as anyone may have guessed by now :-)), C/C++ would be > a disaster! Of those mentioned, I believe Ada is a better choice, there may > be others but I have no experience with those languages so I can't comment. > Caveat: ANY LANGUAGE can produce working code for an application, it is just > the amount or work and effort required to get there. Python *could* be used > for an ATC application, so can assembler - but I haven't heard anyone > advocating that one :-). I too immediately thought that Ada (Ada 95) would be the right tool for this job. It is the primary ATC language in much of the world (don't know about the U.S.). I think strong static typing is a must in a safety-critical application such as ATC -- throwing an exception at runtime is a Very Bad Thing in such applications (once out of testing), so it is extremely desireable to catch errors at compile time. As has been suggested in this thread, strong typing (as opposed to the C/C++ "it's all buckets of bits" approach) is an excellent tool to force the designer/programmer to model the problem correctly, rather than just funnelling bits here and there. It also usually results in reducing errors by an order of magnitude vs. C/C++ (and the Ada runtime checking makes it much easier to catch most of the ones that slip through). While Python (from the little I know of it) is clearly stronger than Ada in certain types of applications this wouldn't seem to be one of them. I can see this project benefitting from Ada features such as fixed-point math, reduced reliance on heap memory (dynamic heap allocation is also a Very Bad Thing in such applications), concurrency (if allowed -- safety-critical projects often prohibit it), and ease of interface with code written in other languages. Take a look at Ada (e.g. the GNAT compiler) for this job (and -don't- yield to the C/C++ temptation!). Mike From nperkins7 at home.com Mon Jul 9 02:24:46 2001 From: nperkins7 at home.com (Nick Perkins) Date: Mon, 09 Jul 2001 06:24:46 GMT Subject: Empty sys.path[0] References: <3B473741.2BE14CB0@engcorp.com> Message-ID: "Gustaf Liljegren" wrote in message news:Xns90D9116ADA12Bgustaflalgonetse at 194.213.69.148... .... when I run it with only the filename: > > E:\test>python syspath.py > > > Nothing! ... hmm, strange.. In those cases, the os.getcwd should give you the right answer. you could start scripts with: import sys if not sys.path[0]: import os sys.path[0]=os.getcwd() From kdl4 at acpub.duke.edu Thu Jul 26 23:37:25 2001 From: kdl4 at acpub.duke.edu (Kevin Lacker) Date: Thu, 26 Jul 2001 23:37:25 -0400 Subject: a break for comprehensions References: <9jpadd$s5k$1@news.duke.edu> <3B60A053.75938301@engcorp.com> Message-ID: <9jqnlr$flb$1@news.duke.edu> > > Can you do this: > > ... > > with a list comprehension somehow? I'm starting to dislike explicit for > > loops just for the purposes of constructing another list from a current one. > > I can clearly understand what the above code is doing. Doing this > as a list comprehension would be less readable for me (I'm not a > heavy user of list comprehensions, yet.) > > Are you sure you really don't like the explicit, readable code > above, and would prefer a more compressed, (admittedly explicit, > I suppose), more cryptic version instead? There are other > languages which could do the above in one tiny line, no doubt. > (No names. :) How cryptic is [process(x) for x in my_list while is_good(x)] ? Not really any more cryptic than [process(x) for x in my_list if is_good(x)] which seems to be agreeably a good thing to have. I certainly like it. I don't really know much Lisp, but in the back of my mind I half remember someone claiming they had more flexible iteration abilities that still looked functional and noncryptic... From Tom_Good1 at excite.com Thu Jul 19 16:50:10 2001 From: Tom_Good1 at excite.com (Tom Good) Date: 19 Jul 2001 13:50:10 -0700 Subject: Bunch lists into sublists via alternation References: <5e8bd451.0107190415.7cc17f93@posting.google.com> Message-ID: kp87 at lycos.com (kevin parks) wrote in message news:<5e8bd451.0107190415.7cc17f93 at posting.google.com>... > I've asked this on another list and never got a reply. Possibly > because i have worn out my welcome with all my dumb questions, or > because it is such a dumb question people hurt themselves laughing and > are now all in the hospital. > > I am trying to figure out how to take a sequence and split it up into > sub-lists > by alternation. For example if i had a sequence like: > > x = [1,2,3,4,5,6,7,8,9] > > and i called a function that was: seqSplit(seq, sub-lists) > > seqSplit(x,2) > > would yield: ([1,3,5,7,9], [2,4,6,8,None]) # None pads lists that are > short elements > > and seqSplit(x,3) --> ([1,4,7], [2,5,8], [3,6,9]) > and seqSplit(x,4) --> ([1,6] [2,7], [3,8], [4,9], [5,None]) > > > I've got something that bunches up consecutive elements into > sub-lists: > > def bunch(mylist, times): > """package up list elements in sub-lists n at a time. > > x=[1,2,3,4,5,6,7,8,9] > bunch(x,1) --> [[1], [2], [3], [4], [5], [6], [7], [8], [9]] > bunch(x, 2) --> [[1,2], [3,4], [5,6], [7,8], [9, None] > bunch(x, 3) --> [[1,2,3], [4,5,6], [7,8,9]] > bunch(x, 4) --> [1,2,3,4], [5,6,7,8] [9, None, None, None]]""" > > out = [mylist[i:i+times] for i in range(0, len(mylist), times)] > if out: > out[-1].extend([None] * (times - len(out[-1]))) > return out > > # -- --------------------------------------- > > But i can't figure out how to get the: > > a = (1,9,1,9,1,9) > b = (1,9,7,1,9,7,1,9,7) > seqSplit(a,2) --> ([1, 1, 1], [9, 9, 9])""" > seqSplit(b,3) --> ([1, 1, 1], [9, 9, 9], [7, 7, 7])""" > > type arrangement, particularly since i want it to work for any > unpredetermined > number of sub-lists. I've got a kludge that works only for the case of > seqSplit(x,2), > but i can't get anything to work for seqSplit(x,n) where n is anything > else. > > cheers, > kevin parks How about this: >>> def seqSplit(mylist, times): ... result = [] ... for i in range(times): ... sublist = [] ... for j in range(i, len(mylist), times): ... sublist.append(mylist[j]) ... result.append(sublist) ... return tuple(result) ... >>> seqSplit((1,9,1,9,1,9), 2) ([1, 1, 1], [9, 9, 9]) >>> seqSplit((1,9,7,1,9,7,1,9,7), 3) ([1, 1, 1], [9, 9, 9], [7, 7, 7]) >>> From robin.garner at i.name.com Tue Jul 24 22:08:41 2001 From: robin.garner at i.name.com (Robin Garner) Date: 25 Jul 2001 12:08:41 +1000 Subject: A use for integer quotients References: <3B5C5665.8D41D1F1@tundraware.com> <3B5C749A.59F97320@tundraware.com> Message-ID: "michael" wrote in news:JDa77.97061$Rr4.549007 at ozemail.com.au: > >> Not formally, AFAIK. For example, 3 with no decimal point following >> could be anything from 2.5 to 3.4. If I remember correctly, to be >> fussy about it, you would need to specify 3.00/4.00 to get 0.75 or am >> I missing something or misremembering my ancient maths courses ;) ? >> > > I'm pretty sure that mathematicians say that > three, 3, 3.00, iii > are different numerals for the same number. > This number is a real number, a rational number, an integer, and a > natural number. In most maths the sets are made explicit, and operators are defined as functions with specific domains. There are standard embeddings of Integers into Rationals and Reals, and if you are working with real numbers, then 2 and 2.0 are generally taken to stand for the same thing. But strictly speaking the Integer 2 and the Real Number 2 are different entities. You would be hard pressed to find anyone writing the natural number 2 as 2.0. Since the Integers aren't a field, there isn't a generally accepted function / : Int x Int -> Int. that agrees with the function / : Real x Real -> Real for all (a,b) where b is divisible by a. >> More importantly, the thing everyone is talking about here is an >> integer operation yielding a real (float) result. Isn't this kind of >> a "no-no" amongst mathematicians? > > I'm not sure whether the "inner product" from vector algebra could be > considered an "operator", but it does operate on vectors and yields a > scalar. > The proposed division operator is a perfectly well defined function of type Int x Int -> Real. You can define it rigorously as the composition of the standard embedding e: Int -> Real with the division function on the reals. Mathematics is full of functions from one set to another. Of course appealing to Mathematical objects has its limitations, since the computer Int and Float types are not the same as Integers and Reals in mathematics, because a) they are finite sets and b) the Reals have finite precision. And very few things (except perhaps fallacious arguments) are '"no-no"s amongst mathematicians'. The computer integers are variously studied as GF(2^32), the Galois Field of 32 direct products of {0,1}, the ring of integers modulo 2^32, a (rather uninteresting) finite topological space etc etc etc. >> >> Maybe I'm wrong here... > > > > From wtanksle at dolphin.openprojects.net Wed Jul 25 15:12:45 2001 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Wed, 25 Jul 2001 19:12:45 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: Message-ID: On Wed, 25 Jul 2001 04:18:35 GMT, Guido van Rossum wrote: >Thanks. I am baffled by the many claims that for mathematicians 1/2 >equals zero; I've never met such a mathematicians. Perhaps the best solution would be to make Python's integers actually be the field of integers mod 4294967291 (not too much of a change -- they're currently very similar to the integers mod 4294967295). The best of all worlds -- divisions no longer have remainders, and everything's exact again. >--Guido van Rossum (home page: http://www.python.org/~guido/) and-writing-the-log-function-becomes-a-lot-more-fun-ly yr's -- -William "Billy" Tanksley From johann at physics.berkeley.edu Wed Jul 18 19:05:58 2001 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 18 Jul 2001 16:05:58 -0700 Subject: Python 2 times slower than Perl References: Message-ID: Roman Suzi writes: > On Wed, 18 Jul 2001, John J. Lee wrote: >> On 18 Jul 2001, Johann Hibschman wrote: >> [...] >>> cc -O2 0.28 >>> cc 0.62 >>> ocamlopt 1.26 (compiled) >>> ocaml 9.42 (interpreted) >>> perl 28.9 >>> python 66.8 After re-compiling python with -O2, my result is: python 31.4 which I find much more believable. That optimization really helps! Perhaps the python configuration process should default to compiling with -O2 rather than with -O? > But in my applications speed is not the main virtue. The top thing is > express logic in a plain language and this is Python great at. I have a good bit of leisure time these days (i.e. I'm only barely employed), so I've been playing around with ocaml. It's nice, although it took me a while to get up to really understand the language. I like it, quite a bit, but then again I do numerics, so speed is always a blessing. If you have some time, take a look at ocaml. It'll teach you something. I don't know if you'll find it useful, but it's educational. > That is why I do not understand why Java is so popular: it is not large > enough improvement over C/C++ in terms of source readability but still > poses serious overhead in execution speed... I have the feeling it stalled > at the middle between C++ and Python... I agree with you here, completely. But it is nice to have GC... > _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ Heh. My mother was born in Karelia, before she had to move rather rapidly to Finland around 1940. I still would like to visit the area one of these days. All right, so I'm rambling now. -- Johann Hibschman johann at physics.berkeley.edu From amartin at wpsnetwork.com Mon Jul 16 08:55:15 2001 From: amartin at wpsnetwork.com (Aurelio Martín) Date: Mon, 16 Jul 2001 14:55:15 +0200 Subject: Network able Chess References: <86f9eea9.0107160423.1e1a0103@posting.google.com> Message-ID: <9iuo7h$l7e2g$1@ID-50400.news.dfncis.de> elecfsh escribi? en el mensaje de noticias 86f9eea9.0107160423.1e1a0103 at posting.google.com... > Hey, > For a while I have been wanting to write a little chess game that > can be played over a network w/ some simple chatting features. I want > to do this in Python, but I'm a little worried about doing the > graphics. Any suggestions as far as gamming libraries? or any standard > libraries I may have missed? Thanks. > > -Andrew Try Tkinter, included in the Python distribution, or Pygame ( www.pygame.org ) From bokr at accessone.com Sat Jul 21 17:51:13 2001 From: bokr at accessone.com (Bengt Richter) Date: Sat, 21 Jul 2001 21:51:13 GMT Subject: Case insensitivity References: Message-ID: <3b59f251.63707346@wa.news.verio.net> On Thu, 19 Jul 2001 20:30:15 GMT, Guido van Rossum wrote: >Fair enough. So let's begin the real discussion. > Perhaps some actual data will help. See below. [...] >To me, the only real important question is, how can we introduce >case-sensitivity for novices without breaking the millions of lines of ^^^^^^^^^^^ -- easy, make no change ;-) >existing Python code. One option could be: forget it, it's too late. >Another: put the case-insensitivity in the tools. > An option to have IDE's or editors make case-sensitivity easy for newbies would have my vote, but not changing the base language case sensitivity. BTW, thanks for a great language! :) Wish I'd decided to look into it sooner. Here is the way symbols have been used with case sensitivity in (windows distribution) Python-2.1\Lib\*.py: [Files with no multi-case symbols omitted, numbers are instances of the symbol. BTW, other than a change not to print headers for no-instance files, the code that made this listing is in another post (Re: Language change and code breaks). Should one include a copy in a case like this, or just refer?] ---- D:\Python-2.1\Lib\aifc.py ---- {'Chunk': 3, 'chunk': 28} {'Error': 40, 'error': 3} {'SetParams': 2, 'setparams': 2} ---- D:\Python-2.1\Lib\asyncore.py ---- {'FCNTL': 4, 'fcntl': 5} {'debug': 2, 'DEBUG': 3} ---- D:\Python-2.1\Lib\audiodev.py ---- {'al': 11, 'AL': 25} {'sunaudiodev': 3, 'SUNAUDIODEV': 3} ---- D:\Python-2.1\Lib\BaseHTTPServer.py ---- {'message': 11, 'Message': 1} ---- D:\Python-2.1\Lib\Bastion.py ---- {'RExec': 1, 'rexec': 2} {'bastionclass': 2, 'BastionClass': 2} ---- D:\Python-2.1\Lib\binhex.py ---- {'hexbin': 2, 'HexBin': 2} {'FInfo': 11, 'finfo': 19} {'type': 6, 'Type': 6} {'linelen': 4, 'LINELEN': 3} {'binhex': 2, 'BinHex': 2} {'FName': 2, 'fname': 8} {'flags': 2, 'Flags': 5} {'Creator': 5, 'creator': 2} ---- D:\Python-2.1\Lib\cmd.py ---- {'Cmd': 1, 'cmd': 11} {'prompt': 3, 'PROMPT': 2} {'IDENTCHARS': 2, 'identchars': 2} ---- D:\Python-2.1\Lib\codecs.py ---- {'Writer': 6, 'writer': 8} {'Reader': 6, 'reader': 12} ---- D:\Python-2.1\Lib\Cookie.py ---- {'K': 30, 'k': 6} ---- D:\Python-2.1\Lib\copy.py ---- {'Error': 2, 'error': 3} {'C': 2, 'c': 2} ---- D:\Python-2.1\Lib\dis.py ---- {'extended_arg': 4, 'EXTENDED_ARG': 2} ---- D:\Python-2.1\Lib\doctest.py ---- {'Tester': 2, 'tester': 7} ---- D:\Python-2.1\Lib\filecmp.py ---- {'BUFSIZE': 2, 'bufsize': 3} ---- D:\Python-2.1\Lib\ftplib.py ---- {'netrc': 2, 'Netrc': 2} {'Error': 6, 'error': 1} {'FTP': 2, 'ftp': 9} ---- D:\Python-2.1\Lib\gettext.py ---- {'Catalog': 1, 'catalog': 2} {'MASK': 9, 'mask': 6} ---- D:\Python-2.1\Lib\gzip.py ---- {'fname': 4, 'FNAME': 3} {'write': 14, 'WRITE': 4} {'read': 15, 'READ': 3} ---- D:\Python-2.1\Lib\ihooks.py ---- {'hooks': 27, 'Hooks': 2} {'VERBOSE': 4, 'verbose': 14} ---- D:\Python-2.1\Lib\imaplib.py ---- {'debug': 14, 'Debug': 4} {'literal': 15, 'Literal': 2} {'USER': 4, 'user': 2} {'flags': 14, 'Flags': 2} ---- D:\Python-2.1\Lib\imputil.py ---- {'Importer': 3, 'importer': 5} ---- D:\Python-2.1\Lib\inspect.py ---- {'name': 13, 'NAME': 1} {'INDENT': 1, 'indent': 12} ---- D:\Python-2.1\Lib\mhlib.py ---- {'path': 67, 'PATH': 2} {'Folder': 2, 'folder': 4} {'mh': 13, 'MH': 2} {'Error': 21, 'error': 23} {'MultiFile': 1, 'multifile': 2} ---- D:\Python-2.1\Lib\mimify.py ---- {'i': 9, 'I': 9} {'file': 9, 'File': 5} ---- D:\Python-2.1\Lib\os.py ---- {'PATH': 2, 'path': 19} ---- D:\Python-2.1\Lib\pdb.py ---- {'bdb': 9, 'Bdb': 3} {'cmd': 4, 'Cmd': 3} ---- D:\Python-2.1\Lib\pickle.py ---- {'dict': 4, 'DICT': 3} {'FLOAT': 3, 'float': 1} {'long': 1, 'LONG': 3} {'inst': 4, 'INST': 3} {'put': 11, 'PUT': 3} {'MARK': 8, 'mark': 13} {'list': 4, 'LIST': 3} {'TUPLE': 3, 'tuple': 3} {'f': 7, 'F': 3} {'APPEND': 3, 'append': 35} {'int': 1, 'INT': 3} {'c': 7, 'C': 2} {'unicode': 7, 'UNICODE': 4} {'GET': 3, 'get': 4} {'None': 16, 'NONE': 3} {'reduce': 7, 'REDUCE': 3} ---- D:\Python-2.1\Lib\pipes.py ---- {'FILE': 2, 'file': 17} ---- D:\Python-2.1\Lib\popen2.py ---- {'popen3': 5, 'Popen3': 5} {'popen4': 3, 'Popen4': 3} ---- D:\Python-2.1\Lib\posixfile.py ---- {'FCNTL': 21, 'fcntl': 14} ---- D:\Python-2.1\Lib\pre.py ---- {'m': 9, 'M': 1} {'i': 14, 'I': 1} ---- D:\Python-2.1\Lib\profile.py ---- {'stats': 7, 'Stats': 2} ---- D:\Python-2.1\Lib\pstats.py ---- {'cmd': 2, 'Cmd': 1} {'stats': 34, 'Stats': 4} ---- D:\Python-2.1\Lib\pyclbr.py ---- {'Class': 4, 'class': 2} ---- D:\Python-2.1\Lib\pydoc.py ---- {'Repr': 6, 'repr': 28} {'message': 2, 'Message': 5} {'Scanner': 3, 'scanner': 9} {'I': 2, 'i': 10} {'Doc': 3, 'doc': 27} {'S': 2, 's': 2} {'GUI': 2, 'gui': 3} {'Entry': 1, 'entry': 10} ---- D:\Python-2.1\Lib\Queue.py ---- {'Empty': 2, 'empty': 1} {'Full': 2, 'full': 1} {'queue': 7, 'Queue': 1} ---- D:\Python-2.1\Lib\random.py ---- {'VERSION': 3, 'version': 4} {'n': 14, 'N': 20} {'Random': 2, 'random': 45} ---- D:\Python-2.1\Lib\repr.py ---- {'repr': 3, 'Repr': 2} ---- D:\Python-2.1\Lib\rexec.py ---- {'hooks': 6, 'Hooks': 2} {'RExec': 2, 'rexec': 13} ---- D:\Python-2.1\Lib\rfc822.py ---- {'AddressList': 3, 'addresslist': 19} ---- D:\Python-2.1\Lib\robotparser.py ---- {'Entry': 5, 'entry': 15} ---- D:\Python-2.1\Lib\smtpd.py ---- {'options': 15, 'Options': 2} {'data': 18, 'DATA': 3} {'command': 16, 'COMMAND': 5} ---- D:\Python-2.1\Lib\sre.py ---- {'s': 15, 'S': 1} {'m': 14, 'M': 1} {'template': 15, 'TEMPLATE': 1} {'i': 19, 'I': 1} {'Pattern': 1, 'pattern': 38} {'SubPattern': 2, 'SUBPATTERN': 2} {'scanner': 4, 'Scanner': 1} ---- D:\Python-2.1\Lib\sre_compile.py ---- {'in': 19, 'IN': 2} {'literal': 2, 'LITERAL': 9} {'ASSERT': 1, 'assert': 2} {'charset': 16, 'CHARSET': 2} {'range': 2, 'RANGE': 3} ---- D:\Python-2.1\Lib\sre_constants.py ---- {'IN': 3, 'in': 2} ---- D:\Python-2.1\Lib\sre_parse.py ---- {'pattern': 16, 'Pattern': 2} {'subpattern': 25, 'SubPattern': 5, 'SUBPATTERN': 2} {'IN': 11, 'in': 40} {'literal': 7, 'LITERAL': 31} {'flags': 11, 'FLAGS': 4} ---- D:\Python-2.1\Lib\symtable.py ---- {'Class': 2, 'class': 5} ---- D:\Python-2.1\Lib\telnetlib.py ---- {'DEBUGLEVEL': 2, 'debuglevel': 9} ---- D:\Python-2.1\Lib\tempfile.py ---- {'MACFS': 3, 'macfs': 4} ---- D:\Python-2.1\Lib\threading.py ---- {'thread': 6, 'Thread': 9} {'lock': 9, 'Lock': 4} {'_VERBOSE': 2, '_Verbose': 14} ---- D:\Python-2.1\Lib\token.py ---- {'STRING': 1, 'string': 1} {'NAME': 1, 'name': 2} ---- D:\Python-2.1\Lib\tokenize.py ---- {'contstr': 10, 'ContStr': 2} {'STRING': 3, 'String': 2, 'string': 3} {'indent': 1, 'INDENT': 1} {'NUMBER': 1, 'Number': 3} {'Name': 3, 'NAME': 1} {'Token': 2, 'token': 23} {'Comment': 3, 'COMMENT': 4} ---- D:\Python-2.1\Lib\unittest.py ---- {'TestLoader': 3, 'testLoader': 5} ---- D:\Python-2.1\Lib\urllib.py ---- {'Close': 1, 'close': 14} {'ic': 4, 'IC': 1} {'ftp': 13, 'FTP': 1} ---- D:\Python-2.1\Lib\urllib2.py ---- {'H': 10, 'h': 20} ---- D:\Python-2.1\Lib\uu.py ---- {'Error': 4, 'error': 1} ---- D:\Python-2.1\Lib\warnings.py ---- {'i': 4, 'I': 1} ---- D:\Python-2.1\Lib\wave.py ---- {'Chunk': 3, 'chunk': 22} ---- D:\Python-2.1\Lib\webbrowser.py ---- {'Error': 2, 'error': 1} ---- D:\Python-2.1\Lib\xdrlib.py ---- {'Error': 3, 'error': 2} ---- D:\Python-2.1\Lib\zipfile.py ---- {'crc': 2, 'CRC': 15} From paulp at ActiveState.com Mon Jul 2 22:26:30 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Mon, 02 Jul 2001 19:26:30 -0700 Subject: Python for air traffic control? References: <134760338.994108231348.JavaMail.root@boots> <20010702211742.A4372@node0.opengeometry.ca> Message-ID: <3B412D56.1388033D@ActiveState.com> William Park wrote: > >... > > Ask silly question, get silly answer. Please stop asking "Can Python do > this, can python do that..." Just read the docs, and do it. If you > can't read, there people who can help you with that too. I think that many of the safety and performance issues are subtle and would not be answered by general purpose documentation. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From cribeiro at mail.inet.com.br Sun Jul 1 20:36:48 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Sun, 01 Jul 2001 21:36:48 -0300 Subject: The standard library In-Reply-To: <9hoe39$8ce$1@newshost.accu.uu.nl> References: Message-ID: <5.0.2.1.0.20010701212940.02778c70@mail.inet.com.br> At 00:09 02/07/01 +0000, Martijn Faassen wrote: >Do I understand PEP 1 right this way? I guess having a number assigned for >a PEP before discussing it in public may be a good idea. :) I'm not sure that this is the best way to handle it. Some people have already sent unnumbered drafts to the list before without being burnt in public by irate PEPmasters . It's good for the discussion; it even allows the PEP to be discussed *before* wasting a number on it :-) I have my own draft right now, dealing only with one small part of the problem. I've thought about it as a annex to PEP 2. It's named "Quality Guidelines For Standard Modules". I'm going to send it in a separate email in a few minutes... Carlos Ribeiro From tdelaney at avaya.com Wed Jul 25 02:55:57 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Wed, 25 Jul 2001 16:55:57 +1000 Subject: proposed language change to int/int==float (was: PEP0238 lame nt) Message-ID: > > The interesting thing is that the one thing that has to change in > > order to get a unified numeric model, whether we introduce rationals > > in the numeric tower or not, is integer division! A numeric tower > > with rationals could look like this: > > > > int < long < rational < float < complex > > > Just a comment: What bothers me is that floats in computers > are not the > same as R continuum im math. This makes me think that > rationals are "better" > than floats. Indeed, any float number can be exactly represented by > rational, but not vice virsa. So my tower would be like that: > > int < long < float < rational < complex float < complex rational I'm going to assume the unification of ints and longs here ... The problem that we have is that long and rational would have a greater range than float, as they are effectively unbounded in size (ignoring memory restrictions of course). I'm starting to think the rational term is incorrect. We could get rid of the above problem by having a "denominated" type. A "denominated" type is represented as long or float numerator, long or float denominator. So long as both the numerator and denominator are within the range of float, the "denominated" number can be as large as you wish. Complex of course could have its real and imaginary parts being long, float or denominated. We would then have a tree like ... long < float iff long in range of float long < denominated float < denominated denominated < complex So, to perform an operation on long and float, the following promotions (and demotions) would occur. 1. Promote long to denominated => long/1 2. Promote float to denominated => float/1 3. Perform operation 4. If the result is in the range of float, demote to float. There are a couple of optimisations possible here, such as promoting a long to float and performing the operation, but if the result is greater than the float can represent it will need to then be promoted to denominated anyway. Tim Delaney From eli-wallach at ugly.com Sun Jul 1 17:12:12 2001 From: eli-wallach at ugly.com (Mexican Bandit) Date: Sun, 01 Jul 2001 21:12:12 GMT Subject: Python cgi script - outputting images References: <5hmujt89383m9n4o044aknd2a0f5d5h0re@4ax.com> Message-ID: >#!C:\Python20\python.exe -u > >and you might find it works. Yep, working fine now. Thanks! >By the way, I'm assuming you have some sensible reason (like a firewall) why >your server has to read the image and write it out, rather than simply >returning the image's URL as the SRC attribute of the IMG tag? I've written a webcam portal java applet, and needed a way of grabbing images from external servers. Because of security, applets can only connect to the server the applet resides on. Thus I needed a little script which could act as a kind of proxy to get images from elsewhere, locally. Regards From SBrunning at trisystems.co.uk Mon Jul 16 08:06:40 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Mon, 16 Jul 2001 13:06:40 +0100 Subject: Is Python Dead? Long Live Python! Message-ID: <31575A892FF6D1118F5800600846864D78BE89@intrepid> > From: Alex Martelli [SMTP:aleaxit at yahoo.com] > How silly -- everybody knows that owning it is irrelevant, the key thing > is sleeping with your head close to it so that its magical effluvia reach > your brain each night. Good thing the standard Python library reference > does specify that usage mode IS keeping it under one's pillow! Alex, You should be ashamed of yourself, passing on rubbish like this. Putting them under your pillow does no good; you have to *eat* them if you want to gain their power. The 'Essential Reference' isn't a problem here, but you'll need to be a *big* eater to cope with 'Programming Python'. Not-saying-a-word-about-Americans-ly y'rs, Simon B. ----------------------------------------------------------------------- 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 burton_kent at bigfoot.com Tue Jul 17 13:20:48 2001 From: burton_kent at bigfoot.com (burton_kent at bigfoot.com) Date: Tue, 17 Jul 2001 17:20:48 -0000 Subject: SGML and Python Message-ID: <9j1s5g+rubh@eGroups.com> What's available for SGML and Python? PyGrove and PySGML are what I've found, however, the website at the University of Waterloo where they're located seem to always be down. I need to do validation and correction of incomplete SGML documents. Thanks. B From mike_haspert at credence.com Tue Jul 31 16:04:15 2001 From: mike_haspert at credence.com (Mike Haspert) Date: 31 Jul 2001 13:04:15 -0700 Subject: importing win32com.client.Dispatch with embedded interpreter Message-ID: Hi all: The minimal function f1(), below in usecom.py, runs fine from the command line, but when I use the C API for the interpreter, it runs the first time and fails thereafter. Can anyone see what I'm doing wrong? The error message "TypeError: this constructor takes no arguments" has me stumped. Thanks in advance for your help. ****************** #include "python.h" #include int minimal(char* modname) { bool success = false; PyObject *mod,*func,*args,*rvals; Py_Initialize(); mod = PyImport_ImportModule(modname); if(mod) { func = PyObject_GetAttrString(mod, "f1"); Py_DECREF(mod); if(func) { if(NULL!= (args = Py_BuildValue("()"))) { if(NULL!= (rvals = PyEval_CallObject(func,args))) { //use_the_rvals() success = true; Py_DECREF(rvals); } Py_DECREF(args); } Py_DECREF(func); } } Py_Finalize(); return success; } int main(int argc, char* argv[]) { cout<<"********first usecom\n"< Message-ID: <37226F27072B5761.2F9AD68312465BA7.B02B0EE3318B2EFB@lp.airnews.net> In article , Don Tuttle wrote: >I have a secure Windows telnet client I'd like to automate with a script. >So far my efforts with the popen family haven't worked. Is this a possible >task? > >Don > > > telnetlib and pyexpect are the usual answers. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From bridgman at wyeth.gsfc.nasa.gov Tue Jul 17 11:50:13 2001 From: bridgman at wyeth.gsfc.nasa.gov (Tom Bridgman) Date: Tue, 17 Jul 2001 11:50:13 -0400 Subject: Handling errors in PyXML/SAX Message-ID: <3B545EB5.6BB5DF57@wyeth.gsfc.nasa.gov> I'm finally starting to work with the SAX parser and DTDs. With the SAX defalult error handler, when parsing a file, I get error messages like: ERROR in Unknown:94:22: Element 'animationtype' not declared ERROR in Unknown:98:18: Element 'thumbnail' not declared ERROR in Unknown:99:14: Element 'medialist' not declared which I find ideal but for the fact that I would like to print the file name rather than 'Unknown'. I've tried setting the systemID (which seems to be where the 'Unknown' comes from) in a locator object like so: location=xmlreader.Locator() location.setSystemId=inputfilename self.handler.setDocumentLocator(location) but still get 'Unknown'. The documentation at http://pyxml.sourceforge.net/topics/docs.html is really pretty vague on how to use this feature. Suggestions? Thanks, Tom -- Dr. William T."Tom" Bridgman Scientific Visualization Studio Global Science & Technology, Inc. NASA/Goddard Space Flight Center Email: bridgman at wyeth.gsfc.nasa.gov Code 935 Phone: 301-286-1346 Greenbelt, MD 20771 FAX: TBD http://svs.gsfc.nasa.gov/ From teo at crepido.com Thu Jul 26 02:46:19 2001 From: teo at crepido.com (teo) Date: 25 Jul 2001 23:46:19 -0700 Subject: xml - parsing with 4Suite, how does it work? References: Message-ID: Martin von Loewis wrote in message news:... > teo at crepido.com (teo) writes: > > > I'm looking for some documentation about howto parsing an xml-file > > into a DOM with the 4Suite-tools. Does anyone have an idea where to > > search, or how to do? > > I recommend the PyXML howto: > > http://py-howto.sourceforge.net/xml-howto/DOM.html > > Regards, > Martin Thanks, that was what i needeed! /Teo From db3l at fitlinxx.com Fri Jul 20 01:02:06 2001 From: db3l at fitlinxx.com (David Bolen) Date: 20 Jul 2001 01:02:06 -0400 Subject: Distributing a Python app References: Message-ID: "Tim Peters" writes: > FYI, I'm seriously looking at switching the PythonLabs Windows installer > over to Inno. It's simple (as such things go) and easy to use (as such > things go). We've been happy with the Wise installer Mark Hammond talked > them into letting us use in '94 or '95, but it's showing its age and I'm > apparently not nearly as persuasive as Mark (they don't even acknowledge > receiving my emails -- but then I wouldn't either ). Wasn't there something or other you mentioned it couldn't quite do that the current Wise stuff does when this last came up? -- -- 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 ehagemann at home.com Sun Jul 22 11:37:38 2001 From: ehagemann at home.com (Eric Hagemann) Date: Sun, 22 Jul 2001 15:37:38 GMT Subject: can't find fpectl Message-ID: <6rC67.32302$Ek3.11785061@news1.rdc1.md.home.com> Quick question, Running through the 2.1 library reference and found info on the 'fpectl' -- floating point exception control module. When I tried to run the examples and import the module I get an Import error -- does this module exist ? From aito at carenet.co.jp Thu Jul 5 22:52:53 2001 From: aito at carenet.co.jp (Akio Ito) Date: 5 Jul 2001 19:52:53 -0700 Subject: Getting data from DBIII References: <3B41CEFD.3BDB4F63@nettonettech.com> Message-ID: <82399a9.0107051852.6e4daaee@posting.google.com> See also: http://www.vex.net/parnassus/apyllo.py/973100124 From aahz at panix.com Sat Jul 28 01:22:37 2001 From: aahz at panix.com (Aahz Maruch) Date: 27 Jul 2001 22:22:37 -0700 Subject: 2.0 or 2.1 on win32 References: Message-ID: <9jti6t$e2g$1@panix2.panix.com> In article , douglas savitsky wrote: > >i am installing a new server and i need to know if there is reason to >install either 2.0 or 2.1 or any other version. The server is win2k (2 >1GHZ, 512, raid, etc.). the clients are also win2k. > >the applications that run on the clients connect the the server via DCOM. >the python running on the server connects to other objects sometimes with >COM and sometimes not. the clients use 2.0 as there seems to be some >weirdness in 2.1/tkinter on windows, but there won't be any tkinter on the >server. so, should i stick with 2.0 on the server as well? are there >stability issues or compatability issues to be aware of with other versions? I'd say for starters that the question should be "2.0.1 or 2.1.1?" Overall, my personal preference is to deal with cross-version issues as little as possible, so if your clients are using 2.0.1, the server should, too. (And, yes, I do definitely recommend upgrading the clients if possible.) -- --- 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 Fortune cookie: Watch your relations with other people carefully, be reserved. From aleaxit at yahoo.com Sat Jul 7 17:11:25 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 7 Jul 2001 23:11:25 +0200 Subject: Comment on PEP-0238 References: Message-ID: <9i7ttg01bnf@enews3.newsguy.com> "Guido van Rossum" wrote in message news:cpelrskgrr.fsf at cj20424-a.reston1.va.home.com... ... > The "div" keyword would be ideal except for the added complexity of > adding a new keyword to the language -- do we need a separate warning > phase here, too? > > (Hm. For various reasons I'm very tempted to introduce 'yield' as a > new keyword without warnings or future statements in Python 2.2, so > maybe I should bite the bullet and add 'div' as well...) I see pro's and con's, but, should you decide to go ahead, might you PLEASE treat 'mod' just the same as 'div'...? mod and div are a great pair, as may be / and %, but having to use div and % would be seriously hard to explain/remember/justify to newbies/... Alex From grayson-wilson at home.com Mon Jul 9 21:21:14 2001 From: grayson-wilson at home.com (EricIDLE) Date: Tue, 10 Jul 2001 01:21:14 GMT Subject: Help with reduce(). References: <3ur27.663627$166.13698874@news1.rdc1.bc.home.com> Message-ID: im sorry i still dont understand reduce can you explain it in simpiler terms? Steve Holden wrote in message news:Sds27.29662$F%5.1909477 at e420r-atl2.usenetserver.com... > "EricIDLE" wrote in message > news:3ur27.663627$166.13698874 at news1.rdc1.bc.home.com... > > Ok well I have ANOTHER problem with one of the examples in my book (By The > > Way, "Teach yourself python in 24 hours" is an extremely poorly written > book > > and I do not reccomend it to any newbies who are just starting off) > > any ways the example is as follows. > > > > n = range(1,11) > > def mult(x,y): > > return x * y > > f = reduce(mult,n) > > print f > > > > I get everything up to reduce. I relize mult() takes the first two numbers > > in range N which would be 1, 2 and multiplys them together to get 2... ok > > fine im good ... now comes the tricky part!! what does reduce do? Does it > > take the whole range and make it into a number (12345678910) then subtract > 2 > > (the result of the function mult) or what does it do. > > > The reduce() function takes a function as its first argument and a sequence > as its second. There's also an optional third argument, which we can ignore > for now. The function is applied to the first two items of the sequence, > then to that result and the third item of the sequence, then to that result > and the fourth item, and so on until the sequence is exhausted. Here's a > loop that might make it a bit clearer: > > >>> def mult(x, y): > ... return x * y > ... > >>> for i in range(2, 11): > ... n = range(1, i) > ... print i, ":", reduce(mult, n) > ... > 2 : 1 > 3 : 2 > 4 : 6 > 5 : 24 > 6 : 120 > 7 : 720 > 8 : 5040 > 9 : 40320 > 10 : 362880 > > Each result extends the value by one multiplication (by one less than I > because of the way range works). > > > And i have another question (not related to first question) > > > > x = ['Thu', 'Aug', '5', '06:06:27', 'MDT', '1999'] > > def strp(x,y): > > return x + ' ' + y > > r = reduce(strp,x) > > print r > > > > my problem is this line return "x + ' ' + y" what does it return the value > > of. I would understand it if it was x + y but the qutation marks are what > > throw me off what do they mean? > > > This is another case where the interactive interpreter is your friend. Try > it and see... > > >>> x = 'one' > >>> y = 'two' > >>> x + y > 'onetwo' > >>> x + ' ' + y > 'one two' > > You can see that the second statement constructs a string from *three* > values: the string bound to x, the string consisting of a single space, and > the string bound to y. > > So all your second example does is append al lthe strings together, with > spaces in between them. It takes 'Thu' and 'Aug" and puts them together with > a space in between them, that takes *that* result and '5' and puts them > together with a space between them, and ... you probably see the point now. > > When you give reduce() a thrid argument, it starts with that and the first > element of the sequence rather than the first two elements of the sequence, > allowing you to put an initial value into the string of function > evaluations: > > >>> x = ['Thu', 'Aug', '5', '06:06:27', 'MDT', '1999'] > >>> def strp(x, y): > ... return x + ' ' + y > ... > >>> print reduce(strp, x, "Date is:") > Date is: Thu Aug 5 06:06:27 MDT 1999 > > I hope the book also (though possibly later) points out that a much better > way to do the same thing would be > > x = ['Thu', 'Aug', '5', '06:06:27', 'MDT', '1999'] > r = string.join(x, " ") > > which uses a function from the string module. And, using string methods, you > could even abreviate it to: > > " ".join(x) > > which tells the string containing a single space to insert itself between > the elements of the list, returning the resulting long string. But that > probably won't appear until you're about ten hours into the book! Good luck. > > regards > Steve > -- > http://www.holdenweb.com/ > > > > > From fredrik at pythonware.com Fri Jul 13 16:51:46 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 13 Jul 2001 20:51:46 GMT Subject: Tkinter: Frames in nested classes? References: <9053f4e3.0107130616.79fd6378@posting.google.com> <9053f4e3.0107131159.4af4d9a4@posting.google.com> Message-ID: Joshua Weage wrote: > Following up to my own message, here is the solution > (as done in Tkinter.py): that's not a solution, that's code bloat. > class Frame1(Frame): > def __init__(self, master=None, cnf={}, **kw): > cnf = _cnfmerge((cnf,kw)) > Frame.__init__(self, master, cnf) no need to use flatten or cnfmerge; just learn how to call the base class constructor in Python, and all will be fine. by the way, the cnf stuff is obsolete, and should not be used in new code. modern Tkinter code should look like: def __init__(self, master=None, **kw): Frame.__init__(self, master, **kw) see my introduction document for more info. From urner at alumni.princeton.edu Wed Jul 25 07:23:18 2001 From: urner at alumni.princeton.edu (Kirby Urner) Date: Wed, 25 Jul 2001 04:23:18 -0700 Subject: PEP0238: overriding // (__intdiv__) ?? Message-ID: Maybe I missed it. Did the PEP specify what we'd use to override the // operator in a class? __intdiv__ and __rintdiv__ ? Seems we'd need something like this, to have our objects play along. And I'd think this wrinkle should become available simultaneously with //. Kirby From grante at visi.com Wed Jul 25 11:27:33 2001 From: grante at visi.com (Grant Edwards) Date: Wed, 25 Jul 2001 15:27:33 GMT Subject: A modest PEP0238 suggestion References: <3b5c6e08.27535083@aplnews> Message-ID: In article , Guido van Rossum wrote: >Stephen Horne writes: > >> More important is all the software that is somehow in-the-field - a >> VERY serious problem. > >You can always use the solution that works so well in many other >situations: don't upgrade Python, or at least keep a copy of Python >1.5.2 or 2.1 around, and use that for your unconverted code. This is >a very common solution. The problem is that it's not _us_ (people who write Python programs) who decide what version of Python is running on a system. It's out customers and the poeple who ship Linux distros. I have no control over what version of Python is running on a customer's machine. I don't get to decide "don't upgrade." When RedHat starts shipping with Python X.Y, then my programs have to run under Python X.Y whether I like it or not. Meanwhile there are still plenty of customers running the old version -- I can't tell them to upgrade any more than I can tell others to upgrade. You may not like it, but Python is now being used in the real world to do real work... -- Grant Edwards grante Yow! World War III? No at thanks! visi.com From matthewm at ihug.co.nz Wed Jul 11 02:51:44 2001 From: matthewm at ihug.co.nz (Matthew) Date: Wed, 11 Jul 2001 18:51:44 +1200 Subject: PythonCOM and Office. Arrgh! References: <9ig91u$ii5co$1@ID-11957.news.dfncis.de> <3B4BB11B.97268EC2@ihug.co.nz> <9igcc1$ill0v$1@ID-11957.news.dfncis.de> Message-ID: <3B4BF780.7F23EB7B@ihug.co.nz> There's hope yet. This amongst other calls to PythonCOM do work >>> xlapp.Workbooks.Open("D:\\fred.xls",None,1,None,'fred') Read only with password does as it should So far as I've tried, 'in order' parameters do definitely work. It's a start but I'd like to figure why named keyword stillappesr to do nothing. Keep those interested posted...matthew PS: Config is win200, Office97 and ActiveState2.0/2.1 Emile van Sebille wrote: > On that machine I've got build 135 installed. > > I'm not sure if this is it, but Password does appear in the file created by > makepy.py. Have you run that? I renamed my copies here and it didn't give > me an error afterwards, so it probably won't help you at all. > > Other than that, I don't know what else may be going on. > > -- > > Emile van Sebille > emile at fenx.com > > --------- > "Matthew" wrote in message > news:3B4BB11B.97268EC2 at ihug.co.nz... > > So, definitely looks like a config issue of some kind. Just out of > > interest, what build of win32all are you running with 1.5.2? As Bill > > rightly noted from my original post , passing keyword args does > > absolutely nothing under my combos of win/python/win32all - no error, > > nor 'effect'. I'm begining to wonder whether Office97 PythonCOM stuff > > only works with similar vintage win32all builds. Will check it out and > > report back. any other ideas? regards, matthew. > > From greg at cosc.canterbury.ac.nz Thu Jul 12 21:50:21 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 13 Jul 2001 13:50:21 +1200 Subject: Language change and code breaks References: <3B4D3622.5B4FC76E@cosc.canterbury.ac.nz> Message-ID: <3B4E53DD.A319FDD9@cosc.canterbury.ac.nz> Dirck Blaskey wrote: > > It's a problem with expectations and the law of least astonishment. > Which audience would you rather astonish, and how much? Depends on what you understand "the problem" to be. To me, it's the fact that I have to write something ludicrously convoluted just to tell Python what sort of division I want to do. This has nothing to do with astonishment. -- 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 vAbazarov at dAnai.com Sun Jul 29 02:50:18 2001 From: vAbazarov at dAnai.com (Victor Bazarov) Date: Sun, 29 Jul 2001 06:50:18 GMT Subject: Unusual minidom behaviour: Part Deux References: <9jvj7e$96b$1@panix2.panix.com> <3B639B99.E068591E@engcorp.com> Message-ID: "Peter Hansen" wrote... > (I'm sure the real solution is to find the time to narrow down > the list of possible causes, because it seems very unlikely this > group will be able to solve your problem without more legwork > on your part. I know that doesn't sound helpful: sorry.) No biggie. I didn't have much hope when I wrote here asking if anyone had a similar problem or if anyone might have a suggestion. It was necessary to ask because as slim as the chance was, it wasn't zero, and I needed to check the newsgroup off my list of paths to take. So, I am moving on with much more conviction in my mind that the whole thing needs to be rewritten in Java. Those non-commercial enterprizes are simply not strong enough yet... Sorry for taking up your time. Victor -- Please remove capital A's from my address when replying by mail From robin at jessikat.fsnet.co.uk Wed Jul 18 04:31:46 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Wed, 18 Jul 2001 09:31:46 +0100 Subject: freeBSD 4.2 + Python2.1 References: <3B554714.EAA32155@oek.dk> Message-ID: In article <3B554714.EAA32155 at oek.dk>, Peter I. Hansen writes >Robin Becker wrote: > >> I'm trying to install Python2.1 and the package seems to install fine, >> but it seems that _socket.pyd is linked against libssl.so.2 which I >> don't have. Attempts to upgrade openssl are refused as openssl is part >> of the 'base' system. Am I really forced to upgrade the whole operating >> system? >> -- >> Robin Becker > >No, you can just download a new openssl (from openssl.org) and install it. > >/Peter > I tried and make seemed only to build statics, any one know how to get Configure to work properly? I don't have the faintest idea what openssldir is/are etc -- Robin Becker From tjenkins at devis.com Sat Jul 7 23:47:39 2001 From: tjenkins at devis.com (Tom Jenkins) Date: Sat, 07 Jul 2001 23:47:39 -0400 Subject: Gotcha in replace Message-ID: <3B47D7DB.9020502@devis.com> Hello all, While I was working on some database scripting, I got bit by this behavior in replace. >>> y = "insert into blah values ('hello','','','','bye')" >>> y.replace(",'',", ",' ',") "insert into blah values ('hello',' ','',' ','bye')" >>> Notice that the second matching set of ",''," characters are not replaced probably because the first and second matching sets overlap on the last and first character, respectively. It was trivial for this script to work around the gotcha (I just put the replace in a loop and broke out when new string equalled the old string). But that method may not be an appropriate workaround in all cases. Is this known behavior and I just missed it; or is this a bug in replace? -- Tom Jenkins devIS - Development Infostructure http://www.devis.com From jparlar at home.com Wed Jul 11 21:14:34 2001 From: jparlar at home.com (Jay Parlar) Date: Thu, 12 Jul 2001 01:14:34 GMT Subject: newbie question References: Message-ID: <1103_994900358@jparlar> To reiterate what Bill said in his post, buy Wesley Chun's book. At the end of every chapter there are a good number of chapter related exercises. Chun tries to cover most of the chapter's topics in these problems, and they really helped me learn Python. I seriously can't recommend this book enough. It's a fantastic piece of work. > > "crombie" wrote: > > > so, i wanna learn python. > > > i read the docs on python.org. what do i do now? is there like a > > website with a list of starter projects that need to be done in > > python to prove you know it and help you learn it? > > > > at a complete loss, will appreciate direction. any direction > > > Book: > > Wesley Chun's "Core Python" has an excellent reputation. Wesley > himself is very helpful on the tutorial list. > > > Problems: > > Can't really help there. Ask on the tutorial list? > > Enjoy, enjoy. > > Bill > Jay P. From guido at python.org Wed Jul 25 01:42:06 2001 From: guido at python.org (Guido van Rossum) Date: Wed, 25 Jul 2001 05:42:06 GMT Subject: Proposal for .py2, py3, etc. extensions. Was: A way to accommodate laguage changes References: Message-ID: philh at comuno.freeserve.co.uk (phil hunt) writes: > >> From: James Logajan [mailto:JamesL at Lugoj.Com] > >> > >> In the interest of proposing a solution everyone can live with, may I > >> suggest adoption of new module name extensions? A module > >> named "module.py2" Not bad; could save a lot of trouble indeed, if the change to the default is made with Python 3.0. --Guido van Rossum (home page: http://www.python.org/~guido/) From duncan at NOSPAMrcp.co.uk Mon Jul 30 04:43:42 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Mon, 30 Jul 2001 08:43:42 +0000 (UTC) Subject: PEP0238 lament References: <5sdnlt072hm6hp17nluu6f0fqq4bvr6mj8@4ax.com> <916olt0p3kciv0evmotdg6jev9bl29l57i@4ax.com> <3B5C52EA.9430255E@alcyone.com> Message-ID: Guido van Rossum wrote in news:cp4rrz95iu.fsf at cj20424- a.reston1.va.home.com: > I don't see when a unified number system would ever be less convenient > than the current number system, *except* in the rare case where you > are transliterating an algorithm from C that depends on integer size. > Unsigned ints of n bits are easily emulated by taking all results > modulo 2**n -- I do this now using Python long ints when I need to > emulate unsigned C longs. The main situation that I was thinking of was calculations involving currencies, which would normally be done using int or long. You want fixed precision and truncation of fractional results. you do not want any automatic promotion to floating point. I think the system you are proposing still allows for this, but it may make it easier to accidentally slip into floating point. > Using the new type/class unification in Python 2.2, you will be able > to subtype the int or long types easily to create your own constrained > types. It may be fun trying this out. -- 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 nospam at nospam.com Fri Jul 27 03:42:50 2001 From: nospam at nospam.com (Grace) Date: Fri, 27 Jul 2001 16:42:50 +0900 Subject: Is this an Intended behaviour of __getattr__? References: Message-ID: "Volucris" wrote in message news:3b6111de$0$325$6e49188b at news.goldengate.net... > > "Grace" wrote in message > news:uu787.103805$ph7.16107665 at news.hananet.net... > > I'm a bit confused with this: > > > > class Node: > > def __init__(self): > > self._next=None > > def __getattr__(self,attr): > > if attr=='next': > > if self._next is not None: > > return self._next > > else: > > self._next=Node() > > return self._next > > print attr,"was called..." > > error=3/0 #supposed to raise exception > > raise AttributeError > > > > if __name__=='__main__': > > f=Node() > > links=[f.next,f.next,f.next.next,f.next.next] > > for each in links: > > print each > > print f.errorPlz > > > > And this yields exactly, > > > > __str__ was called... > > __repr__ was called... > > <__main__.Node instance at 0081608C> > > __str__ was called... > > __repr__ was called... > > <__main__.Node instance at 0081608C> > > __str__ was called... > > __repr__ was called... > > <__main__.Node instance at 0081601C> > > __str__ was called... > > __repr__ was called... > > <__main__.Node instance at 0081601C> > > al was called... > > Traceback (most recent call last): > > File "...", line 22, in ? > > print f.al > > File "...", line 12, in __getattr__ > > k=3/0 > > ZeroDivisionError: integer division or modulo by zero > > > > Why did it suck up all ZeroDivisionErrors while outputting the "was > > called..." messages? Special case with magic methods? Is this an intended > > behaviour? Then what is the exact process/mechanism? > > > > Thanks in advance. > > > > > > in __getattr__ if the attr is 'next', if checks the value of _next and > returns whether it's None or not. the code after return never gets executed. > the only time it didn't return first, was when __getattr__ was called with > 'errorPlz' (not 'next'). > > That was too wordy, but I hope it's intelligible. > -- Thanks, but I don't think it answers my question. I think when __repr__ and __str__ are called internally via the interpreter as in the print statement, it passes through the __getattr__ method of Node class while all exceptions are simply ignored. Am I right on this? Not sure. ps. when I use "not equal operator" != in the "if self._next is not None:" line, __ne__ (above python 2.0) is searched after, and as it fails, __getattr__ is called, and goes into the same strange process as above, ignoring all exceptions. From akuchlin at mems-exchange.org Thu Jul 5 17:55:39 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 05 Jul 2001 17:55:39 -0400 Subject: Most important text processing examples References: <3dr8vvqrfl.fsf@ute.cnri.reston.va.us> <3B44D0BD.63A3F795@home.net> Message-ID: <3dofqzqbvo.fsf@ute.cnri.reston.va.us> Chris Barker writes: > Anyone writing a computer book should read this: > http://philip.greenspun.com/wtr/dead-trees/story.html > It's interesting (and humorous) reading for the rest of us as well. Indeed; that page cured me of my desire to write a book for physical publication. Sure, there's the ego-thrill of a big wad of paper with your name on the front, but it also means you have to work to a deadline, errors in the final product can't be corrected, and you have to cope with potentially clueless editorial interference (sure, maybe your editor will offer lots of good suggestions -- what if they don't?). Putting things on Web pages, you can fix errors whenever you like, write sections whenever you like, and can get direct feedback directly from readers; the advantages are all in the Web's favor. --amk From guido at python.org Wed Jul 11 10:26:41 2001 From: guido at python.org (Guido van Rossum) Date: Wed, 11 Jul 2001 14:26:41 GMT Subject: Comment on PEP-0238 References: <3B4A775B.1212684C@cosc.canterbury.ac.nz> Message-ID: Greg Ewing writes: > Guido van Rossum wrote: > > > > I just discovered that we don't need to add a new operator overloading > > name for the div and mod operations: classes already look for a > > __divmod__ method to overload divmod(), and we should naturally define > > div(x, y) (or x div y) as divmod(x, y)[0]. > > That sounds suspiciously similar to the argument that > we don't need __eq__, __le__ etc. because we can just > as well funnel them all through __cmp__... Darn. That's a reasonable argument. If a numeric array module defines __divmod__, does it return a tuple of two arrays, or does it return an array of tuples? In either case, it would be a waste for div to call __divmod__ and then have to throw away half of the result. --Guido van Rossum (home page: http://www.python.org/~guido/) From maxx at easynews.com Wed Jul 25 12:02:46 2001 From: maxx at easynews.com (maxx at easynews.com) Date: Wed, 25 Jul 2001 16:02:46 GMT Subject: Python for Palm OS References: <20010725.4442652@mis.configured.host> Message-ID: <1brtltk197fgufo68r8f4b93hc7bk5onr6@4ax.com> http://www.endeavors.com/pippy/ On Wed, 25 Jul 2001 04:38:55 GMT, Robert Roberts wrote: >I have heard several times that there is a version of Python for the palm >os. Have palm version 3.5. Can anyone direct to the proper download? > >Thanks in advance. From skip at pobox.com Mon Jul 2 19:20:40 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 2 Jul 2001 18:20:40 -0500 Subject: Postgres support In-Reply-To: References: Message-ID: <15169.456.489888.509381@beluga.mojam.com> >> As an example, I would like to find a cross-platform (Linux, Windows, >> etc.) Postgres interface that works with Python 2 or greater and >> Postgres 7 or greater, conforming to the dbAPI. Not too much to ask, >> one might think. Apparently, it has been too much to ask so far. Nobody else in the Python community appears to have needed what you asked for badly enough to implement it and make it available. I certainly haven't, and I've been doodling around with one or another database thing in Python for several years. I've been happy with the interface to MySQL, though the You can do one of three things: * implement it and keep it to yourself * implement it and release it for others to use/improve * find someone willing to do it for you for a fee (perhaps a fee of $0) -- Skip Montanaro (skip at pobox.com) (847)971-7098 From gustafl at algonet.se Wed Jul 4 09:50:22 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 4 Jul 2001 13:50:22 GMT Subject: Two problems with backslashes Message-ID: I have two problems with backslashes in DOS path strings: >>> path = 'e:\test\test.txt' >>> path.replace('\\', '/') 'e:\test\test.txt' Expected: 'e:/test/test.txt' Also, split() doesn't like backslashes: >>> paths = 'e:\test\file1.txt e:\test\file2.txt' >>> paths.split() ['e:', 'est', 'ile1.txt', 'e:', 'est', 'ile2.txt'] Expected: ['e:\test\file1.txt', 'e:\test\file2.txt'] Alternative ways would be much appreciated. Regards, Gustaf Liljegren From philh at comuno.freeserve.co.uk Sat Jul 21 16:29:38 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Sat, 21 Jul 2001 21:29:38 +0100 Subject: converting from perl: variable sized unpack References: <9j2dnn$ndm$0@216.39.144.220> Message-ID: On 21 Jul 2001 01:49:19 GMT, Quinn Dunkan wrote: >On Thu, 19 Jul 2001 12:36:49 +0100, phil hunt >wrote: >>On 18 Jul 2001 21:19:54 GMT, Quinn Dunkan wrote: >>>It's not just you, but I don't agree, and it's not just me either. >>>NameErrors, KeyErrors, and IndexErrors have saved me many times. One of the >>>things I didn't like about perl is how it magically created values on >>>reference, and then I had to go hunt down the bad reference that created it. >>>And I often store None in dicts and lists. It would be weird if d.has_key(x) >>>could be true or false while d[x] always evaluated to None. That means that >>>d[x] is implicitly creating a None when d.has_key(x) is false, >> >>It doesn't, it's just returning a value. > >But where is that value coming from? It wasn't stored in the dict! Consider the expression 2+3. Where is the 5 coming from; it wasn't stored anywhere previously. >And keep in mind that looking up global names and looking up object attributes >are conceptually dictionary lookups (in globals() and obj.__dict__, >respectively). I'd be happy for a reference to a non-existant variable to create it with a default value (e.g. None). Awk does this, and I find it a good feature ofd not having to manually cross the t's and dot the i's. > >This is the kind of automatic creation and coercion that many people love >about perl. Many other people, however, don't :) One of the few things Perl does right, then. Personally I find Perl almost impossible to code in as I cannot make head or tail of it as far as lexical analysis goes. -- #===== Philip Hunt == philh at comuno.freeserve.co.uk ======# Herbivore: effort-free public key encryption. See: ** First software release coming soon! ** From shriek at gmx.co.uk Fri Jul 27 01:55:59 2001 From: shriek at gmx.co.uk (Stephen) Date: 26 Jul 2001 22:55:59 -0700 Subject: Going from webscripting to server-client software. References: <6572890e.0107251014.47e07810@posting.google.com> <9d848d5d.0107251349.68519652@posting.google.com> Message-ID: <97ae44ee.0107262155.5abdb82@posting.google.com> > > intranet and it was really easy. But it was possible for one of the > > staff to be looking at a resource (eg. a squash court) and not > > be aware of a booking made by another member of staff in real time, > > which could lead to double-bookings if telephone bookings are made. > > They do not like to hit refresh in order to see the most up to date > > status of a particular resource. They want software more like > > Windows-applications. > > Have you considered a small applet that displays the status of the > currently viewed resource? This might be created in Jython and > automatically update from the server at a specific interval. Yes, I did consider it, and am still considering it for sales staff who only have read ability (see below for reasons). This is also why I didn't consider Worldpilot as somebody else kindly suggested. It would still result in the same problem with changes by one client being updated on all other clients in real time. Do the applets keep polling for changes ? If Sue books the slot 2-3pm on squash court 1, I'd like the block representing it to turn red on all other clients in real time, without staff intervention. (They've got other jobs to do, as well as taking phone bookings etc) > > How should I keep all of the client applications in synchronization > > with each other? When each client app is opened, it gets all the > > bookings for the day from the server. > > Are they able to edit the bookings once the data has been downloaded? > i.e., do they get the data in "read only" mode then click on a button > or link to edit the data? If so you might create a lock file, or > similar item, on the server when someone clicks on the edit button or > link. > > If anyone after that clicks on the edit button it could check for the > existance of the lock file. If the file is present they might see the > current information and who has it locked but not be able to edit the > information. Yes, they can edit the data (insert new entries or move/change existing bookings). Using a lock creates the problem if they then kill the web browser. Yes, the lock could be timed out after say 3 mins (it can take them that long to insert contact data etc) but that still could result in a lost booking if another person were trying to book the same time during those 3 minutes. Really, I'm trying to get away from a stateless, non-updated-in-realtime web app to more of a client app, something that might have been created in Delphi or VB in the past. Especially since it might give us the flexibility to integrate with other applications, such as the membership system and email apps. (The web just doesn't lend itself to building look-ahead auto-complete fields for names, emails etc). Thank you for taking the time to help. S. From loewis at informatik.hu-berlin.de Sat Jul 21 15:34:58 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 21 Jul 2001 21:34:58 +0200 Subject: Python XSLT Processor? References: <3B55F528.A0FE6181@nospam.de> Message-ID: Uwe Hoffmann writes: > > I'm looking for a pure Python XSLT processor (i.e. no C/C++ extensions); > > does anyone have any good pointers? I know of a few Java ones, so I > > could use a Java XSLT program + Jython, but I'd really prefer to keep > > using CPython if possible. > > maybe 4xslt from http://4Suite.org/ That actually uses a C extension, namely a bison-written XPath parser. The current PyXML CVS replaces this with a pure-Python solution, but that doesn't work at the moment. Still, the XSLT engine would then use C extension, namely the boolean module. If the question really was for "no external libraries needed", then 4xslt is a good solution. Regards, Martin From aleaxit at yahoo.com Tue Jul 3 18:08:55 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 4 Jul 2001 00:08:55 +0200 Subject: Eiffel better than Python ? References: <9hsf0c0210e@enews1.newsguy.com> Message-ID: <9htfmj0csk@enews4.newsguy.com> "Dublanc, David" wrote in message news:qRq07.9790$Wc.6458460 at nnrp4.proxad.net... > What is exactly weak typing ? I believed that Python was weak typing ! Python has dynamic typing, but it's far from weak: it won't turn int into string, or viceversa, for example, unless you tell it explicitly. Perl's penchant for turning numbers into strings and VV is a good example of weak typing. > About Visual Basic : My brother (a VB developer :-) thinks that if you only > develop on MS platform and for MS platform without speed goal, VB is very, > very productive ! Apparently Microsoft disagrees from your brother;-), since in the next release they're making many incompatible changes to the VB language (almost every one of which, funny enough, takes it closer to Pyton -- though not quite close enough:-). > (there are for instance a browser of DLL, so system programming is very > easy ). The impressive array of tools that comes with VB _almost_ (but not quite) makes up for the language deficiencies, which are many (they will be fewer in next release, since MS is removing some of the most glaring ones, like the Set vs Let distinction in assignments, the related concept of 'default attribute' of an object, etc, etc). In a sense the situation is close to Java (though Java as a language has fewer warts than VB, and it ain't so much the tools but the libraries and frameworks:-). Into both niches Python fits just great -- you get to keep using the same libraries and some of the tools AND at the same time you code in a sane language....!-) Alex From thomas at xs4all.net Thu Jul 12 05:38:33 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Thu, 12 Jul 2001 11:38:33 +0200 Subject: Apache, CGI, Python... In-Reply-To: <3b4cc04f.1657030403@wa.news.verio.net> References: <3B45051300120CE9@mail.san.yahoo.com> <3b4cc04f.1657030403@wa.news.verio.net> Message-ID: <20010712113833.H5396@xs4all.nl> On Wed, Jul 11, 2001 at 09:38:41PM +0000, Bengt Richter wrote: > Can a python script be run efficiently and su-exec'd? I.e, Apache can run > CGI as a particular account owner (e.g.,for access to private directories > etc. that 'nobody' shouldn't see). Naturally it would work if you got a > whole instance of the interpreter to yourself, but does modPython take > care of su-exec properly? (I guess I should ask at modpython, but I'm here > ;-) No, just like mod_perl and mod_php, mod_snake and mod_python both embed Python into Apache, and so it runs under the permissions of the Apache server, not as a separate user like 'suexec'. But note that you don't need mod_python or mod_snake to run Python scripts at all. They're just handy speedups and provide hooks into Apache, and some forms of persistance and such. If you want to have fast CGI's, persistance *and* run them as another user, you should consider FastCGI instead. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From mal at lemburg.com Wed Jul 18 16:31:14 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Wed, 18 Jul 2001 22:31:14 +0200 Subject: [Python-Dev] PEP: Defining Python Source Code Encodings References: <3B559B71.C08C6145@lemburg.com> Message-ID: <3B55F212.9B11346A@lemburg.com> Barry has assigned the PEP number 0263 to this PEP. If you prefer to read the PEP online, here is the URL: http://python.sourceforge.net/peps/pep-0263.html -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From kelleys at ucsu.colorado.edu Wed Jul 25 12:31:38 2001 From: kelleys at ucsu.colorado.edu (Scott Kelley) Date: Wed, 25 Jul 2001 09:31:38 -0700 Subject: trouble importing module _socket Message-ID: <3B5EF46A.9A7E61E6@ucsu.colorado.edu> Hello all, I seem to be having a problem importing modules. I am installing on Slackware 3.5 over a previous installation of Python 1.5.2 . I just installed Python 2.1 which is working for the most part, but then I get errors like this one: File "/usr/local/lib/python2.1/socket.py", line 41, in ? from _socket import * ImportError: No module named _socket I can't find any _socket module in the Python libraries. Also as I was installing I noticed problems with several modules that didn't seem to want to install making me think this might be a general problem. Has anyone out there experienced similar problems and have a notion of what I can do about it? I really appreciate any help you can send me. -Scott ------------------------------------------------------------------------------ Scott T. Kelley, Ph.D. E-mail: Scott.Kelley at Colorado.edu Dept. MCD Biology Phone : 303-735-1808 Campus Box 347 Fax : 303-492-7744 University of Colorado Boulder, CO 80309-0347 U.S.A. From gmcm at hypernet.com Wed Jul 11 09:28:38 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 11 Jul 2001 13:28:38 GMT Subject: py2exe & Pmw References: <9ihb0c$ivgp5$1@fu-berlin.de> Message-ID: <90DB6DF40gmcmhypernetcom@199.171.54.155> Matthias Huening wrote: >I know this has been asked before. Can't find the solution right now... >So here is the problem: using py2exe with Tkinter works fine. >But when I want to build a .exe which uses Pmw something goes wrong. >Here is the output: I'm sure it's the same as with Installer - you need to run Pmw's bundlepmw.py script (instructions in the bin directory). - Gordon From tim at vegeta.ath.cx Wed Jul 18 03:21:20 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Wed, 18 Jul 2001 07:21:20 GMT Subject: Python 2 times slower than Perl References: <8f41cfd.0107171238.6ff33b9b@posting.google.com> <3B54D9A2.45C23B14@Lugoj.Com> <8f41cfd.0107172305.5e2f3a70@posting.google.com> Message-ID: Me parece que Xu, C.S. dijo: > Interesting is for perl: On the same PII 450 MHz, "for" loop > in stead of "while" loop increase about 10% speed, but on another > PIII 1GHz, "for" slowes down speed by 30% (from 8 seconds of > "while" to 10.6 seconds of "for"). Only computers themselves > can understand, :-( Algorithms for these structures have changed over the years. Are both perls the same version? Is either or both of them compiled with processor-specific options? I will assume you're measuring actual CPU seconds. HTH -- Sometimes we can choose the path we follow. Sometimes our choices are made for us. And sometimes we have no choice at all. -- Morpheus, The Sandman From djc at object-craft.com.au Wed Jul 11 02:28:37 2001 From: djc at object-craft.com.au (Dave Cole) Date: 11 Jul 2001 16:28:37 +1000 Subject: Why database modules are incomplete References: <5174eed0.0107060820.ff90805@posting.google.com> <23891c90.0107090815.3685a9@posting.google.com> <23891c90.0107100600.13e4fc7c@posting.google.com> Message-ID: >>>>> "Paul" == Paul Boddie writes: >> Boy, would I ever like to be able to complete my modules... Paul> Isn't that true for most of us? ;-) It is the universal constant. Paul> Understood. But as I pointed out in the thread from which the Paul> message you respond to came from, the usefulness of your module Paul> in your business, and your reliance on that module, should be Paul> seen as guarantees that you take its development seriously. It Paul> is for this reason that I took exception to Mr Wilson's Paul> "Maverick" accusations. It is not enough to be a serious user yourself. When things start to go wrong in the server (resource shortages, ...), you get to see all sorts of things happen at the interface layer. Only by having lots of users can you build a reputation of providing a "serious" module. Given that almost no-one ever tells me that they have used the module (successfully or otherwise), it is a bit hard to know just how serious a module I have developed. Paul> Actually, I think I did try your Sybase module out about a year Paul> ago or so, by the way. What held me back there was, I think, the Paul> lack of certain required libraries with my Sybase system, but I Paul> may have got it working in the end. Sorry if I never Paul> communicated that! That is OK - you are free to use whatever module you like. I have just added one more module to the list of possible solutions to your problem. There is also no obligation to tell me about your experience with my module. Paul> An interesting point emerges here, though. The process of module Paul> discovery can be somewhat stressful. It's quite likely that many Paul> people give up "too easily" while building extensions, for Paul> example, and move on to the next candidate module. In my Sybase Paul> adventures, I tried your module and ctsybase first; ctsybase was Paul> easiest to get working but lacked support for bind/bound Paul> variables. Since I can't abide working without them, I moved Paul> over to mxODBC, even though the effort in getting ODBC working Paul> can be significant, but at that point I had the possibility of Paul> choosing other database systems and was satisfied enough not to Paul> do any more evaluation of other modules. When a module does not just compile and work it is very annoying. You tend to question the competence of the developer. It is only by getting feedback from people who fail to have the module "just work" that the installation can be made more robust. I have some ideas about how to make it easier to get my module working - maybe for the next release. Paul> I certainly accept this. It can be disheartening to release Paul> something which seems interesting and exciting to oneself, only Paul> to be met with near silence in response. I can see people downloading the module - there have been 182 unique IP addresses which downloaded the Sybase-0.2x module. I have no idea how many them even compiled the module. Paul> I think obscure bugs are the things that worry people most Paul> particularly about database modules. ;-) Yeah. If you are simply passing the SQL and parameters from the Python code directly to the database API then there is not a lot of scope for changing the meaning of the SQL and parameters on the way through. About the only thing I can see going wrong is incorrect binding of binary values... >> 2- People who experience problems do not bother contacting me. >> >> Although it would be nice to think that option 1 is true, I suspect >> that option 2 is closer to the truth. Paul> There's another possibility: people may experience problems but Paul> may not have your level of skill to diagnose or investigate Paul> them. I accept that this isn't a good enough excuse when, in Paul> this case, there is someone taking responsibility for the Paul> module, but then in periods of a maintainer not having enough Paul> time to work on the module whilst doing paid work, development Paul> and fixes are understandably delayed. Whilst it seems harsh and Paul> ungrateful, developers are often impatient creatures who only Paul> report problems when they happen and frequently give up quickly, Paul> choosing the path of least resistance (to the next candidate Paul> module). I think that is what I was trying to say. Paul> Of course, and no-one can or should be blamed for this. One big Paul> problem in the development of database modules in particular is Paul> the rarity of developers motivated enough and with enough Paul> resources to help people like you out. Never a truer word spoken. Paul> Not many people in the past have had access (or the inclination Paul> for ideological or other reasons to access) Sybase database Paul> systems whilst developing interfaces to the native libraries. Paul> Indeed, even those who have access to such systems may find Paul> libraries and headers missing. True. Paul> What this means in general is that some projects are likely to Paul> be driven by a single developer without "peers". A good way to Paul> make this situation more bearable for such developers and for Paul> the community would definitely go down well. Now you have your work cut out for you... :-) - Dave -- http://www.object-craft.com.au From Randy.L.Kemp at motorola.com Mon Jul 2 13:02:26 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Mon, 2 Jul 2001 12:02:26 -0500 Subject: Is Python Dead? Message-ID: I walked into this bar, and asked the piano player, "Do you know? Is Python dead?" He replied, "no, but if you hum a few bars, I will try to play it." -----Original Message----- From: m.faassen at vet.uu.nl [mailto:m.faassen at vet.uu.nl] Sent: Monday, July 02, 2001 11:22 AM To: python-list at python.org Subject: Re: Is Python Dead? Edward B. Wilson II wrote: > I have been following Python for five years now, and I am still just as > frustrated with it as I was in 1996. And 'is Python dead' will guarantee you people will read your post. > Python still doesn't have good database support, I realize I'm not familiar with Perl's dbi, which I hear is more powerful than Python's database interfacing, but I've happily connected Python to things like Access, MySQL and PostgreSQL. Also from within Zope. What do you consider to be 'good database support'? > nor has it grown to be > useful in the web space as mod_perl. PyApache has been around longer than > mod_php, yet php has far surpassed it as a productivity tool in the web > space. What about Zope, Quixote, WebWare? I mean, really, this is an area which has seen a lot of growth in recent years. http://www.zope.org http://www.mems-exchange.org/software/python/quixote/ http://webware.sourceforge.net/ And then there's this: http://www.vex.net/parnassus where you can find much more web related stuff, in case that wasn't enough. > It would seem Python can do everything, yet nothing. Everyone wants to > write the next killer application with Python, XML parsers, image > manipulators, super computer steering modules, yet no one wants to work on > making Python perform where it matters most. Python is the best language at > eclectic stuff, however, poor at bread and butter tasks. You'll just have to be more specific about this.. > Python needs better leadership in areas of its growth. Python is truly the > best language in use today, except it still isn't very useful for the > largest solution sector, database access, and information presentation (web, > or otherwise). But those areas are exactly what I've been using it for the last couple of years! Surely I would've noticed it if Python was dead. :) Of course, some things could be nicer (relational object integration would be nice), and as have been discussed recently, the Python Standard Library could've seen some more development. Also of course a comprehensive Python Catalog ala CPAN would be nice. But really, either you've managed to miss an amazing amount of developments the last few years (really, had you missed Zope?), or your post here was rather unclear -- what exactly is it that you're missing? Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From stremler at rohan.sdsu.edu Mon Jul 9 22:27:19 2001 From: stremler at rohan.sdsu.edu (stremler at rohan.sdsu.edu) Date: 10 Jul 2001 02:27:19 GMT Subject: BASIC or Python? References: <3d157fa0.0107051904.7ec368b8@posting.google.com> <0t_17.14670$Fk7.131382@news.indigo.ie> Message-ID: <9idp67$jln$2@gondor.sdsu.edu> In rec.games.roguelike.development Mark 'Kamikaze' Hughes wrote: [snip] > However, do you not indent your code in C? > if(foo) > bar(); [snip] > It's a very old, very bogus argument, dragged out every time by the > people who haven't used Python; once you program in Python, it becomes a > non-issue. I'll just quote: This is also one reason I dislike Python. Indentation is part of the documentation of the program, and as such it shouldn't be parsed by the compiler. -- Peter da Silva (September 1999) -- Stewart Stremler stremler at rohan.sdsu.edu ----------------------------------------------------------------------------- I'm glad that you're beginning to understand the shortcomings of analogies and will bear that in mind in the future. -- Peter da Silva (2001) From uioziaremwpl at spammotel.com Tue Jul 3 11:38:05 2001 From: uioziaremwpl at spammotel.com (Carsten Geckeler) Date: Tue, 3 Jul 2001 17:38:05 +0200 (CEST) Subject: Augmented Assignement (was: Re: PEP scepticism) In-Reply-To: Message-ID: On Tue, 3 Jul 2001, Fredrik Lundh wrote: > Carsten wrote: > > > Well, the Python world before augmented assignment was quite simple: > > Operators never changed the objects they acted on. > > nothing prevents __add__ from changing the objects. Thank you very much for deleting my next sentence which clearly stated that it can be done, of course, by a user defined object by operator overloading. I'm sticking at first with builtin types which behave in that way. And I hope most authors also try to do the same in this case for clearity. > > Now we have augmented assignments. x=+y _can_ change the object > > bound to x, depending if x is mutable or immutable. > > has nothing to do with mutability, and all to do with how the > __iadd__ method is implemented: > > + is an alias for __add__ > += is an alias for __iadd__ > > as for all other operators, the exact semantics are up to the > type/class implementation. Again, my argument was for builtin types. And for them the distinction is made for mutable and immutable types. That user defined classes can define some strange operator overloading is o.k. But allowing people doing things does not neccessarily mean that thay should do it, especially when it's not logical. Cheers, Carsten -- Carsten Geckeler From sill at optonline.net Fri Jul 13 18:31:43 2001 From: sill at optonline.net (Rainy) Date: Fri, 13 Jul 2001 22:31:43 GMT Subject: Long Live Python! References: <3B4CC986.A5C8E605@engcorp.com> <3B4E4932.78F8B7D3@engcorp.com> Message-ID: On Thu, 12 Jul 2001 21:04:50 -0400, Peter Hansen wrote: > Rainy wrote: > >> I meant more like sending somewhere my resume saying I know python and did >> this and that, and getting hired. I actually did use some python at my >> previous job (some cgi/image manipulation). I was then asked to redo it >> in perl :-/. > > Is that the reason you left? :) No, I left because I got bored of image manipulation, which constituted the bulk of the job. > -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: http://silmarill.org/cymbaline From sheila at spamcop.net Fri Jul 20 10:42:39 2001 From: sheila at spamcop.net (Sheila King) Date: Fri, 20 Jul 2001 14:42:39 GMT Subject: Case insensitivity References: Message-ID: On Fri, 20 Jul 2001 10:01:45 -0300, Gustavo Niemeyer wrote in comp.lang.python in article : :Indeed, I don't think case-sensitiveness is something that will help :non-programmers to get used to the language. You have so many factors :to learn when you're starting, case sensitiveness will be just one more :behavior of the language (not a wart at all). On the other hand, I :think that, if you create a case-insensitive tool or command line option :and let users get used to it, it'll take forever to learn how to program :in sensitive mode. As a high school computer science teacher, I must agree. I have been teaching C++ for the last couple of years, to students with no prior programming experience. Aiyee! And, there were many things that gave them difficulty. Missing closing braces. Misplaced semi-colons. Forgetting "break" in a switch-statement. But case-sensitivity was never an issue. I mentioned it one day, and explained it, and I don't remember it ever being a problem, where a student called me over to his/her machine and asked me for help finding a bug, and it came out to be related to case-sensitivity. I don't remember this happening even once. There were many other bugs that made us tear our hair out, but never, never this. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From guido at python.org Tue Jul 31 13:44:59 2001 From: guido at python.org (Guido van Rossum) Date: Tue, 31 Jul 2001 17:44:59 GMT Subject: FEEDBACK WANTED: Type/class unification References: <6edd2418.0107301344.439affc8@posting.google.com> Message-ID: Martin von Loewis writes: > By default, instance attributes are not accessible outside of instance > methods. In instance methods, attributes are denoted by an initial > ampersand (e.g. @age, @name, @counter). You can declare attributes as > accessible, using [etc.] (Thanks for the explanation.) It seems that because of the access rules, this makes sense for Ruby. But since attrs are public by default in Python, it makes less sense here. We could easily have a shortcut that creates a pair of accessor functions to map a public attribute name to a private attribute, but what good would it do us? You only need to use accessor functions when you want additional functionality. I guess a read-only attribute is the simplest added functionality. Thinking aloud: def readonly(name): def get(obj): return getattr(obj, '_' + name) return getset(get, None) class C: foo = readonly('foo') def __init__(self): self._foo = 12 # access raw attribute x = C() print x.foo # legit x.foo = 21 # error --Guido van Rossum (home page: http://www.python.org/~guido/) From fredrik at pythonware.com Mon Jul 23 05:26:46 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 23 Jul 2001 09:26:46 GMT Subject: A use for integer quotients References: Message-ID: David wrote: > 6 instances of determining transformed image sizes: > newX = (oldX * targetSize)/max(oldX,oldY) etc. I don't know whether PIL > allows image.resize() to take float arguments, whether it throws an > exception, or whether it just does something bogus. PIL picks the largest possible image size not larger than the given size. > Not even counting the divisions I'm sure are lurking in PIL? PIL will break. > So, anyone who I might have passed the program on to will one > day suddenly see ugly floats in their generated web pages, if the > program still works at all, and won't have any clue why or how to > fix it. welcome to the wonderful world of Python 3000. From claird at starbase.neosoft.com Mon Jul 30 12:10:44 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 30 Jul 2001 11:10:44 -0500 Subject: Language Niches (long) References: <8beb91f5.0107280407.5a30341d@posting.google.com> Message-ID: <175D9DAD48302704.2A098F904A50FA12.D77210EAD1B10B5B@lp.airnews.net> In article , Robin Becker wrote: . . . >Java actually represents a new thing; write once run anywhere. . . . More so than Forth, UCSD Pascal, Lisp, Cobol (which deserves more appreciation for getting some of the social questions right), ...? -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From akuchlin at mems-exchange.org Thu Jul 12 10:32:54 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: Thu, 12 Jul 2001 10:32:54 -0400 Subject: cursesmodule: remove 2-argument form of newwin()? Message-ID: In the curses module, newwin() when called with two arguments returns a pad instead of a window. This is equivalent to the newpad() function, and it's a bit confusing. I'm tempted to change this for 2.2, having the 2-argument newwin() return a window, not a pad, and set nlines and ncols to zero, making ncurses use the rest of the screen for the window. This matches the actually documented behaviour. I'm doubtful anyone uses the 2-argument newwin() at all, but wanted to ask the group -- does anyone rely on newwin(x,y) returning a pad? This is bug #417212 on SourceForge; you can make comments on that bug, or here on python-list. --amk From dgrisby at uk.research.att.com Wed Jul 25 05:53:15 2001 From: dgrisby at uk.research.att.com (Duncan Grisby) Date: 25 Jul 2001 09:53:15 GMT Subject: PEP0238 lament References: <5sdnlt072hm6hp17nluu6f0fqq4bvr6mj8@4ax.com> <3B5C52EA.9430255E@alcyone.com> Message-ID: <9jm4ub$ulf$3@pea.uk.research.att.com> In article , Guido van Rossum wrote: >If you agree that, if it weren't for breaking old code, PEP-238 would >make Python a better language, what can we do about that old code? I agree that PEP-238 would make Python a better language. But it's not just about breaking old code -- as I've said a few times already, it's also about making it very awkward to write _new_ code which must be able to run on more than one version of Python. Cheers, Duncan. -- -- Duncan Grisby \ Research Engineer -- -- AT&T Laboratories Cambridge -- -- http://www.uk.research.att.com/~dpg1 -- From emile at fenx.com Tue Jul 10 22:02:34 2001 From: emile at fenx.com (Emile van Sebille) Date: Tue, 10 Jul 2001 19:02:34 -0700 Subject: PythonCOM and Office. Arrgh! References: <9ig91u$ii5co$1@ID-11957.news.dfncis.de> <3B4BB11B.97268EC2@ihug.co.nz> Message-ID: <9igcc1$ill0v$1@ID-11957.news.dfncis.de> On that machine I've got build 135 installed. I'm not sure if this is it, but Password does appear in the file created by makepy.py. Have you run that? I renamed my copies here and it didn't give me an error afterwards, so it probably won't help you at all. Other than that, I don't know what else may be going on. -- Emile van Sebille emile at fenx.com --------- "Matthew" wrote in message news:3B4BB11B.97268EC2 at ihug.co.nz... > So, definitely looks like a config issue of some kind. Just out of > interest, what build of win32all are you running with 1.5.2? As Bill > rightly noted from my original post , passing keyword args does > absolutely nothing under my combos of win/python/win32all - no error, > nor 'effect'. I'm begining to wonder whether Office97 PythonCOM stuff > only works with similar vintage win32all builds. Will check it out and > report back. any other ideas? regards, matthew. > From missive at frontiernet.net Sun Jul 8 16:35:26 2001 From: missive at frontiernet.net (Lee Harr) Date: Sun, 8 Jul 2001 20:35:26 +0000 (UTC) Subject: [ZOPE] External Method process limits? References: <9i9rmn$kc6$1@node21.cwnet.roc.gblx.net> Message-ID: <9iag6e$1l2k$2@node21.cwnet.roc.gblx.net> On Sun, 08 Jul 2001 17:03:30 +0200, Rene Pijlman : > missive at frontiernet.net (Lee Harr) schreef: >>Here is the error message I get: >>Error Type: TypeError >>Error Value: expected string, ImplicitAcquirerWrapper found >>File /usr/local/www/Zope/Extensions/Thumbnail.py, line 18, in makeThumbnail >>Any wisdom? > > Yes, the error is on line 18 of > /usr/local/www/Zope/Extensions/Thumbnail.py :-) > > Post lines 1-25 if you want more help. > Well, the code is cut and pasted from the Zope Book, so I am _assuming_ there are no errors in the script. And, like I said it works fine on other images. What I am trying to determine is if there are any limits set on External Methods which I might be running in to trying to process such a large image. I have looked through many pages of docs and everything seems to be saying that External Methods are unrestricted. Is that true? From mirko.liss at web.de Wed Jul 11 13:00:13 2001 From: mirko.liss at web.de (Mirko Liss) Date: Wed, 11 Jul 2001 19:00:13 +0200 Subject: Bug in __imul__ In-Reply-To: References: Message-ID: <20010711170014.626C3E1E.NOFFLE@niccolo.ke4.de> On Wed, 11 Jul 2001, Roman Suzi wrote: > P.S. Going to write Fython ;-) > (F for Forth) I'm looking forward to it. I guess Fython can be a nice intermediate language to apply user defined optimization strategies without having to take care of this or that new Python feature or on the other hand any platform specific bytecode. regards, Mirko From rnd at onego.ru Wed Jul 4 00:28:59 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 4 Jul 2001 08:28:59 +0400 (MSD) Subject: Changing default font in idle/linux In-Reply-To: Message-ID: On Tue, 3 Jul 2001, Stephen Boulet wrote: >Anyone know how to change the default font in idle in linux? >I've looked at the file "EditorWindow.py" but found no "text['font'] = >("lucida console", 8)" line. Probably, this isnfo is outdated. In 2.1 you can specify font in the configuration file under "EditorWindow" chapter. Look at config*.txt (with IDLE) for example. >Here are my versions: > ># rpm -q python tkinter >python-2.1-1mdk >tkinter-2.1-1mdk > >Thanks. > >-- Stephen > Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Wednesday, July 04, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Mediocrity requires aloofness to preserve it's dignity" _/ From fleet at teachout.org Tue Jul 24 11:38:06 2001 From: fleet at teachout.org (fleet at teachout.org) Date: Tue, 24 Jul 2001 11:38:06 -0400 (EDT) Subject: intersection and union idea Message-ID: "Learning Python, First Edition (1999) page 109. provides examples. - fleet - >Message: 17 > Date: Tue, 24 Jul 2001 08:42:27 +0100 > From: Stephen Horne >Subject: Re: intersection and union idea > >On Mon, 23 Jul 2001 16:57:20 -0700, "Neil Macneale" > wrote: > >>I was day dreaming about python today, and I realized that it would be >>very python-ish to have intersection and union operators for lists and >>tuples. Eg: >> >>>>> (1,2,3,4) | (1,3,6,8) >>(1,2,3,4,6,8) >>>>> (1,2,3,4) & (1,3,6,8) >>(1,3) > >You could define your own set object, or an alternative to a >dictionary or list, using a class and defining the following >methods... > >__and__(self, other) >__or__(self, other) > >Whether it's really useful, though, is a different thing - you're >probably better off with simple functions operation on the existing >types. > >As a language addition - well, it wouldn't break anything I can see. >It could have some consiseness value, but it is really syntactic >sugar. From steveha at animal.blarg.net Mon Jul 16 18:00:27 2001 From: steveha at animal.blarg.net (Steve R. Hastings) Date: 16 Jul 2001 15:00:27 -0700 Subject: Cross-platform GUI app -- Tkinter? References: <3b4e211f$1@news.blarg.net> Message-ID: <3b5363fb$1@news.blarg.net> Mark 'Kamikaze' Hughes (kamikaze at kuoi.asui.uidaho.edu) wrote: > if the expensive book is John Grayson's _Python and > Tkinter Programming_, get it now, it's a damn fine book. Thanks for the tip. I took your advice and got it. I checked www.amazon.com, and found that they offer the Grayson book for 20% off--an even better deal than the sale at the store!--so I ordered the book from Amazon. > If what you want is portability, though, Python's probably more > portable than Java Okay. I thought Java bytecodes were my best hope for cross-platform compatibility... but Python has its own bytecodes, doesn't it! Suppose I wanted a program to be runnable on platforms like BSD, PowerPC Linux, PowerPC BSD, etc. without having to build on each of those. If I were to distribute .pyo files, and users of all those platforms already had Python installed on their systems, could I build and distribute a single .pyo file? If I do this project, I will directly support Win32, Mac, and x86 Linux. But I was hoping I could also distribute something that would be portable for everyone else outside these three platforms. If .pyo files are cross-platform, then they are the solution I wanted. The project I have in mind is a game, and I would use the Pygame library (a Python layer over SDL). But I would like the game to run in a well-behaved window, with pull-down menus and dialogs and such, rather than taking over the whole screen as some SDL games do. Thus my interest in Tkinter. -- Steve R. Hastings "Vita est" steve at hastings.org http://www.blarg.net/~steveha From tim.one at home.com Wed Jul 11 16:18:31 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 11 Jul 2001 16:18:31 -0400 Subject: Freeing memory from Python lists! In-Reply-To: Message-ID: [Chris Spencer, on Win2k "losing" memory after result = [] for count in xrange(510*478): result.append(count) del result ] > I can confirm these results. Why would a deleted list > retain 90% of its memory usage after being deleted? Sounds like > a pointer is getting lost somewhere. Nothing is lost. All flavors of Windows have flaky (yet different) malloc() implementations that work especially poorly with append-one-at-a-time list behavior. If you try it under the current CVS Python, it should work better on (all flavors of) Windows. In the meantime, Windows malloc has chewed up some *address space* (virtual memory) due its own internal fragmentation, which is not necessarily the same thing as "memory" (RAM). Getting an accurate view of Windows memory use can't be done from Task Manager; you have to walk the heap structures and analyze them yourself. From esharpe at uswest.wet Mon Jul 9 11:58:09 2001 From: esharpe at uswest.wet (Ed Sharpe) Date: Mon, 9 Jul 2001 08:58:09 -0700 Subject: New library software development project. References: <3B3601BE.3C84E49A@earthlink.net> Message-ID: there are already things like this out there.... re-inventing the wheel is not an option. check out www.koha.org or .com see what they are up to downunder! there is also openbook out of Seattle www.trfoundation.org Lets all put our efforts into one of these directions, they need our help rather than birthing yet another unique enity. ed sharpe archivist for smecc see us at: www.smecc.org Richard Snow wrote in message news:3B3601BE.3C84E49A at 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 revyakag at umdnj.edu Wed Jul 4 02:30:08 2001 From: revyakag at umdnj.edu (Andrey Revyakin) Date: Wed, 04 Jul 2001 02:30:08 -0400 Subject: sys.stdin.read() HELP! Message-ID: <3B42B7F0.50B624BD@umdnj.edu> I have a cgi script which reads XML data from a FLASH5 movie. The script reads data into a string like this: text = sys.stdin.read() After I moved my scripts from a machine with python 1.7.2 to to a one with python 2 .0, I started getting the following error: text = sys.stdin.read() IOError: [Errno 9] Bad file descriptor WHAT THE #$^ does that mean??? Please help! If I can't use my way with 2.0 anymore, what can I use instead? Thanks in advance! Andrey From gmcm at hypernet.com Sat Jul 21 09:23:12 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 21 Jul 2001 13:23:12 GMT Subject: 3rd beta of Win32 Installer release 4 References: <9jb2gl$milpe$1@ID-44371.news.dfncis.de> Message-ID: Cristian Echeverria wrote: > I tested release 4 with Python 2.1, Win98 and with a simple program: > > print "Hello" > > and I got the following errors > > W: exec statment detected at line 295 of imputil > W: No module named dos > W: No module named mac > W: No module named os2 > W: No module named posix > > I don?t know what is happening, all the previous version worked for my, > but version 4 has not worked at all, I always get a similar error. Those are not errors. Depending on what platform your python is built for, you have a builtin from the list [dos, nt, mac, os2, posix]. The os module (which is the same on all platforms) has code that, (depending on which of those it sees in builtins), imports the appropriate one. In scanning the code for "import"s, all 5 import statements are found, but only one of them names an existing module. So the other 4 are reported as warnings. This kind of thing is very common in cross platform code. To see if it works, try it. If it doesn't run, the warning messages may provide a clue. - Gordon From duncan at NOSPAMrcp.co.uk Mon Jul 30 09:58:19 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Mon, 30 Jul 2001 13:58:19 +0000 (UTC) Subject: Static method and class method comments References: <9jn382$lqf$1@license1.unx.sas.com> Message-ID: Kevin.Smith at themorgue.org (Kevin Smith) wrote in news:MdW77.10395$UB6.966994 at e3500-atl1.usenetserver.com: > I really like this idea. This is better than the current > implementation and the Jack Jansen syntax (which I found mildly > confusing). It also allows the current classmethod()/staticmethod() > built-ins to still be used, but in a more appropriate spot in the > method definition. I can see a lot of additional power and flexibility > with this idea. This one gets my vote! Ok, I'll see if I can write this up into a PEP. One thing that worries me slightly though is that I can't see a really good way to include getset in this proposal. (I can think of loads of slightly tacky ways to do it though). -- 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 whats_really_hot at hotmail.com Fri Jul 6 08:12:38 2001 From: whats_really_hot at hotmail.com (whats_really_hot) Date: Fri, 6 Jul 2001 15:12:38 +0300 Subject: any books for python for downloading? References: <993939668.727430@athnrd02.forthnet.gr> Message-ID: <994422491.679470@athnrd02.forthnet.gr> yea.great sites but they don't have any books for downloading, only for web reading and this requires time -internet time, which is unfortunately expensive. so, any other proposals for sites that contain text about python tutoring? every recommendation is welcome! thanks in advance! From web2ed at yahoo.com Mon Jul 2 11:47:06 2001 From: web2ed at yahoo.com (Edward Wilson) Date: 2 Jul 2001 08:47:06 -0700 Subject: Python--eclectic or ubiquitous Message-ID: <5174eed0.0107020747.6836d160@posting.google.com> Why is it that one can attempt the most daring tasks with Python, e.g. write image manipulation programs, steer super computing applications, write interactive games, parse XML, yet still can not perform the more basic tasks of hitting a database and generating a report. After five years of following Python, I haven’t seen much improvement in the areas that seem to be the most natural fit for Python: Commercial quality database support and robust web server modules. Are not developers more likely to write games in C, Assembler, or C++. And are not developers more likely to use scripting languages for building web applications, and generating reports. The Python camp seems to be more enthusiastic about building impractical solutions better suited for C libraries than for scripting languages. I understand that it is COOL to do so, but what about making Python more useful in the workplace so we can all start using it more often. One of the most annoying post I commonly see is, "Python is great, but there aren't many Python jobs". I write this out of frustration. I want to bring Python into my workplace, and eventually tackle everything with Python. Yet first I must to find and entry point. For me, that entry point lies in commercial quality database support, and some kind of web server plug-in like mod_perl. I know I can't be alone. Python has so much to offer, yet it’s impossible to handle the most common scripting tasks--the tasks which present the most convincing arguments to management. I will never use Python to parse XML if I can not first retrieve data from a database. Is everybody too busy writing flight simulators and gaming engines? Is anybody interested in resurrecting PyApache and making it better than PHP, and adding state-of-the-art database support for Oracle, DB2, Sybase, and SQL Server. Sure, I understand MySQL and Postgres are supported, but I just convinced my group to start using Linux. It will be several years before we start using open source databases. Python is without doubt, one of the finest-most-useful languages to come around. It stands to make computing so much more productive, cutting costs, reducing bugs, shortening development times, and bringing solutions to the market that would never be attempted with other tools, due to the natural inherent risks of software development. I keep asking myself, “when will it be our (Python’s) time to take center stage in the arena of software champions?” Not until developers can first handle the simple day-to-day applications. Everyone wants to be Super Bowl Champions, yet no one wants to first excel at blocking and tackling—the very attributes which champions are made of. Python excels at everything except the basics, the very tasks which make it acceptible. Please don’t kill my thread, I would like to rally a group to extend Python with what I feel it needs the most to gain the widest audience at this time. I would love to write applications, which talk to the satellites and barrow time from the local super computer, but first I have to retrieve the data from my company’s database. From guido at python.org Wed Jul 11 10:43:32 2001 From: guido at python.org (Guido van Rossum) Date: Wed, 11 Jul 2001 14:43:32 GMT Subject: A modest proposal (was: Comment on PEP-0238) References: Message-ID: "Arthur Siegel" writes: > But it is Guido's language and Guido's call. Just wish it was > all just left to his own sense of design elegance, which there > is reason to trust - rather his public justifications, which I > never find very satisfactory. Good point, Art. I trust my intuition more than my reasoning in these things, and often when I try to defend my intuition against challenges, what comes out are unsatisfactory rationalizations. Sometimes Tim's "channelings" say it better than I could have said it myself... :-) --Guido van Rossum (home page: http://www.python.org/~guido/) From tim.one at home.com Mon Jul 23 03:11:47 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 23 Jul 2001 03:11:47 -0400 Subject: PEP0238 lament In-Reply-To: Message-ID: FYI, PEP 42 (the "small feature request" PEP) contains - New math module radians() and degrees() functions. Somebody quick add grads before Python becomes obsolete . From guido at python.org Fri Jul 27 22:02:40 2001 From: guido at python.org (Guido van Rossum) Date: Sat, 28 Jul 2001 02:02:40 GMT Subject: 2.2 features References: Message-ID: Kirill Simonov writes: > It would be nice to have 'in' operator for types: > > assert (num in int) > assert (msg in str) Not bad. :) --Guido van Rossum (home page: http://www.python.org/~guido/) From payou at free.fr Thu Jul 5 07:20:59 2001 From: payou at free.fr (Alexandre Perrin) Date: Thu, 05 Jul 2001 11:20:59 GMT Subject: call Python from a multithreaded DLL Message-ID: Hi ! I'm working on a Win 32 Multithreaded DLL (in C++) and I need to call the Python (2.1) interpreter from differents threads of my DLL. It works fine when I call python from the main thread but it crashes when i call python from others threads. Here's a sample : -------------------------------------------------------------------- #include #include DWORD WINAPI myThread(LPVOID) { PyEval_AcquireLock(); PyRun_SimpleString("print \"Crash...\""); PyEval_ReleaseLock(); } void main() { DWORD lpThreadId = 0; PyEval_InitThreads(); Py_Initialize(); PyRun_SimpleString("print \"OK until now...\""); hTic = CreateThread( NULL, 0, myThread, NULL, 0, &lpThreadId); Py_Finalize(); } If someone can help me... Payou From tim at digicool.com Mon Jul 23 18:27:06 2001 From: tim at digicool.com (Tim Peters) Date: Mon, 23 Jul 2001 18:27:06 -0400 Subject: PEP0238 lament In-Reply-To: <9s4pltg7l5r04652q60oqgfu792ha0f1b2@4ax.com> Message-ID: [Tim] > Already said I don't care what other languages do here, and, > yes, of course that's my opinion -- like yours is yours. [Stephen Horne] > And that's *ALL* I need to prove to show that there is no good reason > to implement PEP0238 - the difference between an opinion and a > supposedly undeniable fact. It's my opinion that what other languages do doesn't matter, therefore there's no good reason to implement PEP 238? Well, as opinions go, at least that one's creative . try-giving-it-a-rest-for-12-hours?-ly y'rs - tim From dougfort at dougfort.net Fri Jul 6 09:57:27 2001 From: dougfort at dougfort.net (Doug Fort) Date: 6 Jul 2001 14:57:27 +0100 Subject: pb with xmlrpclib References: Message-ID: <3b45c3c4$1_7@news5.uncensored-news.com> Alexandre Fayolle wrote: > Hi, > > I'm using python 2.1 and the latest release of xmlrpclib from pythonware. > > If I use the default server, the following call causes an error on the > server: > > from xmlrpclib import * > > server = Server("http://localhost:8000") > > print server > > try: > print server.echo('\231') > except Error, v: > print "ERROR", v > > Is this a bug in xmlrpc or in the underlying xmllib ? > > Alexandre Fayolle The XML-RPC standard only supports ASCII text. (I found this our from the new O'Reilly book 'Programming Web Services with XML-RPC'. The book is pretty light weight (I skimmed it in an hour) but it has some worthwhile tidbits. -- 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 sheila at spamcop.net Fri Jul 20 19:18:31 2001 From: sheila at spamcop.net (Sheila King) Date: Fri, 20 Jul 2001 23:18:31 GMT Subject: Case insensitivity References: Message-ID: On 20 Jul 2001 18:09:22 -0400, pinard at iro.umontreal.ca (Fran?ois Pinard) wrote in comp.lang.python in article : :[Guido van Rossum] : :> To me, the only real important question is, how can we introduce :> case-sensitivity for novices without breaking the millions of lines of :> existing Python code. One option could be: forget it, it's too late. :> Another: put the case-insensitivity in the tools. : :(I presume you meant "case-insensitivity" on the second line of the above :paragraph). : :Would not it be convenient, before asking "how", to wonder "why"? The real :prerequisite question might be to define quite precisely "What are we :wanting to achieve, here?". Once this done, another question might be to :ask ourselves? "Is modifying the language the proper answer to about how :to reach the goals?", meaning the goals identified by the first question. : :I worry a bit that you state that the real important question is "how", :as if you were trying to escape the prerequisite questions, or maybe trying :to tell us that your mind got firm answers about them. In an attempt to address the "why" of this problem, I have posted the following article to two mailing lists to which I belong, for AP Computer Science teachers: > As some of you have probably noticed (or maybe not), I've become quite a > fan of the Python programming language, lately. I follow the newsgroup > comp.lang.python. Python is a language which is under development. > > One of the recent language changes recently discussed in > comp.lang.python has to do with whether identifiers should or should not > be case-sensitive. > > Those of us who programmed in Pascal, certainly recall the > case-insensitivity of that programming language. And now that we are > programming in C++, and moving to Java in another couple of years, we > are programming in a case-sensitive language. Python is currently a > case-sensitive language. > > I would like to conduct a small survey on the issue of case-sensitivity > in identifier names... > > When answering these questions, please do not consider only AP level > programming students, who are usually very sharp and often have > programming experience, but please think of beginning programming > students, and particularly those students who are not especially adept > at programming. > > Reply to: case at thinkspot.net if you please, and I will compile all the > results, summarize them and report back to the list on the findings. > > 1. Are you a computer science teacher? > > > 2. In your experience, have you found that cs students, especially > beginners, have difficulty due to case-sensitive identifier names? > > > 3. If you were designing a new programming language, would you choose to > make it case-sensitive or case-insensitive? Why? > > > 4. If you were using a language that had an option to set some sort of > flag or compiler directive to turn case-sensitivity off, would you use > such a feature with a beginning class? > > > 5. When trying to select a programming language for instructing > beginning students, do you consider case-sensitivity to be an important > factor in selecting a language for your beginning programming course? > > > Any other comments? If/when I get a reasonable number or responses, I will compile a summary and post the results here. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From chrishbarker at home.net Fri Jul 6 14:39:39 2001 From: chrishbarker at home.net (Chris Barker) Date: Fri, 06 Jul 2001 11:39:39 -0700 Subject: Tkinter doesn't work for MFC applications with Embedded Python? References: <48365474.0107052029.12d28427@posting.google.com> Message-ID: <3B4605EB.D801CB85@home.net> Chris Tavares wrote: > Tkinter and MFC don't mix in the same process. Neither will Tkinter and > WxWindows, or MFC and WxWindows, or Tkinter and GTK+, or any other gui > toolkits. > > The basic problem is that they all want control of the message loop - and > the first one there gets it. This is also the reason you can't run Tkinter > apps under PythonWin. While you might want to try to hack your way around this limitation, you will have a hard time of it, and you will, at best, get a result where the GUI elements created by the C+++ code will look and feel different that those created by the Python code. Your best bet is to use the same toolkit for the C++ and Python portions. This will result in a far more seamless transition between them. I know it can be done with wxWindows and wxPython, I imagine it could be done as well with QT or GTK. given that you are using MFC now, wx is probably your best bet. Check out the wxWindows/wxPython mailing list archives for info on how to do it. 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 anon at nym.net Sun Jul 1 07:22:04 2001 From: anon at nym.net (anon at nym.net) Date: Sun, 01 Jul 2001 04:22:04 -0700 Subject: GUI Builder for Python ? References: Message-ID: <9hn12v$p0r$1@slb7.atl.mindspring.net> Have you tried using Glade? With the assistance of libglade it is exceptionally easy to use Glade and attach handlers written in Python. In article , "Lothar Scholz" wrote: > Is there something other then "Black Adder" which is behind an alpha > version ? > From peter at engcorp.com Mon Jul 16 21:11:24 2001 From: peter at engcorp.com (Peter Hansen) Date: Mon, 16 Jul 2001 21:11:24 -0400 Subject: windows port access References: <3b520bcb@news.cybertours.com> <3B522E98.BAAA9E93@engcorp.com> Message-ID: <3B5390BC.C5FFCD2A@engcorp.com> Chris Gonnerman wrote: > > ----- Original Message ----- > From: "Peter Hansen" > > > If you look back through the last two days' worth of postings for subject > > "parallel port?!?" you should find something to help. Yes, it is > possible, > > no the result is not compatible (but you could always write a higher level > > wrapper to make it so). > > Unfortunately what Bryan is asking is not what you are answering. He wants > to access the I/O port 0x280, which he states is assigned to a "custom ISA > card" which (I assume) is not using the standard parallel port interface, > nor serial, etc. and for which he evidently has no driver. I admit I didn't actually look at the winioport stuff proposed in the "parallel port?!?" thread, but given that it was called winioport and not winparallelport, I assumed it was a way of providing generic access to IO ports under Windows. If I was wrong, then you are right to correct me! (Do you know winioport would not work or were you just tricked by the name of the thread?) Of course, it's probably moot given Jon Nicoll's response which suggests a perfectly viable alternative. > Bryan, please tell us a bit more about the device you are trying to control, > and perhaps we can help you. Always good advice to someone looking for assistance! -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From chris.gonnerman at newcenturycomputers.net Thu Jul 26 02:04:22 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Thu, 26 Jul 2001 01:04:22 -0500 Subject: And now, something completely different... Message-ID: <01e901c11598$d1de3ea0$0101010a@local> The PEP0238 flamewar has been rather bad the last few days, and a lot of ill will has been exchanged. I was among the detractors, and I feel I must apologize to Guido for contributing to his impending ulcer... So, like, I'm sorry, man. I found myself considering yesterday what programming language I would switch to if Python failed me, and I came to the conclusion that, even with PEP0238 suddenly breaking mucho code (as appeared likely before Guido's most recent postings), Python would still be head and shoulders (and beltbuckle and kneecaps) above everything else. Now, with the changes taking firm hold in 2+ years, and evidence that Guido takes our concerns seriously, I'm a much happier camper. Guido, I for one am happy to call you my Fearless Leader. From sholden at holdenweb.com Mon Jul 2 18:03:58 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 2 Jul 2001 18:03:58 -0400 Subject: MS "bans" GPL References: <7iq1ktcmslo24kbr8qvob2g3hpgleuf025@4ax.com> Message-ID: wrote in message news:7iq1ktcmslo24kbr8qvob2g3hpgleuf025 at 4ax.com... > Do the folks at MS _want_ us to find them unreasonable? > > http://dailynews.yahoo.com/h/zd/20010702/tc/ms_attacks_open_source_1.html > > "The license for Microsoft's Mobile Internet Toolkit, which is in its > second beta release to developers, says that it may not be used with > any software under the Free Software Foundation's General Public > License (GPL) and six other forms of "potentially viral software." > That language refers to open source code's freely available and shared > code licensing agreements. The wording of the license cites the Linux > OS and the Perl scripting language as examples." > Not at all. They simply don't care. regards Steve -- http://www.holdenweb.com/ From lawick at wanadoo.nl Thu Jul 19 10:47:03 2001 From: lawick at wanadoo.nl (lawick at wanadoo.nl) Date: 19 Jul 2001 14:47:03 GMT Subject: python sha module and ldap Message-ID: <3b56f2e7$0$26381@reader4> Hi, I have a problem using the sha module in python and sha encryption with ldap. The python sha module can generate a digest of a (password) string like this: >>> import sha >>> pwd='secret' >>> so=sha.new(pwd) >>> print so.hexdigest() e5e9fa1ba31ecd1ae84f75caaa474f3a663f05f4 >>> With openldap, a sha can be generated like this: joost at saba:~ > ldappasswd -h saba -t "" -vv -n -Hsha -e geheim :{sha}kGByAB793z4R5tK1eC9Hd/4Dhzk= The two don't match because Python sha is hex and ldap not. How can I make them match? Is there also a ssha module for Python? Cheers, Joost -- -- Joost van Lawick E: joost at lawick.com W: http://www.lawick.com/ From gustav at morpheus.demon.co.uk Wed Jul 25 16:56:02 2001 From: gustav at morpheus.demon.co.uk (Paul Moore) Date: Wed, 25 Jul 2001 21:56:02 +0100 Subject: ADO Events with win32com References: <21e393ee.0107210640.54f3e20c@posting.google.com> <54bjlt4sq1sloqvkaadr8a4q7pfvl30ibu@4ax.com> <21e393ee.0107251159.5dd16bc2@posting.google.com> Message-ID: <9ibultodlargmo296trtfef3sq55rkekl4@4ax.com> On 25 Jul 2001 12:59:44 -0700, nmack at pacbell.net (angusm) wrote: >You might want to wait for a more convincing explanation from someone >else but I was able to duplicate the problem and the code below worked >for me...it ain't pretty :-). Thank you, thank you, thank you! It's perfectly clear now. Your code may not be pretty, but it gave me all the pointers I needed... >I encountered two problems based on your code: >1)It appears the event class sees a different 'finished' variable from >what you define in your module. Doh! Yes, Python treats any variable which gets assigned to in a function as local unless it's explicitly declared using 'global'. If I could actually write code in Python, I'd be dangerous :-) >2)adAsyncConnect doesn't seem to work because the infinite loop that >gets created to wait for the events hogs the entire thread. There is >no way for the dispatched event to break in asynchronously... Again, I probably should have known this. In order to get COM events, the application must pump the Windows message loop. Your solution works fine for me, but there's also a win32gui.PumpWaitingMessages() call which just services any waiting messages. You can just put a call to this inside the wait loop (which, of course, would be doing real work if this was a proper application...) >hope this helps, >Angus It does. Thanks for your help. FWIW, the following is a working version of my code: from win32com.client import DispatchWithEvents, constants import win32gui finished = 0 class ADOEvents: def OnWillConnect(*args): pass def OnConnectComplete(*args): print `args` global finished finished = 1 def Test(): Conn = DispatchWithEvents("ADODB.Connection", ADOEvents) ConnStr = "Provider=msdaora;Prompt=complete" Conn.Open(ConnStr, Options=constants.adAsyncConnect) while not finished: win32gui.PumpWaitingMessages() print '...' pass if __name__ == '__main__': Test() Paul From tim.one at home.com Sat Jul 7 14:35:11 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 7 Jul 2001 14:35:11 -0400 Subject: Limiting thread intruction count In-Reply-To: <3b474e87$0$322$8eec23a@newsreader.tycho.net> Message-ID: [Neil Macneale, wants to limit ... Yes, bytecode intructions. ] > ... > So round robin scheduling is automatically used? The game is being > written strictly for unix; is there a way to find out if the unix > version uses round robin scheduling? On any platform with thread support, Python code runs under the protection of a global interpreter lock (GIL), which gives a thread exclusive access to the Python Virtual Machine for a fixed number of bytecodes. You can alter that magic number by calling sys.setcheckinterval(). Say you set it to 100. Then every 100 bytecodes, the eval loop forces the current thread to release the GIL, allowing some other thread to acquire it. Python has no control over *which* thread gets it next -- since Python threads are real OS threads, that's up to the OS thread implementation. So is it round robin? Beats me, and, more importantly, beats you too . The Stackless Python variant http://www.stackless.com/ implements a notion of (pseudo)microthreads instead, which may be more to your liking. They're not related to OS threads at all, and typically enjoy much lower memory consumption and much faster context switching than "real threads". Also more potential for influencing exactly when they swtich. Note that "a bytecode" is a very high-level thing in Python, and number of bytecodes has no clear relationship to elapsed time. For example, one bytecode may add 1+1, while another may sort a million-element list. From boegli at iinet.net.au Sun Jul 15 17:12:15 2001 From: boegli at iinet.net.au (Richard B) Date: Sun, 15 Jul 2001 14:12:15 -0700 Subject: got winioport.zip from http://www.geocities.com/dinceraydin/ now what? Message-ID: <3B52072F.BBC97885@iinet.net.au> How do I use the python scripts that come in this zip file? From guido at python.org Sun Jul 29 06:01:17 2001 From: guido at python.org (Guido van Rossum) Date: Sun, 29 Jul 2001 10:01:17 GMT Subject: FEEDBACK WANTED: Type/class unification References: Message-ID: Paul Prescod writes: > I'm reading the section on the introspection API but I don't understand > something. > > 1. If I am sitting at an interpreter prompt and I have an object how do > I figure out the complete list of currently available attributes > available on that object. Same as currently if it's a class: look in inst.__dict__ for instance vars, then look in inst.__class__ for methods and class vars, then recursively look through int.__class__.__bases__ for inherited methods and class vars. Weed out duplicates. The new type system defines "static" and "dynamic" types. For static types, you don't need to search through the bases because the class __dict__ is consolidated. But the recursive algorithm doesn't hurt. > 2. If I have an object that hides its attributes behind an __getattr__, > is there any way to tweak the list returned by the API described above? > > If I understand correctly, doing this is not sufficient: > > >>> T = foo.__class__ > >>> T > > >>> dir(T) > > I don't think that this will get base class attributes or attributes > hidden in __getattr__. And even if it did, it would be nice to have a > single API that combined instance attributes and class attributes > according to the fallback rules. i.e. I'd like something as close to > this as is realistically possible: > > def attrs(x): > return [y for y in all_possible_strings if hasattr(x, y)] (Note: this may return an infinite list!) In general, this is as impossible as it ever was -- you won't be able to tell *for sure* whether an object has an attribute x, since __getattr__ may be dynamic. I added getset attributes so that for most practical purposes you won't need to override __getattr__ so the inspection becomes more useful. > Take a recipe. Leave a recipe. > Python Cookbook! http://www.ActiveState.com/pythoncookbook BTW, now also linked from the python.org home page side bar. --Guido van Rossum (home page: http://www.python.org/~guido/) From guido at digicool.com Fri Jul 20 09:51:45 2001 From: guido at digicool.com (Guido van Rossum) Date: Fri, 20 Jul 2001 09:51:45 -0400 Subject: Case insensitivity In-Reply-To: Your message of "Thu, 19 Jul 2001 23:57:57 CDT." <00b801c110d8$93151fa0$0101010a@local> References: <00b801c110d8$93151fa0$0101010a@local> Message-ID: <200107201351.JAA09967@cj20424-a.reston1.va.home.com> > > So I'd say, please don't change the language itself, but it would be > > interesting to see experiments on a friendly python-oriented editing > > environment (to simplify things like finding modules and documentation, > > importing, reloading, etc.). > > Guido, isn't this the sort of environment you mentioned in your > back-to-the-future-type-article in Linux Journal? A programming > environment built around Python but optimized for the novice > programmer? Yes. > You seem to want to change the core of the language every other day. Eh? Evolution of the language is inevitable. We *need* to fix old design mistakes. When it's possible to do so without breaking old code, everybody cheers. Sometimes it's not possible without breaking old code, and then I try my darndest to find a way that will let old code work. > I've been there myself, on other projects... everything works correctly > and is almost perfect, but being a programmer you want to change > SOMETHING just to be fiddling with it. "Almost perfect" is about the > best anyone in the Real World can hope for. Sorry, that's not the affliction I am suffering from. I know very well that Python will always be an 80% solution, and I'm happy to leave well enough alone. There just are areas where I think future generations would thank me if I fixed it now... > I've said it before, and I'll say it again... thanks with all my heart > for the best programming language I've ever worked in. You're welcome. --Guido van Rossum (home page: http://www.python.org/~guido/) From jmarshal at mathworks.com Mon Jul 9 01:09:11 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 9 Jul 2001 05:09:11 GMT Subject: "has" Operator References: Message-ID: <9ibe9n$ffu$1@news.mathworks.com> Quinn Dunkan wrote: ... > 'x has y' would also have a nice resemblance to 'x in y', where one > checks if y is in the object itself, and the other checks if y is in > the container the object represents. I don't want the former > functionality often enough to think a keyword is worth it, though. In the case of 'x in y', 'x' and 'y' are both variables, but in the case of 'x has y', 'x' is a variable but 'y' is a name. I think that could be confusing. On the other side of things, it seems this could be introduced into the language without making 'has' a keyword--no syntactic rules currently use concatenation. From ullrich at math.okstate.edu Sat Jul 28 10:20:59 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sat, 28 Jul 2001 14:20:59 GMT Subject: [OT] Number theory [Was: A use for integer quotients] References: <3B5C5665.8D41D1F1@tundraware.com> <3B5C749A.59F97320@tundraware.com> <3b602afa.930850@nntp.sprynet.com> <3b617133.1013412@nntp.sprynet.com> Message-ID: <3b62c8c4.2448381@nntp.sprynet.com> On Sat, 28 Jul 2001 00:04:58 +0100, Gareth.McCaughan at pobox.com (Gareth McCaughan) wrote: >David C. Ullrich wrote: > >> >> Strictly speaking the natural number 2 is the set {{},{{}}} >> > >> >Tut. You're failing to distinguish interface from implementation. >> >> Tut what? If you read more than one paragraph you see that my >> point was exactly that when we say that Z is not strictly a >> subset of R that's an irrelevant implemenation detail. > >You said "Strictly speaking the natural number 2 is ..." >and gave one possible implementation. It's by no means >the only one, as I'm sure you know; but you didn't say >so. It's the only one in standard use that I'm aware of. I know several different "standard" "implementations" of integers, rationals and reals as sets, but a different implementation for natural numbers does not spring to mind. Of course infintiely many others are possible. But what's another "implementation" of the _natural_ _number_ 2 as a set that's actually in general use? Not that it matters. >> >I'm pretty sure you already know all this, but it's worth >> >saying explicitly. :-) >> >> Probably the fact that I _did_ say explicitly that there >> are several different "standard" ways to implement integers >> and reals is what makes you suspect I know this, eh? Very >> astute of you. > >I appear to have given offence, and I'm very sorry for >that. What I actually said is that because you said explicitly >that there are several ways to implement integers and reals, >you almost certainly are well aware that there are also >several ways to implement natural numbers. > >I was just concerned that some people might conceivably >misunderstand you to be saying, as Kronecker didn't :-), >that God made the von Neumann implementation of the >natural numbers and all else is the work of man. Ah. No, I didn't mean to say that, and yes I suppose that one might have got that idea. But if we're talking about implementations _as_ _sets_, and implementations that are actually _used_, then no I'm not aware of another. What's an example? (Hint: The two other "implementations" of natural numbers that spring to mind are not implementations as sets, which for some reason is what I thought the topic was. Those would be regarding natural numbers as defined by Peano arithmetic and regarding 2 as the class of all sets with two elements (spelled out without using the word "two", of course).) >Gareth McCaughan Gareth.McCaughan at pobox.com >.sig under construc David C. Ullrich From michael.g.abbott at ntlworld.com Mon Jul 23 14:35:22 2001 From: michael.g.abbott at ntlworld.com (Michael Abbott) Date: Mon, 23 Jul 2001 18:35:22 GMT Subject: PEP0238 lament References: <44ioltcofs8i897flbo7bfqtec5ki06n0s@4ax.com> Message-ID: Steve Horne wrote in news:44ioltcofs8i897flbo7bfqtec5ki06n0s at 4ax.com: > On Mon, 23 Jul 2001 15:08:32 GMT, Michael Abbott > wrote: > >>Actually, I'm quite suprised at just how rude Guido is in his replies. > > Here I do disagree, though I was rather annoyed once when I > *complemented* Python by saying that, although I was initially > sceptical about list comprehensions, I actually found them very useful > - and rather than accepting the complement he twisted that single case > into a character judgement where I was supposed to be *always* be > excessively judgemental about things and blatantly about to burst a > blood vessel. > > ... > > Anyway, in general Guido handles the benevolent-dictator role > extremely well - it has to be extremely frustrating in the position he > is in, and I'm surprised he has been generally as polite as he has. > I think you're probably right, and that what I wrote wasn't very sensible. I think I understand his frustration. > I hope he sees my current posts as they are intended - I see PEP0238 > as being something worthy of extreme scepticism if not outright > terror. But I only care at all because Python *is* a good and > worthwhile thing, and as a result I have been a very vocal advocate in > my company. I'm a relative newcomer to Python, but on the whole I've been *very* encouraged by my experience with it so far. (We also have a vocal advocate in my company, and I am becoming another.) From dhumphrey at pdqdot.net Tue Jul 31 18:33:06 2001 From: dhumphrey at pdqdot.net (David Humphrey) Date: Tue, 31 Jul 2001 17:33:06 -0500 Subject: Yet another flavor of extension debugging problem Message-ID: <7B30F7FB1736F67B.D89C159D0BA16ADE.2C73E602E671B2FD@lp.airnews.net> I managed to compile a debug version of ActiveState Python 2.0.203 using MSVC++ 6.0 and work on my C++ extension under the MSVC debugger. Now, I'm trying to do the same thing with Python 2.1.1 that I downloaded from www.python.org and can't seem to get the extension to load. I'm painfully aware of the _d naming convention. The release version of the extension loads fine as shown below: $ python Python 2.1.1 (#20, Jul 20 2001, 01:19:29) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> import sys >>> sys.path ['', 'c:\\BGIUtils', 'd:\\dlh\\bin', 'd:\\Utils\\Python21\\DLLs', 'd:\\Utils\\Python21\\lib', 'd:\\Utils\\Python21\\lib\\plat-win' , 'd:\\Utils\\Python21\\lib\\lib-tk', 'd:\\Utils\\Python21'] >>> for p in sys.path: ... print p ... c:\BGIUtils d:\dlh\bin d:\Utils\Python21\DLLs d:\Utils\Python21\lib d:\Utils\Python21\lib\plat-win d:\Utils\Python21\lib\lib-tk d:\Utils\Python21 >>> import bgilib >>> After building the debug version from source, I moved the libs, exes, and executables around to make a Python 2.1 debug version tree in d:\utils\python-2.1.1 just like the Python 2.1 release tree. Pure python modules in the c:\BGIUtils directory load fine, but when I try to import bgilib, I get the following result: $ python_d Adding parser accelerators ... Done. Python 2.1.1 (#20, Jul 31 2001, 11:59:53) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> import sys [5358 refs] >>> for p in sys.path: ... print p ... c:\BGIUtils d:\dlh\bin d:\utils\python-2.1.1\DLLs d:\utils\python-2.1.1\lib d:\utils\python-2.1.1\lib\plat-win d:\utils\python-2.1.1\lib\lib-tk d:\utils\python-2.1.1 [5360 refs] >>> import bgilib Traceback (most recent call last): File "", line 1, in ? ImportError: DLL load failed: Invalid access to memory location. [5397 refs] >>> ^Z [5397 refs] [1826 refs] dhumphrey at ROADRUNNER /c/bgiutils I can't find any reference to this exact string in a google search, so I'm posting it here hoping that someone out there can spot the problem. Regards and Thanks In Advance, David L. Humphrey Manager, Software Development Bell Geospace, Inc PS. Both the release and debug versions of the extension dll exist as shown below. Using dumpbin /imports shows nothing suprising for either file: one imports python21.dll while the other imports python21_d.dll. $ ls -al *.dll -rwxr-xr-x 1 dhumphre Domain U 73728 Jul 31 11:25 PyGx.dll -rwxr-xr-x 1 dhumphre Domain U 266284 Jul 31 11:25 PyGx_d.dll -rwxr-xr-x 1 dhumphre Domain U 258048 Jul 31 14:44 bgilib.dll -rwxr-xr-x 1 dhumphre Domain U 794670 Jul 31 14:40 bgilib_d.dll -rwxr-xr-x 1 dhumphre Domain U 338944 Jun 22 17:57 cvwmpi.dll -rwxr-xr-x 1 dhumphre Domain U 143506 Jul 31 09:46 mpatrol.dll dhumphrey at ROADRUNNER /c/bgiutils From tjreedy at home.com Tue Jul 24 22:05:40 2001 From: tjreedy at home.com (Terry Reedy) Date: Wed, 25 Jul 2001 02:05:40 GMT Subject: PEP0238 lament References: <5sdnlt072hm6hp17nluu6f0fqq4bvr6mj8@4ax.com> <916olt0p3kciv0evmotdg6jev9bl29l57i@4ax.com> <3B5C52EA.9430255E@alcyone.com> Message-ID: "Guido van Rossum" wrote in message news:cpofqaova7.fsf at cj20424-a.reston1.va.home.com... > If you agree that, if it weren't for breaking old code, PEP-238 would > make Python a better language, what can we do about that old code? Even people who do not agree, but who are willing to go along anyway, can contribute to the discussion about old code. I hope such people will. Terry J. Reedy From fcnpereira at home.com Wed Jul 11 18:05:05 2001 From: fcnpereira at home.com (Fernando Pereira) Date: Wed, 11 Jul 2001 22:05:05 GMT Subject: Language Shootout References: Message-ID: <110720011805044955%fcnpereira@home.com> In article , Tim Peters wrote: > a general "good thing to > know" is that an order-N linear recurrence can be viewed as mapping > N-vectors to N-vectors via multiplication by a fixed NxN matrix M. For a related set of "good things to know": M. D. McIlroy, Functional pearl: Power series, power serious, J. of Functional Programming 9 (1999) 323-335 http://www.cs.dartmouth.edu/~doug/pearl.ps.gz and M. D. McIlroy, The music of streams, Information Processing Letters 77 (2001) 189-195 http://www.cs.dartmouth.edu/~doug/mdmspe.ps.gz -- F From chrishbarker at home.net Thu Jul 5 18:39:55 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 05 Jul 2001 15:39:55 -0700 Subject: Time for a Python "distribution" ? was:Not enough Python library development References: <3B44B63A.BB507CBF@home.net> Message-ID: <3B44ECBB.B6050C92@home.net> Paul Prescod wrote: > I'd suggest you take a look at this: > > http://python.sourceforge.net/peps/pep-0206.html I had forgotten about that, but I just looked again, and I remember being all excited about it, but it doesn't seem to have happened: "proposal for Python 2.0" what happend? Anyway, I do like htat PEP, but I am thinking of something a little different: what I am thinking of is a collection of hte final tarballs (or installers, or rpms, or whatever). How we get to that big package I don't know yet, the ideas in that PEP are good ones, but no exactly what I had in mind. In general, I'm imagining that someone installing "Comprehensive Python" (please someone, give me a better name!) will end up with something that looks just like a current set-up with a lot of modules installed. They just wouldn't have had to go to ten places to get it! > We've discussed this often in the past. I didn't expect it was an original idea. > The difference between Python > and Linux is that people are either willing to wait almost indefinately > to download an operating system, or they buy it in CD. Python cannot get > that large. It also won't get that large, it is a smaller entitiy by it's very nature. If it did get that large, maybe we could start selling CDs. In fact Ithikn that revinue stream would be very helpful, but I imagine Python is small enough (people's net connections are getting alot faster, too) that not many people would bother buying it. Are many people buying the activestate cd? > So you have to make choices about what goes in and what > stays out. These choices are inevitably controversial. I think a better > solution is to make it as easy to install things as possible. Yes, that's exactly what I'm going for. > Here's what an ActivePython user does to install 3 out of 4 those > modules: > > pyppm install Numeric > pyppm install egenix-mx-base > pyppm install PIL > > wxPython is next on our list of modules to add. I think that this is a > more scalable solution than a "fat" Python build because we can include > as many modules as we can build. Actually, that's pretty much exactly what I had in mind. In fact, when I heard about ActiveState Python, I thought it had been done, but when I looked at the web site, I saw no mention whatsoever about what was included (except the windows stuff). In fact, I just installed ActiveStae Python on Windows, and then when and got the other packages by hand. I guess that means two things: a) Activestate needs to improve the usability of their web site b) I need to RTFM !!! I'm going to go now and look again at ActiveState's Web page...I may be out of a project. Of course I'd rather it wasn't a commercial entitiy doing it, but if they do it well, that's fine with me. -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 skyer.bbs at openbazaar.net Sun Jul 15 12:50:01 2001 From: skyer.bbs at openbazaar.net (·Q¤@¤U) Date: 15 Jul 2001 16:50:01 GMT Subject: [Q]Remove Directory in Win2k Message-ID: <3hMlEP$l9c@openbazaar.net> Hi~~guys ^^ My patition is NTFS when I execute below codes, it return error "Permission Denied". And, the directiory "test" remainly exist. import os os.mkdir('test') os.remove('test') How to remove directory in NTFS? -- ?? Origin: ???????uBBS   ?? From: h9.s208.ts30.hinet.net From qrczak at knm.org.pl Tue Jul 17 10:23:10 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 17 Jul 2001 14:23:10 GMT Subject: list and implicit continuation may cause bugs in Python programs References: Message-ID: Tue, 17 Jul 2001 17:13:58 +0400 (MSD), Roman Suzi pisze: > Still lint-like tools could report such problems as warnings, > because it is too easy to make error here. Things which are warned about should be easily rewritable in a way which doesn't provoke warnings, otherwise warnings will be annoying sometimes. For example C compilers and tools which warn about "while (a = f())" typically don't warn about "while ((a = f()))". Badly mixed tabs and spaces can always be fixed too. > I even think, that things like: > > for i in list: > if cond: > do_something > else: > somethingelse > > must be reported. But how to rewrite it? I'm not sure if I like this: for i in list: if cond: do_something else: pass else: somethingelse -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From michael.g.abbott at ntlworld.com Mon Jul 23 11:08:32 2001 From: michael.g.abbott at ntlworld.com (Michael Abbott) Date: Mon, 23 Jul 2001 15:08:32 GMT Subject: PEP0238 lament References: Message-ID: "Arthur Siegel" wrote in news:mailman.995894318.12197.python-list at python.org: > > To the extent anybody cares - and there is no particular > reason anybody should - the anger in my posts that Guido > interprets as directed toward him, is real anger. But not > meant to be directed at him. > > Except to the extent that I feel he unwittingly collaborates > in the breakdown of community dynamics. Aloofness from > the community should count against, not for, one's cause - > whatever it happens to be. Actually, I'm quite suprised at just how rude Guido is in his replies. Just for the record, I think that PEP0238 is an extremely stupid idea, and that the last thing Python needs is a deluge of half baked and incompatible changes. From bsass at freenet.edmonton.ab.ca Mon Jul 30 17:18:57 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Mon, 30 Jul 2001 15:18:57 -0600 (MDT) Subject: FEEDBACK WANTED: Type/class unification In-Reply-To: <01073013291201.00729@frock.ddmweb.com> Message-ID: On Mon, 30 Jul 2001, Sam Penrose wrote: > Guido van Rossum wrote: > > Correct on both counts again. > > >> One minor suggestion: > >> I think it would help if you set a convention for the name > >> of the first argument in classmethods. Like self for standard > >> methods. Well, even self can "work" here, too. > > > I think 'self' would be confusing. I'd like to propose 'cls'. > > How about an English word or phrase in lieu of YATATL (yet another > terse acronym to learn)? Insofar as "self" derives from the notion of > an instance, we want somethign that derives from the notion of one's > classification. > > The GNU-based Roget's Thesaurus at > > suggests for "class" : > > division, category, categorema[obs3], head, order, section; > department, subdepartment, province, domain. kind, sort, genus, > species, variety, family, order, kingdom, race, tribe, caste, sept, > clan, breed, type, subtype, kit, sect, set, subset; assortment; > feather, kidney; suit; range; gender, sex, kin. > > I like order, genus, and kind. On balance I guess "kind" seems best: > short, appropriate, and not a term I've noticed used in the corners of > the language I deal with. How about "kit": short, easy to pronounce, unused, means... A box for working implements. [1913 Webster] - Bruce From bill-bell at bill-bell.hamilton.on.ca Tue Jul 10 14:55:43 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Tue, 10 Jul 2001 14:55:43 -0400 Subject: Marking a Python COM server safe for Internet Explorer In-Reply-To: <994676617.255.31573.l10@yahoogroups.com> Message-ID: <3B4B176F.2461.3996A49@localhost> "Duncan Booth" wrote, in part: > ... if your control isn't marked as safe for scripting, IE creates > the control before it pops up the box asking you whether you want > to allow the script to run. In other words, if your control is > written in Python, the __init__ method is called *before* the user > is asked whether to permit it. Duncan, thanks for your comment. This is indeed what happens. It occurs to me that one could prevent the appearance of the control itself by using a factory to build it. The user would need to permit the use of the factory which would in turn create the control. Since we're on the topic, and I haven't tried working out the details of something like this, would you care to comment? Bill From emile at fenx.com Wed Jul 4 11:39:23 2001 From: emile at fenx.com (Emile van Sebille) Date: Wed, 4 Jul 2001 08:39:23 -0700 Subject: Two problems with backslashes References: Message-ID: <9hvdke$ftpq9$1@ID-11957.news.dfncis.de> The r prefix turns the string into a raw string, essentially turning off escape recognition, except in the last position. see 2.4.1 String Literals in the reference manual. -- Emile van Sebille emile at fenx.com --------- "Courageous" wrote in message news:bde6kt0c8f8fdfcf204qprakatj9v9ooa2 at 4ax.com... > > > path = r'e:\test\test.txt' > > What am I looking at here, and how do Iearn more about it? > IOW, what's the 'r' do, and is there more to this? > > > > C// > From greg at cosc.canterbury.ac.nz Thu Jul 12 01:36:09 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Thu, 12 Jul 2001 17:36:09 +1200 Subject: Language change and code breaks References: <6A%27.454703$eK2.93741234@news4.rdc1.on.home.com> Message-ID: <3B4D3749.6A42878E@cosc.canterbury.ac.nz> Skip Montanaro wrote: > > I'm not sure that the purpose of a//b would be all that evident to a new > Python programmer So they'd have to look it up. What's so bad about that? If Guido is not courageous enough to change the meaning of /, this seems like a good alternative plan to me. -- 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 bellman at lysator.liu.se Thu Jul 26 18:37:20 2001 From: bellman at lysator.liu.se (Thomas Bellman) Date: 26 Jul 2001 22:37:20 GMT Subject: Suggestion for impriving list comprehensions References: <3B5F0867.7447E5FB@ccvcorp.com> <9jphkk$rhc$1@newsy.ifm.liu.se> Message-ID: <9jq630$2m2$1@newsy.ifm.liu.se> Guido van Rossum wrote: > paul at svensson.org (Paul Svensson) writes: >> [x for x in fib() while x < 50] > Neat, but maybe not general enough. How do you request the first N? How about one of these: l = [] for i,v in zip(range(N), fib()): l.append(v) or l = []; g = fib() for i in range(N): l.append(g.next()) or my personal favourite map(lambda x,g=fib(): g.next(), range(N)) Not *every* list needs to be generated using list comprehension, you know. :-) (My personal preferens is that every list should be generated using map(), filter() or reduce(). :-) > And fuzzy: does this include or exclude the first x >= 50? Exclude. Definitely exclude. > How about a library of functions for iterator algebra? E.g. > def first(n, sq): > it = iter(sq) > for i in range(n): yield it.next() > def lessthan(n, sq): > for x in sq: > if x >= n: break > yield x Could be usable, but please not in the builtin namespace. I'm already starting to feel that the __builtin__ module is a bit crowded. Or, well, perhaps not *crowded*, but rather that it is somewhat a mish-mash of functions that no-one had the energy to find the proper module for. -- Thomas Bellman, Lysator Computer Club, Link?ping University, Sweden "Adde parvum parvo magnus acervus erit" ! bellman @ lysator.liu.se (From The Mythical Man-Month) ! Make Love -- Nicht Wahr! From niemeyer at conectiva.com Fri Jul 27 13:12:19 2001 From: niemeyer at conectiva.com (Gustavo Niemeyer) Date: Fri, 27 Jul 2001 14:12:19 -0300 Subject: PEP 238 (revised) In-Reply-To: ; from guido@python.org on Fri, Jul 27, 2001 at 02:09:43PM +0000 References: <3B60B3D5.664A3D7F@engcorp.com> Message-ID: <20010727141219.D19610@tux.distro.conectiva> > The PEP can't address everything. I have no idea how to write such a > scanner, and I think it would require type inference of unrivaled > sophistication, so I'm not keen on promising it in the PEP. I assume > there will be some kind of conversion tool, but it's outside the scope > of the PEP. I don't think a perfect solution for this will ever exist, besides interpreter warnings when running the code. But some assumptions may be used to detect problems in some cases. Something that came into my mind right now is about lists. I don't know if this issue has been discussed before: >>> [1,2][0.0] Traceback (most recent call last): File "", line 1, in ? TypeError: sequence index must be integer So, if some algorithm uses a value returned from a division as a list index, it will certainly be an error in the future. Maybe a nice idea in this case would be to allow lists to accept float indexes. This could preserve some old code. But I'm not sure making such thing possible is nice, in the long run. -- Gustavo Niemeyer [ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ] From aahz at panix.com Sat Jul 28 11:53:55 2001 From: aahz at panix.com (Aahz Maruch) Date: 28 Jul 2001 08:53:55 -0700 Subject: How to break? (was Re: A modest PEP0238 suggestion) References: <3b5c6e08.27535083@aplnews> <9jjk9g$8tk$1@newsy.ifm.liu.se> Message-ID: <9jun6j$c5$1@panix2.panix.com> In article <9jjk9g$8tk$1 at newsy.ifm.liu.se>, Paul Svensson wrote: > >The only choices that make sense to me here are, either we break stuff, >or we do nothing. Either way, we'll most likely have to revisit the >issue if/when syntax for rationals is to be added to the language. Well, no. I think that there's now a fairly widespread agreement that what we've got now is broken. The question is, how do we switch to a future such that new code isn't broken, while breaking as little old code as possible? Whoops! Actually, that's the wrong question. The *real* question is, how do we break old code in a way that makes it least-painful to fix? Phrased that way, I think it *has* to be true that there is never a future in which old code can break silently. -- --- 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 Fortune cookie: Watch your relations with other people carefully, be reserved. From aleaxit at yahoo.com Tue Jul 3 04:18:59 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 3 Jul 2001 10:18:59 +0200 Subject: Python and DB support (was: Re: Is Python Dead?) References: Message-ID: <9hrv5k016q4@enews1.newsguy.com> "Roman Suzi" wrote in message news:mailman.994135925.11224.python-list at python.org... > On 2 Jul 2001, David Bolen wrote: > > >Roman Suzi writes: > > > >> However, my collegues were not satisfied with it. One somplain was that in > >> ASP/IIS it is "very easy" to receive a "recordset" from database and then > >> apply it in different situations in the ASP-page, because recordset is an > >> object and even subqueries could be made without quering DB again. > > > >Just curious, but did your colleagues try using Python's COM interface > >to ADO to retrieve an actual recordset object that they could > >manipulate the same in Python as in other ASP languages? > > Aha! Now I could understand what is the brake of Python library > development. Most of Python users are Windows users. And they > have COM for whatever is in their system. I strongly doubt that "most Python users are Windows users", but it's certainly true that most Python users *WHO CONSIDER ASP/IIS AN ALTERNATIVE* are Windows users (and pretty-clueless ones, if they don't know Python can work perfectly well WITHIN ASP/IIS!-). > We mostly have Linux servers, so COM+ADO is no option. The point was not > to choose between Windows and Linux, ASP was choosen to serve particular > purpose, for the database already implemented in Microsoft land. If COM+ADO is not an option then neither is ASP/IIS! Alex From ejr at cs.berkeley.edu Thu Jul 12 13:07:50 2001 From: ejr at cs.berkeley.edu (Edward Jason Riedy) Date: Thu, 12 Jul 2001 17:07:50 +0000 (UTC) Subject: Comment on PEP-0238 References: <3B4D2AF6.7F76CBA1@cosc.canterbury.ac.nz> Message-ID: <9iklh6$gfv$1@agate.berkeley.edu> And Greg Ewing writes: - - It seems to me that, if you want adjustable precision at - all, you want to adjust it in a very fine-grained way - based on the kind of data you're using and what you're - doing with it. For _fixed-point_ arithmetic, this is often true. Your monetary example is best served by an extremely flexible arithmetic, as the laws governing the calculations are complex. The Euro docs are a good, recent example. - So the notion of precision being part of some sort of - context that you establish and then go off and do your - calculations seems fundamentally wrong-headed. For many geometric and scientific codes using floating-point, this is exactly what you want. You bump the precision up once, or you multiply it after trying to get a good-enough answer. The precision changes are always establishing a working precision related to some desired output precision. You change the precision rarely. If you know of floating-point codes that mix desired precisions frequently and intentionally, I'd really like to hear of them. - I don't know what the best solution to this is. I feel - it lies somewhere in the direction of using specialised - data types which know their own precision and also - what precisions are needed for various combinations - of them. I don't have a copy of Martin Fowler's Analysis Patterns handy, but I believe he addresses some of these issues. There are a few articles that might relate: http://martinfowler.com/articles.html Jason -- From chrishbarker at home.net Mon Jul 9 20:21:11 2001 From: chrishbarker at home.net (Chris Barker) Date: Mon, 09 Jul 2001 17:21:11 -0700 Subject: File processing References: <9id5p9$8r62@interserv.etn.com> Message-ID: <3B4A4A77.C592FAFA@home.net> Chris McMillan wrote: > Why am I doing this you may ask: I have tens of data files that I need to > strip the first line before I can process it in Matlab. So, I dream of a > script that opens every file in a directory, deletes the first line, ..... Not that I want to trow a wet blanket on your Python enthusiasm, but you have gotten all the help you need with Python, no I'll try this: If you want the read the file into MATLAB, why not use MATLAB? I am a big Python fan, and do almost everything with it, including much that I used to use MATLAB for, but if I needed to get data into MATLAB, I'd use MATLAB. I suspect you are trying to use the load function to load a table of data, but MATLAB chokes on the header line. The solution is to use some of MATLAB's other file reading capabilities. Here is an example function: ********* WARNING MATLAB code on the Python newsgroup ********* % a function that reads a file without the first line function data = readfile(filename,cols,rows); if nargin < 3; rows = inf; end if nargin < 2; cols = 1; end file = fopen(filename,'r'); % discard the first line junk = fgetl(file); data = fscanf(file,'%g',[cols,rows])'; return *** END MATLAB CODE **** I made a number of observations when I wrote this: 1) I wanted to use default argument values 2) I forgot all the semicolons 3) I forgot the "end"s 4) I missed Pytons object oriented syntax for file operations 5) I really like MATLAB's fscanf: I wish there was a Python option like that. 6) I also miss Inf in Python In Python, this function would look something like: # a function that reads a file without the first line def readfile(filename,rows = -1): file = open(filename,'r') # discard the first line junk = file.readline() data = [] line = file.readline().strip() while line: if (rows < 0) or (len(data) < rows): data.append(map(float, line.strip().split())) line = file.readline().strip() return data -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 mikael at isy.liu.se Thu Jul 12 02:38:41 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Thu, 12 Jul 2001 08:38:41 +0200 (MET DST) Subject: Language change and code breaks In-Reply-To: <6A%27.454703$eK2.93741234@news4.rdc1.on.home.com> Message-ID: On 11-Jul-2001 Nick Perkins wrote: > but why not leave int/int->int alone, > and use // for int//int->float. > > No code breaks, and it is almost as easy for the newbies. > > 1/2 -> 0 > 1//2 -> 0.5 > > That way we still have / = div, % = mod, > and we add // = float-divide. Being in EE, I would immediately interprete a//b as two resistors, a and b, in parallel. Thus, I would expect 1//2 to return 0.666666... just-half-joking-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-Jul-2001 Time: 08:33:18 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From chris.gonnerman at newcenturycomputers.net Tue Jul 17 01:15:52 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Tue, 17 Jul 2001 00:15:52 -0500 Subject: windows port access References: <3b520bcb@news.cybertours.com> <3B522E98.BAAA9E93@engcorp.com> <3B5390BC.C5FFCD2A@engcorp.com> Message-ID: <00ba01c10e7f$921b9080$0101010a@local> ----- Original Message ----- From: "Peter Hansen" > Chris Gonnerman wrote: > > > > Unfortunately what Bryan is asking is not what you are answering. He wants > > to access the I/O port 0x280, which he states is assigned to a "custom ISA > > card" which (I assume) is not using the standard parallel port interface, > > nor serial, etc. and for which he evidently has no driver. > > I admit I didn't actually look at the winioport stuff proposed in the > "parallel port?!?" thread, but given that it was called winioport > and not winparallelport, I assumed it was a way of providing generic > access to IO ports under Windows. If I was wrong, then you are right > to correct me! (Do you know winioport would not work or were you just > tricked by the name of the thread?) Whups. Evidently the low-level package in use by winioport DOES support generic access. My mistake... I was going by the commentary on the main winioport page, where he says "I am now able do printer port IO." I assumed that was the entire scope of the package, but evidently not. > Of course, it's probably moot given Jon Nicoll's response which suggests > a perfectly viable alternative. Indeed... to wit: ----- Original Message ----- From: "Jon Nicoll" > This is exactly what my code can be used for - you can set it up to > get access to arbitary IO ports (via the ioperm mechanism in Linux), > and then read or write etc. as you like. Admittedly, it doesn't > currently cater for interrupts. Which could be vitally significant or totally unimportant. > I originally started writing this to drive an ISA 8255/8253 card, and > although this project-ette is currently in limbo, the basics are all > there and working, if Bryan wants to do eg. polled access to an A/D > card etc. > > You don't need a VxD (for W95 at least), although it's probably the > 'better' way of doing things. My code is in C and turns into a little > '.PYD' (= .DLL) file. In NT, you need a kernel mode driver, which I > haven't yet got around to looking at. Here the winioport module (and the underlying DriverLYNX package) might be better for Bryan. > I've just resurrected my code and am looking at using distutils to get > it in a form more easily distributed. Email me if would be of use to > you in the meantime. Bryan hasn't responded since he initially requested this information... are you out there, Bryan? From thedustbustr at aol.com Wed Jul 25 17:51:10 2001 From: thedustbustr at aol.com (TheDustbustr) Date: 25 Jul 2001 21:51:10 GMT Subject: how to import curses Message-ID: <20010725175110.25823.00001273@ng-cf1.aol.com> import curses #returns "no module named curses" I have no trouble importing other modules. I have the docs for curses on my system, I just can't import it. So, where can I download the actual module? -Dustin From philh at comuno.freeserve.co.uk Tue Jul 3 16:13:50 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Tue, 3 Jul 2001 21:13:50 +0100 Subject: Redirecting input? References: Message-ID: On Tue, 3 Jul 2001 12:14:44 -0400, Steve Holden wrote: >From the Python 2.0 Library Reference Manual: > >"""6.11 getpass -- Portable password input > >The getpass module provides two functions: > > >getpass ([prompt]) >Prompt the user for a password without echoing. The user is prompted using >the string prompt, which defaults to 'Password: '. Availability: Macintosh, >Unix, Windows. > >getuser () >Return the ``login name'' of the user. Availability: Unix, Windows. >This function checks the environment variables $LOGNAME, $USER, $LNAME and >$USERNAME, in order, and returns the value of the first one which is set to >a non-empty string. If none are set, the login name from the password >database is returned on systems which support the pwd module, otherwise, an >exception is raised.""" Now that Mac OS X is based on Unix, will this work for Macs too? -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From paulp at ActiveState.com Fri Jul 6 12:43:01 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Fri, 06 Jul 2001 09:43:01 -0700 Subject: Time for a Python "distribution" ? was:Not enough Python library development References: <3B44B63A.BB507CBF@home.net> Message-ID: <3B45EA94.5B3D3C38@ActiveState.com> Fredrik Lundh wrote: > > Paul Prescod wrote: > > > Here's what an ActivePython user does to install 3 out of 4 those > > modules: > > > > pyppm install Numeric > > pyppm install egenix-mx-base > > pyppm install PIL > > and then he does "import Image", gets an import error > (JPEG62.DLL missing), and sends me a nastygram ;-) I think that's fixed but if you supply standard distutils scripts and a test suite I'll guarantee it won't happen again. :) > where's the PPM protocol docs? I would say the best documentation is the code: http://www.xav.com/perl/site/lib/PPM/SOAPServer.html > how do I add new nodes to the PPM distribution network? You can set up a PPM server by running PPM::SOAPServer or porting it to Python. There are PPM srevers around the world. PPM isn't a network like CPAN though. In the Perl world it builds on the CPAN network (and hopefully something like it in Python one day too.) -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From max at alcyone.com Tue Jul 24 18:59:04 2001 From: max at alcyone.com (Erik Max Francis) Date: Tue, 24 Jul 2001 15:59:04 -0700 Subject: PEP0238 lament References: <5sdnlt072hm6hp17nluu6f0fqq4bvr6mj8@4ax.com> <916olt0p3kciv0evmotdg6jev9bl29l57i@4ax.com> <3B5C52EA.9430255E@alcyone.com> Message-ID: <3B5DFDB8.2C37A54C@alcyone.com> Guido van Rossum wrote: > Erik Max Francis writes: > > > Indeed. If this is implemented, it will be a black eye for Python. > > Any > > anti-Python advocate will be able to point at this and say, "Look, > > that's why you shouldn't switch to Python. The semantics of the > > builtin > > operators changes from release to release." Problem is, they will > > be > > absolutely right. > > This seems to be the crux of the anti-PEP-238 sentiments, and I want > to take it very, very seriously -- without losing the PEP. > > If you agree that, if it weren't for breaking old code, PEP-238 would > make Python a better language, what can we do about that old code? I wouldn't say that _that_ issue is the primary one, nor that I would agree that PEP 238 semantics are preferable. Since I have your ear for the moment, let me try and summarize my feelings on the situation. I would categorize the objections to PEP 238 into three categories: 1. Making such changes is backward incompatible, something that is universally agreed to be very dangerous. If Python had always done division as in PEP 238, then this would be a non-issue. But since it wasn't, changing it will break code. Even if this change is forced very gradually, or a very long period of time, there will _always_ be legacy code around (either passed around from person to person or at a client site that is inaccessible). In the latter case, the customer is forced to 1. hire a consultant to fix it, 2. get patches from the original author (if he's still around), or 3. trash the system and start over again. Similar concerns are how to write portable Python code (portable across multiple versions that is) if fundamental operators are changing. 2. Many responders don't agree that the division semantics described in PEP 238 are favorable in the first place, for a wide variety of reasons. The responses in this newsgroup don't constitute a poll, of course, but it appears there is more than just a handful of people who disagree with the division semantics in PEP 238. It's unfortunate that such a change is being considered when it doesn't even seem to be an overwhelming opinion. Some also question whether the intention of the change (to make Python easier for newbies) will even achieved by the change. 3. Doing PEP 238 means changing the semantics of a fundamental operator. This sets a very bad precedent, and makes Python advocacy harder if such things continue to happen. If PEP 238 and similar PEPs get approved and implemented, then someone against using Python can simply point out that Python is a moving target and coding against it is a risk, and they'd be right. Now people have been making these different points with different strengths. Some (including admittedly myself) have been a little too forceful in pointing them out. Point 3 is a PR issue and point 2 is a matter of (differing) opinion. I think what the impartial and objective complaints about PEP 238 can boil down to here is concerning point 1. PEP 238 constitutes a significant (i.e., code-breaking) change in the way a fundamental operator works. The question of whether Python should have behaved like PEP 238 when it was first implemented is a separate question (it is of course true that if it did, nobody would complaining about it now because it would simply be the way things were), but the hard fact is that changing it now is going to break a monumental amount of code, and some of that code is going to be in place that are not easy to fix. Nobody's talking about the technical aspects of fixing it, of course; we're talking about the logistical aspects of fixing code that is no longer necessarily easily accessible. Now that I've hopefully summarized the anti-238 sentiments, let me continue with your proposal. > I propose the following measures. Let's discuss whether these are > conservative enough, from the perspective of someone who has a large > body of old working Python code. (From the perspective of someone who > wants int division for other reasons, these can never be conservative > enough. :-) ... > Anything else? Unfortunately, I'm afraid this still doesn't address legacy code that is longer easily "just fixed." I can't really think of any reasonable way to do that, except have vendors tie their scripts to a certain version and (potentially) force customers to install multiple versions of Python to get scripts with different version requirements running. I would argue that Python popularity has reached a threshhold where fundamental changes to the language are getting to be less and less feasible, even if very well intentioned. We'd be seeing the same objection to a PEP even if the intent and goal were universally hailed to be laudable. What concerns me most about PEP 238 -- or rather, your interest in implementing it -- is that it sets a very disturbing precedent. One might ask (without cynicism or rudeness): Are there other code-breaking, fundamental changes lurking in the dark that we should know about? Is this going to be among the first in a long sequence of changes that will culminate in Python X being a substantially different language than Python 1.5.2 or Python 2.1, or is this just an isolated incident? The issue is if that a code-breaking PEP is being considered, engineers need to know about it _now_ so that they can implement their software to use constructs that will not be affected by Python upgrades in the distant future when their code is lurking on some client machine, nearly forgotten but still being regularly used. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ I want a martini that could be declared a disaster area. \__/ Capt. Benjamin "Hawkeye" Pierce Physics reference / http://www.alcyone.com/max/reference/physics/ A physics reference. From dsavitsk at e-coli.net Sun Jul 22 14:39:09 2001 From: dsavitsk at e-coli.net (douglas savitsky) Date: Sun, 22 Jul 2001 18:39:09 GMT Subject: 2.0 or 2.1 on win32 Message-ID: i am installing a new server and i need to know if there is reason to install either 2.0 or 2.1 or any other version. The server is win2k (2 1GHZ, 512, raid, etc.). the clients are also win2k. the applications that run on the clients connect the the server via DCOM. the python running on the server connects to other objects sometimes with COM and sometimes not. the clients use 2.0 as there seems to be some weirdness in 2.1/tkinter on windows, but there won't be any tkinter on the server. so, should i stick with 2.0 on the server as well? are there stability issues or compatability issues to be aware of with other versions? thanks, doug From thomas at xs4all.net Mon Jul 16 10:12:07 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 16 Jul 2001 16:12:07 +0200 Subject: converting from perl: variable sized unpack In-Reply-To: <9iulp401r93@enews3.newsguy.com> References: <9iulp401r93@enews3.newsguy.com> Message-ID: <20010716161207.G5396@xs4all.nl> On Mon, Jul 16, 2001 at 02:12:52PM +0200, Alex Martelli wrote: > > I have to admit, that would be somewhat consistant with the way the rest > > of the language works, but it sure would make it more complicated to do > > something like: > > if re.match (pattern1, string): > > do stuff > > elif re.match (pattern2, string): > > do other stuff > > elif re.match (pattern3, string): > > etc, etc, etc. > I find I can rarely throw away the match-objects in this cavalier > way, because they carry much, often-needed information -- so, I > don't get to use this idiom anyway. Rather, I have to code: > mo = re1.match(thestring) > if mo: > dostuff(mo) > else: > mo = re2.match(thestring) > if mo: > dootherstuff(mo) > else: > mo = re3.match(thestring) > if mo: > etcetcetc(mo) > else: > nomatchatall() > > which is hardly elegant and clean. I usually start out this way, and then end up rewriting it a bit so it fits into something like for reX in (re1, re2, re3, re4, re5): m = reX.match(thestring) if m: do_stuff_depending_on_"m.re"_(m) or def do_re1(): ... def do_re2(): ... etc... actions = ((re1, do_re1), (re2, do_re2)) for reX, func in actions: if reX.match(thestring): func(thestring) or just build a dispatch table instead. It ends up a lot more readable and usually a lot more *correct* than the if/elif/else version. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From lars at ibp.de Wed Jul 18 14:19:23 2001 From: lars at ibp.de (Lars Immisch) Date: Wed, 18 Jul 2001 20:19:23 +0200 Subject: distutils and documentation Message-ID: <3B55D32B.52B6B0F2@ibp.de> Dear all, I have written a Python C-extension that some people have expressed interest in. I have a distutils setup for my extension, which works nicely, but I'd like to include some documentation with the binary distribution. Is there a recommended way to do this? Thanks, Lars From mike_haspert at credence.com Wed Jul 18 14:16:08 2001 From: mike_haspert at credence.com (Mike Haspert) Date: 18 Jul 2001 11:16:08 -0700 Subject: "installing" sources on windows Message-ID: Hi all: What is the consensus on the safest, most efficient way to "install" on Windows when you build the interpreter from source?? Is there a script somewhere that helps with the registry? (I found regsetup.py, which I thought was for "installing" the windows extensions.) I've tried 1. Building the sources and manually making registry entries. OW. 2. Running the install program for the non-source download, which sets up the registry. I then unzip the sources to a different directory, batch build, and, as a post-build step, copy the DLLs, PYDs, and EXEs to the expected directories in the non-source download,overwriting the old ones. Seems to work, and allow tracing into the interpreter, but is bulky, and I fear it will be fragile. 3. Running the install program for the non-source download, which sets up the registry. I then swap in the source code tree and edit registry entries. This looked like it would work until PythonWin complained "correct the install", and I couldn't figure out what it wanted. From nospam at newsranger.com Fri Jul 13 23:55:01 2001 From: nospam at newsranger.com (Levente Sandor) Date: Sat, 14 Jul 2001 03:55:01 GMT Subject: More on "with" statement References: <3b4f3602$0$15367@wodc7nh6.news.uu.net> Message-ID: If you absolutely need a 'with' statement... import re def with(object, statements): """ 'with' for the very lazy programmer :) :) :) Someone might prefer Ctrl+C, Ctrl+V, ... instead.""" exec(re.sub('\B\.', '%s.' % object, statements)) #--- example usage: class a_class: pass an_instance_of_a_class_with_a_very_long_name = a_class() with('an_instance_of_a_class_with_a_very_long_name', ''' var1 = 111 var2 = 222 var3 = 333 var4 = 444 var5 = 555 ''') with('an_instance_of_a_class_with_a_very_long_name', ''' print .var1, .var2, .var3, .var4, .var5 ''') Levi In article <3b4f3602$0$15367 at wodc7nh6.news.uu.net>, Rufus V. Smith says... > >I went to the FAQ to check the entry about a "with" statement >that is available in other languages. I can only think of two >reasons to use it. > > 1) You're a lazy typist. (Or haven't learned to cut and paste) > > 2) You are generally concerned that multiple references to the > same object with complex, multilevel access might be confusing > to the reader or not optimized by the compiler. > >I used to like the "with" statement in Pascal or VB. Very useful >for using or setting multiple fields. However, as programs got large it >could >get difficult knowing if the field was a local, global, or part of a with >block that started several pages back (in Pascal at least. VB used a >preceding '.', which is a good idea). > >A better solution is to assign a temporary reference. This is possible >in C++: > >DeeplyHiddenStruct & rdhs = >&SomeClass.SomeMemberArray[SomeIndex].SomeStruct; > >rdhs.Field1 = NewValue; >DoSomethingWith(rdhs.Field2); > >etc. which IMO is easier and cleaner than > >SomeClass.SomeMemberArray[SomeIndex].SomeStruct.Field1 = NewValue; >DoSomethingWith(SomeClass.SomeMemberArray[SomeIndex].SomeStruct.Field2); > >I don't know if the same thing can be done in VB. > >Isn't it possible to do this in Python by simple assigning to a new object >reference? > >rdhs = SomeObject.SomeMemberArray[SomeIndex].SomeStruct > >The other advantage in the alternate reference is seen when copying >fields from one object to another: > >rdest = >rsrc = > >rdest.field1 = rsrc.field1 >rdest.field2 = rsrc.field2 >etc. > >I am a newbie just cutting my fangs in Python, but if I'm right about this, >perhaps this preferred workaround should be added the FAQ. If I'm >not... never mind... > > > > > > From graham at coms.com Mon Jul 2 05:55:08 2001 From: graham at coms.com (Graham Ashton) Date: Mon, 02 Jul 2001 10:55:08 +0100 Subject: any books for python for downloading? References: <993939668.727430@athnrd02.forthnet.gr> Message-ID: <0yX%6.1611$h45.10769@news.uk.colt.net> 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...... http://diveintopython.org/ From rb at tiscali.be Mon Jul 16 05:39:13 2001 From: rb at tiscali.be (Raphael Bauduin) Date: Mon, 16 Jul 2001 11:39:13 +0200 Subject: pipe in read and write mode Message-ID: Hi! I want to pipe the standard input of my script to a command. I use popen, and it's fine. However, I want to take the standard output of the command and put it in a variable. I can't open the pipe in read and write mode. I made it work by redirecting the output of the pipe to a file, and reading this file. I would prefer not to write it to a temporary file, as the text piped is somewhat sensitive (I use the script to encrypt it, so it would be better not to write it to a file ;-) thanks. Raph -- Open Source and Free Software Developers Meeting See you at the 2002 edition. Check the 2001 sessions on www.opensource-tv.com Visit http://www.osdem.org and subscribe to the mailing list! From guido at python.org Tue Jul 31 07:17:10 2001 From: guido at python.org (Guido van Rossum) Date: Tue, 31 Jul 2001 11:17:10 GMT Subject: FEEDBACK WANTED: Type/class unification References: Message-ID: Duncan Booth writes: > Guido van Rossum wrote in news:cp66cd12yp.fsf at cj20424- > a.reston1.va.home.com: > > > Any questions, don't hesitate to ask. > > I have a question, or perhaps an observation about the new rules for > resolving diamond inheritance. > > Given a class hierarchy such as: > class A: pass > class B(A): > def save(self): pass > class C(A): > def save(self): pass > class D(B, C): > def foo(self): > self.save() # Calls B.save > > Now, if I add the following code: > class E(B): pass > class F(D, E): pass > > f = F() > f.foo() > > My understanding of the new rules is that calling f.foo() will result in a > call to C.save instead of B.save (or in other words, any class that depends > on the search order for base classes may find this order mysteriously > changing if it itself is subclassed). > > Is my understanding correct? Does it matter? Something similar already > happens in existing Python programs (define class F(C, D) and you get the > same effect), but previously you were less likely to encounter diamond > inheritance. Correct. There's a missing section in PEP and tutorial on "cooperation", a generalization of a "super" call that allows you to spell "call the next method in the chain" without naming its class explicitly. No time to explain that now. --Guido van Rossum (home page: http://www.python.org/~guido/) From rnd at onego.ru Tue Jul 10 04:47:40 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 10 Jul 2001 12:47:40 +0400 (MSD) Subject: File processing In-Reply-To: Message-ID: On 10 Jul 2001, Harald Kirsch wrote: >"Chris McMillan" writes: > >> Hello all! >> >> I'm trying to write a script that will open a file, delete the first line, >> and then save the file with the same name. Can someone please point me in >> the right direction? Thanks! > > >Umpf. I really like python, but sometimes other solutions are less >cumbersome. With bash it's a one-liner like: > > for x in *; do y=`basename $x`.new; tail +1 $x >$y; mv $y $x; done Or even "simpler" using ed: for x in *; echo -e "1,1d\nw" | ed $x; done >Sorry, couldn't read from your message if you are on Microsoft where >a bash script usually does not help a lot. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Tuesday, July 10, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "-- is the key to success" _/ From guido at python.org Wed Jul 25 16:15:10 2001 From: guido at python.org (Guido van Rossum) Date: Wed, 25 Jul 2001 20:15:10 GMT Subject: Opcode compatible division References: Message-ID: com-nospam at ccraig.org (Christopher A. Craig) writes: > I was wondering if it would be possible to add two new opcodes to the > VM language which I will refer to as ExactDivide and IntegerDivide and > keep the current opcode with its current behavior? > > Even if there was no way in the actual language to generate the > CurrentDivide opcode, its existance would allow modules compiled and > distributed under the current system to continue to work with future > revisions. > > I haven't thought this through that much, so it may be a totally > stupid idea, but I thought it might fix some of the issues with > backwards compatibility. Check out my patch on SourceForge: it does exactly that. http://sourceforge.net/tracker/index.php?func=detail&aid=443474&group_id=5470&atid=305470 --Guido van Rossum (home page: http://www.python.org/~guido/) From rnd at onego.ru Tue Jul 10 08:17:21 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 10 Jul 2001 16:17:21 +0400 (MSD) Subject: import namespace issues In-Reply-To: Message-ID: On 10 Jul 2001, Harald Kirsch wrote: > "Alex Martelli" writes: > > > "Harald Kirsch" wrote in message > > news:yv2lmlxgnji.fsf at lionsp093.lion-ag.de... > > > QUESTION 2: > > > Is there a detailed description somewhere in the docs about the > > > namespaces (or dictionaries) used/created/shuffled during an import? > > > > I think the documentation for __import__ is pretty clear about > > it, "the standard implementation does not use its locals argument > > at all, and uses its globals only to determine the package context > > of the import statement". > > I sometimes find that the python docs seem to expect some prior > knowledge about `obvious behaviour' from the reader and consequently Probably because one learns about import statement first, and then (if at all) learns about __import__() function. > are a bit terse. Therefore I believed the above statement only after > having read the code :-) > > Harald. Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From markus at kepler.ibp.de Tue Jul 3 08:51:59 2001 From: markus at kepler.ibp.de (markus at kepler.ibp.de) Date: 03 Jul 2001 14:51:59 +0200 Subject: Is this a true statement: Part III References: <9hsckg$4rt$1@taliesin.netcom.net.uk> Message-ID: "MDK" writes: > The thing that I found interesting about the Part II posts were the positive > things said about the C language. Is C that much different than C++? It is smaller. Even if C has its idiosyncrasies (and it has lots of them), one can master them in a reasonable time. > Why the leaning towards C over C++? I thought C++ was supposed to > be the 'New and Improved C.' It didn't live up to its expectations. - Markus From ajs at ix.netcom.com Mon Jul 23 09:19:53 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Mon, 23 Jul 2001 09:19:53 -0400 Subject: PEP0238 lament Message-ID: <000d01c1137a$292ae760$a9e1fea9@carol> >>Change assignment to work like a >>copy, because there are many people >>confused with the reference semantic? >EXACTLY. To the extent anybody is interested in the first hand experience of a novice programmer - rather than the second hand report (made privately to the appropriate authorities) of non-programmers - you happen to be right near the mark of where some real issues lie. To the extent anybody cares - and there is no particular reason anybody should - the anger in my posts that Guido interprets as directed toward him, is real anger. But not meant to be directed at him. Except to the extent that I feel he unwittingly collaborates in the breakdown of community dynamics. Aloofness from the community should count against, not for, one's cause - whatever it happens to be. PEP0238 is conclusionary as to the experience of novices. Certainly its conclusions were not out of the experience of its advocates. How were conclusions drawn before the question was asked? Why aren't the folks who drew and reported those conclusions here to defend them, to the extent they are called into question. Under the circumstances of considerable controversy, at least. Let the evidence stand up to at least a little scrutiny before decisions are made based on it. Why isn't some anger to be expected - or why doesn't the leadership at least recognized how the dynamics here are primed beautifully for an angry debate? ART From sholden at holdenweb.com Tue Jul 31 09:38:56 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 31 Jul 2001 09:38:56 -0400 Subject: Long: Python Is Really Middleware References: <3B667EBA.DA6C298@tundraware.com> <3B66B1AA.EF2FFE3A@engcorp.com> Message-ID: "Peter Hansen" wrote ... > Tim Daneliuk wrote: > > > > *** Python Is Really "Middleware" *** > > Tim Daneliuk > > Copyright (c) 2001, TundraWare Inc. > [...] > > by coding around them. This leads to REALLY ugly, hard-to-maintain > > systems. CHANGING UNDERWEAR MATTERS. > > I think you meant "UNDERWARE" ... :) No, he meant underwear. His underwear had clargs on it. That does indeed make them really ugly and hard to maintain. i-promise-i'll-stop-this-now-ly y'rs - steve -- http://www.holdenweb.com/ From rnd at onego.ru Mon Jul 16 23:28:32 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 17 Jul 2001 07:28:32 +0400 (MSD) Subject: [Mojonation-devel] Re: memory leak with dynamically defined functions? In-Reply-To: Message-ID: I've run the following: import gc def silliest_func(): x = [0] * (2**10) def inner_silliest_func(x=x): pass return inner_silliest_func while 1: blarg = {} for i in range(2**13): blarg[i] = silliest_func() print gc.collect() --------------------------------------- (Python 2.1, glibc 2.1.3, Linux 2.2.) - and then watched 'top'. Memory jumps from 1.5Mb (normal for empty Python) up to 35Mb. and zeros are printed: refcount probably works fine. >"Gregory P . Smith" writes: > >> It doesn't appear to leak memory for me either. The difference as >> zooko noticed does show up though: >> >> His first example that didn't use a function holding a reference via >> default parameters -immediately- released the consumed memory when the >> reference to blarg was deleted. >> >> The version above that uses the function reference doesn't seem to >> ever release that memory even when the reference to blarg has been >> deleted. (yet it doesn't go above 34M when I put it in a while 1 loop >> as you have) > >That could just be a behavior of the underlying memory allocation from >the OS. Depending on OS (and if variable, allocation implementation), >an application might not actually yield its working set memory back to >the system, but just reuse it within its own memory space as necessary. > >>From the behavior described, I'd guess that the allocation system in >use on the test system was willing to give back memory if it was >possible to do so contiguously at the top of the currently allocated >space for the application in simple cases, but not in other cases >(where the space becomes more fragmented). > >This isn't really a Python issue (I expect Python has properly freed >all relevant memory), but more a platform memory allocation issue. > >-- >-- David > Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Tuesday, July 17, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "...put knot yore trust inn spel chequers." _/ From malcolm at commsecure.com.au Mon Jul 9 23:53:35 2001 From: malcolm at commsecure.com.au (Malcolm Tredinnick) Date: Tue, 10 Jul 2001 11:53:35 +0800 Subject: Language Shootout In-Reply-To: <3B4A6662.B862792@yahoo.com>; from slinkp23@yahoo.com on Tue, Jul 10, 2001 at 02:26:44AM +0000 References: <3B49F724.1F3DF6B3@yahoo.com> <3B4A6662.B862792@yahoo.com> Message-ID: <20010710115335.A23435@Vetinari.home> On Tue, Jul 10, 2001 at 02:26:44AM +0000, Paul Winkler wrote: > Fredrik Lundh wrote: > > does your fastest iterative solution beat this one? > > That's pretty fast, once I got it to work... but still not as fast as > my best one. Yours iis definitely interesting, largely because I > don't understand what the hell it does. If I rename one of the fibs > and change the appropriate call to use the new name, it still computes > fibonacci numbers but performance goes way down as N rises. So you're > somehow relying on the duplicated names for speed. That's a pretty > weird optimization technique. Ooh, ooh ... I know this one. :-) It's a scoping trick (and it really is a "trick" here, because the same name is being used and this leads to a bit of confusion). /F's solution makes sure that the code objcet of the first 'fib' is in the local namespace of the second 'fib' function. This speeds up lookups to it significantly (local variables are implemented as a dictionary, globals are not). Does that make it understandable (I could rabbit on a lot further, but why spoil all the fun)? Cheers, Malcolm -- Honk if you love peace and quiet. From eppstein at ics.uci.edu Mon Jul 30 02:40:00 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Sun, 29 Jul 2001 23:40:00 -0700 Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <3b60d65e.219212588@news.eircom.net> <3b64d4ce.777475039@wa.news.verio.net> Message-ID: In article , Marcin 'Qrczak' Kowalczyk wrote: > I don't see the point in the compiler inferring > whether it managed to get a particular result exact or not. Well, unless it was part of a more general interval arithmetic package -- that could be useful. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From mac4-devnull at theory.org Tue Jul 10 14:33:19 2001 From: mac4-devnull at theory.org (Neil Macneale) Date: Tue, 10 Jul 2001 11:33:19 -0700 Subject: license suggestions? References: Message-ID: <3b4b4a70$0$319$8eec23a@newsreader.tycho.net> In article , "Chris Watson" wrote: > > Communism \Com"mu*nism\, n. [F. communisme, fr. commun common.] > A scheme of equalizing the social conditions of life; specifically, > a scheme which contemplates the abolition of inequalities in the > possession of property, as by distributing all wealth equally to > all, or by holding all wealth in common for the equal use and > advantage of all. > > communism > n 1: a form of socialism that abolishes private ownership > 2: a political theory favoring collectivism in a classless > society > You can't compare communism and capitalism. One is a political structure while the other economic structure. It makes more sense to say that you perfer Capitalism over Socialism, or Democracy over Communism. I am for democracy, and socialism, so I'm going with GPL :-) Thanks for the lively discussion... Neil Macneale -- To reply to me via email, remove the '-devnull' from my address. From thomas at xs4all.net Sun Jul 15 11:02:07 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Sun, 15 Jul 2001 17:02:07 +0200 Subject: How to use os.access()?? In-Reply-To: <3B4FD004.D0CCFBC2@engcorp.com> References: <3B4F82F8.D21C6EF3@uniserve.com> <3B4FD004.D0CCFBC2@engcorp.com> Message-ID: <20010715170207.C5396@xs4all.nl> On Sat, Jul 14, 2001 at 12:52:20AM -0400, Peter Hansen wrote: > >>> from os import * "*bweep* *bweep* danger, Will Robinson!" And I didn't even like that movie :) > >>> F_OK > 0 > Unless you want to "from os import *", which is generally bad form, In this case, it's not just bad form, it's disastrous! Do not import * from os, unless you *really* *really* *really* know what you are doing. If you don't understand why 'from os import *' is a bad idea, try this: >>> from os import * >>> f = open("spam") Traceback (innermost last): File "", line 1, in ? TypeError: function requires at least 2 arguments; 1 given >>> f = open("spam", "w") Traceback (innermost last): File "", line 1, in ? TypeError: illegal argument type for built-in operation If-you-do-import-*-from-os-or-any-other-module-and-it-ends-up-biting-you-in-the-rear-hind-end-posterior-keister-tushy-derriere-you'll-go-"d'oh-I-should-have-listened-to-Thomas"-and-I'll-go-"Yes-you-should-have-because-I-told-you-so-darnit!"-and-you'll-never-live-off-the-shame-ly y'rs, -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From sholden at holdenweb.com Sun Jul 1 16:29:19 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sun, 1 Jul 2001 16:29:19 -0400 Subject: problems with class initiation References: <9ho0dl$ri0$1@tyfon.itea.ntnu.no> Message-ID: "Magnus Lie Hetland" wrote ... > "I?igo Serna" wrote ... > [snip] > > I suppose the error comes due to Main class hasn't finished its > > initiation when 'app.prefs.a' is executed so app is None in that moment. > > The assignment isn't finished, so app is indeed None. Instead of > relying on global variables, you should supply app as a parameter > to the constructor of Second, IMO... Thus: > > class Second: > def __init__(self, app): > return self.init_fn(app) > def init_fn(self, app): > return app.prefs.a > Note also that there is no logical reason why the "__init__()" method should be returning something. AS far as I know, nothing takes any notice of what __init__() returns, and it's usual to omit a return statement (impying a return value of None). So there doesn't really seem to be any need here to split the initialization of the Second objects into two parts. As far as I can tell the Second class could equally well be defined as class Second: pass without the effect of the code being changed in any way. If __init__() doesn't change self, and it doesn't call anything with side effects, I don't think it does *anything*. > class Main: > def __init__(self): > self.prefs = Preferences() > self.fns = [] > self.fns.append(Second(self)) > > ... or something like that. (The design seemed slightly confusing to me, > but I think this should work, at least :) > It may well work, but the Secod object appended to Main's self.fns will have no attributes other than those common to every class instance, so there doesn't seem to be much point in its having an __init__() method in the first place. regards Steve -- http://www.holdenweb.com/ From ralph at inputplus.demon.co.uk Fri Jul 20 14:59:03 2001 From: ralph at inputplus.demon.co.uk (Ralph Corderoy) Date: 20 Jul 2001 19:59:03 +0100 Subject: Distributing a Python app References: Message-ID: <9j9v1n$tfu$1@inputplus.demon.co.uk> > ms-should-bundle-python-as-a-public-service-ly y'rs - tim Well, at least they're to stop bundling a JVM. Whether as a public service or not that made me chuckle. disliked-java-since-i-learned-enough-about-it-to-form-an-opinion-ly y'rs, Ralph. From jerk at 163.net Sun Jul 8 21:43:09 2001 From: jerk at 163.net (jerk@163) Date: Mon, 9 Jul 2001 09:43:09 +0800 Subject: python startup memory size and memory leak Message-ID: <117483633808.20010709094309@163.net> Hello python-list, my app is a server that receive client's request in xml and query the mysql database to response to client,I use python 2.0 on linux(2.2.13),with expat 1.95 statically link into python and MySQLdb 0.3.5,as I am not so familary with xml so I didn't call unlink() on those created xml document before they are deleted,this is definitely a leak,right? but this leak may show different behavior with different startup environment.if all py is compiled into pyc and then start my app,top shows that it takes about 2.8M memory at first,as client requests comes,memory goes up very fast.then if I touch one of those py files and start my app again,top shows that it takes about 5M memory at first,as client requests comes,memory goes up very slow(althought it still leaking). I don't know why python startup size is different when I just touching one of those py files but seems it related to python compilation. Best regards, jerk mailto:jerk at 163.net From wtanksle at dolphin.openprojects.net Sat Jul 28 18:24:22 2001 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Sat, 28 Jul 2001 22:24:22 GMT Subject: FEEDBACK WANTED: Type/class unification References: Message-ID: On Sat, 28 Jul 2001 13:07:32 -0700, Paul Prescod wrote: >2. If I have an object that hides its attributes behind an __getattr__, >is there any way to tweak the list returned by the API described above? Not without the object's cooperation -- it's not even theoretically possible to figure out what attributes __getattr__ might support. Such an object, unmodified, would not support introspection. Can anyone who's used __getattr__ speak up and say whether any introspection support would be possible or useful? >def attrs(x): > return [y for y in all_possible_strings if hasattr(x, y)] Yes, that would work, for certain values of "work". all_possible_strings is a pretty simple generator. So is attrs(), actually. def attrs(x): for y in all_possible_strings(): if hasattr(x,y): yield y Amusing. -- -William "Billy" Tanksley From thecalm at NOSPAM.btinternet.com Fri Jul 27 13:55:53 2001 From: thecalm at NOSPAM.btinternet.com (G. Willoughby) Date: Fri, 27 Jul 2001 18:55:53 +0100 Subject: how on earth do i get a drive list? References: <9jpqlh$phf$1@uranium.btinternet.com> Message-ID: <9js9u1$3et$1@uranium.btinternet.com> Thanks m8, very helpful, i didn't realise it was so platform specific! well you live an' learn :) ta, G. willoughby "David Bolen" wrote in message news:uwv4vut4n.fsf at ctwd0143.fitlinxx.com... > "G. Willoughby" writes: > > > how on earth do i get a drive list? i've been searching for a command to > > display a tuple or list containing all available drives, but i can't find > > it! is it just me or are the standard python docs quite confusing. oh well > > any ideas out there? > > Assuming you mean under Windows... > > Since the concept of "drives" is an operating-system specific issue, > it's not something in the standard Python libraries, but something > that you generally need to handle in an OS-specific manner. Sometimes > you'll find such stuff in the os module, but in this case you're > better off with the win32all package which provides interfaces to > windows-specific functions. > > win32all is a package that can be installed on top of a stock Python > installation, or in some distributions, like ActiveState, may be > included already. > > The simplest method is via the win32api module: > > >>> import win32api > >>> import string > >>> string.split(win32api.GetLogicalDriveStrings(),'\0')[:-1] > ['A:\\', 'C:\\', 'D:\\', 'E:\\'] > > The actual code is mildly complex, as I'm doing three things at once. > GetLogicalDriveStrings (which is a native Windows function) returns a > single string with the drives separated by NUL characters (\x00). It > also terminates the list with an extra NUL. > > So, I take that string, and then split it on the NULs. This yields a > list of which the final entry will always be the empty string ('') due > to the extra NUL terminator, so I take a slice of that list to exclude > the final element. > > There is also a GetLogicalDrives() that returns a bitmask, which may or > may not be more suitable for your purposes. > > Another poster suggested iterating through possible drives using > os.path.exist() which will also work, but will end up activating all > the devices it tries (e.g., your floppy disk may try to be accessed, > and/or the CDROM may spin up briefly), and since the notion of > existence of a drive is platform specific, it's probably worth too > much trying to keep the check platform independent. > > -- > -- 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 kosh at aesaeion.com Wed Jul 25 21:43:19 2001 From: kosh at aesaeion.com (kosh) Date: Thu, 26 Jul 2001 02:11:19 +0028 Subject: And now, something completely different... References: Message-ID: Chris Gonnerman wrote: > The PEP0238 flamewar has been rather bad the last few days, > and a lot of ill will has been exchanged. I was among the > detractors, and I feel I must apologize to Guido for > contributing to his impending ulcer... > > So, like, I'm sorry, man. > > I found myself considering yesterday what programming > language I would switch to if Python failed me, and I came > to the conclusion that, even with PEP0238 suddenly breaking > mucho code (as appeared likely before Guido's most recent > postings), Python would still be head and shoulders (and > beltbuckle and kneecaps) above everything else. > > Now, with the changes taking firm hold in 2+ years, and > evidence that Guido takes our concerns seriously, I'm a > much happier camper. > > Guido, I for one am happy to call you my Fearless Leader. He has to be fearless to put up with us. I think you are doing an excellent job also Guido. Sorry to add to the overall flamefestival here. Keep up the good work and get an asbestos outfit. ;) From peter at engcorp.com Thu Jul 26 01:39:29 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 26 Jul 2001 01:39:29 -0400 Subject: Eliminating upgrade risk References: Message-ID: <3B5FAD11.FB9D737E@engcorp.com> John Roth wrote: > > After enduring the PEP 238 threads for far too long, as well as other > threads, I've come to the conclusion that Python is simply too unstable > for real use. Do you really mean "is" too unstable, or you mean it looks like it "might be" unstable, solely because of the proposals about changing the way the / operator works? I've used Python for about a year and a half in dozens of practical areas in industry. I consider it *bar none* the most stable language I've ever used. Not only with respect to the stability of the applications I write, but also the runtime (I can hardly recall a crash, although I'm sure I've had a few when using calldll around third-party DLLs) and definitely *even the language definition*. Changing from 1.5.2 to 2.1 required us to do, let me see: nothing! I reviewed the list of changes, predicted we would not be impacted, and so far (after several months of ongoing development and continued use of our many utilities and applications) I've been proven correct. So I'm guessing you really just mean that this PEP 238 proposal is scarey. I agree, to the extent that code breakage is never nice to contemplate, but with the ongoing consideration being given to the issue by the developers, I'm reasonably satisfied that even this drastic change will end up having relatively little effect on my opinion of Python's stability. Planning over two years in advance and guaranteeing the breakage will only occur when a major upgrade (Python 3.0) is released is pretty much the best you could hope for from any language. After all, by convention major upgrades are where you are supposed to *expect* code breakage. > Hopefully, this is going to provide more food for thought than fuel for the > flames. I hope you don't consider this a flame. But I'm not responding to the suggestion of "required" other than to say I don't think it's really necessary (because I don't think it's really necessary... as should be evident from the above). -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From guido at python.org Sat Jul 7 09:39:02 2001 From: guido at python.org (Guido van Rossum) Date: Sat, 07 Jul 2001 13:39:02 GMT Subject: Augmented Assignment (was: Re: PEP scepticism) References: Message-ID: Thomas Wouters writes: > But > x = () > x += y > > is not, and that's exactly what I meant. But x will never have a refcount of two in this case: there's one reference from x, one from the argument list to +=, and one from the global variable that holds on to the empty tuple so it can be shared with others. --Guido van Rossum (home page: http://www.python.org/~guido/) From paulp at ActiveState.com Tue Jul 17 14:03:24 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Tue, 17 Jul 2001 11:03:24 -0700 Subject: SGML and Python References: <9j1s5g+rubh@eGroups.com> Message-ID: <3B547DEC.8DBB0703@ActiveState.com> burton_kent at bigfoot.com wrote: > > What's available for SGML and Python? PyGrove and PySGML are what > I've found, however, the website at the University of Waterloo where > they're located seem to always be down. > > I need to do validation and correction of incomplete SGML documents. Neither PyGrove nor PySGML dealt very well with incomplete (i.e. not well-formed) SGML documents. Anyhow, what I typically do these days is to use something like SX to translate into XML, use the wealth of XML tools available and then translate back into SGML if necessary. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From peteris_martinsons at swh-t.lv Fri Jul 27 09:02:44 2001 From: peteris_martinsons at swh-t.lv (Peteris Martinsons) Date: 27 Jul 2001 06:02:44 -0700 Subject: byte compiled files References: <3B602FA0.6030809@herts.ac.uk> <3B6127EB.2080002@herts.ac.uk> Message-ID: <44da3708.0107270502.182af936@posting.google.com> A little bit shorter (and perhaps faster) version :) #do not need to instantiate on each run of function repeats = ('AAAA', 'CCCC', 'GGGG', 'TTTT') nucleotids = ('A', 'G', 'C', 'T' ) ... def checkValidData(bsite): for x in bsite: #check new bsite contains valid charactors if x not in nucleotids: return 0 for x in repeats: if (string.find(bsite, x) != -1): return 0 return 1 Peteris Martinsons From salnikov at inp.nsk.su Fri Jul 27 01:27:01 2001 From: salnikov at inp.nsk.su (Andy Salnikov) Date: Fri, 27 Jul 2001 12:27:01 +0700 Subject: PEP 238 (revised) References: Message-ID: <9jqu35$voua$1@sky.inp.nsk.su> Well, what I see is a strong determination to get this PEP through. It's unwise to continue arguing under these conditions, but anyway... Don't take it personally, I understand pretty much your ideas to make this world nicer, the only thing I do not like is the burden you put on all your Puthon programmer guys. "Guido van Rossum" wrote in message news:cp4rrz5onj.fsf at cj20424-a.reston1.va.home.com... > > We propose to fix this by introducing different operators for > different operations: x/y to return a reasonable approximation of > the mathematical result of the division ("true division"), x//y to > return the floor ("floor division"). We call the current, mixed > meaning of x/y "classic division". > It's very much like in any PR company, giving it tag of "true division" seems to imply that this is the only way to do division correctly:) I think there is no more truth in it than in the classic. (Just my opinion, and its useless to debate about what truth is, it's rather ethical cathegory, has nothing to do with division operator.) > > - Let / keep its classic semantics; introduce // for true > division. This doesn't solve the problem that the classic / > operator makes it hard to write polymorphic numeric functions > accept int and float arguments, and still requires the use of > x*1.0/y whenever true divisions is required. > How is it? The x//y is supposed (in this only suggestion) to do exactly the same as x*1.0/y. Please, correct it. I still do not see a word about what it does to migrate all the existing code, what you do and what Python coders do, the tools we should expect, time scale. Would be nice to have complete understanding of these issues _before_ we get into the boat. Cheers, Andy. From skip at pobox.com Wed Jul 18 15:54:37 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 18 Jul 2001 14:54:37 -0500 Subject: Readline on RedHat 7.1 with Python 2.1 In-Reply-To: <3B55DFA3.E5BBC46E@mindspring.com> References: <3B551BD7.4D666D9E@mindspring.com> <0Ne57.1129$KC.143209@news3.oke.nextra.no> <3B55DFA3.E5BBC46E@mindspring.com> Message-ID: <15189.59773.784076.694003@beluga.mojam.com> kelly> OK, I installed the readline-devel package. Now I am getting the kelly> following error message: kelly> /usr/bin/ld: cannot find -ltermcap kelly> collect2: ld returned 1 exit status kelly> make: *** [python] Error 1 kelly> Thanks for the response. I am getting closer, but there is still kelly> something wrong. Any idea what I should do next? Try installing libtermcap-devel... ;-) -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From robin at jessikat.fsnet.co.uk Wed Jul 25 20:20:54 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 26 Jul 2001 01:20:54 +0100 Subject: Eliminating upgrade risk References: Message-ID: well in the last two years I've upgraded four times. It is never a pleasant experience; I'm lucky enough to be able to follow many of the discussions and thus get some kind of handle on what's likely to go wrong. I think it's foolish to expect everyone to be so lucky. Most people who use python don't use it full time. The C code I wrote in 1983 still compiles, my python code from 1999 probably has bugs if I use 2.1. If the advice from the Gods is that Python is a 'research' language then I'll know better what to do. Please inform us. Skip's posts in the dev list seem full of promise. -- Robin Becker From thedustbustr at aol.com Mon Jul 23 21:02:18 2001 From: thedustbustr at aol.com (TheDustbustr) Date: 24 Jul 2001 01:02:18 GMT Subject: thread module Message-ID: <20010723210218.11240.00000881@ng-fv1.aol.com> What args are encessary when you call thread.start_new_thread()? The module index says: "start_new_thread (function, args[, kwargs]) Start a new thread. The thread executes the function function with the argument list args (which must be a tuple). The optional kwargs argument specifies a dictionary of keyword arguments." How do I create a simple thread like so: def hi(): print "Hi!" thread.start_new_thread(hi(),args) What are the args? From sabren at manifestation.com Sat Jul 7 11:47:46 2001 From: sabren at manifestation.com (Michal Wallace) Date: Sat, 7 Jul 2001 10:47:46 -0500 (CDT) Subject: [OT] Eternal programming In-Reply-To: Message-ID: On Sat, 7 Jul 2001, Roman Suzi wrote: > I want to be 100% sure that some things I use today will stay forever. > My main concerns are: Hey Roman, You've got an interesting idea here.. But I'm not sure I understand the problem it's meant to address. If you're worried about your code suddenly ceasing to work, of course you know that code doesn't break unless you change things. A pyhon 0.1 script would work just fine today if you had python 0.1 installed. So it must be that you want your programs to keep working even as you keep changing the underlying libraries / languages, or upgrading to new versions that other people create. If that's the case, you can defend against this problem by writing unit tests. If you have a test for every feature of your program, you're free to upgrade any libraries it uses. Just run the tests and you'll find out instantly if anything broke. If something did break, you can either update your code, or just go back to the old version of the library. Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.net www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ From 63.203.225.62 Mon Jul 2 15:54:28 2001 From: 63.203.225.62 (63.203.225.62) Date: Mon, 02 Jul 2001 19:54:28 GMT Subject: What is best of breed for HTTPS clients? Message-ID: Is it possible (easy) to build an HTTPS client with mxCrypto? http://www.lemburg.com/files/python/mxCrypto.html Python 2.1 seems to have some support for HTTPS, but maybe these are just stubs. I would like to build HTTPS support into my application in a way that will be supported by current or future standard extensions. I was able to use M2Crypto with success: http://mars.post1.com/home/ngps/m2/ my only complaint was the lack of documentation. Otherwise I had an easy time getting this to work once someone showed me how to do it. I'm looking for "the best" way to do an HTTPS client. If there is nothing else, then I will probably place my bet with M2Crypto. Yours, Noah ================================== Poster's IP address: 63.203.225.62 Posted via http://nodevice.com Linux Programmer's Site From alf at leo.logilab.fr Mon Jul 16 13:11:34 2001 From: alf at leo.logilab.fr (Alexandre Fayolle) Date: Mon, 16 Jul 2001 17:11:34 +0000 (UTC) Subject: Most efficient solution? References: Message-ID: On 16 Jul 2001 11:57:13 -0400, Alex wrote: > >Oh, I'd thought hash lookups were constant time. That's interesting. Well, there goes my credibility. Of course hash lookups are more or less constant time. I've been working with the mapping types in C++ STL which are binary trees, and therefore have log(n) access time. Please accept my apologies for replying before having completed the context switch. Alexandre Fayolle -- LOGILAB, Paris (France). http://www.logilab.com http://www.logilab.fr http://www.logilab.org Narval, the first software agent available as free software (GPL). From msoulier at storm.ca Sat Jul 7 20:21:58 2001 From: msoulier at storm.ca (Michael P. Soulier) Date: Sun, 08 Jul 2001 00:21:58 GMT Subject: lvalues and the lgb rule References: Message-ID: On Fri, 6 Jul 2001 18:09:31 -0400, Tim Peters wrote: > > This is a flawed mental model: the local vs non-local distinction is made > at compile-time, by static inspection of the program text. There's nothing > dynamic about that (in the absence of "import *" and "exec" abuses). Granted, not dynamic in the sense that the underlying interpreter is calling malloc(), but it acts as a double assignment/declaration. Not much different than C++ really, except that you don't have to declare a type, it's inferred by what you're assigning. Understood. >> Now, while this is great for scripting, it can cause major >> headaches with large programs if you're a bad typist. > > I expect bad typists have lots of other problems writing code too . :) Everybody makes mistakes... > A tool like PyChecker will detect that, in the example exactly as given, > "myvar" and "myver" are *both* unreferenced, and flag both lines with > warnings. PyChecker? Ok, I'll look for that. Lets face it, mistakes happen. I mean, Python's design has been in part to minimize typical errors found in other languages. For example, in Python I cannot do a standard Cism of assignment with testing: if ((length = strlen(string)) > 2) /* do something with string > 2 */ This was removed in Python, preventing the classical error of assignment when one intended to test Intent: if (x == 5) Accidental assignment if (x = 5) It seems to me that Python has been designed to avoid such errors, and yet the omission of forced predeclaration, or at least warnings, seems like a glaring omission to me. Just my opinion. I'll give PyChecker a shot. > The size of the program doesn't really matter; regardless of program size, > if you don't keep your individual functions and methods to well under a > screen of code almost all the time, you're going to have lots of problems > (in Python or any other language; it may even be worse in Python, because > indendation for grouping really doesn't work well when code blocks slobber > over screen pages; that's one of the clever pressures in Python *nudging* > you toward writing better code). > > guido-can-lead-you-to-clarity-but-he-can't-stop-you-from-peeing-in- > the-stream-ly y'rs - tim :) Perhaps, but these idealistic ideas don't always work. They're not exercised enough in the industry, true, but sometimes you can't afford the overhead of all of those function calls. Granted, if you can afford Python, you can probably afford the function calls. ;-) Thanks, 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 tim.one at home.com Sun Jul 22 20:10:47 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 22 Jul 2001 20:10:47 -0400 Subject: PEP0238 lament In-Reply-To: Message-ID: [Tim] > The current integer division loses information silently and without > a trace. [Grant Edwards] > No, it doesn't. Of course it does, but note that I'm using "information" in its technical sense. Current int division is a many-to-one mapping, so necessarily loses information. Loss of information is often a good thing (like, losing most of the repetitions of these old arguments would be a good thing <0.5 wink>), but silent loss by default is generally bad design. > Integer division is integer division. The correct answer for the > value of 3/4 is 0. If Guido has his druthers, the correct answer for 3//4 will be 0. It's not the *operation* but the *spelling* he's seeking to change. > If you wanted the remainder, you should ask for it. If you want to > divide floating point numbers, you should _use_ floating point numbers. Whether 1/2 would return a float is still open. > Perhaps my mind was warped by using nothing but integer arithmatic > in my software for many years because floating point was simply too > slow and too expensive. Or maybe you needed integer semantics -- I can't guess. Doesn't much matter to the current debate. If you bought a hand calculator that truncated division results to integers, would you be happy with that? That's what informs the expectations of the generations after us. From guido at python.org Fri Jul 6 07:34:04 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 06 Jul 2001 11:34:04 GMT Subject: Augmented Assignement (was: Re: PEP scepticism) References: Message-ID: "Rainer Deyke" writes: > Correctness: Consider the following function: > > def f(x): > x += (1, 2, 3) > print x > > This function is just plain incorrect. Depends on context. If you write a small program that by convention manipulates tuples, this would be totally acceptable. Not every function needs to be written polymorphically to work on all kinds of arguments. Many functions are by convention only used on specific argument types, and both the caller and the function author know that. Then using the += notation on an argument is totally acceptable. The statement that f is *incorrect* is meaningless without context. --Guido van Rossum (home page: http://www.python.org/~guido/) From worm at gdp-group.com Thu Jul 26 08:38:31 2001 From: worm at gdp-group.com (Thomas Volkmar Worm) Date: Thu, 26 Jul 2001 14:38:31 +0200 Subject: Informix IDS2000 and Zope/Python/Perl/PHP on Linux Message-ID: <3B600F47.2F59C1FC@gdp-group.com> Hi all! I am consindering to use Informix Dynamic Server (Informix Internet Foundation 2000/Linux) together with Zope and the other 3 P's. I wonder, whether somebody has any experience with Linux and - IDS 2000 and Perl or - IDS 2000 and PHP or - IDS 2000 and Python or - IDS 2000 and Zope and can tell me about the experience he made with one or more of these combinations. I am interested to hear about - availibility of the needed drivers - their (practical) compatibility to (eg. perl DBI, python DB-API 2.0, etc.) - stability - and what else someone has experienced I already was an php.net, python.org, perl.org, zope.org - I guess I know whats available. It looks to me as if the support for IDS is not so strong, so I am really interested in real experience somebody had rather that what you can read in the READMEs. If you stopped using IDS together with P..., please tell me why and what db (other than mySQL, thats allready running here) are you using instead. If some Informix/IBM people are around: Are there any contributions planned or in progress for the 3 P's by Informix/IBM? Where can I find online information about it? If you respond to this posting, please send a CC to my email-address too. Thanks for your efforts in advance Regards Thomas Volkmar Worm -------------- 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 aahz at panix.com Sat Jul 21 00:11:30 2001 From: aahz at panix.com (Aahz Maruch) Date: 20 Jul 2001 21:11:30 -0700 Subject: Language change and code breaks References: Message-ID: <9javdi$bbp$1@panix2.panix.com> In article , Mark 'Kamikaze' Hughes wrote: > > Who actually names their classes with one-letter names like A or C as >I've seen in this thread? Anyone? Didn't think so. > > Actual use is more like: >a = Anything() >c = Cookie() or smpt = SMTP() -- --- 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 Fortune cookie: Watch your relations with other people carefully, be reserved. From tim.one at home.com Sat Jul 14 19:03:37 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 14 Jul 2001 19:03:37 -0400 Subject: Light Speed Socket Connections In-Reply-To: Message-ID: [Tim] > Python doesn't use the MS clock() for time.clock() on Windows; > it uses the MS QueryPerformanceCounter API instead. [/F] > so you mean I cannot trust the Python documentation? ;-) The regular expression docs, sure . time.clock() on Windows actually returns an approximation to the wall-clock time that's elapsed since the *first* time you called time.clock(). The first time you call it you get back a few millionths of a second, and no matter how long your program has been running. so-it's-accurate-but-probably-not-a-satisfying-lover-ly y'rs - tim From mac4-devnull at theory.org Tue Jul 10 14:15:35 2001 From: mac4-devnull at theory.org (Neil Macneale) Date: Tue, 10 Jul 2001 11:15:35 -0700 Subject: Limiting thread intruction count References: <3b46ddb2$0$332$8eec23a@newsreader.tycho.net> <9i9spk$1hr$1@verence.demon.co.uk> Message-ID: <3b4b4647$0$318$8eec23a@newsreader.tycho.net> COOL! Thats a good tip. Thanks a lot. Neil Macneale In article <9i9spk$1hr$1 at verence.demon.co.uk>, "Paul Wright" <-$Paul$- at verence.demon.co.uk> wrote: > Greg Stein has a Robot Wars implementation which does what you want by > playing with thread locks in a function which is a sys.settrace hook. > sys.settrace lets you specify a function to run after every line of code > (it's intended for people writing debuggers). > > http://www.pythonpros.com/gstein/war/ > > (Unfortunately it's not a complete implementation: it'd be a cool way to > help beginners learn Python, especially those with a limited attention > span :-) > -- To reply to me via email, remove the '-devnull' from my address. From paul at boddie.net Thu Jul 26 04:53:28 2001 From: paul at boddie.net (Paul Boddie) Date: 26 Jul 2001 01:53:28 -0700 Subject: re bad leadership References: <0+yM4IAgmKX7EwIQ@jessikat.fsnet.co.uk> <20010724171838.A21770@xs4all.nl> <4crrlt0jbn9ovvkli3qvhqbc5do3lmpg4j@4ax.com> <%kn77.25759$EP6.6204923@news1.rdc2.pa.home.com> <23891c90.0107250216.2f49e2e6@posting.google.com> <3B5EEED7.C9C7117B@home.net> Message-ID: <23891c90.0107260053.70747d65@posting.google.com> Chris Barker wrote in message news:<3B5EEED7.C9C7117B at home.net>... > > I'm sure that was the intention, but we need to keep in mind that the > PEP proposed two types of division, NEITHER of which is the current one, > so in order to keep total backward computability, we would need to add > two operators, which would really get messy. Well, having read the PEP more thoroughly I accept that the two division operators will work differently from the existing one, given that they will each provide consistent operations across all numeric types, and this would be a good thing to have when designing a *new* language. (Although many people accustomed to working with floating point numbers would probably explicitly signal ceiling and floor operations rather than have them implicitly performed by some strange new operator.) However, it's arguably more relevant to discuss the fact that this changes well-defined semantics in the language. It's extremely important for pragmatic reasons to discuss how much damage this change will cause. It's not at all acceptable or interesting to respond to such concerns with how "nice" this will make Python's numeric system. > And, this has been repeated MANY times, but despite the working in the > PEP "Rationale" section, there are some very good and compelling reasons > to have the proposed division that are relevant to experienced > programmers, not just people learning. Guido recently said he will > re-write the Rationale section to include this. I have been convinced by > those reasons, though I think we need a better way to handle the > backward computability issue. I'm sure we'd all love to see a nice and consistent numeric system, but Python is a mature language in widespread use. It's tempting for some to think that with a supposedly inevitable huge influx of new users that the volume of existing code will be dwarfed by new code within a short period of time, but regardless of whether this will happen or not, I think such "ideological" changes to the language with such limited justification send the message to numerous highly-respected community members that their work is considered to be of little value and can be sacrificed to the "language gods" on a whim. Paul From paulp at ActiveState.com Mon Jul 2 18:24:39 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Mon, 02 Jul 2001 15:24:39 -0700 Subject: Augmented Assignement (was: Re: PEP scepticism) References: <20010702145211.M8098@xs4all.nl> <9hq57a0jnd@enews4.newsguy.com> <9hqlel016bl@enews4.newsguy.com> Message-ID: <3B40F4A7.38CB6ACE@ActiveState.com> Alex Martelli wrote: > >... > > Care to expand on this...? Say that x is (a lightweight proxy holding) > a Python long of a few hundred digits which is counting the number > of occurrences of some event-classification in a space of events that > is pretty huge because of combinatorial-explosion. y is another count > I have to add to x, typically a few hundred thousands or a few millions > at most. How would x and y being lightweight proxies save me any > computational effort? I shouldn't have said to use proxies instead of mutable integers. I meant that you should have proxy x holding mutable integer x' and proxy y holding mutable integer y'. Then when you see x+y you can mutate x because you claim that you know that there is only ever one reference to these objects. That doesn't rely on the person using a particular syntax for adding to x. >... > I don't understand whether you're arguing in the abstract, or concretely > proposing to break any Python program, written in the last year or so, > which decided to code "mylist += somemore" as opposed to coding > "mylist.extend(somemore)" while some other reference to mylist may > be outstanding. If the latter, I don't see how such code breakage may > be "a compromise". It preserves your ability to use += to define "integer mutation" without making common Python usage more complicated. > .... In the abstract, if you were designing a new language > from scratch and wanted to have both mutable and immutable datatypes > in it, I guess you could draw the line for a switchover in +='s behavior at > different thresholds; mutable vs immutable is very easy to draw, 'ordinary' > vs 'advanced' may not be, but maybe in such a hypothetical language > you might have other ways to easily flag ordinary vs advanced data > types so people cannot get confused. ... How do we "flag" types that have in-place behavior now? How would I recognize that your integers were mutable based on anything other than reading the documentation or code? -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From aleaxit at yahoo.com Tue Jul 3 16:56:01 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 3 Jul 2001 22:56:01 +0200 Subject: Hiding Console? References: <9ht9to$fei$1@neptunium.btinternet.com> Message-ID: <9htbcn084j@enews4.newsguy.com> "G. Willoughby" wrote in message news:9ht9to$fei$1 at neptunium.btinternet.com... > Is there a way in your script to include a command that when run on a > WinME/32 platform the console does not appear? such as the IDLE ide. I wanna > write apps with neat little gui's using Tkinter but i dont want the console > there when there run, any ideas? Name your program foo.pyw rather than foo.py, and/or run it using explicitly pythonw.exe rather than python.exe -- either way, no console will appear. Alex From com-nospam at ccraig.org Thu Jul 19 21:24:22 2001 From: com-nospam at ccraig.org (Christopher A. Craig) Date: 19 Jul 2001 18:24:22 -0700 Subject: Python 2 times slower than Perl References: <8f41cfd.0107171238.6ff33b9b@posting.google.com> <170720011359545210%mday@apple.com> <87n163mfdc.fsf@elbereth.ccraig.org> <3b550e40.2201271731@wa.news.verio.net> Message-ID: bokr at accessone.com (Bengt Richter) wrote in message news:<3b550e40.2201271731 at wa.news.verio.net>... > Well rare, but not always dumb, I think. If you're only using a constant > in one place that happens to be in a loop, and the clearest way to express > it is as a constant expresssion, you do it that way when you know it's going > to be folded. E.g., compare (5280.0/60.0*60.0) vs 1.4666667 -- which would > you feel surer about, reviewing the code, given the same comment saying > mph->fps? > > Of course, with Python it would be dumb not to move it out of the loop, if > you could save significant execution time. > Or worse I frequently need things like (1L<<1024)-1, and though I know my powers of two quite well, I don't think I'd immediately recognize that one :-) From bokr at accessone.com Tue Jul 10 21:47:30 2001 From: bokr at accessone.com (Bengt Richter) Date: Wed, 11 Jul 2001 01:47:30 GMT Subject: Language Shootout References: <3b4b04fb.1257683@nntp.sprynet.com> Message-ID: <3b4bab70.1586151915@wa.news.verio.net> On Tue, 10 Jul 2001 13:54:47 GMT, ullrich at math.okstate.edu (David C. Ullrich) wrote: >On Tue, 10 Jul 2001 01:18:16 -0400, "Tim Peters" >wrote: > >>[Bengt Richter] >>> ... >>> I just did a python recursive fib(100000) in >>> just over 15 seconds, including startup and which turned out to be mostly str conversion for the print, so I thought I'd try recursion on that... (see below ;-) [...] >(Took a minute to find fib.py just now, because it was filed >under "MatrixTypes". I calculate fib(100000) in 1.7 >seconds this way; for comparison, str(fib(100000)) takes >8.0 seconds.) Hi Dave ;-) Try strL for comparison. It's recursive, and faster than str for big numbers. I got >>> len(strL.strL(ffib(100000))) 20899 so you can type in 10L**20899 on the command line for a number in the same ballpark as the fib, for a test. On my system I get [18:47] C:\pywk\fib>strL.py str 10L**20899 str took 13.601617 seconds [18:47] C:\pywk\fib>strL.py strL 10L**20899 strL took 1.044989 seconds Recursion rides again ;-) BTW, how do you put everything inside the strL def to hide names, and how do you recurse inside without a warning message? A couple of lines wrapped... _______________________________________________________________ # strL.py -- recursive long to decimal string conversion # 2001-07-10 bokr # p10d={} def p10(n): if not p10d.has_key(n): p = p10d[n] = 10L**n return p return p10d[n] def strLR(n,w=0): # w>0 is known width, w<0 is searching guess if w == 0: return [] if w > 0: if w <=9: return [('%0'+chr(w+48)+'d') % n] wr = w/2 nl,nr = divmod(n,p10(wr)) return strLR(nl,w-wr)+strLR(nr,wr) else: nl,nr = divmod(n,p10(-w)) if nl: return strLR(nl, 2*w) + strLR(nr,-w) else: if w >= -9: return ['%d' % n] else: return strLR(nr,w/2) def strL(n): if n<0: return ''.join(['-']+strLR(-n,-9)) else: return ''.join(strLR(n,-9)) from time import clock import sys def main(): def pr(x): print x def psl(x): s = strL(x) sys.stdout.write(s) sys.stdout.write('\n') dt={'str':str,'strL':strL,'repr':repr, 'print':pr, 'printStrL':psl } try: x=long( eval(sys.argv[2]) ) fn=sys.argv[1] fcn=dt[fn] except: sys.stderr.write("usage: %s [str strL repr print printStrL] \n" % sys.argv[0]) sys.exit(2) t0=clock() fcn(x) t1=clock() print "%s took %9.6f seconds" % (fn,t1-t0) if __name__ == "__main__": main() _______________________________________________________________ From ak42 at altavista.com Sun Jul 22 21:30:03 2001 From: ak42 at altavista.com (Alex K) Date: 22 Jul 2001 18:30:03 -0700 Subject: compiling a program --with-python fails (Py_Initialize in -lpython... no) References: <3B566DAD.C2A08D1E@altavista.com> Message-ID: <2ff373b0.0107221730.28e7c0e4@posting.google.com> "M.-A. Lemburg" wrote in message news:... > Alex K wrote: > > > > hello! > > > > i am trying to compile a program (a module for icecast called ices) > > with pythonsupport. but that fails. > > > > i am on a slackware8 system, with python 2.2a1 installed > > (from tarball with no special conf-arguments). > > > > [root /usr/local/src/ices-0.1.0]# ./configure > > --with-python-includes=/usr/local/include/python2.2 > > ... > > checking for Python.h... yes > > checking for Py_Initialize in -lpython... no > > checking for Py_Initialize in -lpython2.0... no > > checking for Py_Initialize in -lpython2.2... no > > checking for Py_Initialize in -lpython1.6... no > > checking for Py_Initialize in -lpython1.5... no > > configure: error: Could not find the python library > > ... > > You will probably have to add the path to the Python lib > using some configure option of that program. > > A look at the config.log will also be helpful. i have tried: --with-python --with-python-includes=/usr/local/include/python2.2/ --with-python-libraries=/usr/lib/python2.0/ and also: --with-python=/usr/local/bin --with-python-includes=/usr/local/include/ --with-python-libraries=/usr/lib/ and many combinations thereof. nomatter what i get the abovementioned error about Py_initialize (provided that i specify the include dir, or else it doesnt find Python.h, which i think is strange in it self, since it is in a standard place). the pertinent part of config.log seems to be this (which doesnt help me at all): ... * We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char Py_Initialize(); char Py_Initialize(); int main() { Py_Initialize() ; return 0; } configure:3791: checking for Py_Initialize in -lpython2.2 configure:3810: gcc -o conftest -g -O2 -Wall -fno-strict-aliasing -I/us r/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/lib/per l5/i386-linux/CORE -I/usr/local/include/python2.2/ -I/usr/local/bin/inclu de -L/usr/lib/python2.0/ -L/usr/local/bin/lib conftest.c -lpython2.2 -lm -ldl -lpthread -lshout -rdynamic -L/usr/local/lib /usr/lib/perl5/i386-li nux/auto/DynaLoader/DynaLoader.a -L/usr/lib/perl5/i386-linux/CORE -lperl - lnsl -ldl -lm -lc -lcrypt -lutil 1>&5 /usr/i386-slackware-linux/bin/ld: cannot find -lpython2.2 collect2: ld returned 1 exit status configure: failed program was: #line 3799 "configure" ... line 3799 in configure is simply: #include "confdefs.h" that part of configure is definitely about python, but i cant quite figure out what goes wrong and why. anyone who has a guess? tia / alex k From aleaxit at yahoo.com Thu Jul 5 08:32:12 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 5 Jul 2001 14:32:12 +0200 Subject: system exec ? References: <9i1er4$mth$1@news.businessobjects.com> <9i1ffe029cm@enews1.newsguy.com> <9i1npl$160$1@news.businessobjects.com> Message-ID: <9i1moe02fou@enews1.newsguy.com> "alphaZeta" wrote in message news:9i1npl$160$1 at news.businessobjects.com... > > Thanks, I was also planning to use the readlines() method. ... > > a = os.popen("ls -l").read() > > > > may be what you want (but you may also prefer to call .readlines() That's good in most cases, just one further thing: if there is the possibility that the output of the command is vaster than will comfortably fit in memory, you may want to import xreadlines and rather than storing said output in your memory all at one loop over it line by line: from xreadlines import xreadlines for line in xreadlines(os.popen("ls -l")): process(line) Not an issue for ls -l, of course, but some OTHER program MIGHT be returning gigabytes of text that you have to process, and in that case doing it sequentially is best. Alex From aahz at panix.com Sat Jul 28 01:28:06 2001 From: aahz at panix.com (Aahz Maruch) Date: 27 Jul 2001 22:28:06 -0700 Subject: A use for integer quotients References: <3B5BA29B.E08FEEE9@alcyone.com> Message-ID: <9jtih6$edu$1@panix2.panix.com> In article , Moshe Zadka wrote: >On Sun, 22 Jul 2001 21:05:47 -0700, Erik Max Francis wrote: >> >> The serious problem I see here is backward compatibility. I shudder to >> think at the volume of preexisting, long-standing code that this will >> quietly break > >Quietly? Note that in the 2.2 release, there will be *no* change except >that you *can* use //, and the only change is if you >"from __future__ import division". >In 2.3, as I understand it, you'll be able to get warnings out when you >are doing something whose semantics will change. Yup, quietly. What happens in Python 2.6, after the changeover is complete? Never in the past has there been a change of such great scope with such a potential for quiet breakage. -- --- 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 Fortune cookie: Watch your relations with other people carefully, be reserved. From thecalm at NOSPAM.btinternet.com Tue Jul 17 18:48:06 2001 From: thecalm at NOSPAM.btinternet.com (G. Willoughby) Date: Tue, 17 Jul 2001 23:48:06 +0100 Subject: Startup question References: <3B4E4A69.4040100@yahoo.com> Message-ID: <9j2fah$vo$1@neptunium.btinternet.com> try these links: http://starship.python.net/crew/theller/py2exe/ or http://www.mcmillan-inc.com/install1.html I haven't got them to work yet, i'll have to buckle down and sort it out, when i get time :) mail me if you have any success, i would like to see working examples. (fyi, i'm using WinME and activestates python 2.1) Gary. "Paulo da Silva" wrote in message news:3B4E4A69.4040100 at yahoo.com... > Hi, > > I am considering to use python in a middle sized project. > I need to be able to build a standalone with a GUI (ex. tkinter) > both for Windows and Linux, however. > > Is this possible? I read the FAQ and I saw it is possible to > build a standalone, but I could not find if it is also > possible when including a GUI. I don't care about to hide > the code. Just to build a distributable standalone. > > TYVMIA > Paulo da Silva > > -- > Please remove the anti-spam Xs from my email address. > PF. retirar os Xs anti-spam do meu endereco de email. > From jparlar at home.com Tue Jul 10 12:38:27 2001 From: jparlar at home.com (Jay Parlar) Date: Tue, 10 Jul 2001 16:38:27 GMT Subject: Unicode -> String problem References: <92ae279c.0107092059.8b56186@posting.google.com> <1103_994765524@jparlar> <3B4B0141.580437D2@stroeder.com> Message-ID: <1103_994771037@jparlar> > > Now, whenever I'm given HTML from IE's cache, it is unicode. There is no doubt > > about that. > > Are you sure? Which encoding of Unicode? UTF-16, UTF-8, ... > Well, I know that it's Unicode for two reasons: 1) The developer of the module that generates the HTML from the cache told me so, and 2) I do a check for UnicodeType in my own code. I don't think I could tell you which encoding it is though (not without knowing how to check for that within my code). Jay P. From bill-bell at bill-bell.hamilton.on.ca Sat Jul 21 09:03:53 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Sat, 21 Jul 2001 09:03:53 -0400 Subject: Unusual minidom behaviour In-Reply-To: <995696264.385.46543.l8@yahoogroups.com> Message-ID: <3B594579.25239.2878ACF@localhost> "Victor Bazarov" wrote, in part > "Bill Bell" wrote... > > (And, forgive > > me, does the code use CoInitialize/CoUninitialize?) > > Not that I know of. Victor, when I suggested CoInitialize I was forgetting that the absence of this raises a recognisable exception. If this were a fault in your particular code then you would have mentioned that exception. And I don't think COM is involved anyway. Sorry. - Bill Bill Bell, Software Developer From tanzer at swing.co.at Fri Jul 27 05:12:15 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Fri, 27 Jul 2001 11:12:15 +0200 Subject: Eliminating upgrade risk In-Reply-To: Your message of "Thu, 26 Jul 2001 09:16:01 EDT." <3B601811.4B68578B@interet.com> Message-ID: "James C. Ahlstrom" wrote: > Robin Becker wrote: > > > If the advice from the Gods is that Python is a 'research' language then > > I'll know better what to do. > > I am afraid I have to agree with Robin here. My company "solved" > this problem by staying with Python 1.5.2. I do plan to upgrade when > I have the time, but absent any tools to at least flag incompatibilities > this may never happen. Starting with Python 1.5, I never yet had serious difficulties in upgrading to new Python versions. If only Pythonlabs kept their release ccyle better decoupled from ours, we might even ship our products with a more current Python version than 1.5.2 now ;-) > The problem is that the new Python features, as wonderful as they are, > are chosen for Computer Science Purity, not day-to-working-day > importance to someone actually trying to write a widely used bullet > proof program. The current rate of language change is fine for a > student or casual programmer I'm sure, but I don't have that luxury. Much as I am concerned about the effects of the division change, I think you're way off the mark here. I'm thankful to Guido and his gang for improving the language as they do. Things like unicode, augmented assignment, iterators, generators, type/class unification improve my life as a professional programmer. But-then-I-didn't-stay-with-FORTRAN-either-y'rs, Christian -- 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 tanzer at swing.co.at Fri Jul 27 04:45:36 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Fri, 27 Jul 2001 10:45:36 +0200 Subject: Future division patch available (PEP 238) In-Reply-To: Your message of "25 Jul 2001 10:01:24 PDT." <18289ee4.0107250901.3910d4e1@posting.google.com> Message-ID: david at boddie.net (David Boddie) wrote: > tanzer at swing.co.at (Christian Tanzer) wrote in > message news:... > > What if `/` applied to two integer values returned neither an > > integer nor a float but an object carrying the float result but > > behaving like an integer if used in an integer context? > > > > For instance: > > > > >>> x = 1/2 > > >>> type(x) > > > > >>> print "%d %f %s" % (x, x, x) > > 0 0.5 0.5 > > >>> 2 * x > > 0 > > >>> 2. * x > > 1.0 > > > > The difficult issue here is how `integer context` is defined. > > Should multiplication by an integer be considered an integer > > context? Pro: would preserve correctness of existing code like > > `(size / 8) * 8`. Con: is incompatible with Rationals which might > > be added in the future. > > A problem arises if the type of the result (x in this example) is not > immediately resolved, requiring this context to be carried forward. A > "neutral" operation immediately following the assignment above, such > as a print statement (for want of a better example) or even another > division would further complicate the issue by leaving the > interpretation of the result until later when the original context is > unavailable. The original context wouldn't matter. The Ratio object would need to carriy all information needed to behave properly depending on context. It has enough other problems to make it an attractive option, though. -- 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 barry at digicool.com Thu Jul 5 15:03:53 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Thu, 5 Jul 2001 15:03:53 -0400 Subject: [ANNOUNCE] PEP 8, Style Guide for Python Code Message-ID: <15172.47641.290174.183847@yyz.digicool.com> I've taken Guido's original style guide essay and converted it to PEP form. It is available as http://www.python.org/peps/pep-0008.html I've done some mild spellchecking and editorial formatting on the file, but left it as incomplete as the original essay. Hopefully though, having this document in PEP form will encourage contributions to update and expand it. Cheers, -Barry From steve at lurking.demon.co.uk Fri Jul 27 18:18:45 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Fri, 27 Jul 2001 23:18:45 +0100 Subject: A use for integer quotients References: <230720010741551768%jwbaxter@spamcop.com> <4h0tltgbrn2b50mueqd2vsgtt3psvkvosv@4ax.com> Message-ID: <17o3mtsb2kurvsderudb91nv2e6q6rce77@4ax.com> On Wed, 25 Jul 2001 22:28:14 +0100, Gareth.McCaughan at pobox.com (Gareth McCaughan) wrote: >By the way, any definition of "mathematician" that excludes >pure mathematicians is spectacularly broken. What about a definition that generalises to include *more* than just pure mathematicians? It is you who is narrowing the definition, not me. I never once claimed that integer division was allowed in all mathematics. I claimed it existed in mathematics. I specifically pointed out that it was generally done-and-dusted and therefore not something of interest to current academics - but that it did survive in everyday life. After all, would you really share five TVs between two people by turning the fifth TV into junk? Or would you perhaps treat it as a remainder? Others claimed 'the methods I use do not allow this, and the methods I use are part of mathematics, therefore mathematics doesn't allow this'. As a mathematician, you *should* recognise this as a false syllogism. Or perhaps you consider that logic - being outside your particular field - doesn't exist? Mathematics includes many ideas that are not applicable to pure mathematics - applied mathematics presumably contains many such ideas. The fact that they do not apply in specifically in current pure mathematical study does not mean they aren't a part of mathematics. From steve at lurking.demon.co.uk Mon Jul 23 00:35:02 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Mon, 23 Jul 2001 05:35:02 +0100 Subject: A use for integer quotients References: Message-ID: On Mon, 23 Jul 2001 00:55:58 GMT, "Terry Reedy" wrote: >During the debate on changing int/int to give a float result, some >proponents appeared to question the usefulness of integer quotients. >Opponents of the change gave calculation of array indexes, including >graphics pixel coordinates, and 'combinatorics' as example uses. I >here present an particular example of a combinatorial use extracted >from the recent thread on partitions. Of course - lets see if I can think of some more... - Pretty much *all* divide-and-conquer algorithms - e.g. binary searching ordered lists/tuples - Crypto algorithms such as RSA - Heaps - priority queues etc - Many mathematical algorithms - e.g. fast fourier transform requires both integer division on integer arguments and float division on float arguments (but does not need integers to magically turn into floats). That's just off the top of my head. I can think of many uses for float division too - many engineering applications for instance - but NONE that need integers and floats to be treated the same way. From Kristen_Blanco at prenhall.com Fri Jul 13 13:39:21 2001 From: Kristen_Blanco at prenhall.com (Kristen_Blanco at prenhall.com) Date: 13 Jul 2001 13:39:21 -0400 Subject: python reviewers Message-ID: <"/GUID:QqKdP5p131RGZOABgCI2PYQ*/G=Kristen/S=Blanco/OU=exchange/O=pearsontc/PRMD=pearson/ADMD=telemail/C=us/"@MHS> I am writing from Prentice Hall publishing and I am seeking reviewers for an upcoming publication. We are one of the largest college textbook publishers in the US. We are publishing a book entitled "Python How to Program" by Harvey and Paul Deitel. They are premier programming language authors, with the best-selling C++ and Java books in the college market place. More information on their suite of publications can be found here: http://www.prenhall.com/deitel We are presently seeking qualified technical reviewers to verify that the Deitels' coverage of Python in their forthcoming book is accurate. In return, we are offering a token honorarium. Might you be willing to participate? If not, could you perhaps suggest a colleague? If you are interested, or have any questions, please contact my colleague, Crissy Statuto, at Crissy_Statuto at prenhall.com Thank you in advance for your assistance and consideration. Sincerely, Crissy Statuto Crissy Statuto Project Manager, Computer Science Prentice Hall One Lake Street- #3F54 Upper Saddle River, NJ 07458 From bill-bell at bill-bell.hamilton.on.ca Wed Jul 11 20:37:27 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Wed, 11 Jul 2001 20:37:27 -0400 Subject: detect if file or dir In-Reply-To: <994895287.608.4172.l6@yahoogroups.com> Message-ID: <3B4CB907.18460.6D5F2B@localhost> pedro at athlet.de (pedro) wrote: > how can i detect if sth. is a file or a directory? exists(directory) > does tell me if sth. is a directory but exits my script wenn it hits a > file. Pedro, I assume you mean that the use of 'exists' raises an exception? Notwithstanding the comments offered by others on this list, I don't think it should. For example, on my machine: >>> os.path.exists ( r'c:\temp.txt') 1 ie, it works without raising an exception given a file name. Bill From tjreedy at home.com Tue Jul 24 02:32:33 2001 From: tjreedy at home.com (Terry Reedy) Date: Tue, 24 Jul 2001 06:32:33 GMT Subject: A way to accommodate laguage changes References: <3B5CB83B.F3B7D51@home.net> Message-ID: <5E877.23798$EP6.5677355@news1.rdc2.pa.home.com> "Chris Barker" wrote in message news:3B5CB83B.F3B7D51 at home.net... > 3) So, the big disagreement is over whether the improvement in the > language resulting from the proposed change is worth the considerable > pain it is likely to cause by: > A) Breaking old code > B) Making it very difficult to write code that can run on old and new > version of the interpreter. This problem, though worse in a way with the division change, is generic to all language changes. To run newly written code under old versions of the interpreter, you have to eschew *all* features added after the oldest version you want to support. For 1.5.2, this means list comprehensions, augmented assignments, nested scopes, iterators, generators, type-class unification features, and what ever else is next added. For the proposed division change, the 'new' meanings will be int/int and float//float. So write float(int)/int and floor(float/float) instead. Only write int//int or float/float. With the tokenizer module, it will then be easy to change all instances of int//int to int/int (old meaning). It should even even be possible to have package installers check sys.version and do this conversion on site as needed. For newly written code, the harder problem will be to not use any of the other neat new features, which mostly *cannot* be automatically back converted. Terry J. Reedy From whrauser at erols.com Wed Jul 4 11:11:00 2001 From: whrauser at erols.com (whr) Date: Wed, 4 Jul 2001 11:11:00 -0400 Subject: Two problems with backslashes References: Message-ID: <9hvbcn$bet$1@bob.news.rcn.net> Here is a clue: >>> path = 'e:\test\test.txt' >>> path 'e:\test\test.txt' >>> print path e: est est.txt And another one: >>> path.replace('\t','/t') 'e:/test/test.txt' >>> Walt '\t' is a tab character "Gustaf Liljegren" wrote in message news:Xns90D4A141E71CDgustaflalgonetse at 194.213.69.148... > I have two problems with backslashes in DOS path strings: > > >>> path = 'e:\test\test.txt' > >>> path.replace('\\', '/') > 'e:\test\test.txt' > > Expected: > > 'e:/test/test.txt' > > Also, split() doesn't like backslashes: > > >>> paths = 'e:\test\file1.txt e:\test\file2.txt' > >>> paths.split() > ['e:', 'est', 'ile1.txt', 'e:', 'est', 'ile2.txt'] > > Expected: > > ['e:\test\file1.txt', 'e:\test\file2.txt'] > > Alternative ways would be much appreciated. > > Regards, > > Gustaf Liljegren From db3l at fitlinxx.com Fri Jul 13 18:01:52 2001 From: db3l at fitlinxx.com (David Bolen) Date: 13 Jul 2001 18:01:52 -0400 Subject: dictionary speed References: <41899b99.0107121100.7b2c2cdc@posting.google.com> <3B4E731F.9040307@webone.com.au> Message-ID: simonb at webone.com.au writes: > ie. a dictionary access n levels deep would incur > time penalty proportional to n times the penalty > due to each dictionary look up (log n i presume). Right. For the purpose of key search, what the dictionary actually holds are just objects that don't get involved in the search, whether values are themselves dictionaries won't matter. But if you nest dictionaries then clearly you'll have to do extra lookups at each dictionary. The first lookup yields the object (which happens to be another dictionary) on which you do another lookup, and so on. If you have a three-level nested dictionary structure that you reference with something like: dictionary[key1][key2][key3] then there are three discrete lookups occuring. Of course, if you are going to be using that nested dictionary a lot, you could always bind a name to that dictionary while you use it, e.g.: nested = dictionary[key1][key2] and then do single level lookups: nested[key3] -- -- 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 skip at pobox.com Tue Jul 17 15:25:52 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 17 Jul 2001 14:25:52 -0500 Subject: Regex for strings utility In-Reply-To: <1103_995396879@pan> References: <1103_995396879@pan> Message-ID: <15188.37184.185120.48674@beluga.mojam.com> rhys> I'm trying to write a script which operates like the Unix rhys> 'strings' utility but I'm having difficulties with the regex. ... rhys> I'm getting a Syntax Error: Invalid Token at the closing brace to rhys> the pattern. You have a couple problems. First, the pattern needs to be a string, so it has to be enclosed in quotes. Second, the terminating character for the for loop needs to be a colon. Third, based upon the way you imported re, you need to refer to the findall function as re.findall. Here's a slightly revised version of your script: #!/usr/bin/env python # strings program import sys, re f = open(sys.argv[1]) line = f.readline() pattern = re.compile("[\040-\126\s]{4,}") while line: # regular expression to match strings >=4 chars goes here matches = re.findall(pattern, line) for match in matches: print match line = f.readline() -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From machin_john_888 at hotmail.com Sun Jul 15 22:46:03 2001 From: machin_john_888 at hotmail.com (John Machin) Date: 15 Jul 2001 19:46:03 -0700 Subject: re Challenge: More Compact? References: <3B51E6B1.47E25214@tundraware.com> Message-ID: <92ae279c.0107151846.7a19d24@posting.google.com> Alex wrote in message news:... > def ip_p(ip_string): > > try: bytes = map(int, ip_string.split('.')) > except ValueError: return None > return 0 <= min(bytes) <= max(bytes) < 256 > This doesn't check (a) that there are exactly four doodads (b) that the doodads are composed of 1 to 3 digits. It will say that "0" and "-0000000.0.9.8.7.+6.0000005" are valid IP addresses. From thomas at xs4all.net Sun Jul 8 19:10:14 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 9 Jul 2001 01:10:14 +0200 Subject: Bug in rfc822 In-Reply-To: Message-ID: <20010709011014.N8098@xs4all.nl> On Sun, Jul 08, 2001 at 08:20:31PM +0100, phil hunt wrote: > I have added a comment to bug #437395, to this effect. Do > I need to notify anyone else? The Bug Report says it was submitted > by Fred Drake, and assigned to Barry Warsaw. Nope. Both of those people, and whomever is on the 'bug admin' list, will have received email with your new comment in it. If you want to supply a patch to fix it, though, I'm sure both of them, and everyone else, would greatly appreciate. Barry does do a lot with rfc822 messages, but he might not get to fixing it soon. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From fredrik at pythonware.com Sat Jul 14 07:47:44 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 14 Jul 2001 11:47:44 GMT Subject: DB-API 1.0 vs. 2.0 Message-ID: DB-API 1.0 (dated April 9, 1996) specifies that a connection object should provide "all Cursor Object attributes and methods". this requirement seems to have been dropped in the (undated) DB-API 2.0 specification -- but this fairly major change isn't listed under "Major Changes from Version 1.0 to Version 2.0"... what's the deal here? should a 2.0 implementation provide an implicit cursor, or not? (btw, maybe the people involved could add a release date to the 2.0 specification?) Thanks /F From volucris at hotmail.com Mon Jul 9 23:36:59 2001 From: volucris at hotmail.com (Volucris) Date: Mon, 9 Jul 2001 22:36:59 -0500 Subject: pinging in python? References: <3B4A6EEC.548A29FD@telocity.com> Message-ID: <3b4a77e7$0$321$6e49188b@news.goldengate.net> OK, you said simple: #on win32 (WinMe at least) import os comp = 'www.python.org' ping = os.popen('ping %s' % comp).read()[-8:-4] print ping -- Volucris (a) hotmail.com "Eu n?o falo uma ?nica palavra do portugu?s." wrote in message news:3B4A6EEC.548A29FD at telocity.com... > could anyone point out to a simple code of pinging a computer; > just toping it and get the results; nothing fancy. > > i have found source codes along the line but its all too overwhelming, > and im still a complete newbie despite my half decent understanding of > python. > > thanks in advance, > > Adonis > From sh at ttsoftware.co.uk Mon Jul 23 14:35:04 2001 From: sh at ttsoftware.co.uk (Steve Horne) Date: Mon, 23 Jul 2001 19:35:04 +0100 Subject: PEP0238 lament References: <3B5C4BB5.932C041D@alcyone.com> Message-ID: On Mon, 23 Jul 2001 13:06:43 -0400, "Tim Peters" wrote: >[Erik Max Francis] >> I wouldn't think how JavaScript does things would be a valid defense in >> any case. > >Neither would I, but in the context snipped away I was replying to someone >who seemed to think that it was, but misunderstood what JS actually does. >Even bad arguments should be accurate . Yes, but as the person who made that error I'll point out that perfection is hard to come by. Anger and frustration has drastically increased my typo, bad spelling and even completely-wrong-word count today - a sign of the strength of feeling, really. Factual and logical errors - though I've made one or two minor ones - are not prevalent, however. -- Steve Horne Home : steve at lurking.demon.co.uk Work : sh at ttsoftware.co.uk From brueckd at tbye.com Mon Jul 30 15:44:30 2001 From: brueckd at tbye.com (brueckd at tbye.com) Date: Mon, 30 Jul 2001 12:44:30 -0700 (PDT) Subject: Typing system vs. Java In-Reply-To: Message-ID: > > For example, if I need to store a list of points and color > > values I can't just make an array of (x,y,color) tuples. I need to > > create a class to hold them and then create instances and store them in > > an array or Vector. > > You seem to be complaining about the lack of tuples, not static type-checking > per-se. Hmmm... no, because in Java, for example, to store something in the container (be it tuple or whatever), the container would have to be declared as one that can contain my type of object, and to get my object back out I'd have to explicitly state what it is. For example, if you want to store the integer 5 in a Java Hashtable, you can't just stick it in there, instead you do a "new Integer(5)" to create an Object descendent that can be stored in Hashtable. Then to get it out: int foo = ((Integer)myHashTable.get(someKey)).intValue(); // bleh What's the value-add of strong typing here? > do not have a good code coverage tool. If the compiler can catch a type error > for me at compile-time, that is at least one less unit test I have to write. How so? The type checking imposed by compilers like Java don't seem to solve any real problems - all they do is free the compiler from blame: Vector v = new Vector(); String s = "hi"; v.addElement(s); Integer i = (Integer)v.elementAt(0); The compiler made me stick in the cast to an Integer, but it didn't solve any problems for me (the code is still wrong). The only result is that the compiler can now say, "Hey, it's not my fault - you're the one who cast it to an Integer!". Others on here have pointed out that using C++/Java as an example of a strongly-typed language is a mistake, so maybe my opinion is closer to "the typing systems in C++ and Java tend to cause me more work and problems" and not strong, static typing. > for you. It would really be nice if Python could add some sort of optional > type declarations. It should be technically feasible. I don't think the technical feasability is the main thing keeping them out. Can you help me better see how the value outweighs the cost? (I'm not saying the value is 0, only that for me the cost has always *seemed* to be greater than the benefit. -Dave From tdelaney at avaya.com Sun Jul 1 21:03:18 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Mon, 2 Jul 2001 11:03:18 +1000 Subject: [Python-iterators] While we're at it... Message-ID: > >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. def iter_map (f, seq): def iter_map_generator (f=f, seq=seq): for o in seq: yield f(o) return iter_map_generator() Tim Delaney From tjreedy at home.com Wed Jul 25 14:08:44 2001 From: tjreedy at home.com (Terry Reedy) Date: Wed, 25 Jul 2001 18:08:44 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: Message-ID: > Right! In fact, the goal of PEP 238 is to make such a redesign of > Python's numeric system possible Saying this explicitly makes explicitly obvious what to me was not, before:-). Even though I do not currently care about such a redesign, but you do, I consider the above a point in favor of 238. (I am assuming that such a redesign would not break 'regular' floating point code, such as Newton's method, that does not depend on every last bit being just as it currently is to run correctly.) I think another, currently less-well-articulated goal/result of 238 is that it will make it possible for you to pursue your CP4E dream project without forking Python and also without needing to make further disruptive changes to the core. If you agree with the last proviso, then I also consider this a point in 238's favor. I think more could be said about the connection that would make what's obvious to you clearer to others. > The interesting thing is that the one thing that has to change in > order to get a unified numeric model, whether we introduce rationals > in the numeric tower or not, is integer division (IMO -- and attempting to be helpful again) This (and similar statements) is rhetorically wrong and counter-productive. In PEP238, you are NOT proposing to delete integer division (and I hope/presume you never will), you are NOT proposing to switch it to C's version (ditto), nor are you proposing any other substantive change (ditto). >From a technical viewpoint, you are merely, in Tim's words, proposing to change it's spelling, so that future i//j == current i/j, down to the very last bit. (I am ignoring any possible effect of int/long unification, which is a completely separate issue.) So to ask another rhetorical question: why frighten people unnecessarily? or futilely attempt to get them to accept something that you are not proposing (and I hope/presume you never will)? The *really* interesting thing is that the one thing that has to change for you to pursue your further numeric goals is the current overloading of integer and fractional division onto one symbol, which is exactly what 238 undoes by adding a second symbol. The main practical technical issue, to repeat from my essay of two weeks ago, is code breakage, forwards and back, and the costs and benefits thereof. The important thing is that the one thing you need from people in order to make 238 work without forking Python is their agreement (for whatever personal reason) to do the respelling and absorb the cost in return for the expected long-term individual and collective benefits. You do not need, and will never get, general agreement on the metaphysical relationships of abstract (count, integer, rational, real) and concrete (int, long, float) number sets. Ditto for the abstract virtue or esthetics of various combinations of type-dependent division rules. Terry J. Reedy From thomas at xs4all.net Mon Jul 2 02:31:16 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 2 Jul 2001 08:31:16 +0200 Subject: The standard library In-Reply-To: <9hoe39$8ce$1@newshost.accu.uu.nl> References: <9hoe39$8ce$1@newshost.accu.uu.nl> Message-ID: <20010702083116.I8098@xs4all.nl> On Mon, Jul 02, 2001 at 12:09:13AM +0000, Martijn Faassen wrote: > Carlos Ribeiro wrote: > > At 15:33 01/07/01 +0000, Martijn Faassen wrote: > >>I've just submitted a version of PEP 2 to Barry. It's only a first step > >>on this path, but it's a step. > > I was going to write on myself. Can you send it to the list for us to work > > with? It is not listed on the website; the "stub" one is there. > I understand from PEP 1 that I ought to send it to the PEP editor (Barry) > first. I'll send it to the list as soon as I've received feedback from him. > Then I'll certainly try to integrate anyone's feedback into it. In this case, this is definately the right way: you're stealing someone else's PEP, after all. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From joonas at olen.to Thu Jul 19 08:21:19 2001 From: joonas at olen.to (Joonas Paalasmaa) Date: Thu, 19 Jul 2001 12:21:19 GMT Subject: Problems with self as default parameter Message-ID: <3B56D025.508F40AD@olen.to> How can I use class members as default values. The code above raises an error. class Test: def __init__(self,s): self.default = s def printer(self, string = self.default): print string test = Test("spam") test.printer() #raises: Traceback (most recent call last): File "", line 1, in ? File "H:\problem.py", line 1, in ? class Test: File "H:\problem.py", line 4, in Test def printer(self, string = self.default): NameError: name 'self' is not defined From mnenadov at stclairc.on.ca Sun Jul 22 16:43:51 2001 From: mnenadov at stclairc.on.ca (Mark Nenadov) Date: Sun, 22 Jul 2001 20:43:51 GMT Subject: If you want to see Python people complaining... References: <3B54497F.B98D34CF@jam.rr.com> <20010721.072418.846942590.1761@d150-169-166.home.cgocable.net> Message-ID: <20010722.165606.1450573622.10918@d150-169-166.home.cgocable.net> In article , "Alex" wrote: > Enh, who cares? Everyone knows the slashdot poll is the only one that > matters, anyway. > Alex. True. True. But don't even expect that one to be 100% accurate, I imagine Perl would win on a Slashdot poll (judging by the ratio of Perl mongers on there versus Python dudes). :) ~Mark Nenadov (author/editor for http:/www.coffeecode.com) From tim.one at home.com Mon Jul 2 13:37:55 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 2 Jul 2001 13:37:55 -0400 Subject: New PEP: Quality Guidelines For Standard Modules In-Reply-To: <15168.43721.839010.193223@beluga.mojam.com> Message-ID: [Courageous] > This is inarguably and obviously bad design. The author's choice of > an implicit singleton in this case was a great error and lacked > even small amounts of foresight. The error here, however, was not > the global variable. It was the implicit global singleton attached > to contextually-dependent state. [Skip Montanaro] > Let's not be too hasty here. Version 1.1 of fileinput.py is dated > 21-Nov-97, well before threading was widespread in Python (which is > where this stray global stuff tends to really bite you in the butt, > the original author's example notwithstanding). ... If you want a threadsafe fileinput reader, create an instance of the fileinput.FileInput class explicitly. The module global is a default instance, catering to approximately 99.999% of expected uses: "the main loop" exclusively chugs over sys.argv -- which is also a shared global. If you use that from multiple threads simultaneously, it's not fileinput that's nuts <0.9 wink>. functioning-as-designed-ly y'rs - tim From paulp at ActiveState.com Fri Jul 20 21:15:38 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Fri, 20 Jul 2001 18:15:38 -0700 Subject: Unusual minidom behaviour References: <2q367.11670$Up.346617@sea-read.news.verio.net> Message-ID: <3B58D7BA.2148B8E5@ActiveState.com> Minidom doesn't use any special threading. minidom is just Python code so you could add trace statements .... You mention java. Is this Jython or CPython? Is there a C extension involved? -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From vAbazarov at dAnai.com Mon Jul 30 13:05:05 2001 From: vAbazarov at dAnai.com (Victor Bazarov) Date: Mon, 30 Jul 2001 17:05:05 GMT Subject: Unusual minidom behaviour: Part Deux References: Message-ID: <5tg97.12412$Up.362964@sea-read.news.verio.net> "Martin von Loewis" wrote... > "Victor Bazarov" writes: > > > > In that case, I recommend to put a number of print statements into the > > > library modules that you suspect to be causes of the problem, and > > > trace that way what they are doing. If you can identify the call that > > > is hanging (i.e. the function you call that doesn't return), please > > > let us know. > > > > > > Didn't I already? __import__ is hanging. It doesn't let another > > thread to start and it doesn't return anything. > > Please try to trace further. I.e. does it start executing the first > line of expatreader? As soon as I have spare time. Victor -- Please remove capital A's from my address when replying by mail From cliechti at mails.ch Tue Jul 31 22:26:14 2001 From: cliechti at mails.ch (chris liechti) Date: 1 Aug 2001 04:26:14 +0200 Subject: how to know whether the item in a diretory is a file/directory References: Message-ID: "sdf" wrote in news:mailman.996630962.3179.python-list at python.org: > I want to process all the files in a diretory,and ignore the > subdirectorys in it > > ,I use os.listdir() to list all the items,but I do not know whether > the selected > item is a file > you have deleted the documentation? take your browser point it to the doc dir in you python installation directory and then look at the module "os" there you find Files and Directories", then please look what's available there and maybe you find "stat". when you are there you find a link to the module "stat". there is also an example in that module which does exactly what you want. sorry for the bad tone in the reply but you post many questions that are quite well answered in the python documentation. neverthles - enjoy programming python :-) -- chris From thomas at xs4all.net Wed Jul 18 09:09:10 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Wed, 18 Jul 2001 15:09:10 +0200 Subject: Python 2 times slower than Perl In-Reply-To: <87itgrmf9k.fsf@elbereth.ccraig.org> References: <8f41cfd.0107171238.6ff33b9b@posting.google.com> <87itgrmf9k.fsf@elbereth.ccraig.org> Message-ID: <20010718150910.B2054@xs4all.nl> On Tue, Jul 17, 2001 at 05:12:23PM -0400, Christopher A. Craig wrote: > > if you put the code in a function, it will be a fair bit faster > > since global variable access is slower than local variable access. > This is, in this case, incorrect. Unless I am horribly mistaken, the > higher cost of dealing with globals is that you first have to do a > failed lookup in the local dictionary. (Plus failed lookups are more > expensive than successful ones) Nope. The compiler knows, at compiletime, which variables are local, and compiles the accesses into separate 'LOAD_FAST' ('optimized' local namespace which is just an array indexed by compile-time constants), 'LOAD_GLOBAL' (global or builtin namespace lookup, basically one (or two) dictionary lookups) and 'LOAD_NAME' (code that tries locals, then globals) -- the latter is only used if the local namespace *might* introduce names by itself, because of an 'import *' or bare 'exec'. As a result, function namespaces (which we call 'local') are faster than global namespaces (which can be the 'local' namespace for a statement, but we don't really *call* a 'local' namespace, because we mean the optimized 'local' namespace in functions when we say 'local namespace'.) > In this particular case the local dictionary is the same as the global > one, so I don't see how moving to a function would offer a time savings. Yes, it is, but if you refactor, the local namespace won't be a dictionary any more, so it'll be faster :) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From michael.g.abbott at ntlworld.com Wed Jul 25 09:43:46 2001 From: michael.g.abbott at ntlworld.com (Michael Abbott) Date: Wed, 25 Jul 2001 13:43:46 GMT Subject: PEP0238 lament References: <3B5B3676.40F39389@alcyone.com> <9jg6ei$ges7$1@sky.inp.nsk.su> <23891c90.0107230118.752e3f00@posting.google.com> Message-ID: Paul Foley wrote in news:m2ofq9g4he.fsf at mycroft.actrix.gen.nz: > On Tue, 24 Jul 2001 16:37:49 GMT, Michael Abbott wrote: > >> Huh? >> (defun list-reverse (list) ...) > >> Looks like lots of parentheses to me. > > > so Python represents the integer 42 as "i*\000\000\000"? :-) > Hmm. I see to my embarrasment that I missed the parentheses in your sig. I don't think I quite get your point though, since I though that LISP programming was done using the language in your sig (which certainly does suffer from a surfiet of brackets). (I'd better confess right away that I've never written more than about a page of code in LISP, and that was just a baby exercise.) From gilesc at hyperlink-interactive.co.uk Tue Jul 3 06:06:53 2001 From: gilesc at hyperlink-interactive.co.uk (Giles Constant) Date: Tue, 3 Jul 2001 11:06:53 +0100 Subject: Singleton classes (with no such thing as static variables) In-Reply-To: <3B40B5F5.1F8F03D9@recombinant.demon.co.uk> References: <3B40B5F5.1F8F03D9@recombinant.demon.co.uk> Message-ID: just what I was looking for :-) thanks loads. (with respect to constant/variable data, I'm actually passing around a class which can provide database cursors from a single active connection, but I can do something with what you've pointed me at!) -- Giles Constant, Systems Programmer Hyperlink Interactive http://www.hyperlink-interactive.co.uk On Mon, 2 Jul 2001, Stephen D Evans wrote: > You mention 'data', but do not state whether it is variable or constant data. > > If you want to use a singleton to pass around constant data there is a useful > Python recipe (by Alex Martelli) on ActiveState's website, titled 'Constants in > Python'. > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65207 > > Stephen D Evans. > > > Giles Constant wrote: > > > Hi there, > > > > Being a C++ head, it's probably more a problem with my design than a python > > problem, but I figured you guys would be able to help. > > > > I'm trying to make a class called "Environment" which will store some > > global data such that all instances of the class have access to it. The > > alternative is to create a single instance and pass it around every single > > object in the entire project, but it gets used so frequently that it would > > be rediculous. > > > > Is there a way of doing this, or do I need a new paradigm? :-) > > > From philh at comuno.freeserve.co.uk Thu Jul 19 07:46:03 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Thu, 19 Jul 2001 12:46:03 +0100 Subject: basic python-unix question References: Message-ID: On 18 Jul 2001 22:38:54 GMT, Quinn Dunkan wrote: > >Yes. Automatic substitution does not take place at all. Strings will never >change their contents. Quite right too! if you want sustitution, use P*rl! >There are many functions that operate on strings, though. > >You can concatenate strincgs with (+): > 'ps ef | grep ' + eachProcess > >You can interpolate strings with (%): > 'ps ef | grep %s' % eachProcess > >Read the docs for more. > >As an aside, the above os.system is not a very good way to check for running >processes (you want a >/dev/null in there at least, not to mention that it >will break if you move it to a bsd). Because BSD doesn't like ``ps ef''? Or because there's a problem with os.system()? -- #===== Philip Hunt == philh at comuno.freeserve.co.uk ======# Herbivore: effort-free public key encryption. See: ** First software release coming soon! ** From quinn at yak.ugcs.caltech.edu Wed Jul 11 18:44:54 2001 From: quinn at yak.ugcs.caltech.edu (Quinn Dunkan) Date: 11 Jul 2001 22:44:54 GMT Subject: Tuple Semantics - Rationale'? References: <3B4CA0A8.20B53230@tundraware.com> Message-ID: On Wed, 11 Jul 2001 21:40:52 GMT, Nick Perkins wrote: > >"Quinn Dunkan" wrote in message >""" >Large complicated data structures of nested tuples might be a mistake. >Tuples >and python's simple pattern matching can be handy for small ad hoc types, >but >don't forget about classes. >""" > >Yes, >...but I have found one good use for such 'tuple gymnastics'. >( perhaps this is what you mean by 'pattern matching' ) No, what I mean by that is what python calls "tuple unpacking". For instance: t = ((green, (10, 20), 1), (blue, (20, 30), 0), (green, (40, 20), 1)) for (color, (x, y), active) in t: ... def display((color, (x, y), active)): ... map(display, t) might be quicker and clearer than throwing together some class for the same. Although some might disagree about that 'def' line (and I might be one of them ). >When you want to have a dictionary that uses some type of object as a key, >but you want 'identical' objects to considered 'the same', you can pack the >relevant bits of an instance's data into a tuple, and use it as the dict >key. In this case I'd write __hash__ and __cmp__ methods and stuff the objects directly into the dict. >example: >Suppose you want to keep track of the color any given x,y point... > >>>> class point: >... def __init__(self,x,y): >... self.x = x >... self.y = y >... def as_tuple(self): >... return (self.x,self.y) >... >>>> p1 = point(3,4) >>>> p2 = point(3,4) >>>> color = {} >>>> color[p1]='red' >>>> color[p2] >Traceback (most recent call last): > File "", line 1, in ? >KeyError: <__main__.point instance at 01373A6C> >>> class Point: ... def __init__(self, x, y): ... self.x = x ... self.y = y ... def __hash__(self): ... return hash((self.x, self.y)) ... def __cmp__(self, other): ... return cmp((self.x, self.y), (other.x, other.y)) ... >>> p1 = Point(3, 4) >>> p2 = Point(3, 4) >>> color = {} >>> color[p1] = 'red' >>> color[p2] 'red' >>> From pkalliok at cc.helsinki.fi Wed Jul 11 16:11:10 2001 From: pkalliok at cc.helsinki.fi (Panu A Kalliokoski) Date: 11 Jul 2001 20:11:10 GMT Subject: Integrating SimpleHTTPServer into asyncore References: <9ifsp7$k1a$1@oravannahka.helsinki.fi> <9ihsuo$255$1@coco.singnet.com.sg> Message-ID: <9iibsu$kj$2@oravannahka.helsinki.fi> Ng Pheng Siong wrote: > In your opinion, how much effort does it take to shoehorn, um, integrate > Medusa's HTTP/1.1 implementation into your framework? It depends. I haven't checked Medusa's code, but if it's done in a sensible way (i.e. protocol handlers are separate objects from socket/channel handlers), it should be at most a 15-minute job. Where could I get the Medusa source to try it out? Is Medusa built on asyncore/asynchat? I've changed two asyncore/asynchat based programs to Selecting-based ones in less than one hour. > Alternatively, what is the best way to get a HTTP/1.1 implementation > running on your framework? Well, HTTP is a quite line-oriented protocol, so TCPServer's default channel handler (buffered line-oriented protocol much like asynchat) is good for the task. Writing an HTTP implementation involves basically writing a protocol handler, which is an object with a method receive(self,data) to be called upon reception of a whole line. So the API is very simple. Writing a HTTP/1.1 protocol handler is not, but I presume Medusa has one already? Panu From guido at digicool.com Thu Jul 19 14:45:33 2001 From: guido at digicool.com (Guido van Rossum) Date: Thu, 19 Jul 2001 14:45:33 -0400 Subject: Language change and code breaks In-Reply-To: Your message of "Thu, 19 Jul 2001 12:23:47 MDT." References: Message-ID: <200107191845.f6JIjXL16993@odiug.digicool.com> > Hehe, so, if both case-insensitivity and multiple encodings were > adopted... > > the easy to distinguish between "a" and "A" would not be allowed, but > the hard to read versions of "a" with diacritical marks would be... > > ...ya, that makes sense. :-/ If that's your whole argument against case insensitivity, I don't find it very convincing. Certainly this issue has been solved before? --Guido van Rossum (home page: http://www.python.org/~guido/) From emile at fenx.com Tue Jul 3 15:14:18 2001 From: emile at fenx.com (Emile van Sebille) Date: Tue, 3 Jul 2001 12:14:18 -0700 Subject: using python to append a file References: <13e6b4a6.0107031113.441998c@posting.google.com> Message-ID: <9ht5pi$fovev$1@ID-11957.news.dfncis.de> >>> print open.__doc__ open(filename[, mode[, buffering]]) -> file object Open a file. The mode can be 'r', 'w' or 'a' for reading (default), writing or appending. The file will be created if it doesn't exist when opened for writing or appending; it will be truncated when opened for writing. Add a 'b' to the mode for binary files. Add a '+' to the mode to allow simultaneous reading and writing. If the buffering argument is given, 0 means unbuffered, 1 means line buffered, and larger numbers specify the buffer size. HTH -- Emile van Sebille emile at fenx.com --------- "Thanh Le" wrote in message news:13e6b4a6.0107031113.441998c at posting.google.com... > I am new to Python and was wondering if anyone could show me a way to > append a file (similar to the way Unix does by using >> ). I've tried > using open('file','r+') method and it overwrote whatever i had in that > file. I am sure there is a way to append a file, but havent had much > luck. > Thanks in advance, > Thanh From hamish_lawson at yahoo.co.uk Tue Jul 3 12:45:55 2001 From: hamish_lawson at yahoo.co.uk (Hamish Lawson) Date: 3 Jul 2001 09:45:55 -0700 Subject: Python and DB support (was: Re: Is Python Dead?) References: Message-ID: <915a998f.0107030845.5c1a77f4@posting.google.com> Alex Martelli: Python can work perfectly well WITHIN ASP/IIS Roman Suzi: ADO could help for those who consider Python for tasks usually done with PHP or ASP. I suspect there may be cross-purposes here, due to differences in how the term 'ASP' is being used. Strictly ASP is a technology for dynamic web pages, but without any reference to any particular programming language. VBScript just happens to be the most widely used language for working with ASP, but other languages can be used - JScript, PerlScript, Python, etc. Thus to compare Python with ASP is, strictly speaking, as meaningless as comparing Python with CGI (when you actually meant Perl). Hamish Lawson From guido at python.org Mon Jul 9 09:57:46 2001 From: guido at python.org (Guido van Rossum) Date: Mon, 09 Jul 2001 13:57:46 GMT Subject: dummy/trash object References: Message-ID: Xavier Defrang writes: > Hello, > > I'm sure that someone already came with a question like : "why is there no > real dummy or trash object in Python which could by used like the magic > '_' in Prolog?" > > Using a "normal" variable like in the following snippet involves useless > assignations... > > > >>> t = 1, 2, 3, 4 > >>> x, _, z, _ = t > >>> _ > 4 > > > Since I'm quite sure that the language designers have already thought > about this, the question is not whether such a magic object should be > added to the Python language but why it has not been done? I'm sure there > are good reasons... The nearly-magic None value could have been used for > this purpose... Some could say that it would break the "no exception" rule > but we've already seen in previous threads (about assigning a value to > None) that the core of the interpreter has some special instructions to > handle None thus turning it into an actual exceptional thing... Assignments are about the fastest operations in Python, as there is no data copying involved -- only a pointer copy. So you don't have to worry about the "cost" of the assignment. Adding a special case would probably slow things down. If you're worried about keeping the unused object alive longer than necessary (which you normally shouldn't worry about unless it's many megabytes is size), assign something else to the same name -- this will delete the object previously held in that name, *if* it was the last and only reference. Or you can use the 'del' statement. --Guido van Rossum (home page: http://www.python.org/~guido/) From aleaxit at yahoo.com Sat Jul 14 02:50:30 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 14 Jul 2001 08:50:30 +0200 Subject: More on "with" statement References: <3B4FD2AC.BF2F9AD6@alcyone.com> Message-ID: <9iortv0pc9@enews4.newsguy.com> "Erik Max Francis" wrote in message news:3B4FD2AC.BF2F9AD6 at alcyone.com... > Roman Suzi wrote: > > > Programmers must be lazy to some degree. So, they tend to write > > > > a*(b+c+d+e) > > > > instead of > > > > a*b+a*c+a*d+a*e > > That's just plain more efficient. Four additions and one multiply > instead of three additions and four multiplies. I think it's _three_ addition and one multiply in the former case. Alex From Greg.Lindstrom at acxiom.com Fri Jul 13 12:56:08 2001 From: Greg.Lindstrom at acxiom.com (Lindstrom Greg - glinds) Date: Fri, 13 Jul 2001 11:56:08 -0500 Subject: greenbeen seeks advice Message-ID: Welcome to the club! I am curious as to how you decided on Python? IM(NS)HO, it is one of the best languages for just about all applications ('cept MUDs :-). My daughter (age 10) has worked through the "How to Think Like a Computer Scientist" (Python edition), and to my amazement, wrote a program to find all of the words in a word-search puzzle she was doing (OK, it needed *some* more work, but I found it to be a great effort). Come in on, and ask lots of questions! Greg Lindstrom Acxiom Corporation, mail: CWY10011149 InfoBase Products Development office: (501) 342-1626 301 Industrial Blvd, Conway, AR, 72032 fax: (501) 336-3911 email: Greg.Lindstrom at acxiom.com "When the solution is simple, God has spoken" Albert Einstein -----Original Message----- From: wyatt stafford [mailto:wyatts at onr.com] Sent: Friday, July 13, 2001 11:33 AM To: python-list at python.org Subject: greenbeen seeks advice Preamble: I am a computer/network support person who has decided to start programming for a vocation (no previous experience beyond minor scripting, etc). After some research I selected Python as a good place to start. I bought "Learn to Program using Python" (Gauld) and "Quick Python" (Harms/McDonald). Also checking out the tutorial, and other good info at www.python.org. I have a leaping, intuitive learning style given to missing the obvious, so I am concerned about having fatal gaps in my learning via home schooling plan. Questions: Beyond those mentioned above, may I have any recommendations for self study resources (books, etc) or techniques that will help me be a good programmer, in general? Do I need to know what is taught in CompSci 101/102/etc, to be great? thanks and happy weekend to all, wyatt "Oh, that's not what I call bingeing" From Fiona.Brewster at wanadoo.fr Tue Jul 17 08:11:28 2001 From: Fiona.Brewster at wanadoo.fr (Fiona Brewster) Date: Tue, 17 Jul 2001 14:11:28 +0200 Subject: shelve error Message-ID: Could someone explain what this means: Traceback (most recent call last): File "index.py", line 83, in ? tokenCount = process(fileIndex[item], item, tokenCount) File "index.py", line 61, in process post[token] = fileIdMap File "c:\program files\python21\lib\shelve.py", line 77, in __setitem__ self.dict[key] = f.getvalue() bsddb.error: (0, 'Error') I have got this error after processing 1900 files and 3.8m words. The program is part of a simplistic IR system which does the indexing to create a postings database (kept in a shelve file). As it took about an hour of indexing to reach the error I am loath to step through 3.8m words to see what the error is! I enclose the program below. Thank you for any light you may shed. Christopher Brewster ---------------------------------------------------------------------------- ---- import shelve, string # variables post = shelve.open("postings", 'n') #post = {} tokenCount = 0 ##################### # Functions #################### # This function reads a file, creates a list containing all tokens and ... def process(fileName, fileId, tokenCount): f = open(fileName) fileText = f.read() tokens = string.split(fileText) # cycle over the words in the text i = 0 for i in range(len(tokens)): if (tokenCount%100000 == 0): print tokenCount token = tokens[i] tokenCount = tokenCount +1 # print "Current token is ", token wordOffset = i # print "Word offset is: ", wordOffset # check if the word exists as a key in 'post' if (post.has_key(token)): # print "Token found in post" currentFileMap = post[token] # print "CurrentFilemap = ", currentFileMap # check if the file id exists as a key in post[token] aka currentFileMap if (currentFileMap.has_key(fileId)): # print "File id-map found: ", post[token][fileId] tempMap = post[token] # print "tempMap = ", tempMap tempMap[fileId].append(wordOffset) # print "tempMap[fileId] after appending: ", tempMap[fileId] del post[token] post[token] = tempMap # print "post[token] now is: ", post[token] # print "New token offset appended: ", post[token][fileId] else: # print "File id not found" post[token][fileId] = [wordOffset] # print "post[token][fileId]= ", post[token][fileId] else: # print "Word not found in post" # create offset list offsetList = [wordOffset] # create fileId --> list map fileIdMap = {fileId:offsetList} # add token --> fileIdMap item to post post[token] = fileIdMap # print "New entries created", post[token][fileId] # raw_input() return tokenCount ###################### # Main Program ###################### fileCount = 0 fileIndex = anydbm.open('filedb', 'r') for item in fileIndex.keys(): # if (fileCount > 100): break if (fileCount%100 == 0): print "file count = ", fileCount # print "Now working on file: ", fileIndex[item] tokenCount = process(fileIndex[item], item, tokenCount) fileCount = fileCount + 1 From peter at engcorp.com Tue Jul 24 21:18:49 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 24 Jul 2001 21:18:49 -0400 Subject: PEP0238 lament References: <3B5B37B9.4D7A80CD@Lugoj.Com> Message-ID: <3B5E1E79.A5C8CEF6@engcorp.com> Michael Abbott wrote: > > [...] From the professional > programming perspective, I imagine that there are two types of programming > task that are relevant to this discussion: > > 1. Scientific programs, [...] > 2. System control programs [...] > 3. Graphical programming can, [...] You've forgotten the *one* type of programming which appeared (at least to me) to be the inspiration for this in the first place: 4. Newbie programs ...as in, tiny, ultimately useless learning exercises which are almost by definition never going to expand into anything that matters in the long run. This is *exactly* where mistakes or confusion like this is supposed to occur for newbies to learn the nature of computing. Trying to prevent them from being confused is much like taking down all the playground equipment to prevent children from hurting themselves: they'll grow up incapable of anything requiring more agility than walking!! Given that the only people seriously likely to be confused by the whole issue of integer/integer division are these newbies and very infrequent/casual users of Python, breaking code *and* annoying a massive part of the existing user base would seem to be an excessive payment for the small gain of having a few more newbie programs work the first time they're run.. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From stupot999 at hotmail.com Mon Jul 30 07:36:33 2001 From: stupot999 at hotmail.com (Soup-a-Stu) Date: Mon, 30 Jul 2001 12:36:33 +0100 Subject: Compiling Message-ID: I am very new to Python and i need a bit of help with compiling my stuff. i'm using windows ME, and the latest version of Python. thanks in advance From steve at lurking.demon.co.uk Sun Jul 22 07:55:31 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Sun, 22 Jul 2001 12:55:31 +0100 Subject: Future division patch available (PEP 238) References: Message-ID: <2kdllt08g3mveg9ojpls6jfe2pfr3j1227@4ax.com> On 22 Jul 2001 07:14:25 GMT, Marcin 'Qrczak' Kowalczyk wrote: >Sun, 22 Jul 2001 00:36:38 -0400, Guido van Rossum pisze: > >> I thought again about the merits of the '//' operator vs. 'div' >> (either as a function or as a keyword binary operator), and figured >> that '//' is the best choice: it doesn't introduce a new keyword >> (which would cause more pain), and it works as an augmented assignment >> (//=) as well. > >Why div= wouldn't work? (Lexed as two tokens.) Because div doesn't exist as a keyword, and therefore has probably been used by many people as an identifier name. div= is therefore something that many people probably have to start a simple assignment. An assignment such as... div="Premier" might exist in many football fans programs, for instance. Guido - here's a thought... How about using some symbol that the Python doesn't use at present, and using it as a 'this is a keyword' prefix. '$' seems a good candidate for the prefix. Once the scanner spots the prefix, it should continue scanning using the rules for identifiers but specifically identify the result as a keyword. That way, any new keyword could be created at will without breaking old code - the prefix might be a little annoying, but most important keywords must already exist by now so the irritation would be kept to a minimum. Any use of a name prefixed by $ (or whatever) which is not recognised should generate an error - unknown keyword or something - to prevent anyone trying to use it in an identifier. Using the prefix in front of existing keywords should be valid but unnecessary - $while should be a synonym of while, for instance - so anyone who is unsure whether a particular keyword needs a prefix can just bung one in to play it safe. If you do add a capability like that, I'd propose $mod and $rem as new operators - modulo and remainder. $rem would do the same as %, but $mod would always give a positive result according to the rules of modulo arithmetic. These wouldn't be worth adding at the expense of breaking existing code, but if that wasn't an issue they should be more readable than '%'. I know that incomprehensible prefixes seem a bit Perl-ish, but I think this would be a good idea anyway - allowing considerable freedom to update Python without the risk of breaking existing code. From cer at tutopia.com Sat Jul 21 01:12:08 2001 From: cer at tutopia.com (Cristian Echeverria) Date: Sat, 21 Jul 2001 01:12:08 -0400 Subject: 3rd beta of Win32 Installer release 4 References: Message-ID: <9jb2gl$milpe$1@ID-44371.news.dfncis.de> Hi Gordon I tested release 4 with Python 2.1, Win98 and with a simple program: print "Hello" and I got the following errors W: exec statment detected at line 295 of imputil W: No module named dos W: No module named mac W: No module named os2 W: No module named posix I don?t know what is happening, all the previous version worked for my, but version 4 has not worked at all, I always get a similar error. Cristian Echeverria "Gordon McMillan" escribi? en el mensaje news:mailman.995662610.14766.python-list at python.org... > The thrid beta of version 4 of the Win32 Installer package is > here: > > http://www.mcmillan-inc.com/installer_dnld.html From piet at cs.uu.nl Fri Jul 13 16:00:48 2001 From: piet at cs.uu.nl (Piet van Oostrum) Date: 13 Jul 2001 22:00:48 +0200 Subject: license suggestions? References: <3B4D0045.EBCDA083@cosc.canterbury.ac.nz> Message-ID: >>>>> Greg Ewing (GE) writes: GE> Roman Suzi wrote: >> >> Microsoft world accuses GPL of being "viral". GE> Well, the GPL *is* viral. The irksome thing about that GE> Microsoft license is that it defines "viral" in a way GE> that includes ALL open-source licenses, even though GE> most of them are not in the least bit viral by the GE> commonly understood meaning of the term in this GE> context. GE> So it's not the GPL they're slandering, it's all GE> the other open-source licenses. They also accuse it to be more viral than it is in reality. They seem to suggest that e.g. code compiled with gcc also has to be GPL'ed. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From dsh8290 at rit.edu Tue Jul 3 18:19:33 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 3 Jul 2001 18:19:33 -0400 Subject: Eiffel better than Python ? In-Reply-To: ; from ddublanc@free.fr on Tue, Jul 03, 2001 at 09:32:06PM +0000 References: <9hsf0c0210e@enews1.newsguy.com> Message-ID: <20010703181933.B26134@harmony.cs.rit.edu> On Tue, Jul 03, 2001 at 09:32:06PM +0000, Dublanc, David wrote: | What is exactly weak typing ? Weak typing is what the shell or perl do : anything can be used anywhere and it only has the type "variable" (or whatever you want to call it). Something like the following : #!/usr/bin/perl print 2 + "1" ; print 2 + "1a" ; print "1" + "2" ; print "1a" + "2" ; print "1" + 2 ; print "1a" + 2 ; What you get is an interesting auto-coercion between strings and integers because there is no difference, as far as perl is concerned. Some of those, in Python, would be type errors : >>> print 2 + "1" Traceback (most recent call last): File "", line 1, in ? TypeError: unsupported operand types for + >>> The closest thing that might work in Python would be >>> print 2 + int( "1" ) 3 >>> but it doesn't always work (as it does in Perl) : >>> print 2 + int( "1a" ) Traceback (most recent call last): File "", line 1, in ? ValueError: invalid literal for int(): 1a >>> Another indication that perl has weak typing is the following behavior : $ perl print $undefined_variable_name + 10 ; 10 $ In perl if a variable doesn't exist, and it is used in numerical context it is treated as 0, or as the empty string if used in string context. In Python that would raise a NameError exception. | I believed that Python was weak typing ! As you can see above, Python actually checks the types to ensure that they are sane for the given operation. It checks them _dynamically_ (at run time) as opposed to statically (at compile time). There are 4 forms of type checking : weak strong dynamic static Some people mistakenly consider dynamic == weak and static == strong, but they are 2 different axis. HTH, -D From johnroth at ameritech.net Mon Jul 2 12:00:03 2001 From: johnroth at ameritech.net (John Roth) Date: Mon, 2 Jul 2001 09:00:03 -0700 Subject: python as plugin language References: <993529827.54981@newsmaster-04.atnet.at> <9hhkpq010gl@enews2.newsguy.com> Message-ID: "Alex Martelli" wrote in message news:9hhkpq010gl at 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...? The fact that my C:\Python21 directory doesn't contain any directory named "Demo"? Where do I get it? It wasn't in my "typical" Win32 installation. John Roth > > > Alex > > > From tundra at tundraware.com Sat Jul 14 02:50:02 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 14 Jul 2001 06:50:02 GMT Subject: ANN: HB - Learn Python A Little Faster Message-ID: <3B4FE9A6.DBBF3919@tundraware.com> Learning a new language always comes to me in two parts: Learn the pieces - Syntax, Semantics, mechanics - i.e., Read tutorials. Put it all together - Learn the idioms, see a complete application, understand the rationale for design decisions and so on. I have completed an application written completely in Python. Although the application itself is very unremarkable (a budget management system), it is certainly not a trivial or toy program. It's just big enough to be interesting. I wanted to make it available to others learning Python along with the requisite documentation to see how all the parts fit together. So, I went back and documented the thing and commented it heavily. You'll find it at: http://www.tundraware.com/Software/HB/HB.tar.gz IMPORTANT NOTE: This is not intended to "teach" you Python or programming or anything else. The idea is that you already know how to program and have a basic understanding of how Python does things. The point here is to "Put It All Together" and show an application of all the pieces as an integrated whole. Program Features ================ This is a pretty straighforward Budget Management system. Nothing too esoteric here, really: Unlimited Different Budgets Up to the limit of your disk space. Unlimited Accounts Well, the limit is what you can squeeze on a single screen. Unlimited UnDo Limited by memory - if you run out of UnDo stack, you're using HB for WAY too complicated budgets ;) Prints Reports To Printer (Win32 Only) Or Disk File (All OS) Handles Monthly "Burn Rate" For Each Account Pay, Debit, Credit, And Transfer Funds Balance The Budget Read And Write Budget Files Code Features ============= This is probably what you really care about: Uses Every Major Python Data Structure Tuples, Tuples Of Tuples, Tuples Of Tuples Of Tuples, Lists, Dictionaries, and Objects Has Mixture Of OO And Procedural Code Python is *really* good at this. Uses A Regular Expression For Input Validation Uses 'eval' To Demonstrate Runtime String Execution (Some) Exception Handling Disk, Keyboard, And Device I/O Code Is Completely "UnStrung" There are no literals (other than newlines) embedded in the code which makes maintenance and internationalization very simple. Completely Table-Driven Command Interpreter Kinda cool, actually. A little complicated at first, but it makes adding new features a snap AND prepares the way for mating the program to a GUI if you must have one in your life. Stack-Based Context Management And UnDo Facilities LOADED With Explanatory Comments So You Understand What's Going On Caveats And Acknowledgements ============================ I am an experienced programmer, but not an experienced *Python* programmer. This means that not everything in HB is necessarily good Python - I hope it is, it probably mostly is, but it probably also has some warts. If you *are* an experienced "Pythonista" and you see something in HB that makes you just wince, send me an email and let me know what needs fixin'. I also want to take a moment and thank the many friendly people of comp.lang.python who answer my many stupid questions promptly and correctly both on the newsgroup and privately. Also, a big "Thank You" to http://www.diveintopython.org for one of the best language tutorials I've ever seen. It is a work-in-progress, but a "must" if you are learning Python. Finally, a huge thanks to GVR and the many people who designed, implemented, and refine one of the slickest programming languages around... -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From fdrake at acm.org Fri Jul 20 17:02:42 2001 From: fdrake at acm.org (Fred L. Drake) Date: Fri, 20 Jul 2001 17:02:42 -0400 (EDT) Subject: [development doc updates] Message-ID: <20010720210242.487322892E@cj42289-a.reston1.va.home.com> The development version of the documentation has been updated: http://python.sourceforge.net/devel-docs/ Some additional information for extension writers. From eppstein at ics.uci.edu Thu Jul 26 11:43:45 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Thu, 26 Jul 2001 08:43:45 -0700 Subject: Toppling the numeric tower References: Message-ID: In article , "Tim Hochberg" wrote: > > 1. isnatural() > > 2. isintegral() > > 3. isrational() > > 4. isreal() > > 5. iscomplex() > > > > a. isexact() > > This is too many. I would strip this down to > > A. iscomplex() > B. isexact() > C. isintegral() I have to say that this would be more convenient for situations such as defining your own extension of number types for, say, exact arithmetic in Q[sqrt(3)]. Or even better Q[sqrt(-3)]. I was wishing I was able to do this recently for a different project unrelated to Python, unfortunately the program I was using didn't make it easy to plug in your own number types... But a couple points of clarification: (1) is it safe to assume that isintegral() implies isexact()? (2) should isintegral() return true for algebraic integers that are not rational integers? -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From bsass at freenet.edmonton.ab.ca Tue Jul 31 18:38:38 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Tue, 31 Jul 2001 16:38:38 -0600 (MDT) Subject: Changing the Division Operator -- PEP 238, rev 1.12 In-Reply-To: <001101c119af$67dd1d80$a9e1fea9@carol> Message-ID: On Tue, 31 Jul 2001, Arthur Siegel wrote: > Bill[sic] writes - > > >In this context, it comes from the CP4E motivation that people may be > >called upon to script operations or interactions between their > >`toys'... calling them "non-programmers" is shorter than saying, > >`people who may need to program without knowing they are doing it' > >(imo). > > But we are going around in circles - as I have been for some few > years on the subject. I guess I had always hoped that CP4E was > really going to focus on turning non-programmers into programmers. > It made sense to me that it would, because it happens that > IMO Python is a great tool for doing so. <...> > To me CP4E is, can and should be a true initiative, > not a semantic game. I think you are missing something... If you were designing a control system for the `toys', and needed to expose a user level programming interface; would you be more likely to choose languages C+S or language P (which can do both jobs) [C+S == P, of course]. Unless CP4E is done as a "semantic game" with a larger language, language P will never exist. - Bruce From Gareth.McCaughan at pobox.com Mon Jul 23 16:36:21 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Mon, 23 Jul 2001 21:36:21 +0100 Subject: proposed language change to int/int==float (was: PEP0238 lament) References: Message-ID: Grant Edwards wrote: > What I don't understand is why polymorphism is all of a sudden > an evil, nasty thing in the Python world -- something that must > be banished at all costs (even if we have to change one of the > basic mathematical operators and break existing programs). > > Are the rulers of the Python Kingdom going to ban all > polymorphism? I thought it was one of the _strengths_ of > Python, and here we are trying to stamp it out! The different behaviour of "/" on floats and ints isn't polymorphism, it's overloading. Two different operations. Closely related, of course, but different. Generally "polymorphism" is reserved for when what's being done is "the same thing" in both cases. Python doesn't generally object much to overloading either, of course (def __div__(self, x): ...); and I find the proposed change scary (what I wish is that Python had made 1/2 give a rational from day 1, but it's too late for that to happen unless Guido gets the time machine out again). So I'm just quibbling. -- Gareth McCaughan Gareth.McCaughan at pobox.com .sig under construc From steve at lurking.demon.co.uk Mon Jul 23 17:34:07 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Mon, 23 Jul 2001 22:34:07 +0100 Subject: A use for integer quotients References: <3B5BC73B.2D52E5E2@alcyone.com> <3B5BA29B.E08FEEE9@alcyone.com> <3B5C5665.8D41D1F1@tundraware.com> <3B5C749A.59F97320@tundraware.com> Message-ID: <415pltcn73cga0lmvtmgdn3vb02f7d28kr@4ax.com> On Mon, 23 Jul 2001 12:47:04 -0700, David Eppstein wrote: >In article <3B5C749A.59F97320 at tundraware.com>, > Tim Daneliuk wrote: > >> Not formally, AFAIK. For example, 3 with no decimal point following >> could be anything from 2.5 to 3.4. > >No no no. '3.' i.e. a floating point number with that value could be >anything in that range. '3' means exactly the integer 3, no approximation >at all. A mathematician is free to use '3' to represent a real - the fact that it is real is implicit in the context. Compilers and interpeters aren't able to determine that, so integers and floats have different notations even when the represent equivalent values. We can't exactly match mathematics here, but we don't have to go so far as having different symbols for integer and float division - mathematics uses the same set of symbols for both operations allowing the context choose the operator. Why should we behave differently to what non-programmers such as mathematicians expect? From thomas at gatsoft.no Wed Jul 25 09:26:37 2001 From: thomas at gatsoft.no (Thomas Weholt) Date: Wed, 25 Jul 2001 13:26:37 GMT Subject: User authentication in SOAP Message-ID: Hi, Just looked at SOAPpy from ActZero and it looks just like the thing I need for a small project. I just wondered what would be the best method of implementing username/password-protected services in a SOAP-server? Does SOAP define any rules for this at all or does it place that responsibility on the server? Any hints appreciated. Thomas From mal at lemburg.com Mon Jul 9 17:36:26 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Mon, 09 Jul 2001 23:36:26 +0200 Subject: Fixed mx.DateTime or alternative? References: <5.0.2.1.0.20010703093458.02498dc0@mail.mindspring.com> <5.0.2.1.0.20010709085854.02491aa0@mail.mindspring.com> Message-ID: <3B4A23DA.9D737F43@lemburg.com> Chuck Esterbrook wrote: > > At 01:15 PM 7/9/2001 +0200, M.-A. Lemburg wrote: > >Side note: > > > > if x is None: ... > > > >is a possible workaround which is faster than using "==" ! > > I switched to that, but then there is this left over: > > if a==b: > > where a and b are literally variables and could both be DateTimes, but one > of them ends up being None and the exception occurs. Someone suggested I > could use: > > if str(a)==str(b): > > although before I got that suggestion, I just wrapped it with a try: and > assumed inequality. In this case you could use: if a and b and (a == b): ... (DateTime instances are always true, None is false) -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From aahz at panix.com Fri Jul 20 19:33:54 2001 From: aahz at panix.com (Aahz Maruch) Date: 20 Jul 2001 16:33:54 -0700 Subject: Which Python version to code for? References: Message-ID: <9jaf52$ff0$1@panix2.panix.com> [posted & e-mailed] In article , Charles Crain wrote: > >I am part of the team working on SCons, the build tool for the Software >Carpentry project. We have an interesting quandry before us: what is >the earliest version of Python we should support? On the one hand, we >would like to use the latest and greatest and be able to take advantage >of the several powerful features added in recent Python releases. On >the other hand, we would like to avoid putting any barriers to adoption >of our product that might arise from requiring users (particularly >those in large organizations with high-intertia IT departments) to >upgrade Python versions in order to use it. Okay, I've done a bit of poking around on the Software Carpentry web site to see if I can give you a good answer. IMO, the answer depends on whether this is intended to be a deployment tool for end users (i.e. would someone installing a package on Linux need to use this?). If the answer is "yes", you need to go back to 1.5.2. If the answer is "no", use whatever version of Python best fits your desire for features versus stability, probably either 2.0.1 or 2.1.1. Essentially, I'm arguing that it's "reasonable" to require a developer to install a current version of a software package, but it's not reasonable to so require an end user. -- --- 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 Fortune cookie: Watch your relations with other people carefully, be reserved. From thecalm at NOSPAM.btinternet.com Mon Jul 30 19:39:03 2001 From: thecalm at NOSPAM.btinternet.com (G. Willoughby) Date: Tue, 31 Jul 2001 00:39:03 +0100 Subject: win32api exception names? Message-ID: <9k4r84$n85$1@uranium.btinternet.com> Hi, See this: [snip] def executeFile(event): if resultPane.size() > 0: try: win32api.ShellExecute(0, "open" , str(resultPane.get(ACTIVE)),"","",1) except EnvironmentError: win32api.MessageBox(0,"File can not be opened, right double click to open\nthe file's directory.", appName, 0, 0) [snip] I'm using this function to open a file listed in a Tkinter Listbox widget, but i've run into some problems. First when i double click on .htm files listed they work perfectly, opening in Explorer, But when i double click on .txt files i get this error: Exception in Tkinter callback Traceback (most recent call last): File "c:\program files\python\lib\lib-tk\Tkinter.py", line 1285, in __call__ return apply(self.func, args) File "D:\Backup\Python Programs\PyFind\PyFind.py", line 61, in executeFile win32api.ShellExecute(0, "open" , str(resultPane.get(ACTIVE)),"","",1) api_error: (31, 'ShellExecute', 'A device attached to the system is not functioning.') i'm trying to handle this exception, but being new to them i dunno what exception is being raised, the 'except EnvironmentError:' line really isn't getting it. any ideas? G.Willoughby From skip at pobox.com Wed Jul 11 11:23:30 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 11 Jul 2001 10:23:30 -0500 Subject: Bug in __imul__ In-Reply-To: <9ihg33$irjha$1@ID-11957.news.dfncis.de> References: <9ihg33$irjha$1@ID-11957.news.dfncis.de> Message-ID: <15180.28530.628508.190958@beluga.mojam.com> Emile> Does it bother anyone that Emile> a *= 3 + 4 Emile> returns a different value from Emile> a = a * 3 + 4 Emile> ?? No more than it bothers me that C behaves the same way. When run, the following program main() { int a; a = 7; printf("before: %d\n", a); a *= 3+4; printf("after (no parens): %d\n", a); a = 7; printf("before: %d\n", a); a *= (3+4); printf("after (w/ parens): %d\n", a); a = 7; printf("before: %d\n", a); a = a * 3 + 4; printf("after (unaugmented): %d\n", a); } produces the following output before: 7 after (no parens): 49 before: 7 after (w/ parens): 49 before: 7 after (unaugmented): 25 In short, the effect of the shortcut assignment operators is to evaluate the expression on the right-hand side and apply it to the variable on the left-hand side. It is *not* a macro facility that just performs some sort of textual substitution. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From peter at engcorp.com Fri Jul 13 21:27:04 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 13 Jul 2001 21:27:04 -0400 Subject: Long Live Python! References: Message-ID: <3B4F9FE8.8B970B9C@engcorp.com> James_Althoff at i2.com wrote: > ... if someone says "good for short > programs <100 lines" -- mentioning a specific number ("100" in this case) > -- wouldn't common sense dictate that the intention was also to indicate > something like "Python is something *different than good* for programs > >=100 lines (or let's say *significantly* greater than 100 lines -- to be > reasonable and fair)? I can't really argue with that. I understand how you interpreted the comment, but I didn't see it the same way, and apparently it wasn't intended that way either. No big deal. > Otherwise, I would think it much simpler and less ambiguous just to say > "Python is good for programs small, medium, and large -- which is, in > fact, my view! :-) And mine, and (apparently) Phil's too! We're close to deafening each other with our agreement on this issue! (Okay, actually I would disagree with the word "good". Clearly Python is "excellent" for medium programs and "stellar" for large programs. Case closed. ;-) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From max at alcyone.com Tue Jul 24 19:24:06 2001 From: max at alcyone.com (Erik Max Francis) Date: Tue, 24 Jul 2001 16:24:06 -0700 Subject: re bad leadership References: <0+yM4IAgmKX7EwIQ@jessikat.fsnet.co.uk> <20010724171838.A21770@xs4all.nl> <4crrlt0jbn9ovvkli3qvhqbc5do3lmpg4j@4ax.com> Message-ID: <3B5E0396.E1210C13@alcyone.com> Ben Wolfson wrote: > So why not swap the proposed meanings of // and /? I realize this is > the > third time I've said this but I think it would silence a lot of > objections > and no one seems to have noticed the other two times. I suspect the reason that this otherwise reasonable proposal sort of defeats the purpose of PEP 238. The idea is to make Python more intuitive to a novice by having the obvious division operator not do integer division, so if you swap / and // in PEP 238, it means that a novice programmer has to use // to get the behavior that's supposedly easier to understand, which sort of misses the goal. I suspect this wouldn't be considered a reasonable counterproposal for that reason (even though it sounds fine to me, but then I don't subscribe to the conclusions of PEP 238 in the first place). -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Who, my friend, can scale Heaven? \__/ _The Epic of Gilgamesh_ Physics reference / http://www.alcyone.com/max/reference/physics/ A physics reference. From cfelling at iae.nl Sun Jul 1 15:39:05 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 1 Jul 2001 21:39:05 +0200 Subject: Is this a true statement: Part II References: <9hiifr$sjs$1@taliesin.netcom.net.uk> Message-ID: <9hnu8p$9fu$1@animus.fel.iae.nl> Kragen Sitaker wrote: ... > I'm not sure how. Nobody has yet come up with an operating system that > could only be directly programmed in C, or Lisp, or Algol, or Java, > despite implementing operating systems in all four. I think some of ucsd-pascal came close, and certainly Wirths's wonderfull machine Lilith programmed solely in Modula-2 did it (there was no other language on the machine:) and surely you're not going to argue about emacs here. And then there was this M8600 based M6809 development machine I once had the joy to play with for which all device drivers had to be programmed in Pascal. So here you have 4 examples, need more? -- groetjes, carel From sheila at spamcop.net Sat Jul 21 14:47:38 2001 From: sheila at spamcop.net (Sheila King) Date: Sat, 21 Jul 2001 18:47:38 GMT Subject: Case insensitivity References: Message-ID: <1djjlt0ho504505v0ljfllb74o76acffjp@4ax.com> On Sat, 21 Jul 2001 14:29:13 GMT, Guido van Rossum wrote in comp.lang.python in article : :Sheila King writes: : :> In an attempt to address the "why" of this problem, I have posted the :> following article to two mailing lists to which I belong, for AP :> Computer Science teachers: : :Thanks, Sheila! Finally someone who *does* something about this :rather than repeating old arguments... :-) Looking forward to the :responses you get. So far, there have been about 8 responses. I think I need to allow a week or two, especially since it is summer--many teachers on vacation and not checking e-mail regularly--before it is worth sharing the results. Especially, the one mailing list is moderated, and sometimes it takes several days for the moderator to approve and post articles. Heck, there's no rush here, right? Maybe I should just wait until mid- to late-August. (The mailing lists have about 450 and 1900 members respectively. Don't know what sort of return I will get.) -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From JamesL at Lugoj.Com Tue Jul 17 20:34:42 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Tue, 17 Jul 2001 17:34:42 -0700 Subject: Python 2 times slower than Perl References: <8f41cfd.0107171238.6ff33b9b@posting.google.com> Message-ID: <3B54D9A2.45C23B14@Lugoj.Com> Ewald van Houte wrote: [ Parts elided for brevity. ] > xucs007 at yahoo.com (Xu, C.S.) wrote > > #!/usr/bin/env python > > i = 2.5; > > while i < 1e7: > > j = 2.5 * 2.5 > > i += 1 > > print i, j > > > > The `time` results on my PII 450M is: > > python script: 37.93u 0.03s 0:38.03 99.8% > > perl script: 15.36u 0.03s 0:15.42 99.8% > > java compiled: 1.07u 0.10s 0:01.20 97.5% > > C compiled: 0.24u 0.01s 0:00.25 100.0% > > Tried the same with for loop and while loop > > def f1(): > i=2.5 > while i<1e7: > j=2.5*2.5 > i+=1 > print i,j > > def f3(): > i=2.5 > for i in xrange(2.5,1e7+1): > j=2.5*2.5 > print i,j > > Results > f1() 34.5 seconds > f3() 18.8 seconds > > some improvement but f3() will still be slower than Perl version (~30%) You forgot to normalize your result with his by using the results of f1(): >>> 15.36/(18.8*(34.5/37.93)) 0.898249768733 Only about 10% slower. From donmalla at yahoo.co.in Thu Jul 19 02:16:54 2001 From: donmalla at yahoo.co.in (donmalla at yahoo.co.in) Date: Thu, 19 Jul 2001 06:16:54 -0000 Subject: python newbie question Message-ID: <9j5u0m+jpri@eGroups.com> Hi All, I am a newbie to python. I am following the "Diving into Python tutorial". However I am having a problem with the for loop Here is the problem: >>> vec = [2,4,6] >>> [3*x for x in vec] SyntaxError: invalid syntax In a list called vec I assign values.when I ask it to print the list , it does print. >>> for x in vec: >>> print x The o/p is 2 4 6 However when I try to manipulate the list , using for loop like this : [3*x for x in vec] I get a syntax error "invalid syntax" Please help me. I am using Python 1.5 on Windows 2000. Cheers !!!! -Ratnakar ------------------------------------------------------------ Ratnakar Malla, ECE Dept, Louisiana State University, Baton Rouge, LA, 70802 From tom-list at home.com Sun Jul 29 23:55:31 2001 From: tom-list at home.com (Tom) Date: Sun, 29 Jul 2001 23:55:31 -0400 Subject: mistake in Python 2.1.1 debug download Message-ID: <3b64daaa$1_5@Usenet.com> I just downloaded the following: Python-2.1.1-Debug.zip It includes Python22 files. I assume this is a mistake. Also, where do the .pdb files go? Aren't .pdb files compiler specific? Is this debug download platform/compiler specific? A readme file would be helpful. Tom. Posted Via Usenet.com Premium Usenet Newsgroup Services ---------------------------------------------------------- ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY ** ---------------------------------------------------------- http://www.usenet.com From claird at starbase.neosoft.com Tue Jul 31 14:54:48 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 31 Jul 2001 13:54:48 -0500 Subject: Python code to express a large integer in words? References: <3B66EDD0.62196C8D@mjs400.co.uk> Message-ID: In article <3B66EDD0.62196C8D at mjs400.co.uk>, ptah wrote: >For interest I have included code below from the as400network Club Tech >iSeries Programming Tips - 06.21.01 it is written in IBM RPG IV and is a RPG--fascinating. >kind of DLL (we call them service programs) that does the above, I would >like to see how much more succinct a Python equivalent could be, purely >because I would like to jump ship and code in something more expressive >and need to put the case for Python to people who are not in the habit >of thinking in an abstract way ;) . . . does the same for Tcl, and several European languages (if you ask nicely, Richard's likely to do it for Tagalog or Tibetan, too). For Python, see . -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From rnd at onego.ru Tue Jul 10 06:29:15 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 10 Jul 2001 14:29:15 +0400 (MSD) Subject: os.nice (or docs) BUG? In-Reply-To: <20010710114119.W8098@xs4all.nl> Message-ID: On Tue, 10 Jul 2001, Thomas Wouters wrote: > On Tue, Jul 10, 2001 at 01:25:28PM +0400, Roman Suzi wrote: > > On Tue, 10 Jul 2001, Thomas Wouters wrote: > > > > > Which category to report it in the Bug tracker? > > > > 'Python Library' is the best fit, I guess, but it doesn't really matter. > > > The group should be 'platform specific', though :) Feel free to assign it > > > to me, I think I'll check in a fix soon anyway :) > > > I did. With hope the fix is not "remove" ;-) > > I guess you don't read python-dev ;) I'm the Backward Compatibility > HogMonster, I do not only not remove, I refuse to let others remove :) Then hope has is not dead. > > It could also be nice to have os.getpriority() And setpriority too. > Yes, I guess it would. Care to submit a patch ? :-) Not before I undestand Python's C API... Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From guido at python.org Thu Jul 26 17:27:41 2001 From: guido at python.org (Guido van Rossum) Date: Thu, 26 Jul 2001 21:27:41 GMT Subject: Unusual minidom behaviour: Part Deux References: Message-ID: "Victor Bazarov" writes: > "Guido van Rossum" wrote... > > [..] > > Victor, we don't have enough information. Are you using Jython, or > > are you somehow invoking C-Python from Java? Can you reproduce the > > problem in a self-contained example program? > > > I am not using Jython. I am running a regular one (if it's called > C-Python, I didn't know) from Java using Runtime.exec("python > something.py"). Its version is 2.0 (at least that's what it > reports when run with -V). > > I cannot always reproduce the problem in my _current_ system (it > only happens in some runs), much less in a whole another program. > > In order to write a test program I have to know what to try to > reproduce. Should it itself be multi-threaded? How complex should > it be? If I don't get the same result, does it mean the problem is > in my Java program or is it just a coincidence? (as I wrote before, > it does not happen if I run Java program under the debugger instead > of simply executing it) You see, it would probably take me as long > to create a "self-contained" example as it did to create the system > in its current state. > > One of my colleagues suggested wrapping the call to minidom.parse > in a critical section (locking something before, unlocking after), > another hint came from you: let the main program sleep after fork. > At this point I frankly care only about one thing: to prevent it > from happening. Debugging this would be tough even if I were sitting next to you. Doing it remote is impossible. Good luck! --Guido van Rossum (home page: http://www.python.org/~guido/) From jorjun at mac.com Sat Jul 21 07:55:02 2001 From: jorjun at mac.com (jorjun) Date: Sat, 21 Jul 2001 12:55:02 +0100 Subject: Language change and code breaks References: <9j9i19$p96$1@panix2.panix.com> Message-ID: <3B596D95.C87DFFCD@mac.com> Aahz Maruch wrote: > i'M aFraId i doN't UnDerStaNd wHy YoU THinK caSE-InsENsitIvitY miGhT bE > A gOoD idEA. > -- Currently if I import a module and the identifiers lOoK_lIkE_ThIs then I have to precisely follow the ugly conventions in my own code. From skip at pobox.com Fri Jul 6 14:04:59 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 6 Jul 2001 13:04:59 -0500 Subject: Marking a Python COM server safe for Internet Explorer In-Reply-To: <3B45A5AD.12631.573C6B@localhost> References: <994426394.405.95578.l7@yahoogroups.com> <3B45A5AD.12631.573C6B@localhost> Message-ID: <15173.64971.638094.552178@beluga.mojam.com> Bill> As a kind of default, Internet Explorer will ask the user's Bill> permission before instantiating an ActiveX control. However, one Bill> can implement IObjectSafety to inform IE that one's control is Bill> safe, thus sparing the user the need to respond to the dialog box. I have nothing useful to help you with your quest, but it seems that if the ActiveX control can say "trust me!", it's sort of like asking the fox to guard the hen house. Did I misunderstand something? Wouldn't all ActiveX controls simply implement IObjectSafety simply to make them easier to use (less annoying to the user)? -- Skip Montanaro (skip at pobox.com) (847)971-7098 From jim at publishingresources.com Tue Jul 3 11:58:24 2001 From: jim at publishingresources.com (Jim) Date: Tue, 03 Jul 2001 15:58:24 -0000 Subject: MS "bans" GPL [OFF Topic] References: <7iq1ktcmslo24kbr8qvob2g3hpgleuf025@4ax.com> <9hshbp$oqv$2@216.39.170.247> Message-ID: >XP: the coming evil - you thought it was bad now? Just wait. >Dave LeBlanc Off topic but really good read on the evils of XP. http://grc.com/dos/winxp.htm From jwbaxter at spamcop.com Wed Jul 25 00:40:54 2001 From: jwbaxter at spamcop.com (John W. Baxter) Date: Tue, 24 Jul 2001 21:40:54 -0700 Subject: PEP0238 lament References: Message-ID: <240720012140547935%jwbaxter@spamcop.com> In article , Tim Peters wrote: > FYI, PEP 42 (the "small feature request" PEP) contains > > - New math module radians() and degrees() functions. > > Somebody quick add grads before Python becomes obsolete . Actually, grads probably should be in there. I can live without points...the intersection of people to whom points are important and and people to whom Python is important is fairly small (although I can think of several members just around Puget Sound). NxE 1/4 N + S 1/4 W --> what? Answer: Over there somewhere...facing North and pointing with the left arm. --John From gustafl at algonet.se Wed Jul 4 08:59:00 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 4 Jul 2001 12:59:00 GMT Subject: AttributeError: 'getopt' module has no attribute 'GetoptError' References: Message-ID: Erno Kuusela wrote: >> I use Python 2.1 on Win98. Try to use the getopt module, but get >> the error in the subject line. What's wrong? >your test program isn't called "getopt.py" by any chance? Oh. Yes, it is... Thank you. Gustaf From steve at lurking.demon.co.uk Mon Jul 23 03:20:08 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Mon, 23 Jul 2001 08:20:08 +0100 Subject: Future division patch available (PEP 238) References: Message-ID: On 23 Jul 2001 06:28:48 GMT, Marcin 'Qrczak' Kowalczyk wrote: >Integers are exact!!! That's the point: if numbers represent inexact >quantities, they should be expressed as floats. Since working with >integers and rationals is predictable and +-*/div,mod give correct >(with int/int->rational), they should be used when we want to know the >true answer. If it's not possible anyway, use floats and don't waste >computation time for the 100th decimal place which is wrong anyway. If I say my local shop is 1 mile away, is that exact? I don't thinks so ;-) Rounding to an integer is much more common even than rounding to decimal places. The problem comes when people confuse this with dealin with an integer measure. Distance is a real measure which is most conveniently and accurately approximated using floats - so use floats and be done with it. If you are working with naturally integer measures then yes, integers are exact - and integer division is the only division that makes sense. If you are working with measures that are inherently real, than using an integer to represent the value is no more exact than if you used a float - less so, in fact, as the float has much more precision. In such cases float division makes sense, but you should have been using floats anyway because it was naturally a real arithmetic problem. From sheila at spamcop.net Thu Jul 12 22:32:21 2001 From: sheila at spamcop.net (Sheila King) Date: Fri, 13 Jul 2001 02:32:21 GMT Subject: Maintaining the Python FAQ References: Message-ID: On Fri, 13 Jul 2001 02:27:56 GMT, grante at visi.com (Grant Edwards) wrote in comp.lang.python in article : :On Fri, 13 Jul 2001 00:23:07 GMT, Joe Block wrote: :> :>> Huh? The FAQ wizard gives you plenty of ways to access individual :>> items or sections. Why would you ever download the whole FAQ? :> :>To print it, so it can be read while I'm away from the net? : :Away from the net? : :Huh? Why would you ever be away from the net? ;) Well, for instance, my DSL connection went down for three days (just this past week). But, I have saved a number of Python tutorial documents for Tkinter to my local machine (thank goodness!). So I was at least able to program! Or, if you teach a programming course for about 20 high school students in a non-networked lab with 28 standalone machines...maybe it would be nice to have local documents on the machines??? -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From chris.gonnerman at newcenturycomputers.net Wed Jul 11 08:53:14 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Wed, 11 Jul 2001 07:53:14 -0500 Subject: Bug in __imul__ References: <9ihg33$irjha$1@ID-11957.news.dfncis.de> Message-ID: <007901c10a08$7432ffc0$0101010a@local> ----- Original Message ----- From: "Emile van Sebille" > Does it bother anyone that > > a *= 3 + 4 > > returns a different value from > > a = a * 3 + 4 > > ?? The behavior of *= is consistent between Python and C (where it was borrowed from). Remember to imagine that there are parenthesis around the RHS of the *= operator. In other words: a *= 3 + 4 != a = a * 3 + 4 a *= 3 + 4 == a = a * (3 + 4) From nperkins7 at home.com Thu Jul 26 03:51:45 2001 From: nperkins7 at home.com (Nick Perkins) Date: Thu, 26 Jul 2001 07:51:45 GMT Subject: 2.2 features References: Message-ID: Here's a nice little use of type/class unification: instead of using: if type(x) is type(0): we can use: if type(x) is int: or, for type checking.. assert type(num) is int assert type(msg) is str ( I assume the use of 'is', rather than '==', is acceptable here ) ..much prettier. From guido at python.org Tue Jul 24 16:20:14 2001 From: guido at python.org (Guido van Rossum) Date: Tue, 24 Jul 2001 20:20:14 GMT Subject: PEP0238 lament References: <6unolt4kg5pjav1k0c7qjv8mg4qe0fdbaj@4ax.com> Message-ID: Steve Horne writes: > The mathematical operation of division is traditionally represented as > ? in general - or as a horizontal line between the numerator and > denominator. Only rationals merit the / in mathematics - it's simply > the best compromise. > > But mathematics uses the same set of symbols equally for both integer > and real division - it's rarely made explicit which is in use as it is > normally blatantly obvious. So I don't believe (1) is valid. I believe you are wrong here on both counts. Knuth, a mathematician if there ever was one, uses / for division when written in-line and a horizontal line in "display" formulas. He also uses an explicit floor notation to indicate integer division, and without that his divisions are real divisions. (Knuth's floor notation acts like a pair of brackets around an expression; the left bracket looks like an L, the right bracket looks like a reverse L. He has a similar ceiling notation where the L's are upside down.) --Guido van Rossum (home page: http://www.python.org/~guido/) From phrxy at csv.warwick.ac.uk Wed Jul 18 15:08:15 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Wed, 18 Jul 2001 20:08:15 +0100 Subject: Python 2 times slower than Perl In-Reply-To: References: <3B55724D.465E8A44@engcorp.com> Message-ID: On 18 Jul 2001, Johann Hibschman wrote: [...] > cc -O2 0.28 > cc 0.62 > ocamlopt 1.26 (compiled) > ocaml 9.42 (interpreted) > perl 28.9 > python 66.8 > > Hm. I'm beginning to wonder if I compiled python with -O2 or not. > Plus, I'm becoming more and more fond of ocaml. > > The python function I used was the basic > > def test (): > i = 2.5 > j = 2.5 > while i < 1e7: > j = 2.5 * 2.5 > i = i + 1.0 > print "%f %f\n" % (i, j) > > if __name__ == '__main__': > test () When do you ever write Python code that does this kind of thing?? For example, if you're doing lots of fp work, don't you use Numeric? Must try OCaml, though (and Haskell)... John From michele_rosen at yahoo.com Thu Jul 26 18:48:03 2001 From: michele_rosen at yahoo.com (Michele Rosen) Date: Thu, 26 Jul 2001 15:48:03 -0700 (PDT) Subject: Newbie Q: Missing Frame In-Reply-To: <996171966.397.88548.l7@yahoogroups.com> Message-ID: <20010726224803.85924.qmail@web13407.mail.yahoo.com> I'm not sure why this is happening, but one way to avoid this would be to use grid instead of pack and specify the row and column where you want the frames and label to appear... M Message: 17 Date: Thu, 26 Jul 2001 17:49:49 GMT From: engsol at teleport.com Subject: Newbie Q: Missing Frame When I run the following code, I see a large window, with two frames, the blue on top, and the yellow on the bottom. When I attempt to add a label to frame 2 , (by removing the #'s), I still see the blue frame, but the yellow frame is missing, and just the label is showing in it's place. Running on NT4, Python versions 1.5+ and 2.0 Any help appreciated. Engsol PS..is there a way to break out of "mainloop" via a button command, and run the code subsequent to the GUI code? ***** Start sample code ****** from Tkinter import * win = Tk() def test(): frame_1 = Frame(win, width = 500, height = 100, bg = 'blue') frame_1.pack() frame_2 = Frame(win, width = 500, height = 100, bg = 'yellow') frame_2.pack() # label_1 = Label(frame_2, text = "Will this work?", bg = 'red') #label_1.pack() win.mainloop() test() **** End sample code **** ===== Give the joy of giving. Find out how at www.charity-checks.org. __________________________________________________ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/ From peter at engcorp.com Wed Jul 18 07:22:02 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 18 Jul 2001 07:22:02 -0400 Subject: windows port access References: <3b520bcb@news.cybertours.com> <3B522E98.BAAA9E93@engcorp.com> <3B5390BC.C5FFCD2A@engcorp.com> <3b5480f5@news.cybertours.com> Message-ID: <3B55715A.DA6C72CD@engcorp.com> Chris Gonnerman wrote: > > Motor control is not *real* timing sensitive (compared with the speed > of the computer IMHO) so the winioport module should work for you. > > Note the prerequisite software when downloading and installing. > > Peter Hansen's module (whatever it is) might also be a good choice if > he publishes it. Ummm... I don't *have* any module.... (I think you mixed me up with another.) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From MarkH at ActiveState.com Fri Jul 6 21:34:11 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Sat, 07 Jul 2001 01:34:11 GMT Subject: Marking a Python COM server safe for Internet Explorer References: Message-ID: <3B46673D.8030309@ActiveState.com> Bill Bell wrote: > Does someone happen to know if there is an incantation that can > be muttered in Python that implements IObjectSafety--or of some > alternative way of doing this? Neil's solution sounds the best. However the win32com.axscript.axscript module supports IObjectSafety. Once you import this module any Python COM object can implement this interface like any other. It is in the axscript module simply due to the fact the AXScript engine must support it (and does). Mark. From phd at phd.fep.ru Wed Jul 11 12:10:21 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Wed, 11 Jul 2001 20:10:21 +0400 (MSD) Subject: Bug in rfc822 In-Reply-To: <15180.30607.11847.673371@anthem.wooz.org> Message-ID: On Wed, 11 Jul 2001, Barry A. Warsaw wrote: > I added a default argument to the _Mailbox class in Python 2.2's > mailbox.py module: > > class _Mailbox: > def __init__(self, fp, factory=rfc822.Message): Sorry, I saw it in Python 2.1, not 2.2. Just tested a minute ago. :) 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 Jul 22 00:44:44 2001 From: sheila at spamcop.net (Sheila King) Date: Sun, 22 Jul 2001 04:44:44 GMT Subject: subclassing Exceptions References: <9ihklt8u0vvh1aa0mg6tadbmjo9mot47e0@4ax.com> Message-ID: On Sat, 21 Jul 2001 20:49:01 -0700, "Brian Quinlan" wrote in comp.lang.python in article : :> I tried looking under the /Python20 directory for source or something :> for the Exception classes, but can't find it. For example, right now :> I'm working on subclassing the rfc822.py module, and I found the file :> rfc822.py in /Python20/Lib and studied the source until I understood :> it, and could subclass it. I'd like to find something similar for the :> standard exception classes. I looked in the /include directory and :> some others but can't find what I'm needing. : :Check out http://www.python.org/doc/current/lib/module-exceptions.html : Thanks, Brian, but I've seen the docs many times. I need more info than that. Like example code, or source code. However, someone else gave me some pointers. If I want to see the actual source for the exceptions.c class, I can browse at sourceforge.net here: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/dist/src/ I found the exceptions.c file here: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/dist/src/Python/exceptions.c However, I may not need that much detail and background. Maybe a few examples of subclassing exceptions in Python would do. So, one might want to look at these: See the source for this module: http://python.org/doc/current/lib/module-xml.sax.html (although, later thought to possibly be a bit complicated) or How about viewing the source for the ConfigParser.py module. Anyhow, I've looked a bit over the exceptions.c file, which is interesting. Now I'm off to study the source for the (above) suggested Python modules, as examples of subclassing exceptions. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From guido at digicool.com Sun Jul 22 13:20:15 2001 From: guido at digicool.com (Guido van Rossum) Date: Sun, 22 Jul 2001 13:20:15 -0400 Subject: PEP0238 lament In-Reply-To: Your message of "Sun, 22 Jul 2001 12:11:09 CDT." <15195.2349.947801.54567@beluga.mojam.com> References: <15195.2349.947801.54567@beluga.mojam.com> Message-ID: <200107221720.NAA11923@cj20424-a.reston1.va.home.com> > I just reread the PEP at > > http://python.sourceforge.net/peps/pep-0238.html > > It looks like it hasn't been updated since March. I see no support for the > argument that the current integer division semantics are confusing, only a > claim that the current semantics are a problem. Perhaps there's a more > recent version of the PEP available that hasn't been released to the > website. Skip, I've asked Moshe today to update the rationale based on the discussion in c.l.py. He said he would. So just be patient. --Guido van Rossum (home page: http://www.python.org/~guido/) From tombraider104 at hotmail.com Thu Jul 26 16:55:18 2001 From: tombraider104 at hotmail.com (Richard Gelling) Date: Thu, 26 Jul 2001 21:55:18 +0100 Subject: (no subject) Message-ID: -------------- next part -------------- An HTML attachment was scrubbed... URL: From rumjuggler at cryptarchy.org Mon Jul 23 13:11:10 2001 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Mon, 23 Jul 2001 17:11:10 GMT Subject: PEP0238 lament References: <3B5B639C.FF5961E7@Lugoj.Com> Message-ID: On Mon, 23 Jul 2001 12:21:58 +0100, Steve Horne wrote: >Integers are much more used in scripting code than floats - subscripts >and loop indices being the main culprits. Integer division happens >quite a bit. All that code is just going to suddenly stop working. How >nice. If integer division is more common than float division, why not let '/' retain its current meaning and use '//' for "yes, I want a float result"? int / int -> int float / int, int / float, float / float -> whatever these currently mean with "//" in Guido's patch int // int -> float, rational, or whatever -- Barnabas T. Rumjuggler No man can run so fast that he can escape his own past's projectile vomit. From bokr at accessone.com Fri Jul 20 14:07:58 2001 From: bokr at accessone.com (Bengt Richter) Date: Fri, 20 Jul 2001 18:07:58 GMT Subject: Language change and code breaks (fwd) References: Message-ID: <3b5873ba.2423857703@wa.news.verio.net> On Thu, 19 Jul 2001 16:18:15 -0400, Lulu of the Lotus-Eaters wrote: [...] >Likewise, in Python you rarely see syntactical but silly choices like: > > >>> xlsoALwl390sslkslWW = 37 > >>> xlsoALwL390sslkslWW = 38 > >>> print xlsoALwL390sslkslWW,xlsoALwl390sslkslWW > 38 37 > That does bring up the subject of machine-generated symbols though. And case sensitivity in dictionaries. I use base52 [A-Za-z] encoded md5's in certain contexts. If I use those as keys, will it break? From dsavitsk at e-coli.net Sun Jul 29 12:47:39 2001 From: dsavitsk at e-coli.net (douglas savitsky) Date: Sun, 29 Jul 2001 16:47:39 GMT Subject: 2.0 or 2.1 on win32 References: <9jti6t$e2g$1@panix2.panix.com> Message-ID: "Aahz Maruch" wrote in message news:9jti6t$e2g$1 at panix2.panix.com... > In article , > douglas savitsky wrote: > > > >i am installing a new server and i need to know if there is reason to > >install either 2.0 or 2.1 or any other version. The server is win2k (2 > >1GHZ, 512, raid, etc.). the clients are also win2k. > > > >the applications that run on the clients connect the the server via DCOM. > >the python running on the server connects to other objects sometimes with > >COM and sometimes not. the clients use 2.0 as there seems to be some > >weirdness in 2.1/tkinter on windows, but there won't be any tkinter on the > >server. so, should i stick with 2.0 on the server as well? are there > >stability issues or compatability issues to be aware of with other versions? > > I'd say for starters that the question should be "2.0.1 or 2.1.1?" > > Overall, my personal preference is to deal with cross-version issues as > little as possible, so if your clients are using 2.0.1, the server > should, too. (And, yes, I do definitely recommend upgrading the clients > if possible.) > -- > --- 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 > > Fortune cookie: Watch your relations with other people carefully, be reserved. thanks for the response. people have always been ambiguous in the past as to whether installing activepython or python + win32 extensions was the better choice. as far as i can tell active python is based upon 2.1 and not 2.1.1. should this be the deciding factor? doug From rnd at onego.ru Tue Jul 17 10:18:39 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 17 Jul 2001 18:18:39 +0400 (MSD) Subject: python vs kung fu In-Reply-To: Message-ID: On Tue, 17 Jul 2001, Kemp Randy-W18971 wrote: > Kung Fu! Karate! Jujitsu. Aikido. > Python. Perl. Java. PHP. > Now I wouldn't want to get into a fight with anyone who is a black belt from > the major four martial arts. But given a preference, I would choose Aikido, > since it redirects the attackers force. > But some people like debates that lead nowhere, and language debates are a > key example. Now smart software developers actually appeal to all the major > camps. Let's look at the open source database sapdb at www.sapdb.org. They > actually have developed interfaces for Java, Perl, and Python. Rather then > saying one language is better, they opened the spectrum to what they feel > are the major players. And activestate at www.activestate.com has developed > tools and language versions for Perl, Python, and TCL. However, I usually see: "Java", "C++" (or more rare: "Perl") in job announces... > Language debates remind me of the old joke about life in Communist Russia. > A supervisor saw a worker digging a hole, and another filling it up. After > this happened with a dozen holes, he went over and asked what was going on. > They replied that the one worker who plants the trees is sick, but they > still wanted to be productive for the day. :-) There is another similar one: A worker runs to and from with empty tray. When asked why it is empty? He answers: I have accelerated(*) my work but the one who must load it have not accelerated yet;-) (*) Acceleration (uskorenije) was another Soviet slogan. Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From me at mikerobin.com Mon Jul 30 12:43:59 2001 From: me at mikerobin.com (Michael Robin) Date: 30 Jul 2001 09:43:59 -0700 Subject: 2.2 features References: Message-ID: <52e5ab5f.0107300843.4f82a2@posting.google.com> Marcin seems to have covered much more detail then I could have, but I thought it intersting to mention one more (simple) thing. Python has not only a single-reciever method dispatch syntax, but also keywords and built-in operators, and it uses these it's advantage to escape a restrictive dispactch. (Python x.plus(y) (with no __overrides__ :)) or Smalltalk x+y or x plus: y has little choice but to depend only on x.) The Python bulit-ins operate in a sometimes arbitrary manner, but they try and do the most "useful thing" and rules are few and can be learned. Take "/" (and PEP238) as an example of how a built-in is special. (Also, [3]*2 == [3,3] but not [[3],[3]], or [6], or an error.) (One could argue that a more generic dispatch (mutli-methods or whatever) could be used to bring the behavior to the user level - but we have other languages for that.) So I think "obj in Class/Type" is useful shortcut as long as it doesn't break something essential. OTOH, (why is there always an OH?) this does suffer from the "it just sounds good" syndrome which could lead to improper uses of "in", like "is" is abused today in place of "==". (I can also see "x is " getting used (and again meaning the wrong thing), as it "sounds good". (Maybe in this case we'd be better off with just "id(x)==id(y)".) "x isa " is really what we want if we want a keyword. m ------------- Marcin 'Qrczak' Kowalczyk wrote in message news:... > 28 Jul 2001 18:33:33 GMT, Quinn Dunkan pisze: > > > This implies (at least to me) that 'in' would be a general shorthand > > for 'isinstance'. But then I would sort of expect '3 in [1,2,3,4]' > > to behave like 'isinstance(3, [1,2,3,4])' > > If you forget about 'isinstance' then everything is ok, right? > 'in' performs some membership test whose details depend on the second > argument. It should not be more confusing that '+' being either addition > of numbers and concatenation of sequences. We don't expect "a"-(-"b") > to be equivalent to "a"+"b" just because 3-(-4) is equivalent to 3+4. > > Now thow in 'isinstance' as an old way to spell a specific membership > test (for types and classes) which doesn't have to be learned about > at all. > > > Or you could just say that type objects implement a __contains__ > > method that does an isinstance. But if classes and types are unified, > > that would get in the way of classes that define __contains__. > > It indeed shows a flaw in unifying "attributes of instances which > are defined by their classes" with "attributes of class objects > themselves". > > For example many objects are hashed by what o.__hash__() returns, > but not type objects, because their __hash__ is something completely > different (it expects an argument and hashes it instead of the > receiver). Similarly for most magic methods. > > It more or less works because intersection of proper attributes of > type objects and attributes which are always polymorphically extracted > using names (and not slots in the representation of type objects) > happens to be empty. > > This is so hardwired into Python and pushed by type/class unification > that I don't believe it can be avoided without redesigning the language > from scratch. > > This particular case of __contains__ is not different than e.g. > __hash__ or __str__. You can't redefine in Python how your class object > (or type object in Python-2.2) will be hashed or printed, you won't > be able to override the membership test either (and you can't now > AFAIK) - unless something solves the generic problem of putting class > attributes and static instance attributes in one namespace. From meowbot at meowing.net Wed Jul 4 04:54:21 2001 From: meowbot at meowing.net (Methodical Meowbot) Date: 04 Jul 2001 04:54:21 -0400 Subject: Python for air traffic control? References: Message-ID: <87lmm5dqjq.fsf@litterbox.meowing.net> 18k11tm001 at sneakemail.com (Russ) wrote: > I am thinking about using Python for a unique safety-critical > application in air traffic control. Software like that would seem to be begging for a language with some formal validation behind it, like Ada. With Python, you would have to reinvent and implement that part of the process yourself, and that doesn't seem like very much fun at all. From michael at stroeder.com Thu Jul 19 09:12:43 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Thu, 19 Jul 2001 15:12:43 +0200 Subject: dnslib license? Message-ID: <3B56DCCB.6EF0DEED@stroeder.com> Hi Guido, sorry to bother you directly. You might have noticed that Anthony Baxter and me are pushing his module DNS derived from your dnslib to SourceForge. So far so good but I don't have any clue about licensing issues. Can you shed some light on it? See below your original README shipped as file README.guido in Anthony's tar.gz. Ciao, Michael. --------------------------------------------------------------------- This directory contains a module (dnslib) that implements a DNS (Domain Name Server) client, plus additional modules that define some symbolic constants used by DNS (dnstype, dnsclass, dnsopcode). Type "python dnslib.py -/" for a usage message. You can also import dnslib and write your own, more sophisticated client code; use the test program as an example (there is currently no documentation :-). --Guido van Rossum, CWI, Amsterdam URL: From chris.gonnerman at newcenturycomputers.net Mon Jul 23 19:35:35 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Mon, 23 Jul 2001 18:35:35 -0500 Subject: PEP0238 lament AND Re: Case (In)sensitivity References: <00867F2E.N22121@rsmi.com> <3B5CAED2.80B9CF3C@ActiveState.com> Message-ID: <011e01c113d0$34d0a9a0$0101010a@local> Both of these changes fall in the same group IMHO... they break a lot of code. Prove to me (to us, the naysayers) why we really need them. Don't tell me that newbies need this to learn the language, as we know they don't. We were all newbies once; which of us had a problem with either int division or case sensitivity. Guido, Moshe, dudes, I have a lot of respect for you, but it has always been because of the high level of reliability in Python. This hurts. From gradha at iname.com Sat Jul 21 13:47:42 2001 From: gradha at iname.com (gradha at iname.com) Date: Sat, 21 Jul 2001 19:47:42 +0200 Subject: The windows python.exe interpreter hangs processing large files. Message-ID: Hi. I have tried to use some Linux scripts I have under Windows, and the python.exe ran in a dos Box under Win98 just hangs when it has to process slightly big text files (over 20 KB). Could it be just because I use the DOTALL option in regular expressions? Under Linux everything goes blazing fast, and since everything hangs I don't know what to do or how to debug it, especially because Windows is not my native work environment and don't master any tools there. What can I do to fix this strange behaviour? I am using a Python 2.0 windows release, if that matters. -- Grzegorz Adam Hankiewicz gradha at terra.es http://gradha.infierno.org From bos at hack.org Fri Jul 20 07:46:23 2001 From: bos at hack.org (Rikard Bosnjakovic) Date: Fri, 20 Jul 2001 13:46:23 +0200 Subject: Problem with Modules/posixmodule.o References: <3B578472.5EA8CAD5@steenerson.com> Message-ID: <3B581A0F.2D180107@hack.org> Blair Steenerson wrote: > ./Modules/posixmodule.c:4053: sys/statvfs.h: No such file or directory > ./Modules/posixmodule.c:4102: sys/statvfs.h: No such file or directory > make: *** [Modules/posixmodule.o] Error 1 sys/statvfs.h belongs to the glibc-distribution. You might want to check that it's installed properly. -- 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 thomas at xs4all.net Tue Jul 24 18:24:31 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Wed, 25 Jul 2001 00:24:31 +0200 Subject: Language change and code breaks In-Reply-To: <4197FA5DD22AD5118ADE00805F6FA62F3B67BD@eden.vmlabs.com> References: <4197FA5DD22AD5118ADE00805F6FA62F3B67BD@eden.vmlabs.com> Message-ID: <20010725002431.C21770@xs4all.nl> On Tue, Jul 24, 2001 at 02:32:05PM -0700, John Schmitt wrote: > Hopefully a tool that would provide [case-insensitive-but-preserving > editing of Python code] isn't tied to something I would like to use. Oh come one, any *decent* editor would have it optional :) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From rnd at onego.ru Tue Jul 31 16:35:45 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 1 Aug 2001 00:35:45 +0400 (MSD) Subject: Generator Comprehensions? was Re: a break for comprehensions In-Reply-To: <3B670BB3.48D4A5A5@ActiveState.com> Message-ID: On Tue, 31 Jul 2001, Paul Prescod wrote: >Michael Chermside wrote: >> >> ... >> >> How about this: >> >> def f(): >> for x in g(): >> yield x * 2 >> >> Of course it gives a generator, not a list... but that >> seems to be a reasonable form to represent an infinite sequence. > >How about if we combine your ideas: > >y = [yield x*2 for x in g()] O, yes! Generators need lambda form too! Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Tuesday, July 31, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "All things are green unless they are not." _/ From Randy.L.Kemp at motorola.com Tue Jul 3 16:12:08 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Tue, 3 Jul 2001 16:12:08 -0400 Subject: What's wrong with this program Message-ID: Thanks. I'll try it, unless someone has a better idea. -----Original Message----- From: Oleg Broytmann [mailto:phd at phd.fep.ru] Sent: Tuesday, July 03, 2001 3:05 PM To: Kemp Randy-W18971 Cc: 'python-list at python.org' Subject: RE: What's wrong with this program On Tue, 3 Jul 2001, Kemp Randy-W18971 wrote: > Thanks for the correction. Actually I think you don't need ftp.connect() at all - it is called in ftp.__init__... > Anyone know the correct format to transfer files > from one server directory to another server directory? I don't know - I've never used ftplib, but the idea is obvious: put it one by one. Something like this: for filename in somelist: ftp.storbinary("STOR " + filename, open(filename, 'rb')) Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From JamesL at Lugoj.Com Fri Jul 27 13:18:45 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Fri, 27 Jul 2001 10:18:45 -0700 Subject: Eliminating upgrade risk References: Message-ID: <3B61A275.82581457@Lugoj.Com> Tim Peters wrote: > > [James C. Ahlstrom] > > ... > > The problem is that the new Python features, as wonderful as they are, > > are chosen for Computer Science Purity, not day-to-working-day > > importance to someone actually trying to write a widely used bullet > > proof program. > > As my physicists friend like to say, "that's not even wrong". Write a PEP. Are you seriously suggesting he write a PEP to inhibit the other PEPs? Or are you demanding something else? > while-compsci-purists-denounce-python-for-its-pragmatism-ly y'rs - tim I've checked the Google archives, and I've come to the conclusion that you are of the position that anyone who doesn't constantly upgrade should not be supported, in the sense that if they report bugs, write books about Python, or ask for porting assistance, their questions will all be answered with "Upgrade first, then we'll talk". Is that basically correct? From bernhard at intevation.de Wed Jul 25 10:23:30 2001 From: bernhard at intevation.de (Bernhard Reiter) Date: 25 Jul 2001 14:23:30 GMT Subject: Nice graphs from class hierarchies? References: Message-ID: <9jmkp2$2d1b$3@ID-89274.news.dfncis.de> In article , Roman Suzi writes: > I want to have nice graphs from Python class hierarchies. The daVinci > package can do it > I need this solution under Linux and Open Source Note that daVince is not Free Software. 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 kseehof at neuralintegrator.com Tue Jul 31 06:40:07 2001 From: kseehof at neuralintegrator.com (Ken Seehof) Date: Tue, 31 Jul 2001 03:40:07 -0700 Subject: FEEDBACK WANTED: Type/class unification References: <3B65FF05.7F262FEB@engcorp.com> <3b667634.884329538@wa.news.verio.net> Message-ID: <009801c119ad$2ad93880$6501a8c0@pacbell.net> Bengt Richter wrote: > On Mon, 30 Jul 2001 20:42:45 -0400, Peter Hansen wrote: > > >William Tanksley wrote: > >> > >> On Mon, 30 Jul 2001 13:12:00 -0700, Sam Penrose wrote: > >> >Guido van Rossum wrote: > >> > >> >> I think 'self' would be confusing. I'd like to propose 'cls'. > >> > >> >How about an English word or phrase in lieu of YATATL (yet another > >> >terse acronym to learn)? > >> > >> Yes, please. Does anyone have any prior art on this topic? 'self' is > >> nice because it was in common use before. > >[...] > >> OTOH, perhaps we don't want a synonym for 'class'; perhaps we just want a > >> plural version of 'self'. 'selves'? 'us'? 'our'? > > > >Without necessarily understanding the question or its implications, > >reading the first posting my subconscious came up with "us", too. > >On the other hand, we use "self", not "me", so it's not conceptually > >consistent. > > > How about clarg? Is that a proposed keyword or a Klingon name? :-) From greg at mad-scientist.com Mon Jul 16 18:23:33 2001 From: greg at mad-scientist.com (Gregory P . Smith) Date: Mon, 16 Jul 2001 15:23:33 -0700 Subject: [Mojonation-devel] Re: memory leak with dynamically defined functions? In-Reply-To: <20010716151219.A30652@glacier.fnational.com>; from nas@python.ca on Mon, Jul 16, 2001 at 03:12:19PM -0700 References: <15187.23983.562368.858629@beluga.mojam.com> <20010716151219.A30652@glacier.fnational.com> Message-ID: <20010716152333.F4410@mad-scientist.com> On Mon, Jul 16, 2001 at 03:12:19PM -0700, Neil Schemenauer wrote: > Skip Montanaro wrote: > > zooko> But if I allocate memory and store a reference to it in a default > > zooko> argument to an inner function, like this: > > > > >>> def silliest_func(): > > >>> x = [0] * (2**10) > > >>> def inner_silliest_func(x=x): > > >>> pass > > >>> return inner_silliest_func > > >>> > > >>> blarg = {} > > >>> for i in range(2**13): > > >>> blarg[i] = silliest_func() > > > > zooko> and then remove the references to this memory, like this: > > > > >>> del blarg > > > > zooko> none of the memory is freed up! > > If I do this: > > while 1: > blarg = {} > for i in range(2**13): > blarg[i] = silliest_func() > > the Python process size seems to remain constant. Are you sure this > leaks memory? I'm testing with Python 1.5.2 BTW. > > Neil [Removed mojonation-devel from the CC list] It doesn't appear to leak memory for me either. The difference as zooko noticed does show up though: His first example that didn't use a function holding a reference via default parameters -immediately- released the consumed memory when the reference to blarg was deleted. The version above that uses the function reference doesn't seem to ever release that memory even when the reference to blarg has been deleted. (yet it doesn't go above 34M when I put it in a while 1 loop as you have) I tested with python 2.1.1c1. Greg From gaul at spam.utexas.edu Wed Jul 11 19:30:21 2001 From: gaul at spam.utexas.edu (Andrew Gaul) Date: Wed, 11 Jul 2001 23:30:21 +0000 (UTC) Subject: Language Shootout References: Message-ID: In article , Roman Suzi wrote: > One more point about shootout. If I understood correctly, advanced > features are banned. You can't change > > k = [] > for i in list: > k.append(f(i) > > into: > > k = [f(i) for i in list] Actually, the former isn't much slower than the latter. Using map is almost twice as fast. I believe that map generates the result list by calling len() on the source list, avoiding the cost of growing the result list. I suppose list comprehensions could be implemented such that if there were not a filter clause, to prealloacte the list. But then, one should be using map anyway (you're only saving an implicit lambda using a list comprehension). meatring [~]$ time python2.1 -c 'k = [] for x in xrange(1000000): k.append(x)' real 0m3.934s user 0m3.440s sys 0m0.490s meatring [~]$ time python2.1 -c '[ x+1 for x in xrange(1000000) ]' real 0m3.402s user 0m2.670s sys 0m0.720s meatring [~]$ time python2.1 -c 'map(lambda x: x+1, xrange(1000000))' real 0m1.899s user 0m1.840s sys 0m0.060s -- | a | n | d | r | e | w | @ | g | a | u | l | . | o | r | g | White trash. Loser. Geek. From r.b.rigilink at chello.nl Fri Jul 13 03:51:14 2001 From: r.b.rigilink at chello.nl (Roeland Rengelink) Date: Fri, 13 Jul 2001 07:51:14 GMT Subject: sort->list References: <9im8jj$1b36$1@news.lf.net> Message-ID: <3B4EAB1B.E376FF96@chello.nl> domi wrote: > > Hello All! > Does somebody know how to sort a numeric list in the right way? > The sort method sort a list in this way: > [1,10,11,12,13,14,15,16,17,18,19,2,20,21,...] > > but I need a list sort like this: > [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,...] > > Any idea thanks domi Make sure that you are sorting a list of numbers and not a list of strings: i.e. >>> alist = ['1', '2', '11', '12', '22'] >>> alist.sort() >>> alist ['1', '11', '12', '2', '22'] >>> blist = map(int, alist) # change the strings to ints >>> blist [1, 11, 12, 2, 22] >>> blist.sort() >>> blist [1, 2, 11, 12, 22] Hope this helps, Roeland -- r.b.rigilink at chello.nl "Half of what I say is nonsense. Unfortunately I don't know which half" From donn at u.washington.edu Wed Jul 18 14:18:13 2001 From: donn at u.washington.edu (Donn Cave) Date: 18 Jul 2001 18:18:13 GMT Subject: Embedded Python 2.1 and AIX References: Message-ID: <9j4jt5$gta$1@nntp6.u.washington.edu> Quoth "Galen Swint" : | I'm embedding Python 2.1 in an AIX 4.3 library and it's crashing every time the | embedded Python calls for an import of the 'string' or 'math' module. With a | little bit of gdb work I can find that it's crashing with SIGSEGV in the | 'initstrop' function (or 'initmath' -- take your pick) when it calls | Py_InitModule4. Apparently, when the library is linked the reference to | Py_InitModule4 is not resolved. ... | Some more info | -Python configured with | ./configure --with-threads --with-gcc --prefix=/opt/local | (also, it is loading the library from the correct directory | (/opt/local/lib/python2.1/lib-dynload) according to gdb) Must you use gcc? I suggest you try the simplest test program that illustrates this problem, and build it with the compiler tools that come with the platform, with the options as specified in /usr/local/lib/python2.1/config/Makefile. Donn Cave, donn at u.washington.edu From dan at eevolved.com Tue Jul 10 14:47:08 2001 From: dan at eevolved.com (dan) Date: Tue, 10 Jul 2001 14:47:08 -0400 Subject: getting argument names from a function References: <6%F27.4784$yh2.453987@weber.videotron.net> Message-ID: Actually, that grabs the entire namespace of the function, not just the function variables. I haven't found anything in the func_code tree that contains only the function argument keys... thank you though, Dan Fredrik Stenberg wrote: > > On Tue, 10 Jul 2001, dan wrote: > >> def aFunction(arg1, arg2): >> print arg1, arg2 >> >> is there a way I can get to the arguments of aFunction (i.e. 'arg1' and >> 'arg2')? >> >> I've tried dir(..) on the function object and subsequent object and can't >> find what I'm looking for. Is it possible to do what I want? >> >> thanks, >> Dan > > If the function has a func_code object you can try this approach, > I have never use it myself and there probably is better ways. > > > Use Ctrl-D (i.e. EOF) to exit. >>>> def foo(bar,bar2): > ... print "foobar" > ... >>>> foo.func_code.co_varnames > ('bar', 'bar2') > > > > I think this will only work for functions written in python, and not > extensions written in C (atleast thats what my brain thinks). > > /fredriks From andymac at bullseye.apana.org.au Thu Jul 26 07:23:48 2001 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Thu, 26 Jul 2001 21:23:48 +1000 (EST) Subject: How to telnet to other unix machines and grep log files etc? In-Reply-To: Message-ID: On 25 Jul 2001, Chris wrote: > Relative unix newbie. Would like to write a python script to do what > I do manually--telnet to two different unix machines from a third unix > machine. Grep through some log files, gather the grep results from > the different machines and spit them out. I think I need to do > something with popen, or popen2, or ??? I don't know where to start. telnetlib (standard library module)? -- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andymac at bullseye.apana.org.au | Snail: PO Box 370 andymac at pcug.org.au | Belconnen ACT 2616 Web: http://www.andymac.org/ | Australia From mcherm at destiny.com Tue Jul 31 14:58:52 2001 From: mcherm at destiny.com (Michael Chermside) Date: Tue, 31 Jul 2001 13:58:52 -0500 Subject: Generator Comprehensions? was Re: a break for comprehensions Message-ID: <3B66FFEC.5335E1C8@destiny.com> > > I believe a separate syntax would be required to represent such a > radically > > different object. But you, of course, may know better ... if you're > looking > > for a syntax, one possibility would be: > > > > [[x * 2 for x in g()]] > > > > regards > > Steve > > That particular syntax won't do since [..snip..] > > How about [... x * 2 for x in g()] > How about this: def f(): for x in g(): yield x * 2 Of course it gives a generator, not a list... but that seems to be a reasonable form to represent an infinite sequence. -- Michael Chermside From kentabacchi at excite.com Wed Jul 25 10:01:20 2001 From: kentabacchi at excite.com (Ken Tabacchi) Date: 25 Jul 2001 07:01:20 -0700 Subject: Threads in Python version 1.5, thread doesn't start until calling process dies Message-ID: I am having some trouble with a threadded process in Python version 1.5. It seems that the thread does not start until the calling process has died. The thread starts immediately when the following program is run under Python version 2.1. ********************************************** import thread, time def Thread1(): while (1): print "I`m in the thread" time.sleep(1) thread.start_new_thread(Thread1, ()) print "about to call time.sleep(4)" time.sleep(4) print "just slept for 4 seconds" ********************************************** This is the Python version 1.5 execution of the above code: about to call time.sleep(4) just slept for 4 seconds I`m in the thread I`m in the thread I`m in the thread I`m in the thread I`m in the thread I`m in the thread and here is the Python version 2.1 execution of the same code: about to call time.sleep(4) I`m in the thread I`m in the thread I`m in the thread I`m in the thread just slept for 4 seconds I`m in the thread I`m in the thread I`m in the thread I`m in the thread I`m in the thread I`m in the thread Does any one have any suggestions? Thanks in advance for your assistance. Ken Tabacchi From peter at engcorp.com Wed Jul 18 19:57:42 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 18 Jul 2001 19:57:42 -0400 Subject: greenbeen seeks advice (24 recommended exercises) References: Message-ID: <3B562276.7EC4000F@engcorp.com> Mike Brenner wrote: > > Wyatt wrote: > > Do I need to know what is taught in CompSci 101/102/etc, to be great? [...] > ... most programmers don't write programs that meet specs. Most > programmer define greatness to be simply having fun while making money. > > To be great in that sense, instead of meeting specs, write the > following Python programs (and for extra credit, do each program > twice -- once using wxPython graphics, and once using Jython.) [snip list of trivial first-year programs ;-)] I think you left out one small thing. How, by writing those programs, fun it may be, would I make some money? -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From g_will at cyberus.ca Fri Jul 13 08:29:12 2001 From: g_will at cyberus.ca (Gordon Williams) Date: Fri, 13 Jul 2001 08:29:12 -0400 Subject: Comparison of different types does not throw exception Message-ID: <000b01c10b97$7da1af80$6f86fea9@wnt20337> I agree that allowing == and != is a requirement for objects of different types but allowing < = and > type operations is questionable. A couple of people have brought up ordering of heterogeneous lists. First, I don't know why anyone would want to do this. (Can anyone give me an example where they have done this for a "real world" problem?). According to Harms and McDonnald, the order of objects is arbitrary and only guaranteed to be fixed for one version of python; the order may be different in the next version. Second, if this is *really* a requirement, heterogeneous lists could still be ordered while not allowing <> operators to act on different object types. I think that leaving heterogeneous list sorting out would not break too much code. It is never too late to correct a design flaw :) Regards, Gordon Williams Guido van Rossum wites: "Gordon Williams" writes: >> I would like to know why python does not produce an exception when a >> comparison of objects of different types is made. For example: >> >> >>> 1 < "aaa" >> 1 >> >> I cant see why anyone would like to have comparisons of different types as >> it has no meaning. It is a programming error and an exception should be >> produced. > >You have already received several rationalizations for why this should >not be considered an error, but I want to say that this is actually >what I consider a design mistake in Python. Long ago I thought that >it made sense to want to sort an array of heterogeneous values. Now >I'm not so sure if that makes sense any more. > >If I could change this, I would probably allow "==" and "!=" >comparisons between objects of different types, but I would disallow >"<", "<=" etc. (actually, I would leave it up to the types, but most >standard types would do it this way). > >But there is probably too much code that would break if we changed the >rules now. (Although I haven't heard a peep from anyone who was >bitten by the change in 2.1 where we disallow "<" etc. for complex >numbers. But then if we removed complex numbers, most folks wouldn't >notice anyway, and those folks who use them are wiser than trying to >compare them...) > >--Guido van Rossum (home page: http://www.python.org/~guido/) From skip at pobox.com Thu Jul 12 10:49:31 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 12 Jul 2001 09:49:31 -0500 Subject: Light Speed Socket Connections In-Reply-To: <3b4d6184.1698299906@wa.news.verio.net> References: <3b4d6184.1698299906@wa.news.verio.net> Message-ID: <15181.47355.177666.13098@beluga.mojam.com> Bengt> On 11 Jul 2001 22:32:16 -0700, tangell at kicker.com (T Angell) wrote: >> I wrote some code to test how long it takes to make socket connections >> and ran it against several hosts around the world, here are some >> sample times: >> >> socket time: 0.0047459602356 >> socket time: 0.00469899177551 >> socket time: 0.00404000282288 >> socket time: 0.00537407398224 >> Bengt> [...] >> t1 = time.time() Bengt> For accurate timing, time.clock() is recommended, I believe: ... Not in this case. He wants to know how long it takes the socket to be connected between the two machines. That is an elapsed time sort of thing, what you measure with time.time. It has little or nothing to do with the CPU time used by the client process making the connection. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From kroesen at T-Online.de Mon Jul 16 03:50:15 2001 From: kroesen at T-Online.de (Burkhard Kroesen) Date: Mon, 16 Jul 2001 09:50:15 +0200 Subject: Nested List Comprehension References: <9iss5k$2dcd$1@news.idiom.com> Message-ID: <3B529CB7.8030905@T-Online.de> James T. Dennis wrote: > This is not a question but merely a comment from a > newbie. I'm reading Beazley's 2nd Ed. "Python Essential > Reference" and playing with things therein and I thought > "list comprehension, what a quick way to make a multiplication > table" > > multtab = [ [ x*y for x in range(13) ] for y in range(13) ] > > ... though I was surpirsed that I got the syntax correct > on the first try. (It still looks wrong, somehow but > [ x*y [x for x in range(13)] [y for y in range(13) ] ] looks > even more wrong). Maybe you feel more comfortable with multtab = [x*y for x in range(13) for y in range(13)] Burkhard Kroesen From bokr at accessone.com Sat Jul 21 20:20:18 2001 From: bokr at accessone.com (Bengt Richter) Date: Sun, 22 Jul 2001 00:20:18 GMT Subject: Language change and code breaks (fwd) References: <3b5873ba.2423857703@wa.news.verio.net> <9jbp9l$90f$1@apollo.csd.net> Message-ID: <3b5a1d11.74651563@wa.news.verio.net> On Sat, 21 Jul 2001 17:54:09 -0500, Skip Montanaro wrote: > > >> That does bring up the subject of machine-generated symbols though. > >> And case sensitivity in dictionaries. I use base52 [A-Za-z] encoded > >> md5's in certain contexts. If I use those as keys, will it break? > > kosh> Losing case sensitivity in dictionaries would screw me pretty > kosh> badly also. > >I think case-sensitivity as we are discussing in this thread runs only to >identifier and attribute names, not the contents of strings, so while > > date = 1 > DATE += 1 > print Date > >should print "2" by my understanding, > > dict = {"date": 1, > "DATE": 2, > "Date": 3} > >would create a dictionary of length 3. > Ok, after the above, what would locals() give you? Which will give the value 2, locals()['date'] or locals()['DATE'] or both? From mcfletch at home.com Wed Jul 4 07:21:55 2001 From: mcfletch at home.com (Mike C. Fletcher) Date: Wed, 4 Jul 2001 07:21:55 -0400 Subject: PyDoc: How to exclude from x import * objects? In-Reply-To: <001001c10442$426d5a60$a9807018@cr706570a> Message-ID: <001901c1047b$88f4d600$a9807018@cr706570a> I know, I know, terribly rude to respond to my own post... I wound up putting together something to get the PyOpenGL documentation to basically work, likely wind up doing a CSS/style based formatter eventually, but for now I can at least generate the entire documentation set fairly easily. class PackageDocumentationGenerator: """A package document generator creates documentation for an entire package using pydoc's machinery. baseModules -- modules which will be included and whose included and children modules will be considered fair game for documentation destinationDirectory -- the directory into which the HTML documentation will be written recursion -- whether to add modules which are referenced by and/or children of base modules exclusions -- a list of modules whose contents will not be shown in any other module, commonly such modules as OpenGL.GL, wxPython.wx etc. recursionStops -- a list of modules which will explicitly stop recursion (i.e. they will never be included), even if they are children of base modules. formatter -- allows for passing in a custom formatter see DefaultFormatter for sample implementation. """ def __init__ ( self, baseModules, destinationDirectory = ".", recursion = 1, exclusions = (), recursionStops = (), formatter = None ): For sample of generating documentation for the PyOpenGLSWIG and OpenGLContext projects (there are modules that fail, but 101 documents do get generated, and the rest seem to be modules which will not properly import due to code in them which assumes they are always run as scripts... if __name__ == "__main__": excludes = [ "OpenGL.GL", "OpenGL.GLU", "OpenGL.GLUT", "OpenGL.GLE", "OpenGL.GLX", "wxPython.wx", "Numeric", "_tkinter", "Tkinter", ] modules = [ "OpenGLContext", "wxPython.glcanvas", "OpenGL.Tk", "OpenGL", ] PackageDocumentationGenerator( baseModules = modules, destinationDirectory = "z:\\temp", exclusions = excludes, ).process () If anyone else is interested, give me a shout and I'll see about packaging it up. Nice little system Ka-Ping Lee, very cool results for a single evening's fooling about. I'm thinking that a system that allowed for such things as generating css code that collapsed inherited methods would be cool as well. Enjoy yourselves, Mike -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Mike C. Fletcher Sent: July 4, 2001 00:32 To: Python List (E-mail) Subject: PyDoc: How to exclude from x import * objects? ... ... From simonb at webone.com.au Fri Jul 13 23:20:49 2001 From: simonb at webone.com.au (simonb at webone.com.au) Date: Sat, 14 Jul 2001 13:20:49 +1000 Subject: Naked function call syntax References: <3b4fa037.1845423078@wa.news.verio.net> Message-ID: <3B4FBA91.6080200@webone.com.au> right. I do this for lists: >>>def lprint(alist): >>> for a in alist: >>> print str(a) so that i don't get repr of elements. And it would be great to be able to write: >>> lprint alist just like print... Im not sure i understand the proposed resolution of leading '[' or '('... "print(1,2)" prints a tuple, so wouldn't you have to mark functions as "naked" so that a tuple would be sent as the first argument? >>>def naked lprint(alist): >>>... Well, this sounds rediculous to me. what about: >>>def lprint alist: >>>... ? Simon. Bengt Richter wrote: >Interactively, I find myself writing little things like: > >def pd(x): > try: > print x.__doc__ > except: > print '(no doc string)' > >so that, e.g., I can type > > pd(vars) > >and get formatted info. But I'm lazy enough that >I would like to to type just > pd vars > >Is there an existing pythonic way to do this? > >If not, would there be breakage if python were modified to make > > foo whatever-up-to-EOL > >equivalent to > > foo(whatever-up-to-EOL) > >when it would be a syntax error otherwise? I.e., I'm wondering >if the grammar could be modified to do this by changing trailer >to accept arglist NEWLINE if _all_ else fails, and treat a match >as if it was an arglist. Leading '(' or '[' ambiguity would be >resolved in favor of normal arglist or subscriptlist. > > From max at alcyone.com Sat Jul 14 03:23:01 2001 From: max at alcyone.com (Erik Max Francis) Date: Sat, 14 Jul 2001 00:23:01 -0700 Subject: More on "with" statement References: Message-ID: <3B4FF355.AFC80981@alcyone.com> Roman Suzi wrote: > > That's just plain more efficient. Four additions and one multiply > > four? Yes, typo. Three, obviously. > The same with "with": it could make name-resolving more efficient > by allowing searching some namespaces ahead of locals() and > globals()... Or you could just make a temporary assignment. Same thing going on, no need for a new keyword and ambiguous code. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ God is love, but get it in writing. \__/ Gypsy Rose Lee Kepler's laws / http://www.alcyone.com/max/physics/kepler/ A proof of Kepler's laws. From xione at prodigy.net Sun Jul 15 00:03:17 2001 From: xione at prodigy.net (Xione Wrent) Date: Sun, 15 Jul 2001 04:03:17 GMT Subject: Tkinter/Win32 Question: Message-ID: <9C847.6$ei.832667@newssvr15.news.prodigy.com> Does anyone know how to add "System Tray Minimization" functionality to a Tkinter GUI? From sholden at holdenweb.com Mon Jul 2 12:37:46 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 2 Jul 2001 12:37:46 -0400 Subject: Augmented Assignement (was: Re: PEP scepticism) References: <20010702145211.M8098@xs4all.nl> Message-ID: <%o107.21422$he.1049178@e420r-atl1.usenetserver.com> "Fran?ois Pinard" wrote in ... > [Thomas Wouters] > [ ... ] > > I would be tempted to guess that augmented assignment has been requested so: > > tedious_or_inefficient_denotation = tedious_or_inefficient_denotation + 1 > > could be rewritten as: > > tedious_or_inefficient_denotation += 1 > > And that's it. > Nope. It was included to allow useful abbreviation of method calls, specifically allowing in-place update of mutable objects where the object implementation decided this was suitable. > Of course, operators may also yield __IMPLEMENT__-like methods in objects > wanting to use these operators, where one can do everything s/he wants, > among which implementing new, different and even surprising semantics. > > I strongly think that the base Python language should strictly limit itself > to the semantic that "a += b" means "a = a + b" with "a" evaluated once. > and be careful at avoiding any surprising side-effect. Let's fulfill the > request for augmented assignment, without overshooting it. > Too late. Since augmented assignment has been around in its present form for almost a year now (IIRC) to change the definition at this stage would break existing code, and that just isn't acceptable. I felt more or less the way you do when this change was made, but there really isn't any point going back to try and fight this battle again. You have to live with Python the way it is (and nobody id going to *force* you to use augmented assignments). > Fuzziness in this area does not bring us anything, really. If you really > want a method to extend an mutable, spell it out as we always did, similar > to list.append(), say, but leave "+" and "+=" alone. > > Please, _please_ protect the long-term legibility of Python. > Sorry. Move on! regards Steve -- http://www.holdenweb.com/ From sholden at holdenweb.com Fri Jul 13 12:09:22 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 13 Jul 2001 12:09:22 -0400 Subject: Apache & Python References: <20010713.15394573@mis.configured.host> Message-ID: <_0F37.12643$u76.678191@e420r-atl3.usenetserver.com> "Paul Duquette" wrote in message news:20010713.15394573 at mis.configured.host... > I have installed python 2.1 on my windows2k machine and would like to > know how to use Python with Apache. I can't find any config instructions > anywhere. The python faq tells me how to configure it with IIS but I > didnt see anything about Apache. > Hopeing you Python experts out there can point me in the right direction. The simplest way is to use Python scripts as CGI's. This appears to work very straighforwardly without any need to configure Apache. You sinply ensure that your scipts appear in cgi-bin directories, and ensure that thay start with a leading comment which allows Apache to run them through the Python interpreter -- typically #!C:\Python20\python -u The -u gives unbuffered I/O. After that, take a look at mod_snake, or the older mod_python, for closer integration. regards Steve -- http://www.holdenweb.com/ From quinn at yak.ugcs.caltech.edu Mon Jul 9 20:39:02 2001 From: quinn at yak.ugcs.caltech.edu (Quinn Dunkan) Date: 10 Jul 2001 00:39:02 GMT Subject: Help with reduce(). References: <3ur27.663627$166.13698874@news1.rdc1.bc.home.com> Message-ID: On Mon, 09 Jul 2001 23:53:35 GMT, EricIDLE wrote: >Ok well I have ANOTHER problem with one of the examples in my book (By The >Way, "Teach yourself python in 24 hours" is an extremely poorly written book >and I do not reccomend it to any newbies who are just starting off) >any ways the example is as follows. > >n = range(1,11) >def mult(x,y): > return x * y >f = reduce(mult,n) >print f > >I get everything up to reduce. I relize mult() takes the first two numbers >in range N which would be 1, 2 and multiplys them together to get 2... ok >fine im good ... now comes the tricky part!! what does reduce do? Does it >take the whole range and make it into a number (12345678910) then subtract 2 >(the result of the function mult) or what does it do. Try the reduce documentation? At the prompt type 'print reduce.__doc__'. Just to convince you how much better off you'd be reading the python documentation, I'll explain it myself: In other languages, 'reduce' is called 'fold' which is because you can think of it as folding a function into a list. Given the list [1,2,3] and the function (+), you get 1 + 2 + 3. You can fold from the right or left, but don't worry about that now (in an eager language like python it doesn't make any difference anyway). Here's a possible definition of a simplified right reduce in python: def reduce(f, lst): if len(lst) == 0: raise TypeError, 'reduce() of empty sequence with no initial value' elif len(lst) == 1: return lst[0] else: return f(lst[0], reduce(f, lst[1:])) It's trying to emulate a functional idiom, so it's somewhat awkward and slow in python. A more natural python solution would be iterative but less clear. >And i have another question (not related to first question) > >x = ['Thu', 'Aug', '5', '06:06:27', 'MDT', '1999'] >def strp(x,y): > return x + ' ' + y >r = reduce(strp,x) >print r > >my problem is this line return "x + ' ' + y" what does it return the value >of. I would understand it if it was x + y but the qutation marks are what >throw me off what do they mean? Quotes surround strings. ' ' is a string containing a space. strp sticks together two strings with a space in between. The above is an awkward, slow, and hard to read way to write "string.join(x)". If you're still at the point where you're not clear on string literals, and this book is heaving all these higher-order functions at you, I'd agree it's not very good (or you skipped a few chapters). reduce, map, and filter are meant to be a small convenience for people who either know what they're doing or who just arrived from scheme or haskell or ml and want their old goggles back. You shouldn't be learning python with these functions, you should be getting friendly with for loops and lists. And dictionaries. When you're comfortably slinging those around, you can revisit reduce. map and filter have been somewhat eclipsed by list comprehensions. Ignore the book. Read the python tutorials on the net. deja c.l.py for URLs. Subscribe to the python-tutor list. And when you want to know what something does, try it at the prompt. From tjreedy at home.com Thu Jul 26 15:57:53 2001 From: tjreedy at home.com (Terry Reedy) Date: Thu, 26 Jul 2001 19:57:53 GMT Subject: A modest PEP0238 suggestion References: Message-ID: <5D_77.30737$EP6.7908379@news1.rdc2.pa.home.com> "Tim Peters" wrote in message news:mailman.996123586.12737.python-list at python.org... > Without that, you're still going to be a lot more portable than raw C code > (as portable as 10 years of development have been able to make the C code in > Python), but there are no reliable all-platform guarantees even for a fixed > Python release. Oh, gee. "Write once, run everywhere forevermore" was such a nice fantasy ... From phd at phd.fep.ru Mon Jul 9 09:49:04 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Mon, 9 Jul 2001 17:49:04 +0400 (MSD) Subject: How to 'from package import module; from module import variable'? In-Reply-To: Message-ID: On 9 Jul 2001, Alex wrote: > Hi. I've recently switched to using packages. Because I use reload a > lot during testing, it'd be helpful to be able to do this sort of thing > successfully: > > >>> from mouse.tools import queues > >>> from queues import Cyclic_queue > Traceback (most recent call last): > File "", line 1, in ? > ImportError: No module named queues > > My understanding of the package import routine is still sort of sketchy, > but I was wondering if there's a way to convince the import function > that queues is actually a module it can import from. from mouse.tools import queues import sys sys.modules["queues"] = queues from queues import Cyclic_queue Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From SBrunning at trisystems.co.uk Tue Jul 3 08:52:40 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Tue, 3 Jul 2001 13:52:40 +0100 Subject: object - oriented programming Help!! Message-ID: <31575A892FF6D1118F5800600846864D78BE01@intrepid> > From: brakedon at hotmail.com [SMTP:brakedon at hotmail.com] > What am I doing wrong? I am trying to learn object oriented > programming, but I don't know what I'm doing wrong. > > >>> import fibonaccii_gui > >>> fibonaccii.fib(fibinstance, 100) > Traceback (most recent call last): > File "", line 1, in ? > fibonaccii.fib(fibinstance, 100) > NameError: name 'fibonaccii' is not defined You are importing a module called fibonaccii_gui, then referring to just fibonaccii. Replace your 2nd line with: fibonaccii_gui.fib(fibinstance, 100) And it just might work. 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 paulp at ActiveState.com Tue Jul 10 18:31:11 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Tue, 10 Jul 2001 15:31:11 -0700 Subject: Long Live Python! References: Message-ID: <3B4B822F.E5BBB9F6@ActiveState.com> Kemp Randy-W18971 wrote: > > So an interesting question is raised. If PHP and Ruby are gaining > acceptance because they address business needs, what needs to be done to > carry Python in that direction? And while Java may be slow, Sun pushing it > for business solutions also gives that language acceptance. How can Python > become as popular as Perl, Java, or PHP? Perl, Java and PHP all grew popular by solving a particular problem at a particular time, better than any other language. (I'm thinking of system administration/CGI, Applets and web page generation). Perl and Java grew into general purpose languages over time. The jury is still out on PHP. Python does not have a niche and is not obviously a niche-friendly language. That means that it has a harder slog to gain adherents. On the other hand, Python is not as dependent on its niche. I think that Python is probably growing faster than Perl and PHP now that those two languages have basically dominated their niches. Consider the status of Tcl which is not growing much since other languages invaded the "easy GUI development" niche. Java has of course outgrown its initial niche but it is hardly fair to compare Python to a language backed by Sun, IBM, etc. If Python had that kind of backing it would be as big or bigger than Java too. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From luthi at vaw.baug.ethz.ch Tue Jul 24 03:37:48 2001 From: luthi at vaw.baug.ethz.ch (Martin Luethi) Date: 24 Jul 2001 09:37:48 +0200 Subject: emacs python mode References: <3B5BF5C7.3070707@herts.ac.uk> Message-ID: Switch on font-lock-mode or put the following lines into your .emacs if you want highlighting in all modes (global-font-lock-mode t) (setq font-lock-maximum-decoration t) Cheers Martin From garyr at fidalgo.net Fri Jul 13 11:19:45 2001 From: garyr at fidalgo.net (Gary Richardson) Date: Fri, 13 Jul 2001 08:19:45 -0700 Subject: Debugging extension modules Message-ID: I have a question regarding the technique of debugging C extension modules. I'm using the ActiveState IDE and MSVS 6.0. I place the C code for a module in one directory and the Python test code that uses it in another. After building the module I copy the DLL to the directory containing the test code and try it out. However, if I have to make a change in the C code I find that I can't delete or overwrite the DLL file unless I exit the IDE. If I start Python from DOS, import the module and do some testing I must exit Python before I can delete the DLL. Is there a way to delete the DLL file without having to exit the IDE or Python? From jm7potter at hotmail.com Thu Jul 5 11:46:38 2001 From: jm7potter at hotmail.com (Joe Potter) Date: Thu, 05 Jul 2001 11:46:38 -0400 Subject: Is Python Dead? References: <458b194a.0107050711.72007607@posting.google.com> Message-ID: On Thu, 5 Jul 2001 11:29:46 -0400, "Steve Holden" wrote: >"Resty Cena" wrote in message >news:458b194a.0107050711.72007607 at posting.google.com... >> "Edward B. Wilson II" wrote in message >news:... >> > I have been following Python for five years now, and I am still just as >> > frustrated with it as I was in 1996. >> > >> > Python still doesn't have good database support, >> >> I, too, have been following Python since 1996, waiting all the while >> to make it easy for me to do database programming. What I'd call good >> database support is where I download a file or set of files into a >> directory under my Python directory, perhaps run an install program, >> then start Python, import a package, issue a command to connect to >> Oracle, and start playing around with the scott/tiger database. I >> don't want, nor do I have the time, to compile anything, nor muck >> around with the Windows registry, nor manually set paths -- I just >> want to try the product, not install it for production use. Ideally, >> I'd like the IDE to do this for me. I'm a database programmer, and I >> want to write applications right away. I'm also lazy and I expect much >> from my tools. > >Of course, one of the reasons why support isn't better is the huge ratio of >consumers to producers. That's not necessarily a bad thing, but most of the >best parts of Python have been the results of individuals providing what >they needed for their own purposes and then opening up the resulting code. > >Continue to sit on your hands by all means. What you need should be along in >another five years or so. But simply posting to complain that things aren't >as you want is unlikely to change in the next six months what nothing else >has changed in the last five years. > >There are lots of people doing much good database work with Python. The >mxODBC package (free for non-commerical use) and the cx_Oracle package >(free) do indeed let you do what you describe (i.e. download, unpack, run an >install script and connect to a database). So I suggest you look a little >harder and complain a little less. Normally I try to include URLs in >postings such as this, but you know, somehow I get the impression that >clicking on a link in a news posting might just be too much trouble ;-) > >Come on in, the water's lovely. > >regards > Steve > Spot on, Steve. Regards, Joe From shredwheat at mediaone.net Wed Jul 18 12:27:16 2001 From: shredwheat at mediaone.net (Pete Shinners) Date: Wed, 18 Jul 2001 16:27:16 GMT Subject: One Worry for 2.2 Message-ID: i'm excited for the new features coming in 2.2. reading some release notes, i found a new difference that bothers me. """ There's one very specific (and fortunately uncommon) bug that used to go undetected, but which is now reported as an error: class A: def foo(self): pass class B(A): pass class C(A): def foo(self): B.foo(self) Here, C.foo wants to call A.foo, but by mistake calls B.foo. In the old system, because B doesn't define foo, B.foo is identical to A.foo, so the call would succeed. In the new system, B.foo is marked as a method requiring a B instance, and a C is not a B, so the call fails. """ now in my mind's understanding of OO, if class B inherits from class A, then class B has a foo() function. what this is implying is that only _instances_ of class B have a foo() function. i don't really see this as "very specific (and fortunately uncommon) bug", i see it as the way things are supposed to work. i can think of several cases where working like this is entirely less flexible and full of problems. (especially in the GUI widget department) is this change implemented because it needs to be? (ie, the type/class merging doesn't work without it) or is this change implemented because it was decided they could add this in? i really think this sort of change should be 'repealed' if that is possible. i just see it as a bit worse rather than a bit better. Being able to do this is what makes OO work. without it, like is going to be a pain in some departments. From fgeiger at datec.at Mon Jul 9 08:49:30 2001 From: fgeiger at datec.at (Franz GEIGER) Date: Mon, 9 Jul 2001 14:49:30 +0200 Subject: [Tkinter]: Grid as in wxPython? Message-ID: <9ic90t$s1l$1@newsreaderm1.core.theplanet.net> Is anybody aware of anything like wxPython grids, but for Tkinter? For a Tkinter GUI I need a grid as it is available in wxPython. I already use PMW, but there isn't such a beast. Regards Franz From aahz at panix.com Tue Jul 31 20:36:36 2001 From: aahz at panix.com (Aahz Maruch) Date: 31 Jul 2001 17:36:36 -0700 Subject: Python Threads on Linux References: <3B671B63.23CC4490@raqia.com> Message-ID: <9k7iuk$85b$1@panix2.panix.com> In article <3B671B63.23CC4490 at raqia.com>, David Lees wrote: > >Question - Does this affect the global lock at all? Is it some way to >get around it? I wrote some simple threaded code awhile back that ran >on a dual processor board. The global lock kept 2 threads from running >in parallel on separate processors. Tim gave you a short answer; for more info, 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 "activist for accuracy" --SJM From loewis at informatik.hu-berlin.de Mon Jul 30 07:16:24 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 30 Jul 2001 13:16:24 +0200 Subject: Unusual minidom behaviour: Part Deux References: Message-ID: "Victor Bazarov" writes: > > In that case, I recommend to put a number of print statements into the > > library modules that you suspect to be causes of the problem, and > > trace that way what they are doing. If you can identify the call that > > is hanging (i.e. the function you call that doesn't return), please > > let us know. > > > Didn't I already? __import__ is hanging. It doesn't let another > thread to start and it doesn't return anything. Please try to trace further. I.e. does it start executing the first line of expatreader? Regards, Martin From esharpe at uswest.wet Sun Jul 15 02:53:24 2001 From: esharpe at uswest.wet (Ed Sharpe) Date: Sat, 14 Jul 2001 23:53:24 -0700 Subject: New library software development project. References: <3B3601BE.3C84E49A@earthlink.net> <7a32d1c7.0107141205.51f7565b@posting.google.com> Message-ID: <0Pa47.981$KI6.835667@news.uswest.net> Hi Richard! I am going to build the RH 7.1 system tomorrow and load the beta of open book, Bette was at ALA in san Francisco and saw it running at the open source library meeting that was held there and she was very impressed by it. Yes I know how you feel on development time, I had thought I would code something out too... but my! they have all done such nice work! Think I will be content being and end user and also someone to help implement some of these systems in small libraries around the state.. The museum has in the past given out grants for computer equipment and this would be a nice thing to see go with the hardware. Have a great rest of the weekend! ed sharpe archivist for smecc There is also a fellow in Canada doing some enhancements to koha in the way of making it conform to marc 21 ( very important) Richard Snow wrote in message news:7a32d1c7.0107141205.51f7565b at posting.google.com... > "Ed Sharpe" wrote in message news:... > > there are already things like this out there.... > snip... > > Richard Snow wrote in message > > news:3B3601BE.3C84E49A at earthlink.net... > > > > > > 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 > snip... > > > 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 > > > > > > > > > > > Ed: I've done a minor update to the web site mentioning koha and > openbook. > When I get more time and details I'll add some more to my site. > Thanks for > pointing out these other projects. It would have taken me a long time > to get > mine to the point that Koha is now. I haven't seen the Open Book beta > yet. > > I have offered to help write some docs for Koha, and I will start on > that > as soon as I have time to get all my software installed that it needs > and > actually install Koha on my system. Rough drafts will be on a new > page on > the above mentioned site before I send them to koha. > > By the way I'm posting this message from my sister's computer using > the new Google Groups system (new to me anyway). Good Job, Google. > > Richard From SBrunning at trisystems.co.uk Thu Jul 19 11:46:53 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Thu, 19 Jul 2001 16:46:53 +0100 Subject: float to str help Message-ID: <31575A892FF6D1118F5800600846864D78BEC4@intrepid> > From: Bryan Webb [SMTP:bww00 at amdahl.com] > In converting a float (5.661706091586558e+240) to a string using str() > I > come up with 5.6617060916+240 . I checked the string variable in the > debugger. I need the full precicsion. I know its probably simple but this > red hair is causing me problems. Have you tried repr()? 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 adjih at inria.nocrap.fr Sat Jul 7 04:40:40 2001 From: adjih at inria.nocrap.fr (Cedric Adjih) Date: 7 Jul 2001 08:40:40 GMT Subject: ICFP 2001 contest - Python team, anyone? References: Message-ID: <9i6hu8$lgh$1@ites.inria.fr> Gerhard H?ring wrote: > The International Functional Programming Contest was announced. I'd like to > join this year. If you are a Python hacker and want to have all the fun and > glory, please contact me :-) > > http://cristal.inria.fr/ICFP2001/prog-contest/ > > """ > On Thursday, July 26, 2001 at 15:00 UTC (see this page to convert to your time > zone), a challenge task will be posted on the Internet. It will also be sent by > mail to the contest mailing list. > > Teams will have 72 hours to implement a program to perform this task and submit > this program to the contest judges. > """ Count me in. -- Cedric From new_name at mit.edu Thu Jul 12 13:18:35 2001 From: new_name at mit.edu (Alex) Date: 12 Jul 2001 13:18:35 -0400 Subject: Compile 2.1 problem References: Message-ID: What output do you get when you run the last command, ./python -tt \ /var/tmp/python2-2.1-root/usr/lib/python2.1/compileall.py \ /var/tmp/python2-2.1-root/usr/lib/python2.1 with the -v flag? Alex. From opengeometry at yahoo.ca Wed Jul 11 11:44:15 2001 From: opengeometry at yahoo.ca (William Park) Date: Wed, 11 Jul 2001 11:44:15 -0400 Subject: Apache, CGI, Python... In-Reply-To: <3B45051300120CE9@mail.san.yahoo.com>; from vincent_a_primavera@netzero.net on Wed, Jul 11, 2001 at 07:33:11AM +0000 References: <3B45051300120CE9@mail.san.yahoo.com> Message-ID: <20010711114415.B1609@node0.opengeometry.ca> On Wed, Jul 11, 2001 at 07:33:11AM +0000, Vincent A. Primavera wrote: > Hello, Looking for some guidance as to the set up of Apache's > httpd.conf for some basic CGI scripting practice in Python... Any > suggestions? Since Python script is like any other CGI script, just rename the file as '.cgi' and have '#!/usr/.../bin/python' as the first line. If you want '.py' to be considered as CGI script by Apache, then put AddHandler cgi-script .cgi .py in your httpd.conf. -- William Park, Open Geometry Consulting, 8 CPUs cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc. From teo at crepido.com Mon Jul 30 05:37:40 2001 From: teo at crepido.com (teo) Date: 30 Jul 2001 02:37:40 -0700 Subject: Is 4Suites xml-parser slow??? (or am i parsing in the wrong way??) Message-ID: Hi all! I wonder if some of you have had problems (not really a problem, but it takes long time to parse) with xml.dom.ext.Sax2.FromXmlStream ? I feed the parser with an wellformed xml-file at 50k, and it takes 6.93 - 7.5 seconds to parse. btw, I'm running my app on an AMD-Athlon 850 Mhz Mandrake-linux PC the code in my app is: ------------------------- Sourcefile = "myxml.xml" # :) from xml.dom.ext.reader.Sax2 import FromXmlStream import timing print "Parse!!" timing.start() dom = FromXmlStream(Sourcefile) timing.finish() print "Parsing XML into DOM took" +str(timing.milli()/1000.00000001)+" seconds..." ------------------------- Thanks for taking your time ;) /teodor From bokr at accessone.com Mon Jul 23 01:55:12 2001 From: bokr at accessone.com (Bengt Richter) Date: Mon, 23 Jul 2001 05:55:12 GMT Subject: Pedants R us (was RE: Language change and code breaks) References: Message-ID: <3b5bb3cb.178773692@wa.news.verio.net> On Mon, 23 Jul 2001 11:21:11 +1000, "Delaney, Timothy" wrote: >> >Guido van Rossum wrote: >> >> In my usage, a "programmer" is someone who is a >> >> professional code-slinger, 8-12 hours a day. >> > >> >Eek - I hope you don't really mean that last subclause! >> >> A *real* programmer gets in a good six hours code-slinging in their >> sleep - that period when all the hard problems find their neat >> original solutions. Apart from the ones that get scribbled on a >> beer-mat, that is ;-) > >Nah - all the best solutions are worked out in the shower. > Seriously, I think a scientific study would reveal a correlation. Probably heat and hydromassage stimulating brain blood circulation. A walk or swim is also good. Otherwise, some point before the end of the second cup of coffee. (Too much coffee, though, leads to ASD -- attention surplus disorder ;-) From rnd at onego.ru Sun Jul 1 01:14:33 2001 From: rnd at onego.ru (Roman Suzi) Date: Sun, 1 Jul 2001 09:14:33 +0400 (MSD) Subject: 'with' statement in python ? In-Reply-To: Message-ID: On Sat, 30 Jun 2001, Steve Holden wrote: >> | 6.31. Why doesn't Python have a "with" statement like Delphi's Object >> | Pascal? >> >6.31. Why doesn't Python have a "with" statement like some other languages? Because nobody wrote a PEP which was consequently approved! Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Sunday, July 01, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "DEVICE=EXXON.SYS may mess up your environment" _/ From stevewilliams at wwc.com Fri Jul 27 17:24:21 2001 From: stevewilliams at wwc.com (Steve Williams) Date: Fri, 27 Jul 2001 21:24:21 GMT Subject: PEP 238 (revised) References: Message-ID: <3B61DCB8.3973C7FB@wwc.com> Tim Peters wrote: > [snipalot] > > But you can't actually tell anything from that, because the Windows C printf > suppresses the sign of a 0. You can't tell by trying to compute the > reciprocal either (to look at the sign of the resulting infinity), because > *Python* stops you from doing that: > > [snip, snip, snip] Wot, no sgn() function in Python? What is the world coming to? > > full-754-is-still-unusable-in-practice-ly y'rs - tim From tim.one at home.com Sat Jul 28 02:42:58 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 28 Jul 2001 02:42:58 -0400 Subject: Nasty typo in PEP 238 (revised) In-Reply-To: Message-ID: [Robin Becker] >>> when/if the grand unification happens what will math.cos do with 1+3j? >>> What will floor do with 1.3+0j etc etc etc. Presumably a Timbot thread >>> is even now busily extending all math functions to the complex domain. [Tim] >> My belief is that the vast majority of Python users are best >> served by the current behavior of never getting a complex result from >> non-complex inputs unless they explicitly invoke functions from the >> cmath module. But that's a question you didn't ask (although you >> should have). A more interesting question is whether math.acos(2) >> should continue to whine. [Robin] > so the statement by the grand designer that int/float(x) won't cut it > if x is complex is just a little fake. I don't grasp your meaning, but not for lack of trying. > If complex x hurts in division are we to accept it won't hurt in sqrt? Sorry, but ditto. Give a concrete example? If someone said complex x hurts in division, I missed it. > The idea that we might import cmath to get complex '/' to work is > interesting given the arguments presented about closure for arbitrary > numerics as inputs to functions. I haven't seen that idea before, and if you're now *suggesting* it I don't see any point to it. Your examples had users explicitly passing complex inputs to functions. I was talking about getting complex results out of functions when complex numbers are *not* passed to them (such as acos(2)). Division can never return a complex result unless given a complex input. I see nothing surprising to anyone about complex-in, complex-out. It's only non-complex-in, complex-out that Python currently shields users from (in the absence of explicitly using cmath functions). As I said, I think that's a benefit for the majority of users; I don't know whether Guido agrees. > Others have been presenting similar schemes to preserve/change the > natural order of literals etc, but these schemes seem doomed. If OO > completeness is desirable why shouldn't math.acos is cmath.acos be > true? Don't know what "OO completeness" means. As a pragmatic matter, I would much rather that the typical business programmer get an exception at the end of their floating-point algorithm for (say) computing standard deviation, when due to fp inexperience they use a numerically naive textbook method that ends up passing a negative number to sqrt due to massive cancellation. Let that silently return a complex result instead, and God only knows how much more computation they'll do with it before getting a meaningless result in the end. For most users most of the time, a complex result is more likely a symptom of an error in their code (or uncaught bogosity in their data) than a useful result. If you're a Comp Sci Purity Guy, you may want to torture them with 4.02j instead. > I accept along with others that there are other numeric models. I don't > accept the grand unification at face value as some kind of panacea. Do you believe anyone does? Not even Moshe has claimed that it would be. > Before all this brouhaha we didn't really understand any of the real > problems and I don't believe we can solve them to everyone's > satisfaction. This stuff isn't new to me, and I know that we can't. That doesn't imply trying to do better would be a net loss. knowing-you'll-die-in-the-end-isn't-an-argument-against-living- either-ly y'rs - tim From anthony at interlink.com.au Tue Jul 17 09:59:28 2001 From: anthony at interlink.com.au (Anthony Baxter) Date: Tue, 17 Jul 2001 23:59:28 +1000 Subject: Bug in Python DNS module In-Reply-To: Message from Michael =?iso-8859-1?Q?Str=F6der?= of "Tue, 17 Jul 2001 01:13:35 +0200." <3B53751F.4CA0DC4@stroeder.com> Message-ID: <200107171359.f6HDxS415171@mbuna.arbhome.com.au> >>> Michael Str?der wrote > I've included it into my version of the DNS module. I wrote Anthony > Baxter who maintained the version I grabbed and modified but no > response so far what to do with the module. If nothing happens > during the next two or three weeks I will probably upload it to a > SourceForge project. [my apologies for the tardy response. it's been a while since I could even pretend to keep up with python-list/c.l.python] Pushing the DNS module to sourceforge sounds like an _excellent_ idea. There's a bunch of internals work that it could really do with to make it a easier to work with. Anthony From not.this at seebelow.org Tue Jul 3 23:26:01 2001 From: not.this at seebelow.org (Grant Griffin) Date: Tue, 03 Jul 2001 22:26:01 -0500 Subject: Not enough Python library development [was PEP scepticism] References: Message-ID: <3B428CC9.1F944ECD@seebelow.org> Roman Suzi wrote: > ... > CPyAN is much more complex task, because there are: ... I think the problem here might be one of marketing, combined with a lack of corporate sponsorship. To that end, I propose this resource be called "Python Program Archive Network", or PyPAN, for short. That might help it attract funding from Mrs. Smith's and Sara Lee. (Heck, if nothing else, maybe those ladies can contribute something tasty to the Python Cookbook.) Seriously, folks, I never was a big fan of CPAN: in fact, for me, it was just another part of my overall poor user-interface experience with Perl . Although CPAN is impressive in terms of sheer girth, the CPAN concept seemed to encourage large interdependencies between modules. Although this seems like good thing in some ways (because it indicates a lot of software reuse), I found it nightmarish to install even fairly simple packages. (I never could get the automatic CPAN installer gizmo to work well--at least without giving it a great deal of manual help.) Having a very large standard library seems a better solution. (Of course, Perl also comes with a large standard library.) I never seem to have large cross-package dependency problems with Python; my experience has been that nearly all packages require zero or one other packages. Presumably, this is a fortunate aftertaste of the fact that PyPAN is still just a half-baked idea. But maybe an increasingly large standard library isn't totally practical. An alternative that I think would be very helpful is "application-targeted" distributions. For example, someone could make a "Numeric" bundle of Python, including NumPy and related modules; likewise, there could be a "webmaster" bundle. Of course, this takes a lot of time and effort for somebody to create and maintain. (ActiveState folks, are you listening?--given that you somehow make money by giving away software, the more software you give away, the more money you'll make .) half-baked-entrepreneurial-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 thomas at cintra.no Thu Jul 12 21:56:44 2001 From: thomas at cintra.no (Thomas Weholt) Date: Fri, 13 Jul 2001 01:56:44 GMT Subject: IRC library for Python? References: Message-ID: There are several modules available at www.vex.net/~x/parnassus, but I think only one implements DCC and more advanced stuff. Thomas "Steve Lamb" wrote in message news:slrn9kscq0.2ld.grey at teleute.dmiyu.org... > I've been doing some searching and haven't found anything on the web or > deja. Is there an IRC library akin to SMTP/POP/IMAP/NNRP/et al for Python in > existence? > > -- > 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 aahz at panix.com Wed Jul 11 11:53:27 2001 From: aahz at panix.com (Aahz Maruch) Date: 11 Jul 2001 08:53:27 -0700 Subject: Python speed References: <9ifjjh$1e3$1@news.mathworks.com> <3B4B562F.77C1B79@yahoo.com> <9ifo90$4hh$1@news.mathworks.com> Message-ID: <9ihspn$c3o$1@panix3.panix.com> In article <9ifo90$4hh$1 at news.mathworks.com>, jcm wrote: > >Well, I say this because I've written a mud engine in Python and it's >slow. Using this engine on a PII 266 running RedHat 6.1, 400 >wandering monsters (with nothing else going on in the mud) will peg >the cpu. In a production mud, you might want to do something >intelligent about wandering monsters (like have them stop wandering if >no players are nearby to save cpu-time), but there will also be lots >else going on. What we have here is a clear failure to communicate. Look, if you have *one* monster sitting in a computation-intensive loop, you're going to peg the CPU no matter what language you're using. The question is, how efficient and fast is each pass through the loop, and how responsive is the loop to external input? Don't make the mistake of measuring the wrong things. -- --- 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 "How come we choose from just two people for President but more than 50 for Miss America?" --AEN From sdm7g at Virginia.EDU Mon Jul 23 17:04:52 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Mon, 23 Jul 2001 17:04:52 -0400 (EDT) Subject: PEP0238 lament In-Reply-To: <15196.36169.246641.246117@beluga.mojam.com> Message-ID: On Mon, 23 Jul 2001, Skip Montanaro wrote: > The response was to your [Tim] statement: > > Tim> Indeed, nobody with a keen interest in numerics has bugged Guido > Tim> about this except Moshe, that I know of; the most visible repeated > Tim> pressures have come from educators using Python as a means to some > Tim> other end. > > Perhaps I was wrong about some of Guido's influences in this area. Anyone > doing 3D computer graphics whether in the context of engineering, computer > art or education has, in my mind, a keen interest in numerics in the sense > of "numerical analysis". They are going to do a lot of floating point math > and much less integer math. This was an issue for the Alice implementors, but it's not supposed to be for Alice users/scripters. The target users were arts majors, animators, writers, artists, etc. ( Don't know how well they found or served that audience, but that was the target -- not computer graphics gurus. BTW: Randy Pausch's Lab (when he was at UVA) had a photo of Doug Engelbart in one corner and Walt Disney in the other -- the "patron saints" of that project! ) -- Steve Majewski From mal at lemburg.com Mon Jul 2 06:08:53 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Mon, 02 Jul 2001 12:08:53 +0200 Subject: [Python-Dev] Support for "wide" Unicode characters References: <3B3BEF21.63411C4C@ActiveState.com> <3B3C95D8.518E5175@egenix.com> <3B3D2869.5C1DDCF1@ActiveState.com> <3B3DBD86.81F80D06@egenix.com> <3B3EA161.1375F74C@ActiveState.com> Message-ID: <3B404835.4CE77C60@lemburg.com> Paul Prescod wrote: > > "M.-A. Lemburg" wrote: > > > >... > > > > The term "character" in Python should really only be used for > > the 8-bit strings. > > Are we going to change chr() and unichr() to one_element_string() and > unicode_one_element_string() No. I am just suggesting to make use of the crispy clear definitions which the Unicode Consortium has developed for us. > u[i] is a character. If u is Unicode, then u[i] is a Python Unicode > character. No Python user will find that confusing no matter how Unicode > knuckle-dragging, mouth-breathing, wife-by-hair-dragging they are. Except that u[i] maps to a code unit which may or may not be a code point. Whether a code point matches a grapheme (this is what users tend to regard as character) is yet another story due to combining code points. > > In Unicode a "character" can mean any of: > > Mark Davis said that "people" can use the word to mean any of those > things. He did not say that it was imprecisely defined in Unicode. > Nevertheless I'm not using the Unicode definition anymore than our > standard library uses an ancient Greek definition of integer. Python has > a concept of integer and a concept of character. Ok, I'll stop whining. Just as final remark, let me say that our little discussion is a perfect example of how people can misunderstand each other by using the terms in different ways (Kant tried to solve this for Philosophy and did not succeed; so I guess the Unicode Consortium doesn't stand a chance either ;-) > > > 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. > > The user can view the data as UCS-2, UTF-16, Base64, ROT-13, XML, .... > Just as we have a base64 module, we could have a UTF-16 module that > interprets the data in the string as UTF-16 and does surrogate > manipulation for you. > > Anyhow, if any of those is the "real" encoding of the data, it is > UTF-16. After all, if the codec reads in four non-BMP characters in, > let's say, UTF-8, we represent them as 8 narrow-build Python characters. > That's the definition of UTF-16! But it's easy enough for me to take > that word out so I will. u[i] gives you a code unit and whether this maps to a code point or not is dependent on the implementation which in turn depends on the narrow/wide choice. In UCS-2, I believe, surrogates are regarded as two code points; in UTF-16 they always have to come in pairs. There's a semantic difference here which is for the codecs and these additional tools to be aware of -- not the Unicode type implementation. > >... > > 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. > > I wouldn't advise that you do all different types of normalization in a > single module but I'll wait for your PEP. I'll see if I find some time at the Bordeaux Python Meeting next week. > > 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. > > It has been proposed that there should be a module that handles > surrogates in narrow Python builds for programmers. If someone > wants to implement that, it will be another PEP. It might also be > combined with features that allow other kinds of character-, > word- and line- based indexing. Hmm, I liked my version better, but what the heck ;-) -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From stain at linpro.no Sat Jul 21 14:24:05 2001 From: stain at linpro.no (Stian Soiland) Date: Sat, 21 Jul 2001 18:24:05 GMT Subject: SocketServer and broken ThreadingMixIn - patch for 2.1.1c1 References: <3B559B80.4C8EDBE3@stroeder.com> Message-ID: * Michael Str?der spake thusly: | Stian Soiland wrote: | | I agree with Guido that it does not hurt to call close_request() | method more than once. Therefore your handler thread can easily call | close_request() without being incompatible to single-threaded | (checked it myself) or forking mode (did not check myself yet). But this ought to work both ways. Even if we always closing the connection after running the handler, nothing wrong will happen if a user's code closes the connection nicely in his (old-style) handler thread. The advantage is that existing code (like SOAP.py) can easily be made threaded without doing anything else than including ThreadingMixIn as a subclass. After all, isn't this what ThreadingMixIn is for? Why should we make a different approach for using threaded servers or not? This close_request()-thing is already a new thing, why not do it completely instead of forcing users to ignore this feature in their programs and do the closing themself? -- Stian S?iland - Trondheim, Norway - http://stain.portveien.to/ Hvorfor har jeg ingen kj?reste? Jeg kan ikke se noen god grunn. Folk som er langt mindre sympatiske enn meg har kj?rester. Idioter har kj?rester. Jeg burde absolutt hatt en kj?reste. [Loe] From gmcm at hypernet.com Sat Jul 14 15:20:00 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 14 Jul 2001 19:20:00 GMT Subject: Importing XML modules in py2exe or Installer? References: Message-ID: [posted and mailed] Gustaf Liljegren wrote: > Gordon McMillan wrote: [snip] >>Edit myscript.cfg and put packages=_xmlplus in the PYZ section. > > It don't work. Here's what I have done: [snip] > 5. Opened the jane.cfg file: > > [MYINSTALL] > type= INSTALL > name= Install_jane.exe > bindepends= jane.py > zlib = INSTALLZLIB > misc= MYSTANDALONE > debug = 0 > excludes = pywintypes, win32api > > [MYSTANDALONE] > type= STANDALONE > name= jane.exe > script= jane.py > zlib = APPZLIB > userunw = 0 > support = 0 > debug = 0 > > [APPZLIB] > name= jane.pyz > dependencies= jane.py > excludes= dospath, posixpath, macpath > > [INSTALLZLIB] > name = installzlib.pyz > dependencies = installutils > includes = installutils > excludes = dospath, posixpath, macpath > > Either these header sections are not documented as they appear, or I'm > looking in the wrong place. The Installer docs talk about PYZ, COLLECT, > CARCHIVE, STANDALONE, FULLEXE and INSTALL. Correct. Those are the "type=" lines. It defaults to ZLIB. (The actual names of the sections don't matter at all, so long as they're unique.) Since you mentioned py2exe, I assumed you were using Standalone (where you'd have only one PYZ section, called APPZLIB), since that's (roughly) the equivalent of py2exe. So put the line packages=_xmlplus in the APPZLIB section. - Gordon From bvdpoel at uniserve.com Fri Jul 13 19:23:36 2001 From: bvdpoel at uniserve.com (bvdpoel at uniserve.com) Date: Fri, 13 Jul 2001 16:23:36 -0700 Subject: How to use os.access()?? Message-ID: <3B4F82F8.D21C6EF3@uniserve.com> I'm trying to use os.access() in my program. But, I'm stuck trying to figure out the parms... obviously the first is the filename; but the 2nd is supposed to be a constant (?) like F_OK. Unfortunately, it doesn't appear that the F_OK, etc are defined anywhere. Either the docs are wrong (no way!), or I'm missing a module file (likely), or I'm just totally wrong about everything (quite likely!). Thanks. -- Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: bvdpoel at uniserve.com WWW: http://users.uniserve.com/~bvdpoel From pfenn at mmm.com Thu Jul 12 13:17:01 2001 From: pfenn at mmm.com (pfenn at mmm.com) Date: Thu, 12 Jul 2001 12:17:01 -0500 Subject: Language change and code breaks Message-ID: Tom> I *always* forget the 1/3 == 0 thing between programming bursts. Tom> OTOH, I also quickly remember after making the mistake the first Tom> time. What is it that reminds you of the mistake? Is it something glaring like using the result of 1/3 as a divisor and getting a divide-by-zero error, or is it something more subtle like getting slightly incorrect results and having to dig through your code to find the problem? -- Skip Montanaro (skip at pobox.com) It's usually easy to find using the primitive tests I set up. Typically, data starts out as floating point, so this behavior won't cause incorrect results. Instead, I get incorrect graph labeling, etc. However, this issue is going to keep coming up as a problem because it's not what an occasional user, even an experienced occasional user expects to happen, particularly with a dynamically typed language like Python. This is the only point on which I consider Visual Basics behavior to be "better" than Python's. Is there really much code that depends on 1/3 == 0 being true? Tom Fenn From arunramu at usa.net Mon Jul 2 00:59:27 2001 From: arunramu at usa.net (Blue whale) Date: 1 Jul 2001 21:59:27 -0700 Subject: os.popen(cmd,mode) question? Message-ID: Can anyone help me understand why I am not able to close() the pipe shown below. p = os.popen('vmstat 5') p.readline() # works p.readline() # works p.close() # does not work Is there a way I can get this to work. The command 'vmstat 5' produces output every 5 seconds, is there a way I can stop the command by just closing the pipe. can I force a pipe to be closed(will that kill the vmstat)??? Arun From piet at cs.uu.nl Fri Jul 27 04:13:30 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 27 Jul 2001 10:13:30 +0200 Subject: PEP0238 lament References: <18289ee4.0107261001.664eb547@posting.google.com> Message-ID: >>>>> david at boddie.net (David Boddie) (DB) writes: DB> So, if you're already resigned to that then just changing __future__ DB> to something else like DB> from __behaviour__ import float_division DB> would be just as easy, and wouldn't break existing code. This just won't work. The most important reason for the change in division is that people are caught by the integer division by surprise. So anything special that they have to do to get float division will not help. That's also the reason that it won't help to introduce // for the new behaviour and leave / for the old behaviour. I have an idea that might help the transition to become less painful: Like someone else noticed about the transition in LaTeX from 2.09 to 2e (\documentstyle vs. \documentclass): If python files for the 3.0 version and beyond could be recognized then at least old files will not be silently executed with the wrong semantics. So we could require that in Python 3+ python files have to start with: module name This doesn't even require module to be a keyword. name should be the same name to import the file (i.e. the filename). >From Python 3.0 onwards files without a module statement should no longer be accepted. These must be repaired, i.e. checked for integer divisions and a module statement added. So they can no longer silently break. In the transition period both forms should be acceptable with the old form finally producing warnings. The module declaration could also be given parameters to specify a specific behaviour, e.g. it could specify that this module wants the old integer division: module mymod (int_div). -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From aleaxit at yahoo.com Sat Jul 14 04:48:43 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 14 Jul 2001 10:48:43 +0200 Subject: LAMBDA IS IT USELESS? References: <9in61201nuf@enews1.newsguy.com> <3b4f6eb5.1832748462@wa.news.verio.net> Message-ID: <9ip0u401117@enews4.newsguy.com> "Bengt Richter" wrote in message news:3b4f6eb5.1832748462 at wa.news.verio.net... > On Fri, 13 Jul 2001 18:01:37 +0200, "Alex Martelli" wrote: > [...] > >or to the def. The ONLY difference is that lambda generates an > >anonymous function (and is an expression), while def generates a > >named function (and is a statement). > > In that case why not allow an anonymous version of def, e.g.., > > map( > def(x): > x**2 > ,xrange(5)) > > which would work like > > map( > lambda x:x**2 > ,xrange(5)) Judging from this sole example, the only difference here would be the inconsequential syntax sugar of WRITING def(x) vs lambda x -- who cares for such trifles? Very different would be if the def was still a statement (and particularly a compound statement, including other statements): in that case, its anonimity would be no use UNLESS one fundamental principle of Python syntax was abrogated -- no expression can include statements. If that were done, then there would be very wide-spread repercussions, needing a careful redesign of many apparently-unrelated things. > (OTOH you could make lambda multi-line ;-) lambda can be multi-line today. I.e., you're free to break the line after the ':' in the above example. Lines are not an issue. STATEMENTS vs EXPRESSIONS is the issue. Alex From piet at cs.uu.nl Mon Jul 23 09:59:51 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 23 Jul 2001 15:59:51 +0200 Subject: Name space quirk? References: <7b9380ca.0107220419.add15d1@posting.google.com> <7b9380ca.0107221047.43a4e97@posting.google.com> Message-ID: >>>>> Alex (A) writes: A> Hi, Gangadhar. I hope I'm addressing you appropriately. :) A> The issue there is that the "if __name__ == '__main__':" block is not A> executed when the module is imported, because in that case, "__name__" A> is bound to the name of the module, in this case, "nspace". As a A> result, in the "nspace" namespace, nothing is bound to "myfile", so the A> "myfile.write" command raises a NameError. The "global" keyword only A> means "global to the module" not "global to the entire program." The A> "myfile" you bound in the interpreter is in the "__main__" namespace. A> Try this version: A> #!/usr/bin/env python A> from os import sys A> def hello (outfile = sys.stdout): A> # We are writing to what should be an A> # unknown file descriptor: A> global myfile # <------- Added A> myfile.write ("Hello, world!\n") But why do you have a parameter outfile that you don't use. Don't you just means outfile.write()? -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From ajs at ix.netcom.com Tue Jul 31 04:15:06 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Tue, 31 Jul 2001 04:15:06 -0400 Subject: Changing the Division Operator -- PEP 238, rev 1.12 Message-ID: <000101c1199a$3c0800e0$a9e1fea9@carol> Paul writes - >* the real target for the newbie-friendliness is new programmers not >non-programmers. A language that is good for new programmers has a lot >of rules that they can easily remember and few pitfalls that they have >to store away in their heads. I agree with you 100% about who the target is/should be. But that is the *main* reason I disagreed with the VPython physics class finding as significantly relevant. Those were non-programmer findings, not beginning programmer findings. Perhaps I have a small point. I would assert we have no findings sited within the context of learning to program, and that your assertion about what is significant in that context is a not illogical, but nonetheless bald. I happen, BTW, not to think there is very much to it. But that is also bald. >if newbie-friendliness were the only issue, it would be probably not >enough. But even competent programmers can make non-robust code if there >is a big gap between the division statement and the provision of an >integer where a float is expected -- and even if there is NOT a big gap. If that is true, and the decision to go forward with the change is on that basis, I, for one, am at peace with it. ART From SBrunning at trisystems.co.uk Mon Jul 16 08:33:37 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Mon, 16 Jul 2001 13:33:37 +0100 Subject: Network able Chess Message-ID: <31575A892FF6D1118F5800600846864D78BE8B@intrepid> > From: elecfsh at yahoo.com [SMTP:elecfsh at yahoo.com] > For a while I have been wanting to write a little chess game that > can be played over a network w/ some simple chatting features. I want > to do this in Python, but I'm a little worried about doing the > graphics. Any suggestions as far as gamming libraries? or any standard > libraries I may have missed? Thanks. Have you looked at pygame? 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 sholden at holdenweb.com Mon Jul 9 07:44:48 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 9 Jul 2001 07:44:48 -0400 Subject: Integrating SimpleHTTPServer into asyncore References: <3B491961.12A83FE5@alcyone.com> Message-ID: "Erik Max Francis" wrote ... > Is there a standard way to integrate SimpleHTTPServer (and related > classes) into the asyncore poll loop, or is it just the rather obvious > process of creating a dispatcher that containers a SimpleHTTPServer and > delegates all the relevant asyncore methods to SimpleHTTPServer? > > Thanks. > No. The HTTPServer classes simply aren't written asynchronously in that way. You could probably use a lot of the code, but the two frameworks are incompatible in the use they make ofthe socket, and would fight each other. regards Steve -- http://www.holdenweb.com/ From Peter.Biela at planet-interkom.de Thu Jul 5 15:12:34 2001 From: Peter.Biela at planet-interkom.de (Peter Biela) Date: Thu, 5 Jul 2001 21:12:34 +0200 Subject: There's got to be an easy way to do this References: Message-ID: Hi Greg, you should be able to use simple a opertaion vom the re Modul, using regular expresion syntax. This line, should return you a string from which any non Digits '\D' were substituted by '', phone_number is your original string upon, which the sub methode is used! import re stripped_phone = re.sub('\D','',phone_number) I hope, this works! Peter Biela From philh at comuno.freeserve.co.uk Tue Jul 10 08:51:23 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Tue, 10 Jul 2001 13:51:23 +0100 Subject: license suggestions? References: Message-ID: On Tue, 10 Jul 2001 07:32:13 GMT, Lee Morgan wrote: > >Hi, > >Forgive my naivety, but ... > >Has anyone proposed the idea of having a timebomb license? > >Similar to drug companies control of new drugs to a market. ie you get >8 years to develop and market your new drug but after that its open >season. (I'm not wholly certain how this works - and 2 years or less is >probably more applicable for software). I've advocated that idea on Usenet previously. >Wouldn't this prevent shrewd business men like Gates gaining runaway >monopolies and yet allow commercial r&d to contribute to technological >innovation? ie You get 2 years to recoup your investment and then the >license drops to GPL or something. Indeed. it has been used commercially by Alladin bto produce Ghostscript. >Also this would probably require legislating software companies - >which I can't imagine happening. The copyright term for software could be limited to, say, 10 years. -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From Tom_Good1 at excite.com Mon Jul 23 12:57:09 2001 From: Tom_Good1 at excite.com (Tom Good) Date: 23 Jul 2001 09:57:09 -0700 Subject: Partition Problem References: <9iv5e9$bru$1@newsg1.svr.pol.co.uk> <0oR47.12485$p7.4220508@news1.rdc2.pa.home.com> Message-ID: Duncan Booth wrote in message news:... [snip] > Followed by the 'how to iterate over all permutations of a sequence'. BTW, > the 'return' statement isn't actually needed, but I think it makes the code > a bit clearer. > --- begin --- > # Permutations using generators. > from __future__ import generators > > def permute(seq): > if len(seq)==1: > yield seq > return > > for i in range(len(seq)): > for perm in permute(seq[:i] + seq[i+1:]): > yield seq[i:i+1] + perm > > def test(str): > for t in permute(str): > print t > > test('bar') > test('flip') > test([1, 2, 3]) > --- end --- Bravo! That's a good one. When you say you prefer having the "return" in there, is your purpose to emphasize that execution does not "fall through" the first "yield"? Tom From martin at strakt.com Thu Jul 26 10:13:34 2001 From: martin at strakt.com (Martin Sjögren) Date: Thu, 26 Jul 2001 16:13:34 +0200 Subject: Submodules in dynamic modules? In-Reply-To: References: Message-ID: <20010726161334.A31154@strakt.com> On Thu, Jul 26, 2001 at 09:59:47AM -0400, Steven D. Majewski wrote: > > > On Thu, 26 Jul 2001, Martin Sjgren wrote: > > > Is there a standardized way to use submodules in a dynamic module written > > in C? I have a module (foo) that should have a few submodules in it, foo > > by itself won't contain much at all, but it's nice to group things up in > > submodules, so I could do > > > > from foo import bar > > > > or > > > > from foo import bar, baz > > > > The way I'm doing it right now is that I've more or less copied the source > > code from Py_InitModule4() to set things up, and then insert the module > > object into the dictionary. > > I don't know if there's a standard way and I don't know if it's better, > but what I have done is to define the macro: > > #define ADD_MODULE(x) if (-1 == \ > PyModule_AddObject( m, (x), PyImport_ImportModule((x)))) return NULL > > > And in Carbonmodule.c (for MacOSX) where I have a whole bunch of these > submodules, I have: > > m = Py_InitModule("Carbon",CarbonMethods ); > > (void) initWin(); > ADD_MODULE("Win"); > (void) initMenu(); > ADD_MODULE("Menu"); > (void) initEvt(); > ADD_MODULE("Evt"); > (void) initDlg(); > ADD_MODULE("Dlg"); [snip] I'm not sure we're talking about the same thing here. I don't want to import other Python modules, I want to have several submodules in my one C library file (foomodule.so on unix). I guess I COULD have several .so files and import them like you do here, but that would be unnecessarily complicated! Thanks for your input anyway. :) Martin -- Martin Sj?gren martin at strakt.com ICQ : 41245059 Phone: +46 (0)31 405242 Cell: +46 (0)739 169191 GPG key: http://www.strakt.com/~martin/gpg.html From fredrik at pythonware.com Mon Jul 9 18:11:01 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 09 Jul 2001 22:11:01 GMT Subject: PEP: Procedure for Adding New Modules (please comment) References: <9hvqhr$gj2$1@newshost.accu.uu.nl> <3B49F9EC.CA10886A@yahoo.com> <3B4A1AE3.BB23C0E1@yahoo.com> Message-ID: Paul Winkler wrote: > I based my suggestion (doctest at minimum, preferably unittest) on the note at > the end of the documentation for doctest: > > """ > The first word in doctest is "doc", and that's why the author wrote doctest: to > keep documentation up to date. It so happens that doctest makes a pleasant > unit testing environment, but that's not its primary purpose. > > Choose docstring examples with care. There's an art to this that needs to be > learned -- it may not be natural at first. Examples should add genuine value > to the documentation. ... > """ for the record, I strongly prefer doctest over unittest also for "real" unit testing (sorry, steve ;-). the trick is to use doctest not only to make sure the module's docstrings are up to date, but more importantly, to make sure that your test programs work as documented! here's an excerpt from SRE's doctest-based test program: def check(pattern, string, *groups): # pattern, string to match, zero or more groups to check r''' # Test ?P< and ?P= extensions >>> check('(?P>> check(r'([ac])+x', 'aacx', 0, 1) ('aacx', 'c') ''' p = re.compile(pattern).match(string) if m: return apply(m.group, groups) return None with this approach, I write tests many times faster than with any other framework -- mostly because I can focus on writing code that exercises the library, without really having to think much about how to verify the results: just print them out, run doctest once, make sure the output look right, copy it into the test script, and you're done. (if I wanted to use tools that required me to think hard all the time, I wouldn't use Python in the first place ;-) Cheers /F From sill at optonline.net Tue Jul 24 18:31:01 2001 From: sill at optonline.net (Rainy) Date: Tue, 24 Jul 2001 22:31:01 GMT Subject: timed event?? References: Message-ID: On Mon, 16 Jul 2001 09:09:31 -0500, NJM wrote: > I want to write a program that does things on a timed basis. Can someone > tell me where is the best place to start? I can't seem to find any modules > that will help me. > > time and sched modules. -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: http://silmarill.org/cymbaline From tim.one at home.com Thu Jul 5 00:25:59 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 5 Jul 2001 00:25:59 -0400 Subject: Tkinter, Sleep and threads In-Reply-To: <3b3827f0.1058042@nntp.ix.netcom.com> Message-ID: [Mike Clarkson] > 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%. Did you measure this? I measure idle Tkinter apps on Windows using from 0% CPU when in the background, to about 0.20% when foreground and they need to blink a cursor at me. Yes, it may wake 50 times per second, but it consumes only enough cycles for Tcl_DoOneEvent(TCL_DONT_WAIT) to report there's nothing to do, and then goes straight to sleep again. If you're measuring 5%, something sounds hosed on your box. > 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.) The Tcl_DoOneEvent call is in the scope of Py_BEGIN_ALLOW_THREADS ... Py_END_ALLOW_THREADS brackets, so other Python threads run independently of what Tk is doing. How signal handlers work in the presence of threads varies widely across platforms. For the rest of this, you're going to have to get the attention of Fredrik and Guido; making Tk work vaguely nicely *at all* in the presence of threads was a multi-year effort (although I doubt it accounted for 5% of their mental cycles the whole time ). > ... > (BTW, what is the difference in Python-C-API between Tkapp_MainLoop > returning NULL and returning Py_None? I'm not a C programmer). Throughout the C API, a NULL return means an error occurred, while a Py_None return is "normal". From chrishbarker at home.net Mon Jul 30 13:44:54 2001 From: chrishbarker at home.net (Chris Barker) Date: Mon, 30 Jul 2001 10:44:54 -0700 Subject: PEP 238 (revised) References: <3B61C0B0.30477AFB@home.net> <3b62459e.609746999@wa.news.verio.net> Message-ID: <3B659D16.5E52DE63@home.net> Bengt Richter wrote: > >What I don't get, is why // couldn't return an integer always? It will > >always have an integral value. I suppose one problem is that the range > >of integers that a float (C double) can handle is larger than a 32 bit > >integer can hold. This could be solved in the future with int/long > >inification, what will be the behaviour then? > > > I think it has to do with being consistent with the idea of using the > representation type as an indicator of exactness. > > Using that idea, float is a visible name and means inexact, > and int and long are visible and mean exact. > > Floor can't turn inexact to exact, so it must return inexact (i.e., float) > if it gets an inexact (i.e., float) input. > > int(x) will effectively be an exactness coercion because of the > representation-type linkage. I'll buy that. In fact, I like that a lot. The problem, for me, is that 1.0 can't be used as a sequence index. While it may not be know whether x//y is an exact value, it IS know that it is an integer value, and should therefor be usable as an index. This brings up the usefulness of the concept of the inexact integer. I'm also not so sure about your above rational: While I do understand that the result of x//y may not be an exact number, given that x and/or y may not be exact, the question is: does that matter? Acn anyone think of a case where they would use // (or floor, or ceil, or round) when it would hurt for the final result to be considered exact? -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 James_Althoff at i2.com Fri Jul 13 16:24:37 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Fri, 13 Jul 2001 13:24:37 -0700 Subject: not safe at all Message-ID: Dennis Roark wrote: >For amusement, run this little script which demonstrates a >near ultimate in the lack of type safety in the language. >(Perhaps there is a bit of type safety in that you can't do >this: 4 + "one") But look at what you can do in the >following script: > >x = 3 >x = x + 2 >print "x =", x >x = "now I'm a string" >print x >x = [ 5, x ] >print "and now a list:", x > >If you don't believe it, run it. Should any language allow >x to be such a chameleon, to where it can even be a >different type on two sides of an assignment? Absolutely!!! Each value is a perfectly good object, so why not? (The variable "x" references an "object" :-). Side note: see what a Java compiler allows you to put into a collection and then consider the same issue. Jim >--------------------------------- >Dennis Roark >Dept. of Computer Science >University of Sioux Falls From rnd at onego.ru Thu Jul 5 06:03:30 2001 From: rnd at onego.ru (Roman Suzi) Date: Thu, 5 Jul 2001 14:03:30 +0400 (MSD) Subject: Python for air traffic control? In-Reply-To: Message-ID: On Thu, 5 Jul 2001, Roman Suzi wrote: >>If it's the latter, then perhaps type checking can be done under >>certain reasonable restrictions. Whatever the case, I want to have my >>cake and eat it too. :-) > >You can add asserts to whatever places to check types: > >from types import * >def add_int(x, y): > assert type(x) is IntType and type(y) is IntType > return x+y > >I can't see how static type-checking could eliminate more >problems than create, though. Ooops! When I read it second time I understood my stupidity saying this. Large program such as ATC need not be to be implemented in one language! So there are certain tasks (like system administration) which could be done better with Python than Ada. Also, for some code rule-oriented languages could be used to add some AI. So, it's not a single-choice! Python could also be useful for arranging testing data because of it's text-processing capabilities. Etc. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Thursday, July 05, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ ">From the Department of Redundancy Dept." _/ From paulp at ActiveState.com Sat Jul 28 20:14:38 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sat, 28 Jul 2001 17:14:38 -0700 Subject: FEEDBACK WANTED: Type/class unification References: Message-ID: <3B63556E.11047A21@ActiveState.com> William Tanksley wrote: > > On Sat, 28 Jul 2001 13:07:32 -0700, Paul Prescod wrote: > >2. If I have an object that hides its attributes behind an __getattr__, > >is there any way to tweak the list returned by the API described above? > > Not without the object's cooperation -- it's not even theoretically > possible to figure out what attributes __getattr__ might support. I am asking whether there is a way for the object to cooperate. >... > >def attrs(x): > > return [y for y in all_possible_strings if hasattr(x, y)] > > Yes, that would work, for certain values of "work". all_possible_strings > is a pretty simple generator. So is attrs(), actually. > > def attrs(x): > for y in all_possible_strings(): > if hasattr(x,y): yield y > > Amusing. I wasn't being theoretical. I was asking whether there is a function, method or parameter with those semantics (and obviously a more sane implementation). -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From gilesc at hyperlink-interactive.co.uk Mon Jul 2 06:45:24 2001 From: gilesc at hyperlink-interactive.co.uk (Giles Constant) Date: Mon, 02 Jul 2001 11:45:24 +0100 Subject: Singleton classes (with no such thing as static variables) Message-ID: Hi there, Being a C++ head, it's probably more a problem with my design than a python problem, but I figured you guys would be able to help. I'm trying to make a class called "Environment" which will store some global data such that all instances of the class have access to it. The alternative is to create a single instance and pass it around every single object in the entire project, but it gets used so frequently that it would be rediculous. Is there a way of doing this, or do I need a new paradigm? :-) From sh at ttsoftware.co.uk Fri Jul 20 06:51:05 2001 From: sh at ttsoftware.co.uk (Steve Horne) Date: Fri, 20 Jul 2001 11:51:05 +0100 Subject: Python 2.2 alpha - generators test Message-ID: I've been playing with the Python 2.2 alpha, found it to be pretty reliable so far, and I've fallen in love with the iterators and generators. However, I did find what I think is a problem in the test_generators.py (sorry if the filenames slightly wrong) file. I was looking at the 2**i * 3**j * 5**k problem, and decided to try my own approach. I reached a point where I needed essentially a duplicate-removing priority queue (if such a thing exists) but I couldn't be bothered revising my heap theory so temporarily I decided to just merge the new items into a simple ordered list. I remembered a generator called merge or xmerge or something, and decided to borrow that to get the initial version running quickly. Trouble is, it didn't work at all. Looking back at the merge function, I realised that when either one of the input generators is exhausted the generator terminates immediately - it does not pass on the remaining items from the other generator. In fact, if one of the input generators ends immediately (empty list), no items will be output at all irrespective of the number of items the other generator could generate. I'm not sure of the implications in the algorithm it was used in (which I didn't fully understand), but it is certainly incorrect for merging two ordered sequences - which is what it appeared to be - and is certainly what caused my problems. Is this a real bug, or just a case of me jumping to daft conclusions about what the generator was meant to do? BTW, sorry about the vague names - I only have that Python version installed at home. -- Steve Horne Home : steve at lurking.demon.co.uk Work : sh at ttsoftware.co.uk From paulp at ActiveState.com Sun Jul 15 15:48:08 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sun, 15 Jul 2001 12:48:08 -0700 Subject: PEP: Defining Unicode Literal Encodings (revision 1.1) References: <3B4F6E98.733B90DC@lemburg.com> <004c01c10be8$af2face0$4ffa42d5@hagrid> <3B4F746C.827BD177@lemburg.com> Message-ID: <3B51F378.7DC06482@ActiveState.com> "M.-A. Lemburg" wrote: > >... > Since Python source code is defined to be ASCII, the Unicode literal > encodings (both standard and raw) should be supersets of ASCII and > match the encoding used elsewhere in the program text, e.g. in > comments and maybe even 8-bit strings (even though their encoding > is only implicit and completely under the programmer's control). Python programmers do not read PEPs to learn how to use new features. I think it makes the whole thing much simpler if we define it on the file level explicitly. To me, the feature is most helpful if it helps the interpreter and various code inspection tools to understand all of the non-ASCII information in the file. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From newgene at bigfoot.com Mon Jul 2 16:59:24 2001 From: newgene at bigfoot.com (newgene) Date: 2 Jul 2001 13:59:24 -0700 Subject: run activepython v2.1 from a folder? Message-ID: I'am trying to run activepython v2.1 from a folder on my zip disc so that I can use it at the public PCs. I can not install activepython successfully without the administrator previledge. First, I put all possible pathes into "PYTHONPATH", and use a bat file to set it before running pythonwin.exe. This is my batch file(pywin.bat): @set PYTHONPATH=d:\python21;D:\Python21\Bio;D:\Python21\DLLs;D:\Python21\Lib;D:\Python21\libs;D:\Python21\PPM;D:\Python21\Pythonwin;D:\Python21\win32;D:\Python21\win32\Lib;d:\python21\lib\plat-win;d:\python21\lib\lib-tk; @start D:\Python21\Pythonwin\pythonwin.exe @exit Second,I copied three dll files( python21.dll,pythoncom21.dll, PyWinTypes21.dll) from system32 into my folder(d:\python21). Then I can import win32ui under command line(python.exe). When I ran pywin.bat, pythonwin GUI interface appears, but raises a error as: File "e:\python21\pythonwin\pywin\framework\intpyapp.py", line 163, in InitInstance import interact File "e:\python21\pythonwin\pywin\framework\interact.py", line 26, in ? import winout File "d:\python21\pythonwin\pywin\framework\winout.py", line 26, in ? from pywintypes import UnicodeType exceptions.ImportError: No module named pywintypes Is it possible to solve this problem and run the activepython v2.1 from a folder independent on system registry? Thank you Newgene From grante at visi.com Mon Jul 23 10:55:40 2001 From: grante at visi.com (Grant Edwards) Date: Mon, 23 Jul 2001 14:55:40 GMT Subject: PEP0238 lament References: <9jhbfj$79s$1@pea.uk.research.att.com> Message-ID: In article <9jhbfj$79s$1 at pea.uk.research.att.com>, Duncan Grisby wrote: >The reality is that the whole world will not switch Python versions >overnight, so everyone who maintains a library will have to face this >issue. I maintain a couple small applications that have to support 1.5.2 and up. There must be plenty of people in the same spot. -- Grant Edwards grante Yow! My polyvinyl cowboy at wallet was made in Hong visi.com Kong by Montgomery Clift! From deltapigz at telocity.com Mon Jul 9 22:56:45 2001 From: deltapigz at telocity.com (deltapigz at telocity.com) Date: Mon, 09 Jul 2001 22:56:45 -0400 Subject: pinging in python? Message-ID: <3B4A6EEC.548A29FD@telocity.com> could anyone point out to a simple code of pinging a computer; just toping it and get the results; nothing fancy. i have found source codes along the line but its all too overwhelming, and im still a complete newbie despite my half decent understanding of python. thanks in advance, Adonis From max at alcyone.com Mon Jul 23 02:45:00 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 22 Jul 2001 23:45:00 -0700 Subject: Alternate numeric proposal References: Message-ID: <3B5BC7EC.3FD6932@alcyone.com> Chris Gonnerman wrote: > > I have been following (and participating) in the integer division > argument for some time (and a divisive one it is, too), and while > standing in the shower (really!) an idea came to me. > > Why don't we add a hook to Python to control the numeric evaluation > rules directly? ... > The module writer says, HEY, what about me? I need consistent math > in my module! That's exactly the problem here. One of the primary reasons people are objecting to the change is because it means a fundamental change in the core language: a builtin operator behaves differently. The solution is not generalizing all builtin operators, certainly -- that makes the problem infinitely worse. -- 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 stronger in the world than gentleness. \__/ Han Suyin Erik Max Francis' bookmarks / http://www.alcyone.com/max/links/ A highly categorized list of Web links. From qrczak at knm.org.pl Sun Jul 29 04:26:51 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 29 Jul 2001 08:26:51 GMT Subject: stat st_rdev in python References: <9jsop4$si0$1@netra.msu.montana.edu> Message-ID: Sat, 28 Jul 2001 03:48:05 GMT, Grant Edwards pisze: > If I had more time, I'd fix up the Posix library and submit a patch... AFAIK st_rdev is not defined by POSIX. Glasgow Haskell's Posix module lacks it too. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From QSB at QRM-QRN.net Sun Jul 29 19:02:44 2001 From: QSB at QRM-QRN.net (Allodoxaphobia) Date: 29 Jul 2001 23:02:44 GMT Subject: Try floating the Back Orifice's dumb PGP and Willy will recycle you! References: Message-ID: On Sun, 29 Jul 2001 22:27:33 GMT, Nick Perkins scribbled: >I laughed at the first one of these I read, >thinking it might be the result of a python program, >but now I have noticed that they are popping up >on other newsgroups, too, all from different names. >Once is funny. Twice is spam. >I have seen four or five today. Take a look in news.admin.net-abuse.email, if you think "...4 or 5..." might be a nuisance. And, trim your posts. Especially if you know them to be trash. tnx. -- | Marvin L Jones | jonz | W3DHJ | OS/2 | Gunnison, Colorado | @ | Jonesy | linux __ | 7,703' -- 2,345m | frontier.net | DM68mn SK From philh at comuno.freeserve.co.uk Thu Jul 19 19:58:23 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Fri, 20 Jul 2001 00:58:23 +0100 Subject: Language change and code breaks References: <9j66an$3bm02@owl.le.ac.uk> Message-ID: On Thu, 19 Jul 2001 12:56:06 GMT, Nick Efford wrote: > >I can appreciate some of the arguments made in favour of a case- >insensitive Python, but there are times when we give meaning to case >in written English: "python" is the snake, but "Python" is the >programming language; "latex" is a material, "LaTeX" is a markup >language for document typesetting; "mud" is something you get on your >shoes, but a "MUD" is something entirely different. I would much >prefer it if Python continued to allow the distinctions we make in >written language to be preserved when coding. I hope you don't use identifiers that differ only in case. BTW, I am happy to use the uncapitalised versions of all the above to rever to the capitalised meanings. >My other worry over case insensitivity is that it creates >opportunities for poor style by allowing the inconsistent use >of case. Into bondage and discipline are we now? -- #===== Philip Hunt == philh at comuno.freeserve.co.uk ======# Herbivore: effort-free public key encryption. See: ** First software release coming soon! ** From tundra at tundraware.com Mon Jul 23 15:20:01 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 23 Jul 2001 19:20:01 GMT Subject: A use for integer quotients References: <3b5c65cf.224345241@wa.news.verio.net> Message-ID: <3B5C7847.EA60FE59@tundraware.com> Bengt Richter wrote: > > On Mon, 23 Jul 2001 11:46:45 GMT, Guido van Rossum wrote:> > > What about mandatory version/requirement marking of code depending > on new features of 2.2 and beyond? > > This would introduce *now* the possibility of using 2.1 rules for unmarked > code, and allowing progress without backwards-compatibility pain[1]. > > Perhaps a requires statement keyword with syntax like print? E.g., > > requires {'Python':'2.3', 'math':'2.4','division':('unified','warn') } > > or short form could be distinguished by arg type > > requires 2.3 This is a *really good* idea. Although I am new to Python, I am not new to very large development projects. This ability to stipulate the minimum required runtime environment could go a long way to mitigate upgrade and release nightmares. I would only suggest that such a keyword: - Have "at least" semantics so that later versions would satisfy the 'requires' as well. - Be generalized so that any module author could apply the same thing to their module independent of all other modules (I think you were hinting at this above.) - Be optional, which would mean that anything works. > All the good arguments on both sides of the '/' question are making me > feel wishy-washy, as I sympathize in alternation, but I do find the > backwards compatibility argument compelling. HTH. > > [1] Other than for implementors ;-) I worry about all this on two levels: - As an architectural matter, new behavior should have new operands, IMHO. - As I said, I'm new to Python, but I've seen a ton of languages come and go. There seems to be a point at which all languages start getting burdened with "boutique" features that clutter up the overall paradigm in favor of rather specialized actions. It seems to be human nature to never leave well enough alone. Python has an extremely elegant structure, and I worry that it too will become burdened with nice, but ugly appendages thereby undermining the cohesion of its initial design. It seems to me that the energy to innovate would be better spent adding more "batteries included" modules to a core lanugage that is stable and remains so. 'C' for example, largely stayed the same until ANSI X3J11 (of which I was an Observing Member). Even there, the initial intent to codify existing practice got polluted somewhat when various factions tried to get their pet semantics plugged into the new standard. Speaking as someone who leads commercial development and architecture organizations, the adoption of any new technology or language is as much or more about stability than it is feature set. The Python community could really distinguish itself here, and thereby garner lots of new converts, if we resisted the feature-of-the-month-club that has characterized Java and Perl, for instance. Just my 2 cents worth... -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From gerhard.nospam at bigfoot.de Mon Jul 2 18:09:44 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Tue, 3 Jul 2001 00:09:44 +0200 Subject: Postgres support References: Message-ID: On Mon, 02 Jul 2001 16:25:20 -0400, robin at illusionsexeculink.com wrote: >[...] >With Python I'm left scrambling around trying out different half-done >modules. > >This is a significant barrier to Python adoption. Until Python ships >with modules for each major database it will not be a mature tool for >many users. Java "ships" with a broken JDBC implementation for ODBC. Everything else you'll have to download and install yourself. >As an example, I would like to find a cross-platform (Linux, Windows, >etc.) Postgres interface that works with Python 2 or greater and >Postgres 7 or greater, conforming to the dbAPI. Not too much to ask, >one might think. >I've found these four candidates, but judging by their sometimes >sparse web sites, none fit the bill. But I could be wrong. I can't comment on conformance to the DBAPI 2 or stability, because I usually don't use advanced database stuff. >PyGreSQL -- http://www.druid.net/pygresql/ This one is now in PostgreSQL CVS. The most recent version is the one from PostgreSQL 7.1.2 (PyGreSQL 3.2), even if the website doesn't tell you, Windows is now supported (you can download a binary distribution from my homepage or build yourself). >psycopg -- http://initd.org/Software/psycopg It seems to be optimized for heavily threaded applications. It looks quite good and well thought-out. Unfortunately, it makes much use of Unix libraries, so it was too difficult for me to port it to Windows. Plus, I am no great fan of GPL'd Python libraries. >PoPy -- http://popy.sourceforge.net/ The new Nekhem website still doesn't work ... >PyPgSQL -- http://www.sf.net/projects/pypgsql Looks very good to me and is progressing fast. The CVS version supports Windows, too 8-) (you'll need to compile with gcc, Visual C++ won't work due to lack of "long long" support). If you want to try this on win32, you'll need a post-7.1.2 PostgreSQL patch from CVS (the file libpq.def). Or you can ask me in PM and I can provide a working win32 version. It looks like libpq wasn't used very much on Windows, there is at least one unsolved issue on win32 (affects everything using libpq, including PyGreSQL and PyPgSQL). 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 fredrik at pythonware.com Sat Jul 14 04:25:26 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 14 Jul 2001 08:25:26 GMT Subject: LAMBDA IS IT USELESS? References: <9in61201nuf@enews1.newsguy.com> <3b4f6eb5.1832748462@wa.news.verio.net> Message-ID: Bengt Richter wrote: > In that case why not allow an anonymous version of def, e.g.., > > map( > def(x): > x**2 > ,xrange(5)) you forgot something: map( def(x): return x**2 , xrange(5)) Cheers /F From m.faassen at vet.uu.nl Wed Jul 4 17:54:39 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 4 Jul 2001 21:54:39 GMT Subject: New PEP: Quality Guidelines For Standard Modules References: Message-ID: <9i03av$c2e$3@newshost.accu.uu.nl> Carlos Ribeiro wrote: > I've got some very good comments on my PEP-to-be. The main concerns are: > - we need to reference the style guide > - the use of tools such as PyCheck should be encouraged > - and yes, my english needs some quality checking also :-) Did you add stuff like '(unit) tests are good'? Very important in my opinion. > I'm going to work on it tonight. Too bad I have a day job . As of > now, I'm still waiting for Martin's proposed PEP2 text - it seems that he > still needs to get either Barry Warsaw or ESR approval on this, mainly > because he's taking over an existing but unfinished PEP. I feel that we're > talking about complementary issues, and it would be very important to be > working together. Definitely. I've just posted my version of PEP 2 after getting an okay from ERS. You also should have received a copy by mail, did it not arrive? I sent it to you earlier, I think monday. And yes, I feel the two are pretty complementary, so that's good. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From garrett at cs.colostate.edu Tue Jul 31 01:21:01 2001 From: garrett at cs.colostate.edu (Deon Garrett) Date: Tue, 31 Jul 2001 05:21:01 GMT Subject: problem with re.rearch References: Message-ID: On Tue, 31 Jul 2001 09:03:36 +0800 (CST), sdf wrote: > since s=abcd ,then I search 'a' in s > the result must be true > but why the result is nono > >>>> a=re.compile(s) >>>> b=a.search('a') >>>> print b > None >>>> print s > abcd Unless you've lost me somewhere, you're describing something like this: s = 'abcd' a = re.compile (s) b = a.search ('a') which means, "find a match of the pattern 'abcd' in the string 'a'.... probably not what you mean. The "None" simply indicates that there is no instance of 'abcd' in 'a'. What you want here, is s = 'a' pat = re.compile (s) b = pat.search ('abcd') > __________________________________________ > DVD??????????10?? http://shopping.263.net/category02.htm > ?????????????????????? http://shopping.263.net/category10.htm > > > > > From aleaxit at yahoo.com Thu Jul 5 08:10:58 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 5 Jul 2001 14:10:58 +0200 Subject: Python for air traffic control? References: Message-ID: <9i1lgh02ei0@enews1.newsguy.com> "Delaney, Timothy" wrote in message news:mailman.994291089.9857.python-list at python.org... > > But the best & highest-motivated guru can only do so much if > > hampered by too-heavy process, inadequate tools, &c. And one > > can't always choose (client needs given process and tools, but > > This bit I agree with wholeheartedly Who wouldn't?-) > > motivation is high anyway e.g. because of VERY good $$ bonus... > > that still doesn't give the same productivity as when process > > and tools are optimally chosen). > > And this I don't. Maybe I didn't express myself well then! (Or maybe different people have different motivations:-). > I've found that I've rarely been motivated to perform well in a project > based on the $$$ I was to receive for it (when I was a contractor). Once I > accepted how many $$$ I was getting, that was the end of it (after that, the I'm talking of a _bonus_ -- in the conditional sense of the word; $$$ you aren't going to get unless (insert acceptance criteria here that are related to quality, performance, timeliness, &c, of the product). > money is uninteresting and indeed annoying because you have to chase it). Most people find money interesting _indirectly_ -- for what you can get by SPENDING it, rather than in and by itself. In my case, I have more money than I can spend (with my reasonably-frugal lifestyle), but it's a family thing -- in a few centuries' of recorded family history, there's a very clear family-memory of who gave a positive net contribution to the family's fortunes, and who left the coffers emptier than they found it -- and I know what side of the ledger I want to be in when some distant descendant thinks about me in a few more centuries' time. Of course it's not JUST money -- one of my great-grandfathers was a painter, and now that they've restored some of the decoration work he did a bit more than a century ago in some of Bologna's prettiest public arcades, I do particularly enjoy going to sit at a cafe there and slowly sipping a good dry martini while enjoying greatgrandpa's handiwork on the ceilings -- even though he WAS a rake, and wasted quite a bundle of money chasing after chanteuses and buying them jewels &c [they didn't call it "Belle Epoque" for nothing:-)]. But I doubt any of my actual _work_ will be around for great-grandkids to admire a century from now, so...:-). > etc) then I tend to work better. Note: casual clothes is not an option - I > have *never* worn a tie or trousers in my professional career, and I never Can't say that myself, since I spent so many years at IBM (but mostly IBM _Research_, so I stuck out a lot with silk suits & ties -- so call it a personal quirk:-). But these days I've changed style... > will. The most formal I've gone to is to wear a button-up shirt at one > place, but that won't happen again. Unfortunately, I've yet to find a place > that will let me work in boxer shorts like I do at home ... :) They wouldn't raise eyebrows here (well, not in the summer -- it DOES get cold in Bologna in winters!-). Anyway, my point (money & clothing aside) was intended to be a pre-emptive move to show one CAN still (sometimes) be highly motivated DESPITE having to use a too-heavy process and tools that are far from optimal!-) Thus separating to some extent the three classes of factors (that do interplay quite a bit): -- individual skill, knowledge, &c -- motivational factors (money, project-interest, whatever) -- quality of environment/tools (process, language, &c) I think the magic spot is hit when ALL THREE factors are big plus, and THEN productivity can soar to crazy heights. Pity (an aside...) that when we estimate delivery times we seem to tend to BET on optimal spots for everything & 1/2...:-). Alex From fspcxh at my.com Fri Jul 6 20:38:13 2001 From: fspcxh at my.com (fspcxh at my.com) Date: Sat, 07 Jul 2001 00:38:13 GMT Subject: Check This Out!!! 5264 Message-ID: Check out our new store at www.our-superstore.com bbkutkxljwspn From ullrich at math.okstate.edu Thu Jul 12 10:19:41 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Thu, 12 Jul 2001 14:19:41 GMT Subject: Language Shootout References: <3b4b04fb.1257683@nntp.sprynet.com> <3b4bab70.1586151915@wa.news.verio.net> <3b4c647e.2934740@nntp.sprynet.com> <3b4ca7bc.1650739848@wa.news.verio.net> Message-ID: <3b4db02f.401207@nntp.sprynet.com> On Wed, 11 Jul 2001 20:17:27 GMT, bokr at accessone.com (Bengt Richter) wrote: >On Wed, 11 Jul 2001 14:48:13 GMT, ullrich at math.okstate.edu (David C. Ullrich) wrote: >[...] >>>On my system I get >>> >>>[18:47] C:\pywk\fib>strL.py str 10L**20899 >>>str took 13.601617 seconds >>> >>>[18:47] C:\pywk\fib>strL.py strL 10L**20899 >>>strL took 1.044989 seconds >>> >>>Recursion rides again ;-) >> >>Recursive or not, the idea that we can write >>a replacement for str that's faster is very >>curious. >> >Well, it's a seldom-used aspect of str to print >monster longs. They surely had more urgent things to do ;-) Certainly - I wasn't meaning to say that they were bad or I wanted my money back or anything. It _is_ curious nonetheless. >>>BTW, how do you put everything inside the strL def >>>to hide names, and how do you recurse inside without >>>a warning message? >I'm leaving this question in ;-) Ok, I'll leave it in too then; maybe someone who knows what they're talking about will have a hint. >[...] >> >>Of course you have to do the recursion in a non-stupid >>manner, as here; if you'd made a recurzive routine >>that concatenated Python strings instead of building >>that list I doubt that recursion would win. But it is >>curious how often recursion does seem to win in Python. >>(Doesn't usually beat built-in functions, though.) >> > >I hope people realize what you are pointing out, >i.e., that it's not recursion per se that made the gains. >The algorithm is the thing. > >Recursion is a powerful way of expressing algorithms, >and the more expressive power you have, the better your >chances of coming up with a good algorithm. >Clean expressive power is Python's main attraction IMO. Huh. A better explanation than I actually expected. David C. Ullrich From aleaxit at yahoo.com Fri Jul 13 08:21:49 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 13 Jul 2001 14:21:49 +0200 Subject: Inheritance Queries References: <9il5qp$iba$1@top.mitre.org> Message-ID: <9imp4u0157o@enews1.newsguy.com> "Angel Asencio" wrote in message news:9il5qp$iba$1 at top.mitre.org... > Is there a package to get information about the inheritance of > a class/instance? > > Methods or functions to answer questions like: > > Which are your decendants? > Which are your ancestors? > Who are your immediate decendants? > Who are your immediate ancestors? A class has absolutely no information about any subclassing performed on it. Conceptually, the only way to gather such information at one point in time would be to go through *all* classes defined at that instant and check if the given class is among the ancestors -- and I don't think there's any sensible way to examine *all* classes in existence at one time. A class knows its immediate ancestors: they're the __bases__ tuple attribute of the class object (you get from an instance to its class via the __class__ attribute of the instance object, of course). Non-immediate ancestors are obtained through recursive walks up the inheritance DAG (Directed Acyclic Graph). Built-in function issubclass() tells you, given any two classes C1 and C2, whether C1 is a direct or indirect subclass of C2. Package inspect has no direct support for inheritance information except for one function that, given a bunch of class objects, places them in a structure evidencing which class inherited from which others. Alex From nospam at nospam Fri Jul 27 13:33:38 2001 From: nospam at nospam (Rufus V. Smith) Date: Fri, 27 Jul 2001 13:33:38 -0400 Subject: Deposing Dictators References: <9jmjne$q54$1@wisteria.csv.warwick.ac.uk> <3b602daf.1623450@nntp.sprynet.com> <$dK+wKA$tZY7Ewin@jessikat.demon.co.uk> Message-ID: <3b61a98d$0$11917@wodc7nh0.news.uu.net> "Robin Becker" wrote in message news:$dK+wKA$tZY7Ewin at jessikat.demon.co.uk... > In article , Guido van > Rossum writes > >Robin Becker writes: > > > >> We all know lightning is God's way of telling us to shut up. Of course > >> God is benevolent no matter how appalling the universe gets. The > >> opposite of benevolent is malevolent. When our quick-sorts go wrong it > >> will be as a result of a benevolent act by a caring designer. > > > >I sincerely wish you would be struck by lightning. Your attitude > >disgusts me. > > > >--Guido van Rossum (home page: http://www.python.org/~guido/) > > Oh dear I sense a humour deficit :( > -- > Robin Becker I think it was just an emoticon deficit. From missive at frontiernet.net Tue Jul 17 04:43:26 2001 From: missive at frontiernet.net (Lee Harr) Date: Tue, 17 Jul 2001 08:43:26 +0000 (UTC) Subject: [ZOPE] External Method process limits? bug fix! References: <9i9rmn$kc6$1@node21.cwnet.roc.gblx.net> <9iajn0$rvm$1@node21.cwnet.roc.gblx.net> <9iicpa$9ju$1@node21.cwnet.roc.gblx.net> Message-ID: <9j0trd$1hfg$1@node21.cwnet.roc.gblx.net> On 16 Jul 2001 18:23:13 -0700, ruckc wrote: > I tried this change, and i still only get a 15 byte Image Object in Zope. > Does the example work for you at all (ie for small images) or is it completely broken? It is working fine for me now... I never got any mangled Image Objects. Either it worked ok, or I got a traceback saying that the type being passed to PIL (or cStringIO, I was never quite sure) was not correct. Is the created image.thumb.jpg a valid image? > missive at frontiernet.net (Lee Harr) wrote: >> Hi: >> >> Thanks for your help. I finally broke down and joined the zope mailing list. >> It was not so difficult, really, just fill out the form at: >> >> http://lists.zope.org/mailman/listinfo/zope >> >> and reply to the confirmation message that goes out to you. >> >> >> Turns out there is a bug in the PIL External Method example in the Zope >> Book. Once the image.data attribute gets to a certain size, it is no >> longer pushed around as a string, but gets wrapped up in its own >> different kind of object. PIL or cStringIO was objecting to that. >> >> The fix is to wrap image.data in str() to force stringiness. >> Here is the corrected code... >> >> (mostly from http://www.zope.org/Members/michel/ZB/ScriptingZope.dtml) >> >> >> def makeThumbnail(self, original_id, size=128): >> """ >> Makes a thumbnail image given an image Id when called on a Zope >> folder. >> >> The thumbnail is a Zope image object that is a small JPG >> representation of the original image. The thumbnail has a >> 'original_id' property set to the id of the full size image >> object. >> """ >> >> from PIL import Image >> from cStringIO import StringIO >> import os.path >> >> # create a thumbnail image file >> original_image=getattr(self, original_id) >> original_file=StringIO(str(original_image.data)) # bug fix here >> image=Image.open(original_file) >> image=image.convert('RGB') >> image.thumbnail((size,size)) >> thumbnail_file=StringIO() >> image.save(thumbnail_file, "JPEG") >> thumbnail_file.seek(0) >> >> # create an id for the thumbnail >> path, ext=os.path.splitext(original_id) >> thumbnail_id=path + '.thumb.jpg' >> >> # if there's and old thumbnail, delete it >> if thumbnail_id in self.objectIds(): >> self.manage_delObjects(thumbnail_id) >> >> # create the Zope image object >> self.manage_addProduct['OFSP'].manage_addImage(thumbnail_id, >> thumbnail_file, >> 'thumbnail image') >> thumbnail_image=getattr(self, thumbnail_id) >> >> # set the 'originial_id' property >> thumbnail_image.manage_addProperty('original_id', >> original_id, >> 'string') From bsb at winnegan.de Thu Jul 5 16:33:14 2001 From: bsb at winnegan.de (Siggy Brentrup) Date: 05 Jul 2001 22:33:14 +0200 Subject: webbrowser module reveals a Netscape bug. In-Reply-To: <01070512214400.00888@whatsup.home> References: <01070512214400.00888@whatsup.home> Message-ID: <87vgl72k1h.fsf@winnegan.de> Hi Gary, If you're running KDE 2.1: I remember a message including a workaround on the debian-kde mailing list the day before. Gary Herron writes: > I'm writing an application which needs to open a web browser on any > platform, so I used the webbrowser module, and it fails to work on my > first system test because of an apparent bug in netscape. I've not > seen any mention of this problem, but I'm hoping someone has a > workaround. Since I don't use Netscape 4.7x any more, I don't have the message at hand, search the archive at http://lists.debian.org/debian-kde-0107/maillist.html for netscape in the subject line. Good luck Siggy -- Siggy Brentrup - bsb at winnegan.de - http://www.winnegan.de/ ****** ceterum censeo javascriptum esse restrictam ******* From nperkins7 at home.com Tue Jul 24 14:32:28 2001 From: nperkins7 at home.com (Nick Perkins) Date: Tue, 24 Jul 2001 18:32:28 GMT Subject: Sorting Lists References: Message-ID: <0bj77.544176$eK2.114166570@news4.rdc1.on.home.com> "Colin Meeks" wrote in message news:lSh77.64029$2V.13507417 at news3.rdc1.on.home.com... > I have a list that comprises of First Name, Surname, Age > The list looks something like > > [["Mickey","Mouse","50"],["Stan","Mantz","3"],["Junior","Wilst","40"],["Kim" > ,"Bean","15"]] > > How can I sort the list to rearrange it by either First Name, Surname, Age > > I believe I'd have to use a cmpfunc in the sort, but not too sure how to > achieve the above. > > Thanks > > Colin > > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.265 / Virus Database: 137 - Release Date: 18/07/2001 > > You don't have to use a custom compare sort. You can get what you want by creating a temp list, consisting of 'decorated' values, and sorting that list. These are actually tuples whose second element is the real data, and the first element is a copy of the field that you want to sort by. (or a computed value, if you want) So, if you want to sort by surname, for example, you can transform each item like ["Mickey","Mouse","50"] into ("Mouse",["Mickey","Mouse","50"]). You use a regular sort on the list of transformed values, then 'extract' your original values. Here's an example of sorting records by a given field: def sort_by_field(seq,index): tmp = [ (item[index],item) for item in seq ] tmp.sort() return [ item for (_,item) in tmp ] data = [["Mickey","Mouse","50"], ["Stan","Mantz","3"], ["Junior","Wilst","40"], ["Kim","Bean","15"]] data_by_lastname = sort_by_field(data,1) print 'by last name:' for record in data_by_lastname: print record ------ OUTPUT: by last name: ['Kim', 'Bean', '15'] ['Stan', 'Mantz', '3'] ['Mickey', 'Mouse', '50'] ['Junior', 'Wilst', '40'] From s713221 at student.gu.edu.au Thu Jul 26 07:39:40 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Thu, 26 Jul 2001 21:39:40 +1000 Subject: python2.2: type('name') -> ?? References: Message-ID: <3B60017C.6CDBCE26@student.gu.edu.au> Guido van Rossum wrote: > > Francisco writes: > > > I just compiled python2.2a and I'm getting this strange response to the > > 'type' command: > > > > Python 2.2a1 (#2, Jul 24 2001, 12:24:09) > > [GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2 > > Type "copyright", "credits" or "license" for more information. > > >>> type('') > > > > > > while I expected to get . > > > > Am I missing something or I just messed up with the compilation?? > > No, the string type changed its name to match the str() function > (which is now the same as the str type). > > --Guido van Rossum (home page: http://www.python.org/~guido/) Very nice. -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From guido at digicool.com Sat Jul 7 14:18:02 2001 From: guido at digicool.com (Guido van Rossum) Date: Sat, 07 Jul 2001 14:18:02 -0400 Subject: [Fwd: Comment on PEP-0238] In-Reply-To: Your message of "Sat, 07 Jul 2001 10:21:58 PDT." <3B474536.DE27A538@3-cities.com> References: <3B474536.DE27A538@3-cities.com> Message-ID: <200107071818.f67II2g18846@odiug.digicool.com> > However, I think that some details of the numerics also need to > be clarified before you boldly go. Specifically, > > - What about long division? A float cannot capture all results. > Should it raise a Value/Range error? > Should the programmer be forced to use divmod? > Should it return a rational? > I don't really like the last two choices and the first two choices > obviate much of the usefulness of longs. We'll introduce a new operator or function (e.g. div(x, y)) for integer division, which will work for ints and longs. When / is used and the result can't be expressed as a C double, we can choose between yielding Infinity or raising OverflowError; I think probably the latter although with two float arguments this currently returns Inf on most platforms. > Perhaps Paul Dubois's kinds mechanism comes to the rescue? > He does have a trial implementation in numeric (though > I am not in favor of seeing much of the current numeric > integrated into the core) I don't think this will help. --Guido van Rossum (home page: http://www.python.org/~guido/) From Randy.L.Kemp at motorola.com Fri Jul 13 11:58:50 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Fri, 13 Jul 2001 10:58:50 -0500 Subject: Book count test Message-ID: I don't know. I am just passing the time while I wait for some software to be FTPed from one server to another. -----Original Message----- From: Andreas Jung [mailto:andreas at andreas-jung.com] Sent: Friday, July 13, 2001 11:30 AM To: Kemp Randy-W18971; python-list at python.org Subject: Re: Book count test And what do we learn from these numbers ? Andreas From: "Kemp Randy-W18971" To: Sent: Freitag, 13. Juli 2001 10:22 Subject: Book count test > I went to www.amazon.com and counted the number of books in these categories > Python - 136 (including snake books) > Java - 1621 > Perl - 430 > C++ - 1341 > PHP - 38 > ASP - 172 > Oracle - 682 > > > -- > http://mail.python.org/mailman/listinfo/python-list From nperkins7 at home.com Fri Jul 6 03:15:35 2001 From: nperkins7 at home.com (Nick Perkins) Date: Fri, 06 Jul 2001 07:15:35 GMT Subject: ICFP 2001 contest - Python team, anyone? References: Message-ID: ..reading contest rules... so, we would have to write for Python 1.52?? ..and this is for a functional programming contest? 2.1 would be better, with nested scopes and list comprehensions, etc. "Gerhard H?ring" wrote in message news:slrn9k9hbd.8uh.gerhard.nospam at lilith.hqd-internal... > The International Functional Programming Contest was announced. I'd like to > join this year. If you are a Python hacker and want to have all the fun and > glory, please contact me :-) > > http://cristal.inria.fr/ICFP2001/prog-contest/ > > """ > On Thursday, July 26, 2001 at 15:00 UTC (see this page to convert to your time > zone), a challenge task will be posted on the Internet. It will also be sent by > mail to the contest mailing list. > > Teams will have 72 hours to implement a program to perform this task and submit > this program to the contest judges. > """ > > (Im not an ubercoder, I just want to have fun) > > 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 tjenkins at nospiced.ham.devis.com Fri Jul 27 14:13:44 2001 From: tjenkins at nospiced.ham.devis.com (Tom Jenkins) Date: Fri, 27 Jul 2001 18:13:44 GMT Subject: a break for comprehensions References: <9jpadd$s5k$1@news.duke.edu> <3B60A053.75938301@engcorp.com> <9jqnlr$flb$1@news.duke.edu> <3B60E96C.2A99AD87@engcorp.com> Message-ID: <3B61B037.3070704@nospiced.ham.devis.com> phawkins at connact.com wrote: >>>>>>"PH" == Peter Hansen writes: >>>>>> > > PH> In my post I was attempting to point out that I find list > PH> comprehensions less readable than the equivalent, longer but > PH> more explicit while loop version, not that one list comprehension > PH> is more or less cryptic than another. > > Personally, as soon as I saw list comprehensions, I found them > splendidly, instantly readable -- so long as they aren't nested, I can > read them at a glance, where it takes me just a little longer to > comprehend all of a loop. This is certainly true for the examples > we've been looking at. So I think this just has to do with how one's > mind works. I couldn't read list comprehensions until I actually started playing around with them. After experimenting and writing (oh about 3 or 4) I discovered I could read them ;) > > and-no-I-don't-find-perl-at-all-readable-ly yr's > Patricia > and-i-don't-find-lisp-readable-either-although-with-list-comprehensions-i'm-starting-to-ly yours Tom From zooko at zooko.com Mon Jul 16 16:18:22 2001 From: zooko at zooko.com (zooko at zooko.com) Date: Mon, 16 Jul 2001 13:18:22 -0700 Subject: memory leak with dynamically defined functions? Message-ID: [cross-posting to python-list[1] and mojonation-devel[2]] Dear Pythonistas, One and All, Large and Small: It was with some interest that I read on Dr. Dobbs weekly Python-URL [3] that someone or other on Usenet was asserting that you couldn't write large distributed applications in a dynamic language without succumbing to bugs. I hack on a large, distributed Python application named "Mojo Nation" [4]. I briefly considered putting Mojo Nation forward as a counterexample, since it definitely qualifies on the first two criteria (large, distributed), but I hesitated to subject myself and my teammates to criticism on the last (non-buggy). Of course, all large applications have bugs, and I'm very proud of Mojo Nation, but recently we've been struggling with a particularly damaging bug: memory leakage which causes our application to use up all available RAM after only a few hours of operation. In searching for the source of the leakge today, I encountered a surprising behaviour of Python which I think may be a bug. If I allocate a bunch of memory with a function like this: >>> blarg = {} >>> for i in range(2**13): >>> blarg[i] = [0] * (2**10) and then remove the references to this memory, like this: >>> del blarg then all the memory is freed up. But if I allocate memory and store a reference to it in a default argument to an inner function, like this: >>> def silliest_func(): >>> x = [0] * (2**10) >>> def inner_silliest_func(x=x): >>> pass >>> return inner_silliest_func >>> >>> blarg = {} >>> for i in range(2**13): >>> blarg[i] = silliest_func() and then remove the references to this memory, like this: >>> del blarg none of the memory is freed up! Even stimulating the garbage collector, with: >>> import gc >>> gc.collect() 0 just returns "0" and the memory is still in use. I tested this with CPython 1.5.2 on Debian and CPython 2.0 on Debian and Red Hat and they all behaved the same. I also tested it with JPython 2.1-alpha1 with j2sdk 1.3.1-1 on Debian, and it *did* do the kind of garbage collection that I expected. (The JVM wouldn't collect until I reached some very high limit on total RAM allocated or something. But I could do the "silliest_func and then delete the dict" indefinitely, with memory usage as reported by Linux fluctuating between 30 MB and 60 MB.) So it appears to me that inner functions and/or their default arguments are not getting properly collected in CPython. If this is the case, it poses quite a problem for Mojo Nation, as we have relied heavily on the convenient closure- like feature of passing around references to dynamically defined functions with default arguments. Thanks, y'all, for the best language and the most friendly language community around. Regards, Zooko [1] http://mail.python.org/mailman/listinfo/python-list [2] http://lists.sourceforge.net/lists/listinfo/mojonation-devel [3] http://lwn.net/daily/pyurl-20010716.php3 [4] http://mojonation.net/ [5] http://zooko.com/memleak.py From cbarber at curl.com Mon Jul 30 10:49:24 2001 From: cbarber at curl.com (Christopher Barber) Date: 30 Jul 2001 10:49:24 -0400 Subject: Typing system vs. Java References: Message-ID: writes: > In most jobs I've used C/C++ or Java and for me the stronger the typing > rules the more problems (and in turn bugs) it caused. I am really surprised to hear this. My experience has been the opposite. > For example, if I need to store a list of points and color > values I can't just make an array of (x,y,color) tuples. I need to > create a class to hold them and then create instances and store them in > an array or Vector. You seem to be complaining about the lack of tuples, not static type-checking per-se. > Strong typing seems to prevent a very small class of errors at great > expense, and none of the errors it prevents should escape good testing > (which you should have anyway). I am all for unit testing, but I know from experience that it is *extremely* difficult to comprehensively test a code unit, and virtually impossible if you do not have a good code coverage tool. If the compiler can catch a type error for me at compile-time, that is at least one less unit test I have to write. I agree that static type declarations add complexity to a language, but there is a significant body of developers that really appreciate what they can do for you. It would really be nice if Python could add some sort of optional type declarations. It should be technically feasible. - Christopher From bokr at accessone.com Mon Jul 23 17:34:51 2001 From: bokr at accessone.com (Bengt Richter) Date: Mon, 23 Jul 2001 21:34:51 GMT Subject: A use for integer quotients References: <3B5BDCB4.A2010560@letterror.com> <3B5C48A0.56D88724@alcyone.com> <7ikoltclv5sjr376ua6m1jlk3a9l1qftju@4ax.com> Message-ID: <3b5c990b.237461111@wa.news.verio.net> On Mon, 23 Jul 2001 19:15:33 +0100, Steve Horne wrote: [...] > >Fixed point arithmetic emulated by using integers with a scale factor, >though, works very nicely. Better still when there's a language >feature to do this automatically, but if we added fixed point types to >Python we'd need *another* division operator - four so far including >the rational one ;-) > This reminds me, is Python configurable to run on a platform with no floating point support? With Linux being embedded all over the place, it seems like it would come up. Do the mini hand-helds (not to mention cell phones) have floating point? From gmcm at hypernet.com Fri Jul 20 09:50:30 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 20 Jul 2001 13:50:30 GMT Subject: xml.dom.minidom + py2exe References: <9ilk1r$quo$1@maud.ifi.uio.no> <9im880$jjh8j$1@ID-59885.news.dfncis.de> Message-ID: Martin von Loewis wrote: > Gordon McMillan writes: > >> You have to do a lot more than that. After all, once xml/__init__.py >> runs and swaps itself for _xmlplus/__init__.py, then xml.sax.expatreader >> refers to _xmlplus/sax/expatreader.py. > > The original reporter did not have PyXML installed, so no swapping of > _xmlplus would happen on this installation. Never read the original report. I was responding to the text I quoted (and you elided). The import hacks in _xmlplus, while clever, make things difficult, and not just for dependency trackers. After all, there are 8 places in _xmlplus that do "import xml.", and where the intent is not to get xml/, but to get _xmlplus/. And 297 that do "from xml. import ..." with the same intent. So only readers (human or tools) that understand what happens in xml/__init__.py have a prayer of figuring out what's going on. PyXML is hardly alone in this. Many package authors indulge in import hacks, thinking they can make their package more user friendly. In the long run, though, this kind of import hack is user hostile. - Gordon From thomas.heller at ion-tof.com Mon Jul 2 05:51:07 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Mon, 2 Jul 2001 11:51:07 +0200 Subject: win32gui Message-ID: <9hpg2o$f4pdk$1@ID-59885.news.dfncis.de> Hi. I'm trying to use the win32gui module. I want to register a custom window class with the following code: import win32gui, win32con def test(*args, **kw): print "test", args, kw wndclass = win32gui.WNDCLASS() wndclass.lpszClassName = "MyPythonWndClass" wndclass.lpfnWndProc = test print win32gui.RegisterClass(wndclass) hwnd = win32gui.CreateWindow("MyPythonWndClass", .....) win32gui.ShowWindow(hwnd, win32con.SW_SHOWNORMAL) win32gui.PumpMessages() All this (basically) works, the window is shown, but nothing is printed from the test function. Wading with the debugger through the code, it seems the 'test' function is never called. The reason seems to be that the default window-proc from win32gui is called, and SetClassLong() is never called with 'test' as the parameter. Has anyone got this to work? Am I doning something wrong? Thomas From greg at cosc.canterbury.ac.nz Wed Jul 11 02:21:18 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 11 Jul 2001 18:21:18 +1200 Subject: PEP scepticism References: <9icbft$okp$1@panix6.panix.com> <3B4A5E00.BDB4245A@engcorp.com> Message-ID: <3B4BF05E.7391121E@cosc.canterbury.ac.nz> Peter Hansen wrote: > > In article <9icbft$okp$1 at panix6.panix.com>, Aahz Maruch > > probably the PSU having killed all the Norwegian Blues > > is overloading sparrows with portable nuclear devices. > I feel sure you meant to say "swallow". The airspeed of a laden > swallow is greater than that of a laden sparrow. (I think... -- Waa!) But does this carry over to the maximum strike range of a nuclear-armed swallow? Enquiring minds with nothing better to do with themselves want to know... -- 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 Tom_Good1 at excite.com Fri Jul 20 18:51:29 2001 From: Tom_Good1 at excite.com (Tom Good) Date: 20 Jul 2001 15:51:29 -0700 Subject: Partition Problem References: <3B5042C2.F821D916@engcorp.com> <9itb14$2oi$1@newsg1.svr.pol.co.uk> <9iv5e9$bru$1@newsg1.svr.pol.co.uk> <0oR47.12485$p7.4220508@news1.rdc2.pa.home.com> Message-ID: "Donovan Hide" wrote in message news:... > Wow, > fascinating! The minds of two 'algorthmistas' battling the pros and cons > of there code and techniques. I can't tell you how interesting this is. I > really get the feeling that Python needs a good combinatorics module. > CombPy, maybe? [snip] And now, for something completely different! "Fun with generators." Here is the "sets of 6 positive integers that sum to 17" problem, solved with generators. Works with Python 2.2. My goal here was to minimize lines of code, not to optimize for performance. Tom # -------- begin code from __future__ import generators import operator def genSet(howMany, minNum, maxNum): # generator if howMany <= 1: for i in range(minNum ,maxNum+1): yield [i] else: for a in genSet(howMany-1, minNum, maxNum): for b in range(max(a), maxNum+1): yield a + [b] def findSum(howMany, minNum, maxNum, sum): # generator for i in genSet(howMany, minNum, maxNum): if reduce(operator.add, i) == sum: yield i if __name__ == "__main__": print "finding sets of 6 positive integers that add up to 17" count = 0 for i in findSum(6, 1, 17, 17): count += 1 print count, ":", i # -------- end code Running it: C:\Python22>python testgen.py finding sets of 6 positive integers that add up to 17 1 : [1, 1, 1, 1, 1, 12] 2 : [1, 1, 1, 1, 2, 11] 3 : [1, 1, 1, 1, 3, 10] 4 : [1, 1, 1, 1, 4, 9] 5 : [1, 1, 1, 1, 5, 8] 6 : [1, 1, 1, 1, 6, 7] 7 : [1, 1, 1, 2, 2, 10] 8 : [1, 1, 1, 2, 3, 9] 9 : [1, 1, 1, 2, 4, 8] 10 : [1, 1, 1, 2, 5, 7] 11 : [1, 1, 1, 2, 6, 6] 12 : [1, 1, 1, 3, 3, 8] 13 : [1, 1, 1, 3, 4, 7] 14 : [1, 1, 1, 3, 5, 6] 15 : [1, 1, 1, 4, 4, 6] 16 : [1, 1, 1, 4, 5, 5] 17 : [1, 1, 2, 2, 2, 9] 18 : [1, 1, 2, 2, 3, 8] 19 : [1, 1, 2, 2, 4, 7] 20 : [1, 1, 2, 2, 5, 6] 21 : [1, 1, 2, 3, 3, 7] 22 : [1, 1, 2, 3, 4, 6] 23 : [1, 1, 2, 3, 5, 5] 24 : [1, 1, 2, 4, 4, 5] 25 : [1, 1, 3, 3, 3, 6] 26 : [1, 1, 3, 3, 4, 5] 27 : [1, 1, 3, 4, 4, 4] 28 : [1, 2, 2, 2, 2, 8] 29 : [1, 2, 2, 2, 3, 7] 30 : [1, 2, 2, 2, 4, 6] 31 : [1, 2, 2, 2, 5, 5] 32 : [1, 2, 2, 3, 3, 6] 33 : [1, 2, 2, 3, 4, 5] 34 : [1, 2, 2, 4, 4, 4] 35 : [1, 2, 3, 3, 3, 5] 36 : [1, 2, 3, 3, 4, 4] 37 : [1, 3, 3, 3, 3, 4] 38 : [2, 2, 2, 2, 2, 7] 39 : [2, 2, 2, 2, 3, 6] 40 : [2, 2, 2, 2, 4, 5] 41 : [2, 2, 2, 3, 3, 5] 42 : [2, 2, 2, 3, 4, 4] 43 : [2, 2, 3, 3, 3, 4] 44 : [2, 3, 3, 3, 3, 3] From steve at lurking.demon.co.uk Sun Jul 22 08:45:25 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Sun, 22 Jul 2001 13:45:25 +0100 Subject: Stability of PYC files Message-ID: Are the Python compiled bytecode PYC files stable enough that you can take PYC files generated by older versions of Python and run them without the source on newer versions? Has anyone ever tried to document Python bytecode? Does jPython compile to Java bytecode, or does it act more directly as an interpreter, or does it use an intermediate bytecode? Sorry for the wierd questions ;-) From tbryan at python.net Sat Jul 21 06:47:10 2001 From: tbryan at python.net (Tom Bryan) Date: Sat, 21 Jul 2001 15:47:10 +0500 Subject: Case insensitivity References: Message-ID: <9jclvg$9m7$1@slb1.atl.mindspring.net> Sheila King wrote: > In an attempt to address the "why" of this problem, I have posted the > following article to two mailing lists to which I belong, for AP > Computer Science teachers: .... >> Those of us who programmed in Pascal, certainly recall the >> case-insensitivity of that programming language. And now that we are >> programming in C++, and moving to Java in another couple of years, we >> are programming in a case-sensitive language. Python is currently a >> case-sensitive language. I'm not sure how much of a difference this makes, but there is another (to me) important difference. Python is an interpreted language, and name errors are not caught until runtime. That is, in Java, the following class gives me an error at compile time public class Test { public static void main( String args[] ) { int var = 0; if (false) { System.out.println( "We don't run this code: " + Var ); } else { System.out.println( "This code is run " + var ); } } } $ javac Test.java Test.java:8: error:Variable "Var" is not defined in current context Whereas the equivalent Python doesn't give me *any* error at run time. if __name__ == '__main__': var = 0 if 0: print "We don't run this code: " + str( Var ) else: print "This code is run " + str( var ) $ python test.py This code is run 0 Thus, whether simple errors like this are detected in Python depend in part on whether the programmer tests every possible path of execution. Of course, case-insensitivity doesn't really "fix" this problem. I more often have problems like mixing var and bar. Perhaps it would be nicer if Python had a switch that gave errors for names that are used that don't exist at compile time. I know that it's possible to create names in Python at runtime, but for those programs that don't use such features, this type of guarantee might be nice. The "should it be a tool solution or a language solution" could then rage over this new issue. ---Tom From bww00 at amdahl.com Tue Jul 24 01:16:37 2001 From: bww00 at amdahl.com (Bryan Webb) Date: 24 Jul 2001 05:16:37 GMT Subject: real-accurate, numpy...increased precision help Message-ID: <9jj0bl$9mq@dispatch.concentric.net> I need to be able to work with numbers up to 2^800 in a floating point envirnoment. I would like an increase of precision over std floats. I also would like to know the internal representation of the numbers, so that I can read and write them to disk in their internal representations.. Should I use real-accurate, or numpy Any help would be appreciated Thanks for the help Bryan Webb From greg at cosc.canterbury.ac.nz Tue Jul 31 22:45:14 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 01 Aug 2001 14:45:14 +1200 Subject: (in)exactness of complex numbers References: <3b62cc78.3396597@nntp.sprynet.com> Message-ID: <3B676D3A.E436943A@cosc.canterbury.ac.nz> "David C. Ullrich" wrote: > > But why should the real and imag of a complex be required to be > floats in the first place? Why shouldn't they be allowed to be > floats or rationals or integers? A complex number, in the mathematical sense, is not a pair of other numbers -- that's just one way of *representing* a complex number. If you have some application for which you need pairs of numbers that are restricted to being integers or whatever, they're not really complex numbers, and so you can't blame Python's complex type for not helping you. -- 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 tundra at tundraware.com Tue Jul 31 11:50:02 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 31 Jul 2001 15:50:02 GMT Subject: Long: Python Is Really Middleware References: <3B667EBA.DA6C298@tundraware.com> <3B66B1AA.EF2FFE3A@engcorp.com> Message-ID: <3B66D37E.52C05154@tundraware.com> Steve Holden wrote: > > "Peter Hansen" wrote ... > > Tim Daneliuk wrote: > > > > > > *** Python Is Really "Middleware" *** > > > Tim Daneliuk > > > Copyright (c) 2001, TundraWare Inc. > > [...] > > > by coding around them. This leads to REALLY ugly, hard-to-maintain > > > systems. CHANGING UNDERWEAR MATTERS. > > > > I think you meant "UNDERWARE" ... :) > > No, he meant underwear. His underwear had clargs on it. That does indeed > make them really ugly and hard to maintain. > Awright, who's been peeking??? -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From tundra at tundraware.com Mon Jul 9 19:41:35 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 09 Jul 2001 23:41:35 GMT Subject: Python Idiom Question Message-ID: <3B4A4126.7AD3CDD0@tundraware.com> What is the equivalent python idiom to the following 'C' code: while (x=getchar() != 'N') { Do something} In other words, is there a convenient way to simultaneously get input, from say, raw_input() or f.read(), and check the return value agains some logical construct, re pattern match, or whatever? I'm sure this is possible, I just cannot seem to find the magic combination that gets me there. Nothing seems to turn up when I look in the Usual Places, but then again, I may not be Lookin' Right. At the moment, I'm doing things like: x=raw_input() while x: Do Something Interesting x = get_input("Prompt: ") TIA, ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From sholden at holdenweb.com Tue Jul 17 15:25:59 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 17 Jul 2001 15:25:59 -0400 Subject: Regex for strings utility References: <1103_995396879@pan> Message-ID: rhys tucker" wrote in message news:1103_995396879 at pan... > I'm trying to write a script which operates like the Unix 'strings' utility but I'm having difficulties with the regex. > > #!/usr/bin/env python > > # strings program > > import sys, re > > f = open(sys.argv[1]) > line = f.readline() > pattern = ([\040-\126\s]{4,}) > > while line: > # regular expression to match strings >=4 chars goes here > matches = findall(pattern, line) > for match in matches; > print match > line = f.readline() > > > > I'm getting a Syntax Error: Invalid Token at the closing brace to the pattern. > Try pattern = "([\040-\126\s]{4,})" for a start. I notice you import re, but don't use it anywhere - your findall() call could be re.findall(), perhaps? I'm not a regex guru, but I have my doubts that the pattern will match what you want it to. Perhaps the effbot or one of his proxies could advise... regards Steve -- http://www.holdenweb.com/ From tim at vegeta.ath.cx Sun Jul 15 20:58:46 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Mon, 16 Jul 2001 00:58:46 GMT Subject: re Challenge: More Compact? References: <3B51E6B1.47E25214@tundraware.com> <92ae279c.0107151429.398e6e9e@posting.google.com> Message-ID: Tim Daneliuk wrote: > The following re is (I think) the description of a legitimate IP addess in > "quad" format (IPV4). My question is, can it be made even shorter? > > ipquad = r"^((\d\d?\d?\.){3}(\d\d?\d?))$" from 'Mastering Regular Expressions', p.124: '^([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.\ ([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])$' The author's own words below the result: "Quite a mouthful! Was the trouble worth it? ..." It's not compact, and it's certainly not the only way to do it, but it performs the 0-255 test within the regex. A later suggestion in the same chapter: '^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$' (capturing parens) for easy subsequenst validation. Easily implemented in Perl: : sub valid_ip { : my ($ip, $failed, @elements) = (shift, 0); : @elements = ($ip =~ /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/); : $failed = grep { $_ > 255 } @elements; : return ($failed) ? undef : 1; : } Slightly more verbose in Python: : import re : def valid_ip(ip): : expr = r'^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$' : elements = map(int, re.match(expr, ip).groups()) : failed = filter(lambda x: x > 255, elements) : if failed: return None : else: return 1 Please excuse the enthusiastic and unnecessary coding. It sounded like fun! HTH -- Destinations are often a surprise to the destined. -- Thessaly, The Sandman From bhahn at spam-spam.g0-away.com Tue Jul 31 19:17:17 2001 From: bhahn at spam-spam.g0-away.com (Brendan Hahn) Date: Tue, 31 Jul 2001 16:17:17 -0700 Subject: "Systems programming" (was: Language Niches (long)) References: <8beb91f5.0107280407.5a30341d@posting.google.com> <4E215400D01D7374.0068C51FD6502BE8.99D4E013ECF0FDFB@lp.airnews.net> Message-ID: grante at visi.com (Grant Edwards) wrote: >As long we're completely off-topic (Python-wise)... [...] >The question of how to write a Linux driver in C++ comes up >fairly regularly. In theory it's possible as long as you don't >use features X,Y, and Z, and you include a set of kenel-mode runtime >support routines. Nobody ever wants to try it badly enough. Exactly -- it's all about the runtime support, and kernel-space C++ runtime implementations are all over the map in terms of features and performance. Microsoft has a pretty good one for NT, but the *n*x world will drive you crazy. There's actually a spec for "Embedded C++", a stripped-down version of the language (no templates, exceptions, or RTTI, I think some inheritance limitations and a few other things) intended for embedded systems and other environments where you just don't want to deal with the whole ball of wax. >>You could use Objective-C on the old NeXT systems -- Apple has >>switched to a C++ IO system, for better performance, but using >>a restricted subset of the language. Haven't tried it yet but >>I think it'll be nice. > >Is that in OS X? I thought it was BSD under the hood? It's a Mach-based system. In a real Mach system you have the Mach kernel and one or more "personalities" layered above it providing your typical "OS" services. For MacOS X Apple has created a sort of hybrid with the kernel and personality layers much more tightly coupled, and the personality is BSD. The IO subsystem ("IOKit") for MacOS X is largely inherited from NeXT, though, and is not at all like the IO environment for a typical BSD system. It's a whole O-O hierarchy modelling interfaces, devices, drivers, etc...Apple has redone it based on C++ rather than Objective-C to cut out the overhead of dynamic dispatch and such that you have with Objective-C. The C++ subset they support is quite like the Embedded C++ I mentioned, but I don't think they picked up that spec exactly. bhahn at transoft.mmangle.net <-- unmangle address to reply From sholden at holdenweb.com Fri Jul 20 14:53:07 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 20 Jul 2001 14:53:07 -0400 Subject: The unPEP: List-Tuple Unification References: <3B586A1E.B037349D@javanet.com> <3B587279.A225AC51@javanet.com> Message-ID: <%3%57.7717$m11.427739@e420r-atl1.usenetserver.com> "Raymond Hettinger" wrote in message news:3B587279.A225AC51 at javanet.com... > Steve Holden wrote: > > > No asbestos required, but what's tha advantage over > > > > mylist = tuple(mylist) > > > > just-wonderingl-ly y'rs - steve > > Good question. Immutable lists don't give you much over > what you get now from tuples (except the automatic coercion > for dictionary keys). > > The big advantage comes from deprecating tuples, simplifying > the language, getting rid of (,) and eliminating the need to remember > which things require tuples, which require lists, and which allow > both (quick, what does the % formatting operator require?). > A tuple. Or a single object. But instead of testing whether things were tuples, you'd then have to check whether the list was immutability. I don't see why immutability has to be a one-way attribute when converiosn between list and tuple is so easy. > never-met-a-list-i-didnt-like,ly y'rs -- Raymond regards Steve -- http://www.holdenweb.com/ From skip at pobox.com Thu Jul 26 15:56:41 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 26 Jul 2001 14:56:41 -0500 Subject: interpreter improvements In-Reply-To: References: <5e8bd451.0107190224.7171e61@posting.google.com> Message-ID: <15200.30201.508222.444597@beluga.mojam.com> Quinn> The other observation is that line editing belongs in the Quinn> terminal emulator or window system, not seperately in every Quinn> single program that runs under it. If you use a terminal Quinn> emulator with cut and paste and line editing then all programs Quinn> automatically have those features. As others (including Guido) have observed, having a line editing subsystem that knows about the structure of the language you are using can be a boon. With readline support I can recall individual lines I've typed at the interpreter, however readline knows nothing about Python's block structure, so I can't recall entire blocks that correspond to (for instance) "if", "for", or "while" statements. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From cliechti at mails.ch Tue Jul 31 00:07:11 2001 From: cliechti at mails.ch (chris liechti) Date: 31 Jul 2001 06:07:11 +0200 Subject: again problem with re.reserch References: Message-ID: "sdf" wrote in news:mailman.996548997.18654.python- list at python.org: >>>>> c = a.search('foo abcd') > print c > > > then how I can get the exact postion the string in 'foo abcd', > for example ,I want it return a number denote the postion > you dont need "re" for that. try find, like: a = "that's a string" pos = a.find('str') if you realy insist on using regular expressions for that use ".start()" on the match object. -- chris From pzw1 at spam.me.please.hotmail.com Tue Jul 31 17:29:06 2001 From: pzw1 at spam.me.please.hotmail.com (Peter Wang) Date: Tue, 31 Jul 2001 17:29:06 -0400 Subject: Arg decoding with a template? References: <4oA97.5883$9i1.519137@e420r-atl1.usenetserver.com> Message-ID: On Tue, 31 Jul 2001 18:01:57 +0100, Dale Strickland-Clark wrote: >"Steve Holden" wrote: > >OK, I've had a good look at this now. > >It's hideous! i believe the euphemism is "legacied". :) >It's no wonder that people get fed up with computers if they get given a user interface that expects >pointless dashes all over the place. actually, the GNU getopt package uses standard UNIX argument-passing paradigms. so for the UNIX users, this interface is quite natural. ("ease of use" is always a relative measure!) >You simply can't use this routine to code a nice arg string. after looking at your original post, i'm not exactly sure what you want. do you want a function which can pass a template, as thus? parse_args("val1=%d val2=%s val3=%f", arg_string) if so, then you're going to need a much more strict semantic system for defining the template. what delimiters are used for strings? how do you indicate strings should be interpreted as values and not as literals? etc. perhaps if you gave an example of what you're looking for, better help could be provided. you could also write your own, and submit it to the vaults. although i'm afraid that you'll be fighting twenty some-odd years of UNIX command-line tradition, and this will render your interface less friendly to the vast majority of UNIX-heads. it all depends on your target audience, i suppose. -peter From rob at jam.rr.com Wed Jul 25 11:53:27 2001 From: rob at jam.rr.com (Rob Andrews) Date: Wed, 25 Jul 2001 15:53:27 GMT Subject: A few things :) References: Message-ID: <3B5EEAFA.635E75DD@jam.rr.com> Lee Nutter wrote: > > Hello, > > Im a beginner, and although (i think) I know the base language all > right, I haven't really made anything. Can anyone recommend anything for > a first project? > > Also, I was just wondering, Why do you use python? To me its a hobby. > Why do some of you use it over other languages? I love the language, > don't get me wrong, I was just curious :) > > Thanks, Feel free to check out Useless Python for lots of ideas on first projects. But my general advice is to play with Python a bit and piece together something small. If you can use Python to read/write from a file, do something randomly, get user input and print to the screen, and use a list or dictionary, you might be surprised at what you can do in a few lines of code. Start playing with any idea that entertains you, and post a question to the Python Tutor email list (http://mail.python.org/mailman/listinfo/tutor) when you get stumped on something. enjoy, Rob -- As foretold by Nostradamus.... Useless Python! http://www.lowerstandard.com/python From blair at steenerson.com Thu Jul 19 21:07:41 2001 From: blair at steenerson.com (Blair Steenerson) Date: Fri, 20 Jul 2001 01:07:41 GMT Subject: Problem with Modules/posixmodule.o Message-ID: <3B578472.5EA8CAD5@steenerson.com> I've tried building Python a couple of times, but have gotten the same error both times. configure works OK, but make stops with this message, gcc -g -O2 -Wall -Wstrict-prototypes -I. -I./Include -DHAVE_CONFIG_H -c ./Modules/signalmodule.c -o Modules/signalmodule.o gcc -g -O2 -Wall -Wstrict-prototypes -I. -I./Include -DHAVE_CONFIG_H -c ./Modules/posixmodule.c -o Modules/posixmodule.o ./Modules/posixmodule.c:4053: sys/statvfs.h: No such file or directory ./Modules/posixmodule.c:4102: sys/statvfs.h: No such file or directory make: *** [Modules/posixmodule.o] Error 1 System is Linux 2.2.19 w/ReiserFS on x86 Anyone seen this problem before? Any suggestions would be much appreciated. Thanks in advance. Blair From db3l at fitlinxx.com Thu Jul 26 23:20:33 2001 From: db3l at fitlinxx.com (David Bolen) Date: 26 Jul 2001 23:20:33 -0400 Subject: Couple of newbie questions... References: <5a140c6d.0107261705.3a4f7db3@posting.google.com> Message-ID: foobarickknob at yahoo.com (Scott Taylor) writes: > I'm just getting started w/ Python - and have run into a couple issues > w/ the Windows extensions... > > 1) time.sleep doesn't seem to release time back to the Win32 > subsystem. I had a tight loop, and CPU was maxed out at 100% even if > I did a PumpWaitingMessages w/ a time.sleep. To actually get the loop > to return slices of time back to windows and not max out the CPU I had > to do a PumpWaitingMessages followed by a win32api.Sleep(0) call. My > question is - shouldn't time.sleep actually make the process sleep w/o > hogging CPU? I've definitely used time.sleep() to yield within threads. On Windows, time.sleep() just directly calls the Win32 Sleep() function, so I can't really think of a good reason why you'd see the discrepancy. Did you really just replace a call from time.sleep(0) with win32api.Sleep(0) and have different behavior? Could there have been any other difference in the application when you were using time. There is a minor difference that (at least in recent versions) win32api.Sleep() actually uses the Win32 SleepEx() function beneath the covers, but unless you pass in a second "bAlertable" parameter it defaults to FALSE and should be equivalent to Sleep(). Note that Sleep(0) is a special case of yielding the current thread's timeslice to any other equal priority thread in the process, but is otherwise equivalent to no delay at all. So if you have no other higher or equal priority threads in your process, time.sleep(0) or win32api.Sleep(0) is almost a no-op. I say almost because the Python wrapping (either the time or win32api module) does release and re-grab the Python interpreter lock across the call, so it's possible that some other Python thread might slip in if it was blocked on the lock. So if you want to be a bit fairer, make the delay non-zero but just really tiny (say time.sleep(0.01)). You can see this from the interactive interpreter - something like: >>> while 1: ... time.sleep(0) ... will peg CPU usage at 100% (machine still responsive, but that loop is taking whatever CPU it can get), versus: >>> while 1: ... time.sleep(0.01) ... which barely nudges the CPU. This is Windows kernel behavior, and not directly related to Python. -- -- 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 chrishbarker at home.net Mon Jul 30 13:33:00 2001 From: chrishbarker at home.net (Chris Barker) Date: Mon, 30 Jul 2001 10:33:00 -0700 Subject: Language change and code breaks References: <9j7gv8$9mg@dispatch.concentric.net> <3B61EEA5.9050306@home.com> Message-ID: <3B659A4C.96DE8CCA@home.net> Kevin Rodgers wrote: > I worked on a program where > we were restricted to pure-ANSI Fortran 77 - including 6-character > monocase variable names. Yes, it was painful, but since a big part of > what I was doing involved manipulating 4-dimensional arrays of data, and > since C's support for multidimensional arrays is rather lacking (I think > the technical term is "sucks"), I'd take Fortran any day. Even > something that you'd think C should excel at, namely concatenating > strings, is much easier in Fortran (using the // operator) than in C > (quick - write down the exact syntax for strcat() from memory). > > These days, I only hack Fortran if I'm using a legacy code, but despite > its quirks, one shouldn't underestimate just how well it served its > target audience . . . This brings up a good point about programming language design: While I appreciate the features of a language that make it clean and easy to read, and all that: basic functionality trumps such cosmetic features, and that means that issues like case sensitive identifiers, indenting issues, needing to use "self", etc, etc, etc, are tiny compared to basic functionality. I always thought Fortran was ugly and often painful to use...but it did handle some things required for computational programming (multi-dimentionial arrays are big one) well, and thus it lives on!. In fact, I think that if Fortran 77 introduced dynamic memory allocation, it would be living even larger than it is: that was kind of a deal killer for a lot of stuff. By the way, Fortran 90/95 is pretty darn nice language. As a matter of fact, I like Python a lot, for a lot of reasons, but I would not be using it at all if it were not for NumPy. To make this relevant to recent discussions: Case sensitivity is a purely cosmetic issue, There is no reason to make a major language change for cosmetic reasons. I think the proposed new division is a functional difference, not a cosmetic one. Having a syntax that makes it clear whether you want an integer answer or not, regardless of the types of the inputs is very important in a dynamic language. Anyway, on with the show!!! -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 rnd at onego.ru Tue Jul 17 10:06:05 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 17 Jul 2001 18:06:05 +0400 (MSD) Subject: Language change and code breaks In-Reply-To: Message-ID: On Tue, 17 Jul 2001, Guido van Rossum wrote: > philh at comuno.freeserve.co.uk (phil hunt) writes: > > > >I also don't want to fork the code base. > > > > Does that imply that you sare no longer interested in making > > radical changes to Python, such as case-insensitive identifiers > > mentioned in CP4E? > > I still have the same end goal, but I believe there must be a way to > obtain it without too much disturbance. Case-sensitivity, for > example, may be a tool feature rather than a language feature, or it > may be a user option or a langage-level choice. (Not that I've > figured out exactly how to do this, but TeachScheme makes this an > option.) Note that case-sensitivity is also controversial: the Alice > folks found it a problem, but the VPython folks have not confirmed > this (while they did confirm the integer division trap). Probably, case{non,}sensitive and integer/fp division are the same analogy as simple vs. engineer/scientific vs. programmable calculator (we recently discussed in the other c.l.p thread: "Re: Bug in __imul__"). Python is in no way simple calculator ;-) It is in the "programmable" category for sure. Then it must be real programming language. So the beginners will join real programming. Not just some funny Logo. ;-) imul vs. fmul aren't necessary example here, but case sensitivity is. I noted that Alice is Windows-only project and their view could be narrowed. Windows is case-insensitive and thus "easy to use" only before one needs to put web-pages on the real (UNIX) web-server. Then they understand all the troubles with mised case, national-charset filenames, abbr~ted filenames, local file references "C:\Mydocs\lalala", bmp-images etc. So, certain degree of wisdom must be preserved. CP4E is not "dumb P to nothing and it will be 4E". If the product has internal integrity thus inherent simplicity it is simpler than the product which ADDS something for "easy of use" to hairly and underthought core. Easiness/complexity must match problems under solution. DNS is complex because NS is overly complex system. So, attempts to build better BIND failed so far, because NS *is* BIND ;-) Python is externally and internally simple and does not do special hook for "easy of use". Lets leave it simple and coherent. Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From mertz at gnosis.cx Wed Jul 4 22:51:59 2001 From: mertz at gnosis.cx (Dr. David Mertz) Date: Wed, 04 Jul 2001 22:51:59 -0400 Subject: Most important text processing examples Message-ID: Always so impressed by the Python discussion group, I figure I will ask its advice. I have recently contracted to write a book called _Text Processing in Python_ for Sybex. The proposal and outline can be skimmed at , if you want to see what I am aiming at (I've made minor adjustments as I've started writing, and will certainly make more as I go along). One of the elements of the book will be example solutions to practical problems in the topic domain. I can think of a number pretty readily off the top of my head. And I have skimmed and to get a sense of what some other people consider important and/or frequent problems that come up (I will probably solve some of the same sample problems at those places, but not using the same code precisely). But I am very interested to know what readers of c.l.py feel are the most important sample problems to address in a book like this. One thing where my focus will differ somewhat from the ASPN cookbooks is that I want to keep the emphasis on the problem itself, and make the quirks and optimization of Python incidental--many of the recipes at ASPN have as much or more to do with idiomatic and clever things that Python does as with solving the problem itself (which could also be solved in a different language, for example). It is tough to keep this focus, since the matters overlap so much, but this is my goal. Anyway, your ideas are welcome. Particular approaches to solutions are always interesting, but I am most interested in what *problems* readers encounter most often in their everyday programming lives. 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 rnd at onego.ru Wed Jul 4 02:26:28 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 4 Jul 2001 10:26:28 +0400 (MSD) Subject: newbie question In-Reply-To: <3B42A1A3.2A7793CC@gmx.at> Message-ID: On Wed, 4 Jul 2001, Freller Alex wrote: > I would like to program a python script that parses a directory and its > subdirectorys after specific files (*.pl) and count their linenumbers. If you are working under UNIX, you do not need to program it: $ find . -name '*.py' | xargs wc (this brokes only when there are too large number of files, but then you could read man find to see how to call a command for each file.) Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From duncan at NOSPAMrcp.co.uk Tue Jul 17 06:43:27 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Tue, 17 Jul 2001 10:43:27 +0000 (UTC) Subject: memory leak with dynamically defined functions? References: Message-ID: Harald Kirsch wrote in news:yv2k818t3wk.fsf at lionsp093.lion-ag.de: >> > >>> def silliest_func(): >> > >>> x = [0] * (2**10) >> > >>> def inner_silliest_func(x=x): pass >> > >>> return inner_silliest_func >> > >>> >> > >>> blarg = {} >> > >>> for i in range(2**13): blarg[i] = silliest_func() >> >> This creates 2**13 references to one and the same object, namely >> silliest_func which (I suspect) has just one reference to an object >> inner_silliest_func. > > Should read: > This creates 2**13 references to one and the same object, namely > inner_silliest_func. Your understanding seems to be slightly flawed here. This actually creates 1 reference to each of 2**13 objects. Each object is a function called inner_silliest_func with a default argument, but every time you call silliest_func you create a new object 'x' and a new function using that x as an argument. > So it appears to me that inner functions and/or their default arguments > are not getting properly collected in CPython. If this is the case, it > poses quite a problem for Mojo Nation, as we have relied heavily on the > convenient closure- like feature of passing around references to > dynamically defined functions with default arguments. Is there a good reason why you cannot upgrade to Python 2.1? It appears that this problem is fixed in 2.1 as the following example shows: --- begin refs.py --- import weakref class Tracker: def __init__(self): self.__trackedobjects = weakref.WeakValueDictionary() def trackLifetime(self, object, name=None): """Track the lifetime of the object. Adds it to a weak reference dictionary. At the end of the test the weak dictionary must be empty again.""" name = name or repr(object) tracked = self.__trackedobjects tracked[(name, id(object))] = object def printStatus(self): print "Tracker is tracking %d objects" % len(self.__trackedobjects) def verifyTrackedObjects(self): tracked = self.__trackedobjects if len(tracked) != 0: names = [] for (name, id) in tracked.keys(): names.append(name) msg = "Objects not freed: " + ", ".join(names) assert len(tracked)==0, msg tracker = Tracker() tracker.printStatus() def silliest_func(): x = [0] def inner_silliest_func(x=x): pass tracker.trackLifetime(inner_silliest_func) return inner_silliest_func blarg = {} for i in range(10): blarg[i] = silliest_func() tracker.printStatus() del blarg tracker.printStatus() tracker.verifyTrackedObjects() --- end --- Which gives you the output: Tracker is tracking 0 objects Tracker is tracking 10 objects Tracker is tracking 0 objects If you comment out the line 'del blarg' you will get a list of unfreed objects. -- 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 phd at phd.fep.ru Tue Jul 3 15:40:25 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Tue, 3 Jul 2001 23:40:25 +0400 (MSD) Subject: zope's acquisition inheritance In-Reply-To: <3B41E221.CE23D83E@home.com> Message-ID: On Tue, 3 Jul 2001, Wostenberg wrote: > Anybody heard of acquisition outside Zope, or is it a new contribution to > OO modelling? Yes, I heard. I saw an URL (from Zope site to an abstract of a book in print) that showed the idea of acquisition was acquired (pun intended!) by Digital Creations (probably Jim Fulton personnaly) from the book. Ask DC people if they can find the URL for you. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From sholden at holdenweb.com Wed Jul 18 12:30:22 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 18 Jul 2001 12:30:22 -0400 Subject: sys.argv not found References: <3B55962C.63F7E2EF@mit.edu> <3B55B2C2.74A8FB3D@mit.edu> Message-ID: "Man Vehicle Laboratory" wrote in message news:3B55B2C2.74A8FB3D at mit.edu... > > I've tried putting a print statement right after I import sys. I have the same > error as before: > > > **************************************************************************** ** > > * WINVRUT 2.4a Copyright 1995-2001 University of California, Santa > Barbara * > * Massachusetts Institute of > Technology * > **************************************************************************** ** > > VRUT 2.4a > voicekey Voicekey 0.9 > serialthrustmaster Serial thrustmaster 1.0 > avstu AvatarStudio 1.1 > Traceback (most recent call last): > File "", line 1, in ? > File "N:\FenZhao\E3_sid_data\e3_sid_data2.py", line 61, in ? > print sys.argv > AttributeError: argv > Well, this traceback looks very suspicious. I assume that the file you are taking about is indeed e3_sid_data2.py? Maybe not ... it is quite weird that sys appears to have no argv attribute. I can only conclude that perhaps some other portion of your code assigns to sys? But you say below this is NOT the case. Aaarrgghh... > The error I get from vrut is from my code looking at argv, not vrut (error > message w/out print statement: > > Traceback (most recent call last): > File "", line 1, in ? > File "N:\FenZhao\E3_sid_data\e3_sid_data2.py", line 62, in ? > mode=string.atoi(sys.argv[1]) > AttributeError: argv > The first line of the tracebacks implies that some code is being executed from a strng variable. If none of your code does anything like that (uses eval/exec, let's say) then the obvious suspect is the vrut module... Your module doesn't by any chance import itself, does it? > So whatever my first operation is dealing with sys.argv, there's an attribute > error with argv) > > What confuses me is that this error is displayed in the VRUT window; VRUT opens > two windows, a display window that shows the 3D VR scene, and a text window that > will display print statements and error messages from python. Logically, if > argv can't be found, an error message will end the program before vrut ever gets > started. > Oh. Is it possible that importing the vrut module modifies sys.stdout/sys.stderr, leaving something weird in place before the vrut.go() call creates the windows? > I've also tried importing vrut after looking at sys.argv in case vrut does > something funky in it's initialization/import. Same problem. Yet commenting > out the vrut.go() command, and the sys.argv is fine. OK, so what you are telling us is that the presence of a function call you have not yet executed is somehow affecting the sys module's namespace. That sounds pretty funky to me, and frankly I'm beginning to wonder whether you have programmed a time machine :-) > > --Fen > > PS. I hope this helps: all of my code up to the call to vrut (minus > comments)... there's not much there, can't figure out what's making it work > improperly. None of the modules that I wrote and imported do anything with sys > I can understand your confusion. I hope the rest of the list will feel free to dive in with suggestions about what's wrong! :-0 > Put "import sys; print sys.argv" here to make sure your program does indeed see the correct value for the argument list. > import vrut Put "import sys; print sys.argv" here too, to verify that the import statement makes no changes to sys. If you see output from the first print bu not the second then the module is indeed doing something funky. > import sid > > > import string > import math > import time > > > import speeds > import e3_dataAn > import sys > > mode=string.atoi(sys.argv[1]) > ARGFILE_stim=sys.argv[2] > ARGFILE_calib=sys.argv[3] > OUTFILE=sys.argv[4] > SUMFILE=sys.argv[5] > sidOutfile=sys.argv[6] > VECTION_DURATION=string.atoi(sys.argv[7]) > path=sys.argv[8] > > vrut.go(vrut.NICE) > > > > Steve Holden wrote: > [ various apparently irrelevant things ] I'm currently betting that a recursive import is somehow messing things up. Otherwise I'm a little stumped, and we'll have to proceed with debugging step by step. regards Steve -- http://www.holdenweb.com/ From rnd at onego.ru Tue Jul 10 11:45:18 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 10 Jul 2001 19:45:18 +0400 (MSD) Subject: [OT] Eternal programming In-Reply-To: Message-ID: On Tue, 10 Jul 2001, Mikael Olofsson wrote: > INTERCAL or Brainf***, anyone? The following script was written in half an hour (after I found this page: http://chemlab.pc.maricopa.edu/pocket/pfmanual.html (Chemists are going to use Forth in nanotech programming. ;-) #!/usr/bin/python # -*- mode: python -*- # future core Eternal/Python implementation ;-) # This code is in Public Domain # $Id:$ global defining, stack, dictionary, executionstack defining = 0 def _DOT(): global stack try: v = stack.pop() print v return 1 except: return None def _ADD(): global stack try: v2 = stack.pop() v1 = stack.pop() stack.append(v1+v2) return 1 except: return None stack = [] dictionary = { "." : {'immediate': 0, 'body': _DOT}, "+" : {'immediate': 0, 'body': _ADD}, } def isnumber(x): try: int(x) except: return None return x def builtin(word): return type(word['body']) == type(builtin) def SEARCH(token): global dictionary try: return dictionary[token] except: return None def EXECUTE(word): if builtin(word): return word['body']() else: return INTERPRETE(word['body']) def EMPTYSTACK(): raise "Empty stack" def WHAT_IS_IT(): raise "???" def COMPILE(token): pass def LITERAL(token): pass def INTERPRET(tokens): global defining, stack for token in tokens: found = SEARCH(token) if found: if not defining or found['immediate']: if not EXECUTE(found): EMPTYSTACK() else: COMPILE(token) else: if isnumber(token): if not defining: stack.append(int(token)) else: LITERAL(token) else: WHAT_IS_IT(token) return 1 INTERPRET(["1", "2", "+", "."]) # End of interpreter.py TODO: - executionstack instead of Python-based recursion - compiling part of the story - what is MCOMPILE and is it useful enough to complicate things? - token reader - where globals should live? (multithreading-safely) - error handling It needs courage to replace Forth's machine-code orientedness into very-high Python structures ;-) I just can't decide if I want to emulate memory arrays or do it in free fashion ;-) Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From jwc3f at spammenolikey.Virginia.EDU Tue Jul 31 15:59:26 2001 From: jwc3f at spammenolikey.Virginia.EDU (Jeffrey W. Collyer) Date: 31 Jul 2001 19:59:26 GMT Subject: SocketServer clean shutdown from signal Message-ID: <9k72mu$l19$1@murdoch.acc.Virginia.EDU> I'm using SocketServer.StreamRequestHandler to write a multithreaded network daemon. In normal useage it will serve requests forever and never shut down. However, I want to be able to send the server a kill signal and immediately restart it on the same port. (this is under Unix, specifically Solaris). I built the signal handler outside of the class, and I don't seem to be able to cleanly release the socket when the server gets a kill. If I have a client connected to the server, when I send the kill, the socket goes into TIME_WAIT no matter what I try. Is there anyway around this? I have something like this : ---- # set up signal handler def sighandler(signum,frame): # my stuff here os._exit(0) signal.signal(signal.SIGINT,sighandler) class MyHandler(SocketServer.StreamRequestHandler): def main(): host='' # localhost name port=31752 # local port number # create the Threading server server = SocketServer.ThreadingTCPServer( (host,port), MyHandler) server.allow_reuse_address=1 server.serve_forever() ---- I can't seem to access the socket object of the Myhandler instance server inside the signal handler. If I do a server.socket.close() I get an exception. Any ideas? -- Jeff From edcjones at erols.com Wed Jul 25 14:25:39 2001 From: edcjones at erols.com (Edward C. Jones) Date: Wed, 25 Jul 2001 14:25:39 -0400 Subject: PEP0238 lament References: Message-ID: <3B5F0F23.4020600@erols.com> Guido van Rossum wrote: > Thanks for the suggestion. I think I'll do it this way: Python 3.x > will be the first incompatible version, Python 2.x will require > __future__ statements or other explicit ways to indicate that the > programmer wants the new feature. > > For less disturbing changes like nested scopes or generators (which > would break only very small amounts of old code), we can introduce the > new feature for real in the next release (e.g., nested scopes will be > standard in 2.2, I expect generators will become standard in 2.3), but > for devastatingly code-breaking changes like division, I'll wait until > 3.0 before it becomes the law. Good decision. The problem is solved as far as I am concerned. 3.0 == 3000/100; 4.0 == 3000/10; 5.0 == 3000 Ed Jones From peter at engcorp.com Thu Jul 12 21:04:50 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 12 Jul 2001 21:04:50 -0400 Subject: Long Live Python! References: <3B4CC986.A5C8E605@engcorp.com> Message-ID: <3B4E4932.78F8B7D3@engcorp.com> Rainy wrote: > I meant more like sending somewhere my resume saying I know python and did > this and that, and getting hired. I actually did use some python at my > previous job (some cgi/image manipulation). I was then asked to redo it > in perl :-/. Is that the reason you left? :) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From cjensen at bioeng.ucsd.edu Fri Jul 13 19:59:19 2001 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Fri, 13 Jul 2001 16:59:19 -0700 Subject: apply problems References: <3B4F3501.E1469159@bioeng.ucsd.edu> Message-ID: <3B4F8B57.7684D13A@bioeng.ucsd.edu> William Park wrote: > > On Fri, Jul 13, 2001 at 10:50:57AM -0700, Curtis Jensen wrote: > > apply( self.ren.Elements, cmd[1], additional_kwds ) > > > def Elements( self, at, deformed, iact, normal, xi, nelist, nodes, > > elements, *args, **kwds ): > > > However, if I replace the apply command with: > > self.ren.Elements( cmd[1][0], cmd[1][1], cmd[1][2], cmd[1][3], > > cmd[1][4], cmd[1][5], additional_kwds ) > > > > It works fine. I can't figure why the apply line doesn't work. There > > Try > apply( self.ren.Elements, (self, cmd[1]), additional_kwds ) > There is subtle difference between calling Elements() as regular > function and as class method within an object, namely 'self' argument. > > -- > William Park, Open Geometry Consulting, > 8 CPUs cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc. I thought about that. But in the test examples below, you can see that you'll that you don't have to pass "self" with apply. In fact if you do, you'll end up with too many parameters. Also, symanticly, I think "apply( self.ren.Elements, (self, cmd[1]), additional_kwds )" will only pass two arguments "self" and "cmd[1]" as apposed to sending "self" and all the items in "cmd[1]" as individual argument. You'd need to put "self" at the beginning of cmd[1], or make a new tuple to pass in. But I know what you mean. In any case, my problem went away. I'm not exactly sure why. It probably had to do with unsafe dynamic binding or something like that. :) >>> class foo: ... def __init__( self ): ... apply( self.bar, [1,2], {'c':3, 'd':4} ) ... def bar( self, a, b, c, *args, **kwds ): ... self.a = a ... self.b = b ... self.c = c ... >>> inst = foo() >>> inst.a 1 >>> inst.b 2 >>> inst.c 3 >>> >>> class foo2: ... def __init__( self ): ... apply( self.bar, [self,1,2], {'c':3, 'd':4} ) ... def bar( self, a, b, c, *args, **kwds ): ... self.a = a ... self.b = b ... self.c = c ... >>> inst2 = foo2() Traceback (innermost last): File "", line 1, in ? File "", line 3, in __init__ TypeError: keyword parameter redefined -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From emile at fenx.com Sat Jul 14 19:40:28 2001 From: emile at fenx.com (Emile van Sebille) Date: Sat, 14 Jul 2001 16:40:28 -0700 Subject: list[] = var => list.append(var) (phpstyle) References: <4e2ddb70.0107141310.3c7ca355@posting.google.com> <9iqfge0gba@enews1.newsguy.com> Message-ID: <9iqlgi$kbg9g$1@ID-11957.news.dfncis.de> Alex is right as long as var_to_append is already a list. For non-lists though you can also do list_var += 1, or, list_var += (1,) -- Emile van Sebille emile at fenx.com --------- "Nick Perkins" wrote in message news:LF447.476898$eK2.98947068 at news4.rdc1.on.home.com... > > "Alex Martelli" wrote in message > ... > > list_var += var_to_append > ... > > you mean: > > list_var += [var_to_append] > > or, > > list_var += list_to_extend > > > From new_name at mit.edu Mon Jul 2 18:13:36 2001 From: new_name at mit.edu (Alex) Date: 02 Jul 2001 18:13:36 -0400 Subject: Python for air traffic control? References: <9hlfbn$6ok$1@nereid.worldonline.nl> Message-ID: > You would be maintaining NxN table to see > - if any position is outside the assigned trajectory, or > - distance (between any two position) is too close You don't need an NxN table, actually. You can partition the space in which you'll be tracking the planes into cubical buckets with diameters greater than your threshold minimum distance. Then you only need to check for each plane the other planes that are in its bucket or an adjacent bucket. It scales linearly with the number of planes. Alex. From bokr at accessone.com Sat Jul 7 20:59:27 2001 From: bokr at accessone.com (Bengt Richter) Date: Sun, 08 Jul 2001 00:59:27 GMT Subject: I'm Sure There's A Better Way References: <3B465858.CB7F38E8@tundraware.com> <9i6e5502d9g@enews4.newsguy.com> Message-ID: <3b478576.1314346961@wa.news.verio.net> On Sat, 7 Jul 2001 09:38:20 +0200, "Alex Martelli" wrote: >"Tim Daneliuk" wrote in message >news:3B465858.CB7F38E8 at tundraware.com... >> I want a function to check a string to make sure it is a legitimate >> dollar amount. Which means it follows these rules: >> >> First character is numeric or "-" >> At most, one "." is allowed and, if present, is followed by exactly two >digits >> All the remaining characters must be in the range "0" - "9" > >These specs seem to be equivalent to: > optional: - > one or more digits I took it to be zero or more > optional: . followed by two digits > end of string > >This is very easy to express as a Regular Expression: > r'-?\d+(\.\d\d)?$' or r'^-?(\d*\.\d\d|\d+)$' if you want to allow .12 (or -.00), see below ;-) > >So one function to check any string to see if it satisfies >this pattern is: > >def isDollar(astring): > import re > return re.match(r'-?\d+(\.\d\d)?$', astring) > I had the same idea, except I didn't realize match didn't need a '^' to anchor at the beginning (!RTFM). And of course my group()==originalString check was mindless ;-) Actually, any minus-zero patterns don't seem reasonable, and other than a single zero, a zero leading digit seems bad, wherther followed by \.\d\d or not. I just RTFM'd a little and found the (? extensions. Whee! r'(-(?!(0*\.?0+$|0+\.0*$)))?(0|\d?\.\d\d|[1-9]\d*(\.\d\d)?)$' From ddublanc at free.fr Fri Jul 27 15:23:58 2001 From: ddublanc at free.fr (Dublanc, David) Date: Fri, 27 Jul 2001 19:23:58 GMT Subject: scoping problems References: Message-ID: Hi, You can do it exactly as you write it ! If I understand namespace in Python, function names a et b are known by the module before that function objects are executed. Regards, David "Narayan Desai" a ?crit dans le message news: yrx66cegqs2.fsf at catbert.mcs.anl.gov... > How can i define the following code: > > def a(): > b() > > def b(): > a() > > (ignoring for a moment that this would never terminate) > How do you get the namespaces right? > > I would solve this with function prototypes in C, but it isn't clear > to me how to do this in python. > thanks... > -nld > From steve at lurking.demon.co.uk Mon Jul 23 02:39:13 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Mon, 23 Jul 2001 07:39:13 +0100 Subject: PEP0238 lament References: Message-ID: <5sdnlt072hm6hp17nluu6f0fqq4bvr6mj8@4ax.com> On Sun, 22 Jul 2001 17:40:10 GMT, sill at optonline.net (Rainy) wrote: >First of all, it's really ugly. It's the ugliest thing in python for a newbie, >imho. Yes, 1/2 is 0. You have to type 1.0/2 to get 0.5. No, there is no good >reason for that, just memorize it. Ugh. No reason! Every five-year-old knows that 5 divided by 2 is 2 remainder 1. What is the problem? Integer division *is* important. Confusing integers and floats is a sign of sloppy thinking, and a clue that far more bugs are going to result. Furthermore, Python is unlikely to *ever* be the only computer language, and most Python users use other languages as well - that is the nature of scripting languages. Surely we should comply with conventions used in the languages we know are unlikely to die - those which are already popular multi-vendor languages, and those which have such powerful single-vendor backing that they are unlikely to disappear. That means the likes of C, C++, Java and Visual BASIC. And what about the languages web developers are used to, such as VBScript and JavaScript. From sholden at holdenweb.com Mon Jul 30 17:46:46 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 30 Jul 2001 17:46:46 -0400 Subject: a break for comprehensions References: Message-ID: "Tom Good" wrote in message news:ac677656.0107301331.5330d4db at posting.google.com... > "Steven D. Majewski" wrote in message news:... > > > > The 'while' clause seems useful, and I don't see anything inherently > > ambiguous about it, but sticking a procedural clause into what's > > otherwise a declarative seens to go against the spirit -- what's > > nice about list comprehensions is that they are just like set > > notations. ( well -- the left hand side is often procedural -- it > > would be even more readable if it were more clearly separated > > with a "where" clause, but that would be Yet Another Keyword... ) > > > > -- Steve Majewski > > That is a compelling argument. However, I am still struggling with > how to best work with infinite sets (which are now easy to create with > generators). With set notation, you can refer to an infinite set > without actually creating each member of the set. List comprehensions > try to "fill up" the list, which causes problems if an unbounded > generator is involved. > > If g is a generator that generates all positive integers, I would like > to write something like: > > L = [x * 2 for x in g()] > print L[:10] > > This does not work, of course, but that is how I would tend to think > about it in my head. List comprehensions with lazy evaluation? Is it > possible? > With the introduction of generators there doesn't seem to be anything inherently impossible about the introduction of such a concept. A major problem with existing list comprehensions, however, is that they produce a list! Seems that a "lazy comprehension" would have to encapsulate a generator somehow, and limit the operations you could perform on it to those for generators. I believe a separate syntax would be required to represent such a radically different object. But you, of course, may know better ... if you're looking for a syntax, one possibility would be: [[x * 2 for x in g()]] regards Steve -- http://www.holdenweb.com/ From gerhard.nospam at bigfoot.de Tue Jul 17 18:55:18 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Wed, 18 Jul 2001 00:55:18 +0200 Subject: [ANN] Database modules on win32 site moved Message-ID: I have changed my ISP, so I had to move my homepage with the Windows binary builds of various database modules (MySQLdb, PyGreSQL, ...). The new URL is http://www.cs.fhm.edu/~ifw00065/ The old URLs were: http://highqualdev.com http://home.t-online.de/home/err666/ 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, [chr(ord(x)^42) for x in list('zS^BED\nX_FOY\x0b')]) From bokr at accessone.com Tue Jul 3 21:17:10 2001 From: bokr at accessone.com (Bengt Richter) Date: Wed, 04 Jul 2001 01:17:10 GMT Subject: Python for air traffic control? References: <9hlfbn$6ok$1@nereid.worldonline.nl> <3b4102f4.887720905@wa.news.verio.net> <0Kd07.7470$e5.974463@newsb.telia.net> Message-ID: <3b425350.973828140@wa.news.verio.net> On Tue, 03 Jul 2001 06:36:44 GMT, "Fredrik Lundh" wrote: >Bengt wrote: >> >> I am wondering if using non-deterministic[1] memory allocation is >> permissible in a safety-critical system. > >note that CPython uses reference counting, which is at least as >deterministic as malloc/free or auto_ptr stuff. > Reference counting is one way to decide when it's ok to free something, but UIAM it doesn't say much about the freeing mechanism, or when that's actually going to be done, nor what may or may not be guaranteed about the state of the pool and the ability to satify future requests for space within an acceptable delay time, or at all. I would expect that malloc/free would not be permissible in a safety-critical system, except perhaps restricted uses such as pre-allocating static space during startup. Part of that space might possibly be used for creating static pools of very well controlled and analyzed reusable space, which could be allocated and freed by specialized methods, as predictably in time and space as a stack push in a fully defined context. Speaking of stacks, no recursion, unless you could prove max stack depth (for which space would have to be pre-allocated to handle proved worst case, I would think). >(if you keep feeding a CPython program the same kind of data, it >tends to either leak all the time, or not at all). > >> What kind of testing could you specify to guarantee that code >> would continue to run? > >I've built mission-critical, real-time Python systems. With careful >design, and a few months in a "sandbox" environment, such systems >tend to run just fine. > I hear you, but do they sign off safety-critical systems on 'tend' ? >And I'm pretty sure people doing safety-critical systems know a lot >more about advanced testing than we do. > Sure hope so ;-/ >So I agree with Gordon: "Go for it (just be careful)." > Um, so where and when will this system first be operational? From hobomo at austin.rr.com Wed Jul 25 16:44:16 2001 From: hobomo at austin.rr.com (James Money) Date: Wed, 25 Jul 2001 15:44:16 -0500 Subject: Any Suggestions for an Editor with MS-Windows ? References: <92757716C8BFF476.D432477A795DB759.E2FB05E062137965@lp.airnews.net> <3B5BDC16.3A348DF6@oce.nl> Message-ID: <3B5F2FA0.26167F74@austin.rr.com> You might try Komodo (by activestate). I've been using it for a couple of weeks now and I generally like its behavior. (A few minor irritations but thats ok) Robert Amesz wrote: > Marco Salden wrote: > > >> Am almost half way through the manual and getting ready for the > >> easy job of bringing over some basic files (yea, right). Currently > >> using Ultra Edit but having doubts about it. > > Why would that be? It's about as configurable as it gets, and can be > made to produce syntax colouring for Python. > > > Try Vim (VI Improved) for Windows. You may find all you need at > > http://www.vim.org/ . I am using it for about half a year now and > > before that used Ultra Edit, TextPad etc but wouldn't want to turn > > back again... Vim supports Python syntax and I think even an > > embedded interpreter is available for it (not sure...). > > But it still is a textscreen app with only a very thin GUI-veneer. > That's not everybody's cup of tea. > > SciTE Edit (I believe the URL is something like www.scintilla.org) is > pretty nice for us Pythoneers. If only it could open multiple files... > > Robert Amesz > -- > http://mail.python.org/mailman/listinfo/python-list -- James Money hobomo at austin.rr.com 512-343-1266 From sheila at spamcop.net Sun Jul 22 02:20:14 2001 From: sheila at spamcop.net (Sheila King) Date: Sun, 22 Jul 2001 06:20:14 GMT Subject: subclassing Exceptions References: <9ihklt8u0vvh1aa0mg6tadbmjo9mot47e0@4ax.com> <3b5a69a3$0$320$6e49188b@news.goldengate.net> Message-ID: On Sun, 22 Jul 2001 00:51:31 -0500, "Volucris" wrote in comp.lang.python in article <3b5a69a3$0$320$6e49188b at news.goldengate.net>: :If all you want is your own exception (nothing fancy), all you need is a :class: : :class SpamException: : pass OK, interesting. I didn't realize you could make an exception without subclassing it. So, I tried this script: -----------begin except.py--------------------- class SpamException: pass while (1): inputstring = raw_input("Enter any string, except 'spam': ") if inputstring == "spam": raise SpamException -----------end except.py----------------------- Here is a sample output: >>> Enter any string, except 'spam': pig Enter any string, except 'spam': spam Traceback (innermost last): File "E:/programs/LearningPython/Exceptions/except.py", line 7, in ? raise SpamException SpamException: <__main__.SpamException instance at 0104C94C> :you can raise and catch that just like any exception, but it'll be kind of :ugly when it gets printed. Well, yes. It doesn't look like normal exceptions, does it? :class SpamException: : def __str__(self): : return "cooking spam is not required" : :that will give a clue as to what the exception means. OK, so I modified my above file, to include the __str__ as you show. Here is a sample run: >>> Enter any string, except 'spam': horse Enter any string, except 'spam': meat Enter any string, except 'spam': spam Traceback (innermost last): File "E:/programs/LearningPython/Exceptions/except.py", line 8, in ? raise SpamException SpamException: cooking spam is not required So, yes, it does look a bit nicer. :That said, I don't :recall ever seeing an exception not subclassed from Exception, so it's :probably a good idea. : :class SpamException(Exception): : def __str__(self): : return "cooking spam is not required" : :I don't know why every one is subclassed, but the HPIC seem to know what :they're doing so far. I have no reason to question them. Yet. Interesting point. When I make this modification to the SpamException class, deriving it from the Exception class, I seem to get the exact same behavior. However, I noticed earlier this evening, from browsing the exceptions.c source (as noted elsewhere in this thread), that the Exceptions seem to have 3 methods and 1 datamember, namely: methods: __init__ __getitem__ __str__ and the datamember __doc__ So, I would imagine that if you subclass it, and do not specifically define these methods/data listed above, that you at least inherit them from the base class. Whereas, if you create an "exception" that does not derive from a base Exception class, it would not have these methods. Hmm...I just tried a little experiment in the interactive shell to see if I could confirm/deny my above theory, and it gave me surprising results that I do not understand, and which seem to indicate no difference between deriving it from an Exception class or not. Well, I am interested in further enlightenment on this topic...? -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From mal at lemburg.com Tue Jul 17 06:08:58 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Tue, 17 Jul 2001 12:08:58 +0200 Subject: PEP: Defining Python Source Code Encodings Message-ID: <3B540EBA.EE5372BD@lemburg.com> After having been through two rounds of comments with the "Unicode Literal Encoding" pre-PEP, it has turned out that people actually prefer to go for the full Monty meaning that the PEP should handle the complete Python source code encoding and not just the encoding of the Unicode literals (which are currently the only parts in a Python source code file for which Python assumes a fixed encoding). Here's a summary of what I've learned from the comments: 1. The complete Python source file should use a single encoding. 2. Handling of escape sequences should continue to work as it does now, but with all possible source code encodings, that is standard string literals (both 8-bit and Unicode) are subject to escape sequence expansion while raw string literals only expand a very small subset of escape sequences. 3. Python's tokenizer/compiler combo will need to be updated to work as follows: 1. read the file 2. decode it into Unicode assuming a fixed per-file encoding 3. tokenize the Unicode content 4. compile it, creating Unicode objects from the given Unicode data and creating string objects from the Unicode literal data by first reencoding the Unicode data into 8-bit string data using the given file encoding To make this backwards compatible, the implementation would have to assume Latin-1 as the original file encoding if not given (otherwise, binary data currently stored in 8-bit strings wouldn't make the roundtrip). 4. The encoding used in a Python source file should be easily parseable for en editor; a magic comment at the top of the file seems to be what people want to see, so I'll drop the directive (PEP 244) requirement in the PEP. Issues that still need to be resolved: - how to enable embedding of differently encoded data in Python source code (e.g. UTF-8 encoded XML data in a Latin-1 source file) - what to do with non-literal data in the source file, e.g. variable names and comments: * reencode them just as would be done for literals * only allow ASCII for certain elements like variable names etc. - which format to use for the magic comment, e.g. * Emacs style: #!/usr/bin/python # -*- encoding = 'utf-8' -*- * Via meta-option to the interpreter: #!/usr/bin/python --encoding=utf-8 * Using a special comment format: #!/usr/bin/python #!encoding = 'utf-8' Comments are welcome ! -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From steve at lurking.demon.co.uk Mon Jul 23 16:47:47 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Mon, 23 Jul 2001 21:47:47 +0100 Subject: proposed language change to int/int==float (was: PEP0238 lament) References: Message-ID: On Mon, 23 Jul 2001 18:53:28 GMT, grante at visi.com (Grant Edwards) wrote: >In article , Steve Horne wrote: > >>On Mon, 23 Jul 2001 09:46:20 -0500, Skip Montanaro >> wrote: >> >>>completely foreign to people. After years of bit rot in their >>>brains due to calculator crutches they may need a minute to >>>refresh, that should be all. >> >>My calculator supports integers - and not with a second integer >>button, I just set the mode and it all works happy. > >And I'll bet cash money that the "integer divide" key and the >"float divide" key are one-in-the-same button. The operation >is determined by the type of the operands (the "mode"). Oops - I meant "and not with a second divide button". Been getting pissed off today, and my typing suffers under those conditions. From careye at spamcop.net Fri Jul 13 23:13:42 2001 From: careye at spamcop.net (Carey Evans) Date: 14 Jul 2001 15:13:42 +1200 Subject: [Python-Dev] Python 2.1.1c1 released References: <200107131721.f6DHLgX16757@odiug.digicool.com> Message-ID: <877kxcrymx.fsf@psyche.dnsalias.org> "Eric S. Raymond" writes: > Should be. They haven't even settled their freeze policy yet, let alone > declared a freeze. I've been tracking this because I'm coming up on a > fetchmail-5.9.0 stable release and want to get that in, too. The freeze for Debian 3.0 is described in Anthony Towns' mail to debian-devel-announce on 1 July: http://lists.debian.org/debian-devel-announce-0106/msg00014.html but that only affects base packages so far. Python is included in the freeze of "standard" packages, so Python 2.1.1 must be done by the end of August; see the end of: http://lists.debian.org/debian-python-0107/msg00041.html fetchmail is "optional" priority, so they'll be time to get a new version into Debian after Python is done. -- Carey Evans http://home.clear.net.nz/pages/c.evans/ "Quiet, you'll miss the humorous conclusion." From robin at jessikat.fsnet.co.uk Mon Jul 30 03:55:51 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Mon, 30 Jul 2001 08:55:51 +0100 Subject: Language Niches (long) References: <8beb91f5.0107280407.5a30341d@posting.google.com> <3B62FAFF.BB987077@Lugoj.Com> <8beb91f5.0107282158.4785ae5e@posting.google.com> <3B6481DB.C5AEA46@ActiveState.com> <3B64CCDD.1D01A7A7@Lugoj.Com> Message-ID: In article <3B64CCDD.1D01A7A7 at Lugoj.Com>, James Logajan writes >Paul Prescod wrote: >> >> I'm not going to respond to the majority of the post because I don't >> really see where the conversation is going. > >I'm not sure it is going anywhere in particular. Just some people shootin' >the breeze. yes the point of discourse is to replace silence. Sometimes the silence is prefereable :) -- Robin Becker From paulp at ActiveState.com Mon Jul 2 10:36:36 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Mon, 02 Jul 2001 07:36:36 -0700 Subject: Comment on PEP-0238 References: <3B3BE855.A6223E70@3-cities.com> <7ef50c46.0107020554.31cc948b@posting.google.com> Message-ID: <3B4086F4.97263C35@ActiveState.com> "Robert J. Harrison" wrote: > >... > The current coercion rules are simple, easy to grasp, and consistent > with how most people are taught arithmetic. That is simply not true. Most people do not expect these four expressions to yield different results: 1.0/3.0 1/3 1.0/3 1/3.0 If you were taught this in school, it must be "new math". >... > 2) Integers should be treated as a distinct type from reals with > automatic coercion only as necessary (with the current rules). What is "necessary"? Why is automatic coercion *ever* necessary? Only to simulate the mathematics we are taught in primary school where the above statement are all equivalent. > For instance, the new proposal sensibly does not suggest that lists > should support real indices, That might well be an implication of PEP 228. http://python.sourceforge.net/peps/pep-0228.html > however simple expressions such > as a[i/3] would have to be coded as a[int(i/3)] or a[i//3] > in order to be sure to avoid a type error. You mean that you would have to say exactly what you mean according to the new syntax. That's hardly a legitimate argument against the syntax. "If you add a 'function' keyword, I would have to precede my function calls with it." Well, yeah, that's the point of adding new syntax. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From mhagger at alum.mit.edu Thu Jul 12 14:42:10 2001 From: mhagger at alum.mit.edu (Michael Haggerty) Date: 12 Jul 2001 20:42:10 +0200 Subject: Two minor syntactic proposals References: <9gkcsn0229c@enews2.newsguy.com> <3B301914.7B60E6F7@my.signature> Message-ID: Greg Ewing writes: > 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. > > (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.) Bengt Richter writes: > I think I prefer just an easier way to type "self." > How about just the dot? I.e., ".x" means "self.x" What about combining the ideas: within a class definition or instance method definition, ".x" means "self.x". Thus: class C: def .x(arg): # defines instance method; "self" would be a magic implicit # first parameter (requires special treatment for word "self". def C.x(arg): # defines class (static) method def f(self, arg): # Defines instance method (for backwards compatibility) Michael -- Michael Haggerty mhagger at alum.mit.edu From db3l at fitlinxx.com Fri Jul 27 17:31:56 2001 From: db3l at fitlinxx.com (David Bolen) Date: 27 Jul 2001 17:31:56 -0400 Subject: byte compiled files References: <3B602FA0.6030809@herts.ac.uk> <3B6127EB.2080002@herts.ac.uk> Message-ID: Mark Robinson writes: > Thanks for the help guys, sorry I didn't include the code (what can I > say, duh). Anyway I did manage to fix the problem but I am still kinda > interested as to why I was getting that previous behaviour. I am running > python 2.1 under red hat 7, and python 2.1.1 under windows NT and had > the same problem under both. Here is the code: > > def checkValidData(bsite): > repeats = ['AAAA', 'CCCC', 'GGGG', 'TTTT'] > for x in bsite: #check new bsite contains valid charactors > if(x is not 'A' and x is not 'G' and > x is not 'C' and x is not 'T' ): > return 0 > for x in repeats: > if (string.find(bsite, x) != -1): > return 0 > return 1 > > Changing where I test if x is A, C, G or T by using the != test rather > than 'is not' solved the problem, and I guess I may have been using it > inappropriately, but I still don't see why it would have working > correctly first run and then incorrectly when working from the .pyc file. Ah - seeing this makes it much clearer what was probably going on. It's because of what "is" does. It's an object identity test, which isn't what you want here. In fact, you're probably just lucky that it worked at all even the first time, due to an implementation optimization in Python. Python will "intern" small strings automatically - placing them in a global table of such strings for improved performance. This guarantees that references to such strings are actually references to single objects. A similar thing happens for small integers (0-100 I think), which makes checks such as "is 1" possibly work too. For example: >>> a='A' >>> b='A' >>> print id(a),id(b),id('A') 8262784 8262784 8262784 This means that (luckily) if you pass the string 'A' into your function and then do a " is 'A'" it'll work, but there's a lot happening under the covers. When you pass 'A' into the function the literal string 'A' produces an object reference to the interned copy, which is then passed to the function. Internal to the function the use of 'A' does the same thing, and thus both references to 'A' are to the same object and "is" works (or "is not" fails). E.g.: >>> def check(val): ... print val is 'A' ... >>> check('A') 1 >>> But that's by no means guaranteed behavior - there could just as easily be two discrete objects involved. Python only interns some string constants (currently string constants with alphanumerics and underscores), so if you happened to use something larger the same code wouldn't work the way you thought, e.g.: >>> a='no intern' >>> b='no intern' >>> id(a),id(b),id('no intern') (8363408, 8361360, 8361968) >>> def check(val): ... print val is 'no intern' ... >>> check('no intern') 0 And I had to peek at the source to see how the current constant interning is handled - it's not guaranteed behavior so certainly not something to depend on. In terms of your pickling behavior - I haven't reviewed the source, but my best guess is that when the compiler loaded the pre-compiled function code from the compiled module, the internal string literals were their own objects, and thus no longer matched against the objects representing the information supplied to the function from the caller. But since such behavior (two independent strings yielding references to the same object) is not well-defined behavior, the compiler is certainly free to do that. So definitely stick with "==" or "!=/<>" if you are trying to compare the actual value of a string, as opposed to the identity of the string object itself. True, identity check can sometimes be faster, but as you can see it is _not_ the same as a value check (and I believe strings already have an optimization of checking object identity before bothering to actually compare contents). -- -- 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 kellydemarco at dontspamme.com Thu Jul 12 06:54:06 2001 From: kellydemarco at dontspamme.com (Kelly DeMarco) Date: Thu, 12 Jul 2001 19:54:06 +0900 Subject: changes in threading and SocketServer since Python 2.0? Message-ID: <9ijvo7$df7$1@news.nuri.net> I used to use webdebug(http://www.cyberclip.com/webdebug/) on Python 1.6 without any problem, but I've been through some problem using it on Python 2.1 thesedays. The source code is quite short and clear, so there doesn't seem to be any good reason why it's failing on Python 2.1 -- maybe some changes in the standard library? What's more interesting is, when webdebug is run with singlethreaded mode, there's no problem. Therefore, I guess it has something to do with threading lib. The platform is win32, and the error I get is: Exception in thread Thread-13: Traceback (most recent call last): File ".\threading.py", line 378, in __bootstrap self.run() File ".\threading.py", line 366, in run apply(self.__target, self.__args, self.__kwargs) File "c:\python21\lib\SocketServer.py", line 246, in finish_request self.RequestHandlerClass(request, client_address, self) File "c:\python21\lib\SocketServer.py", line 495, in __init__ self.handle() File "WDhandler.py", line 116, in handle self.httpRequest = HTTPrequest.HTTPrequest(self.rfile, self.client_address) File "HTTPrequest.py", line 73, in __init__ self.raw_requestline = self.readLine(input) File "HTTPmessage.py", line 69, in readLine str = input.readline() File "c:\python21\lib\socket.py", line 233, in readline new = self._sock.recv(self._rbufsize) AttributeError: 'int' object has no attribute 'recv' [as you see, the socket instance is erroneously an int object here -- and it happens only when in threading mode using threadingmixins from socketserver] Can anyone help me out? Thanks in advance. From digitig at cix.co.uk Fri Jul 27 20:54:00 2001 From: digitig at cix.co.uk (Tim Rowe) Date: Sat, 28 Jul 2001 01:54 +0100 (BST) Subject: Language change and code breaks References: Message-ID: In article , mcherm at destiny.com (Michael Chermside) wrote: > Roman (ironicly): > > > Windows is case-insensitive and thus "easy to use" only before one > > > needs > > > to put web-pages on the real (UNIX) web-server. Then they > > > understand all > > > the troubles with mised case, national-charset filenames, abbr~ted > > > filenames, local file references "C:\Mydocs\lalala", bmp-images etc. > > GvR: > > But it's still open for debate whether the problem here is Windows or > > Unix! > > > > I'm very surprised to hear this. Yes, I've taught lots of beginners, and > I've found that they often complain about the case sensitivity. But I > tell them that "Computers are EXTREMELY literal", and "you must be VERY > precise when programming", and they get it. I also get complaints (not > so many) about the computer not understanding a mis-spelled system call. > > It seems to me that whether the language requires case sensitivity or > not, it is still very poor style to vary the capitalization of a given > identifier. It's kind of like indentation... and (in Pascal, C, Basic, > and other non-Python languages) I mark my student's programs WRONG if > they don't use consistant indenting. > > Don't encourage sloppy habits: require case sensitivity. > > Besides... if you make identifiers NOT case sensitive, then when they > try opening files or URLs and find that those ARE... they'll REALLY > have problems. Sorry to come into this debate rather late, but in my programming community (mission critical systems) both case sensitivity /and/ case insensitivity are seen as problematic and a rich source of bugs. The hardliners would have it be an error to have two identifiers differing only in case, the moderates would have it produce a warning. The latter could be a way forward for Python. A message to the effect of "You are using both 'Foo' and 'foo' in this program. You do realise they're not the same, don't you?" would help the newbies and, with a suitably configurable tool need not bother the experts because they'd turn the warning off. As Guido (I think it was) points out elsewhere, the whole thing could be seen as a tool issue, and I would consider it a good feature for a tool (provided it /can/ be turned off). I /don't/ think the language should be changed -- I'm already finding it impossible to get anybody to adopt Python because of the (perceived?) instability of the language spec. From klaus-gerd.meyer at de.bosch.com Tue Jul 24 10:20:44 2001 From: klaus-gerd.meyer at de.bosch.com (Klaus-G. Meyer) Date: Tue, 24 Jul 2001 16:20:44 +0200 Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <9jjubo$2vm$1@slb6.atl.mindspring.net> Message-ID: <9jk07s$gq0$1@proxy.fe.internet.bosch.com> > those guys. It *is* odd to have to do something like: > x = float(y)/z > to get best-possible division in Python. But what is with the "best possible" multiplication? 99999*99999 -> integer overflow Why not an long integer result? (or maybe float) You must explicit type: 99999*99999L or 99999*99999. Is that not the same thing as type 1./3 ??? Klaus From jkraska1 at san.rr.com Tue Jul 31 02:12:25 2001 From: jkraska1 at san.rr.com (Courageous) Date: Tue, 31 Jul 2001 06:12:25 GMT Subject: "Systems programming" (was: Language Niches (long)) References: <8beb91f5.0107280407.5a30341d@posting.google.com> <4E215400D01D7374.0068C51FD6502BE8.99D4E013ECF0FDFB@lp.airnews.net> Message-ID: >You can do kernel stuff in C++ on a lot of systems, but it's often more >trouble than it's worth... I recall a Usenix where Linus spoke. Upon being asked if he'd redo the kernel in C++, he all but laughed the questioner's question away. At the time, he plainly indicated that he thought that the question was absurd. C// From news at dorb.com Thu Jul 5 00:10:10 2001 From: news at dorb.com (Darrell) Date: Thu, 05 Jul 2001 04:10:10 GMT Subject: Converting from long integer to read-only buffer References: <3b42780c@news.ucsc.edu> Message-ID: Whoops The some test code made it into my post. This bit of code has no purpose. binData = ''.join([chr(eval('0x'+val)) for val in re.findall('..|.',hex(x)[2:-1])]) -Darrell From michael at stroeder.com Tue Jul 10 11:32:35 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Tue, 10 Jul 2001 17:32:35 +0200 Subject: Python: Database to Web Part II (and "teaching language") References: <5174eed0.0107060820.ff90805@posting.google.com> <23891c90.0107090815.3685a9@posting.google.com> <14m27.2182$z21.428719@newsc.telia.net> <23891c90.0107100440.2eb444af@posting.google.com> <3B4AFE8D.DE1F6563@stroeder.com> Message-ID: <3B4B2013.F8BF210@stroeder.com> Grant Edwards wrote: > > But that doesn't mean you have to write code. You can: > > Help maintain a web site. > Write a tutorial on something. > Maintian a manual. > Hang around a newsgroup and answer questions. Off course, these things would help. But the reality is that people ask for help since they did not read the docs which were already there. Not to speak of how difficult it is to find somebody for maintaining a decent manual. Many ask for documentation but they won't read it. Ciao, Michael. From new_name at mit.edu Tue Jul 24 22:37:16 2001 From: new_name at mit.edu (Alex) Date: 24 Jul 2001 22:37:16 -0400 Subject: raw_input() with out blocking process References: <20010724211512.04292.00000898@ng-fh1.aol.com> Message-ID: Check out the curses module: http://py-howto.sourceforge.net/curses/curses.html HTH Alex. From deltapigz at telocity.com Wed Jul 4 00:08:56 2001 From: deltapigz at telocity.com (Adonis) Date: Wed, 04 Jul 2001 00:08:56 -0400 Subject: Python distribution... Message-ID: <3B4296D8.6DAA39FF@telocity.com> could it possible (under windows) to distribute the python executable + libs needed + python*.dll + script to other windows users ? i was looking into py2exe, but did not get it to work? i have python2.1 (distutils already in it) but then when i was attempting to compile the sample code it mentioned something about win32api* (something in that sense) do i need to get those files if need be? any help is appreciated. Adonis From quiptiq at yahoo.com.au Thu Jul 12 06:15:26 2001 From: quiptiq at yahoo.com.au (Quiptic) Date: 12 Jul 2001 20:15:26 +1000 Subject: A modest proposal (was: Comment on PEP-0238) References: <9ihse1011n3@enews4.newsguy.com> Message-ID: <87ofqqwj0h.fsf@ivory.localhost> "Alex Martelli" writes: > "Guido van Rossum" wrote in message > news:cpr8vnh6ln.fsf at cj20424-a.reston1.va.home.com... > > > > Good point, Art. I trust my intuition more than my reasoning in these > > things, and often when I try to defend my intuition against > > challenges, what comes out are unsatisfactory rationalizations. > > Sometimes Tim's "channelings" say it better than I could have said it > > myself... :-) > > Being a great designer (or other kind of decision-maker) and > being a good rationalizer/evangelist/salesperson/marketeer are > really separate skills, and pretty much uncorrelated ones to > boot. Indeed. Intelligence and talent often go together, but they're not the same. I think language design is the one area of CS in which "taste" matters most. The ability to see solutions that are "good", clean, simple, elegant, clear, concise, etc apparently comes from a deeper (or at least different) level of awareness than the ability to rationalise after the fact. Of course, there's always the remote possibility that a buffoon is fated to produce an accidental masterpiece ;-) > People in general just won't accept that, which of course suits us > good rationalizers just fine (as we often get credited for better > decisions than we actually make, just because we rationalize better > than others do:-). Sure. It's like the distinction between artists and critics in other fields. It's reasonably easy to work from insight down to rationalisation / realisation, but I've never yet seen it work the other way. There is no recipe for quality; we recognise it _after_ we see it. (I think that even applies to the person who creates it). I've heard gifted musicians and painters sound like complete idiots when they try to explain their work. I've also read the work of intelligent critics who genuinely add to a work of art by their thoughtful interpretations, even though they could never have produced the work themselves. Plenty of that here on c.l.p. It creates a nice synergy. Whether Guido's explanations are satisfying or not (sometimes yes, sometimes no), I'll always trust his judgement. I'm grateful that Python is not mine. If it were mine, it would be one fucking ugly mother. From me at nospam.net Thu Jul 12 04:52:29 2001 From: me at nospam.net (Scottie) Date: Thu, 12 Jul 2001 01:52:29 -0700 Subject: Partially evaluated functions References: Message-ID: "Nick Perkins" wrote in message news:iS5Y6.296363$eK2.60388388 at news4.rdc1.on.home.com... > ...The cookbook version is the only one ...which gives priority to kw > args supplied at call-time over args supplied at create-time.... > 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) Not so easy if you want to avoid the copy: def go(curry): def fn(a=1,b=2,c=3): print a, b, c f1 = curry(f,a=4,c=5) f1() f1(a=6) f1(c=9) I want this to print: 4 2 5 6 2 5 4 2 9 The others print: 4 2 5 4 2 5 4 2 5 If you do the obvious, you'll get: 4 2 5 6 2 5 6 2 9 -Scott David Daniels Scott.Daniels at Acm.Org --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.264 / Virus Database: 136 - Release Date: 7/2/2001 From desai at mcs.anl.gov Fri Jul 27 16:14:29 2001 From: desai at mcs.anl.gov (Narayan Desai) Date: 27 Jul 2001 15:14:29 -0500 Subject: scoping problems In-Reply-To: ("Rich Harkins"'s message of "Fri, 27 Jul 2001 15:57:28 -0400") References: Message-ID: >>>>> "Rich" == Rich Harkins writes: Rich> Try this: class baseclass(): Rich> def __init__(self): Rich> self.__myfunc__() Rich> class a(baseclass): Rich> pass Rich> class b(baseclass): Rich> pass Rich> a.__myfunc__=b b.__myfunc__=a Rich> __myfunc__ in a and b will reference class instances, not Rich> functions, but who am I to quibble? :) Someone had suggested using nested_scopes earlier, but I think that this is really slick :) thanks... -nld From aleaxit at yahoo.com Sun Jul 15 03:06:01 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 15 Jul 2001 09:06:01 +0200 Subject: Long Live Python! References: <9ir1l7$3ja$1@panix2.panix.com> Message-ID: <9irfbc11jaq@enews1.newsguy.com> "Aahz Maruch" wrote in message news:9ir1l7$3ja$1 at panix2.panix.com... > In article , > Paul Prescod wrote: > > > >Python allows you to build larger systems because it allows a looser > >binding between granular components, it allows more to be done in less > >code and it makes testing so much easier that the loss of compiler > >warnings is trivial. > > Allow me to quote myself: > > The way to build large Python applications is to componentize and > loosely-couple the hell out of everything. s/Python//. Lakos' "Large Scale C++ Programming" book, and Martin's articles (originally in C++ Report, now on his objectmentor site), show much the same approach is needed in other languages. Of course, the key issue is that different languages require different approaches to componentization and dependency management. Alex From tim.one at home.com Tue Jul 24 22:32:57 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 24 Jul 2001 22:32:57 -0400 Subject: Language change and code breaks In-Reply-To: Message-ID: [Guido] > How did engineers cope with Fortran? Fortran has long been the > preferred language for engineers, after C.S. folks moved on to C and > C++... [Robin Becker] > engineers of which I am one, hated it when we only had 6 characters and > no case sensitivity. Even Fortran 90 retained case-insensitivity. This page is a hoot, and a hint of what happens when backward compatibility is taken as absolute: http://www.llnl.gov/sccd/lc/asci/fpe/fpe.source.html view-each-vendor-as-a-fork-ly y'rs - tim From tjreedy at home.com Thu Jul 26 15:21:57 2001 From: tjreedy at home.com (Terry Reedy) Date: Thu, 26 Jul 2001 19:21:57 GMT Subject: PEP0238 lament References: <5sdnlt072hm6hp17nluu6f0fqq4bvr6mj8@4ax.com> <916olt0p3kciv0evmotdg6jev9bl29l57i@4ax.com> <3B5C52EA.9430255E@alcyone.com> Message-ID: "Guido van Rossum" wrote in message news:cp4rrz95iu.fsf at cj20424-a.reston1.va.home.com... > I don't see when a unified number system would ever be less convenient > than the current number system, *My* worry, based on some of your expressed views, is that you might someday decide to *unify* ints and floats by eliminating ints |-( > Using the new type/class unification in Python 2.2, you will be able > to subtype the int or long types easily to create your own constrained > types. Thanks for answering my unasked question 8-). Terry J. Reedy From Randy.L.Kemp at motorola.com Tue Jul 3 08:52:56 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Tue, 3 Jul 2001 08:52:56 -0400 Subject: Is Python Dead? Message-ID: Roses are red, and violets are blue, I program in Python, and so can you. -----Original Message----- From: Jaap Spies [mailto:j.spies at hccnet.nl] Sent: Monday, July 02, 2001 5:12 PM To: python-list at python.org Subject: Re: Is Python Dead? Armin Steinhoff wrote: > It seems that Python should strive to be great at the ABC's before it > attempts poetry. > > --Ed > You should know that the roots of Python are in the ABC Programming Language and as I mentioned before reading/writing Python is really Poetry! Jaap Spies From gerhard.nospam at bigfoot.de Fri Jul 13 13:45:54 2001 From: gerhard.nospam at bigfoot.de (=?iso-8859-1?Q?Gerhard_H=E4ring?=) Date: Fri, 13 Jul 2001 19:45:54 +0200 Subject: Apache & Python References: <20010713.15394573@mis.configured.host> Message-ID: <9inc3p$13ba$1@news.space.net> Apache & Python"Paul Duquette" schrieb im Newsbeitrag news:20010713.15394573 at mis.configured.host... I have installed python 2.1 on my windows2k machine and would like to know how to use Python with Apache. I can't find any config instructions anywhere. The python faq tells me how to configure it with IIS but I didnt see anything about Apache. Hopeing you Python experts out there can point me in the right direction. http://www.faqts.com/knowledge_base/view.phtml/aid/8264/fid/199 HTH Gerhard PS: Sorry for the HTML, I'll try to configure that damn Outlook Express later. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gerhard.nospam at bigfoot.de Sun Jul 8 09:24:34 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Sun, 8 Jul 2001 15:24:34 +0200 Subject: Unix Scripting Host References: Message-ID: Thank you all for your suggestions. I just wanted to make sure that I didn't forget any alternative. It has become clear that Unix is still lacking support for a component architecture that supports all of Windows' COM. My findings currently are: - DCOP: client side usage is easy; server-side more difficult; KDE only; can use XML-RPC instead because KDE has a DCOP-XMLRPC bridge - SOAP/XML-RPC: very easy to use from Python; much encoding/decoding overhead - CORBA: very good Python support with omniORBpy; omniORB 4/omniORBpy2 will improve performance by taking shortcuts when the C++ and Python code is in the same address space (no loopback interface involved) - XPCOM: still have to get this to work on my machine, but looks promising; no wide language support currently available (only C++/Python) 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 pobrien at orbtech.com Sun Jul 15 13:51:32 2001 From: pobrien at orbtech.com (Patrick K. O'Brien) Date: Sun, 15 Jul 2001 17:51:32 GMT Subject: This is spoiling Python image! References: Message-ID: This IDLE bug has been submitted to the IDLE revitalization project: https://sourceforge.net/tracker/index.php?func=detail&aid=441472&group_id=95 79&atid=109579 --- Patrick K. O'Brien Orbtech "I am, therefore I think." From jkraska1 at san.rr.com Fri Jul 27 04:19:46 2001 From: jkraska1 at san.rr.com (Courageous) Date: Fri, 27 Jul 2001 08:19:46 GMT Subject: Case insensitivity References: <93d9a839.0107200315.4a0a8c28@posting.google.com> <4n4klt8ud0es25jep3u2v9pj02dctnte0u@4ax.com> <3ui1mt0e07vgp1b18306jd70pdufs91uva@4ax.com> Message-ID: >>Because when identifier and someone else writes IdEnTIFIER, I want >>to kill them Actually, I'd like to kill them for changing the case at all. > >But if the language is the same, their editor would warn them about the case >mismatch, and the code would crash, just like yours would. It would be just >like your editor, only yours won't warn about those things. Oh right. Just _my_ editor. Right. Isolated little ole me, I'm the only small sole in the whole wide world who wants to use vim. You're just not getting this, I can tell. C// From rupe at metro.yak.net Thu Jul 26 18:20:34 2001 From: rupe at metro.yak.net (Rupert Scammell) Date: 26 Jul 2001 15:20:34 -0700 Subject: HTML to formatted text conversion function References: <79179cf5.0107241216.7345d345@posting.google.com> Message-ID: <79179cf5.0107261420.150d4936@posting.google.com> Duncan, Consider submitting this to the Python Cookbook (http://aspn.activestate.com/ASPN/Python/Cookbook/) if you get a moment. --- Rupert Rupert Scammell rupe at metro.yak.net http://metro.yak.net From qrczak at knm.org.pl Tue Jul 31 16:34:54 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 31 Jul 2001 20:34:54 GMT Subject: 2.2 features References: <15206.48884.18637.676324@beluga.mojam.com> <200107311705.NAA16444@cj20424-a.reston1.va.home.com> <15206.61485.360973.566871@beluga.mojam.com> <200107311904.PAA17115@cj20424-a.reston1.va.home.com> Message-ID: Tue, 31 Jul 2001 14:28:05 -0500, Skip Montanaro pisze: > x in Foo same as isinstance(x, Foo) > Bar in Foo same as issubclass(Bar, Foo) > x.__class__ in Foo same as issubclass(x.__class__, Foo) It makes impossible to check whether an object is an instance of Foo using the 'in' operator. For example Bar is not an instance of Foo but 'Bar in Foo' would be true. It also makes impossible to check whether an object is a sublass of Foo. For example x is not a subclass of Foo but 'x in Foo' would be true. In effect it doesn't correctly answer either question. > I assume x can't be both an instance and a class at the same time. Even if it was true, it would require the programmer to check this condition, instead of letting 'in' check it. It's not true in a broader view where types and classes are treated similarly. For example 'type in type' is true in both senses and 'int in string' is false in both senses, but you can't distinguish between classes and instances here - all objects involved are type objects. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From hnowak at cuci.nl Wed Jul 25 07:02:40 2001 From: hnowak at cuci.nl (hnowak) Date: Wed, 25 Jul 2001 13:02:40 +0200 Subject: Methods of setting class attributes Message-ID: <3B6F10F6@twigger.nl> >===== Original Message From Piotr Legiecki ===== >I'm C++ user and new to Python. I don't know what is the proper method >of setting attribute value in a class. I thought that this is ok: > >class a: > atr1=0 > atrb=1 >..... Do you mean class attributes or instance attributes? It's not the same in Python. Assuming you just want the default behavior to set attributes in a class and get going, this is a common idiom: class Foo: def __init__(self, x): self.x = x self.y = "blah" This creates attributes x and y when Foo is instantiated: foo = Foo(3) print foo.x, foo.y # prints 3 and blah Note that this is different from a class attribute; those are often used to share values between instances: >>> class Counter: count = 0 def __init__(self): Counter.count += 1 def __del__(self): Counter.count -= 1 def report(self): print "Ah, already", Counter.count, "instances created!" This class keeps track of the number of instances. It does so by assigning to Counter.count, which resides at the class level (as opposed to the instance level). >>> c1 = Counter() >>> c1.report() Ah, already 1 instances created! >>> c2 = Counter() >>> c3 = Counter() >>> c3.report() Ah, already 3 instances created! >>> c1.report() Ah, already 3 instances created! >>> Counter.count 3 >>> c3.count # Counter.count can be accessed through the instance 3 >>> dir(c3) # attributes of c3 (none) [] >>> dir(Counter) # attributes of class Counter ['__del__', '__doc__', '__init__', '__module__', 'count', 'report'] >>> del c2 # remove an instance >>> c1.report() Ah, already 2 instances created! >>> Python is much more dynamic than C++ and attributes of a class or instance can be set or deleted at will. >__setattr__(s, name, val) called when setting an attr > (inside, don't use "self.name = value" > use "self.__dict__[name] = val") >..... I think it's best to forget __setattr__ for now; it's mainly used to fake attributes and control values assigned to an attribute. HTH, --Hans Nowak From covouh at my.com Fri Jul 6 23:19:02 2001 From: covouh at my.com (covouh at my.com) Date: Sat, 07 Jul 2001 03:19:02 GMT Subject: I Truly Appolige To ALL For The: Check This Out: 6948 Message-ID: I truly apoloize to everyone for what happened. I was tring to send it to a test group and not the world. This was the first time I used Agent Poster and did relize what had happen until I got all you e-mails. I am truly sorry and you can be assured, it wont happen again. Tom Partridge rqvrtsryqjiqwszplggsuklmtumsi From sbrunning at bigfoot.com Tue Jul 3 09:50:34 2001 From: sbrunning at bigfoot.com (Simon Brunning) Date: 3 Jul 2001 06:50:34 -0700 Subject: Kevin Dahlhausen' Gallery module. Message-ID: <12f02d51.0107030550.7804a569@posting.google.com> I tried to grab a copy of this, via Parnassus, but the target site seems to be down. Anyone know where I can get this module, or have a copy of it that they can send me? Cheers, Simon B. From grante at visi.com Sat Jul 14 17:47:42 2001 From: grante at visi.com (Grant Edwards) Date: Sat, 14 Jul 2001 21:47:42 GMT Subject: Getting major/minor number of device file in Linux? References: Message-ID: <26347.15610$B7.2813994@ruti.visi.com> In article , Grant Edwards wrote: >I can't figure out how to get the major and minor numbers of a >char special file under Linux. What I want is the st_rdev >field of the stat struct, but os.stat doesn't seem to return >that field. It doesn't appear that the posix module wraps the mknod() call either, so I guess the inability to deal with device special files is at least consistent. -- Grant Edwards grante Yow! Did we bring enough at BEEF JERKY? visi.com From scarblac at pino.selwerd.nl Fri Jul 6 02:14:38 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 6 Jul 2001 06:14:38 GMT Subject: There's got to be an easy way to do this References: Message-ID: Lindstrom Greg - glinds wrote in comp.lang.python: > I am reading in a phone number field and would like to throw away everything > except the digits. Being an old C programmer, I know how I would do this. > Even with my limited knowledge of Python, I know how I would do it: > > stripped_phone='' > for c in phone_number: > if c in digits: > stripped_phone += c > > but with all of the data structure support native to Python, I'm sure there > is "an obvious way" to do it (perhaps it's because I'm not Dutch:-). Some other solutions: # Closest to yours, readable stripped_phone = '' for c in phone_number: if c.isdigit(): stripped_phone += c # The same with filter, too bad we need a lambda stripped_phone = filter(lambda c: c.isdigit(), phone_number) # Translate might be fast, but not very readable (only the last line needs to # be inside a tight loop) import string transtable = string.maketrans("","") nodigit = filter(lambda c: not c.isdigit(), transtable) stripped_phone = phone_number.translate(transtable, nodigit) The last one might be fastest inside a tight loop, or maybe the re solution someone else gave. However, if your code isn't a speed problem, just leave it. Funny, I think there's one obvious way to do this in Perl :-) ($x =~ s/[^0-9]//g) -- Remco Gerlich From sh at ttsoftware.co.uk Mon Jul 2 13:01:04 2001 From: sh at ttsoftware.co.uk (Steve Horne) Date: Mon, 02 Jul 2001 18:01:04 +0100 Subject: Augmented Assignement (was: Re: PEP scepticism) References: <6qn16r7i69.fsf@abnoba.intevation.de> <9hhu6701d5j@enews2.newsguy.com> <6qae2r71hd.fsf@abnoba.intevation.de> <3B3CECEA.5D02A66E@Lugoj.Com> Message-ID: On Fri, 29 Jun 2001 14:02:34 -0700, James Logajan wrote: >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? How exactly do you have an augmented assignment version of a unary operator? And given that, just where is the confusion supposed to come from? I've always liked having a colon on my assignment operator - I think the single = for assignment was a mistake. If we had := for assignment, then augmented assignments would be more clearly distinct from other operators - :+=, :-=, :*= etc etc. The trouble is - well - yuck. Horrible. := works, but :+= looks too much like a deformed rabit smily with a broken nose ;-) Of course, I wouldn't mind a !! operator to toggle flags with ;-) >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.) How did so many databases come to be written using COBOL when SQL is so much better? - because COBOL existed first. This is a drag factor to progress, but it doesn't mean progress is bad. BTW - I think the latest FORTRAN standard has augmented assignments, though I could be wrong. Anyone know for sure? -- Steve Horne Home : steve at lurking.demon.co.uk Work : sh at ttsoftware.co.uk From piet at cs.uu.nl Fri Jul 13 16:11:42 2001 From: piet at cs.uu.nl (Piet van Oostrum) Date: 13 Jul 2001 22:11:42 +0200 Subject: Bug in __imul__ References: Message-ID: >>>>> Roman Suzi (RS) writes: RS> There is a joke about americans: RS> they were confused that Excel give different result from RS> pocket calculator: RS> [5] [+] [3] [*] [4] [=] RS> | 32 | My pocketcalculator gives 17. But then it's a Dutch one (Philips). -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From annis at biostat.wisc.edu Thu Jul 12 09:54:21 2001 From: annis at biostat.wisc.edu (William Annis) Date: 12 Jul 2001 08:54:21 -0500 Subject: Pickle translation References: Message-ID: > wazor /u/annis/code/NewMom $ python2.1 -i bin/momd > Traceback (most recent call last): > File "bin/momd", line 83, in ? > kserv = load(f) > ValueError: invalid \x escape I suppose I should mention that I'm using cPickle. -- 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 cjc26 at nospam.cornell.edu Sun Jul 22 17:41:14 2001 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Sun, 22 Jul 2001 21:41:14 GMT Subject: PEP0238 lament References: Message-ID: <_LH67.100281$T97.13843165@typhoon.nyroc.rr.com> * Tim Peters menulis: | | The meaning of integer division wasn't the | focus, but naturally came up. By show of hands, about 3/4ths of the | participants agreed that 3/4 should not return 0, but rather *something* | [snip] In other words, nobody raised their hand, since 3/4 == 0. Well, that settles it, then -- nobody wants this change <0.75 wink>. -- Cliff Crawford http://www.sowrong.org/ A sign should be posted over every campus toilet: "This flush comes to you by courtesy of capitalism." -- Camille Paglia From robin at jessikat.fsnet.co.uk Tue Jul 24 20:24:10 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Wed, 25 Jul 2001 01:24:10 +0100 Subject: Language change and code breaks References: <9j7gv8$9mg@dispatch.concentric.net> Message-ID: In article , Guido van Rossum writes >Travis Oliphant writes: > >> I'll just chime in to say that as one who uses Python for >> science/engineering, I would be very unhappy not to be able to define the >> variables h and H to mean two different things. Engineers often uses >> case to distinguish between the function and it's Fourier transform for >> example. > >How did engineers cope with Fortran? Fortran has long been the >preferred language for engineers, after C.S. folks moved on to C and >C++... > >--Guido van Rossum (home page: http://www.python.org/~guido/) engineers of which I am one, hated it when we only had 6 characters and no case sensitivity. -- Robin Becker From philh at comuno.freeserve.co.uk Sat Jul 21 16:38:28 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Sat, 21 Jul 2001 21:38:28 +0100 Subject: Python, C++, Java, Smalltalk, Eiffel,... References: <9is8rm$46d$1@panix3.panix.com> <9iv7ae$gs0$1@nntp6.u.washington.edu> <9j63lk$ogp$1@newsfeed.th.ifl.net> <3d4rs74t5d.fsf@ute.cnri.reston.va.us> Message-ID: On 20 Jul 2001 09:38:54 -0400, Andrew Kuchling wrote: >philh at comuno.freeserve.co.uk (phil hunt) writes: >> Supposedly, Microsoft's C# and CLR system will provide a fix for >> this, by allowing the programmer to use any language that compiles >> to CLR to call a routine in any other language that does. >> >> Does anyone have details on this? > >I'm a bit doubtful that the CLR will really be suited for languages >other than C# or VB. Sure, with some hammering you can compile Python >to CLR, just as you can compile it to Java bytecodes, but there seems >to be a sizable performance hit, judging by a message from David >Ascher archived at >http://aspn.activestate.com/ASPN/Mail/Message/638072. I suspect >.NET's multilanguage will turn out to be a feature used more as a >selling point than in practical use. In much the same way, Internet >Explorer is theoretically multiplatform, but I expect almost no one >out there uses the Solaris and HP-UX IE ports. Just like windows' POSIX compatibility is only "checkbox-compatibility" not "real-world-I'd-actually-use-this-compatibility". -- #===== Philip Hunt == philh at comuno.freeserve.co.uk ======# Herbivore: effort-free public key encryption. See: ** First software release coming soon! ** From aahz at panix.com Sat Jul 28 01:46:49 2001 From: aahz at panix.com (Aahz Maruch) Date: 27 Jul 2001 22:46:49 -0700 Subject: TK + cmd.cmdloop() in threads (was Re: howdoI: Exception in thread - terminating the program? References: <9j5lq9$jl7$1@panix2.panix.com> Message-ID: <9jtjk9$fnj$1@panix2.panix.com> In article , Ville Vainio wrote: >aahz at panix.com (Aahz Maruch) writes: >> >> Generally speaking, it's safest to have only one thread accessing any >> external resource (GUI, file handle, DB connection, etc). > >But one would think it's reasonably safe to access a resource one >thread at a time, via mutexes etc. (and some external resource, such >as sockets, almost *have to* be accessed in multiple threads). Is TK >really such a beast that all the access to TK widgets have to be called >via it's own event loop? One might think that. One would even be technically accurate. But writing threaded programs is difficult enough; I always recommend that people put each external resource into a separate thread, and if they want to hang themselves it's no skin off my nose. -- --- 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 Fortune cookie: Watch your relations with other people carefully, be reserved. From com-nospam at ccraig.org Tue Jul 24 08:35:51 2001 From: com-nospam at ccraig.org (Christopher A. Craig) Date: 24 Jul 2001 08:35:51 -0400 Subject: proposed language change to int/int==float (was: PEP0238 lament) In-Reply-To: References: Message-ID: <87ofqaqzbs.fsf@elbereth.ccraig.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 "Tim Peters" writes: > I'm burned out on the repetition here. It's not a question of being hard to > teach. It's largely that it's never sensible for > > x = y / z > > buried in the middle of some routine to do truncating division if y > and z happen to be ints but best-possible division if they happen > not to be ints. It's this damage to polymorphism that hurts people > in real life, and we've had years of testimony about that on c.l.py > (even in this incarnation of the debate, although it's hard to find > unless you read every msg). I haven't spoken out on this yet, but now I'm going to. I don't like PEP238, but I am not going to repeat what everyone else has said. What I don't like about it is that in every case I can think of right now if you apply an operator to two operands of the same type, you get a result of the same type. / = would change this, and I don't like it. (yes, you can argue that math.something() returns a float, but that's a library module, not a builtin, so I don't count it.) Many people have argued that they would like to see the behavior from the PEP if Python were a new language. I disagree. I would prefer to see '/' defined as "exact division" and '//' defined as "truncated division" and have types that don't support either raise a TypeError if the types don't support the operation in question. I think this parallels existing operations better. As examples: * raises a TypeError ** raises a ValueError ** would presumably raise a TypeError - -- Christopher A. Craig "Software hoarding is not a victimless crime." Richard Stallman -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: Processed by Mailcrypt iEYEARECAAYFAjtda6cACgkQjVztv3T8pztiwACg2bnc0YssqlmsHx0B6zrcE/Bx RtkAoI0pA4Q3O5ogY3NErL1Y77PtaBMO =mfMO -----END PGP SIGNATURE----- From aleaxit at yahoo.com Sat Jul 14 17:55:29 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 14 Jul 2001 23:55:29 +0200 Subject: python and applications References: <9ipv9k$nda$1@panix2.panix.com> Message-ID: <9iqf6r0g0r@enews1.newsguy.com> "William Park" wrote in message news:mailman.995133450.2297.python-list at python.org... > On Sat, Jul 14, 2001 at 10:25:08AM -0700, Aahz Maruch wrote: > > tyler spivey wrote: > > >how many blind programmers use python? > > > > No idea. Python is probably good for blind people because you usually > > write less code in Python -- each statement in Python does more. > > If the original author meant "visually impaired", then I agree. Python > code is short, easy to read, and easy to write. This would be important I have modest visual impairment (slowly worsening with age) and I agree. But when and if it gets to blindness, I don't know if Python's reliance on whitespace/indentation will be a problem -- normal screen readers won't help much, I guess it would require a special one that understands the significance of indent and dedent. Perhaps not too big a project, but I'm not aware of any such special readers, which would seem to indicate a dearth of blind (as opposed to visually impaired) Python programmers -- even pretty serious visual problems still leave one able to see the block structure/indentation quite well (perhaps with some magnification of course, but less than would be needed for, say, braces!) -- but total blindness is another issue. Alex From rnd at onego.ru Wed Jul 4 00:48:01 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 4 Jul 2001 08:48:01 +0400 (MSD) Subject: New PEP: Quality Guidelines For Standard Modules In-Reply-To: <5.0.2.1.0.20010702082413.02776040@mail.inet.com.br> Message-ID: There could be even use of some special __-word to stress that the module is standard: __distribution__ or __belongs__ And probably standard modules need to clean-up unused names after they done, so there will be no other standard modules in the module namespace like in this situation: >>> import uu >>> uu. uu.Error uu.__doc__ uu.__name__ uu.decode uu.os uu.test uu.__all__ uu.__file__ uu.binascii uu.encode uu.sys uu.sys is the same sys here! Also maybe standard modules need to have __all__ to explicitely mention their interface (or we'll wait for interface PEP to be adopted?) Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Wednesday, July 04, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Mediocrity requires aloofness to preserve it's dignity" _/ From michael at stroeder.com Fri Jul 13 04:47:30 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Fri, 13 Jul 2001 10:47:30 +0200 Subject: SocketServer and threading mixin? References: Message-ID: <3B4EB5A2.6BEC1DCA@stroeder.com> Greg Copeland wrote: > > I've been following the bug report on the SocketServer module > and how it is broken with the threading mixin. The bug report > has been closed and the people that posted offered several > solutions, however, from what I've seen, SocketServer, the > module, is still broken and requires a minor patch or two to > work correctly. Does anyone know what the plans are to address > this issue down the road? Guido checked in SocketServer.__version__='0.4' and announced it on the bug tracking page. If you read the page carefully you will notice that. The various URLs were posted here several times during the last days. Actually I won't repost them because I'm currently trying not to mutate to a SocketServer.ThreadingMixin-in-Python-2.1 robot. The only URL I'd like to suggest today is: http://groups.google.com/advanced_group_search?as_ugroup=comp.lang.python Ciao, Michael. From matt at mondoinfo.com Wed Jul 4 13:43:19 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Wed, 04 Jul 2001 17:43:19 GMT Subject: Tkinter Scrollbar get method References: <9hvbla$1bpq$1@node21.cwnet.roc.gblx.net> Message-ID: On Wed, 4 Jul 2001 15:10:34 +0000 (UTC), Lee Harr wrote: >I am trying to use the Tkinter Scrollbar class. >The docs say that the get() method returns a >two element tuple of values between 0.0 and 1.0 > >What I am getting, though is a 4 element tuple: >>>> g = sb.get() >>>> print g >(0.0, 0.0, 0.0, 0.0) Lee, That is odd and I don't know just why that is. It seems that scrollbars return four items until they've been set once: >>> from Tkinter import * >>> root=Tk() >>> sb=Scrollbar(root) >>> sb.pack(side=LEFT,fill=Y) >>> sb.get() (0.0, 0.0, 0.0, 0.0) >>> sb.set(0.0,1.0) >>> sb.get() (0.0, 1.0) The good news is that they work fine in practice. Mostly, you don't have to use their get() and set() methods directly. Generally, the thing you want to scroll has the corresponding xview and yview methods and it's just a matter of hooking them up. There's a good example of doing that with a listbox in Fredrik Lundh's excellent An Introduction to Tkinter at (wrapped for line length): http://www.pythonware.com/library/tkinter/ introduction/x7205-patterns.htm (The whole document is a very valuable resource.) If the standard Tkinter widgets don't provide the scrollable things you need, Pmw probably does. Pmw is at: http://pmw.sourceforge.net/ Among other very convenient widgets, Pmw adds scrolled frames and text widgets. Still, there are times when it's necessary to do one's own scrolling and that works fine as long as you do a set() on the scrollbar before you do a get(). That must be true -- I have an app that I've been working on for a year in which I need to do my own scrolling and never ran into the 4-tuple. Regards, Matt From emile at fcfw.fenx.com Mon Jul 16 10:00:25 2001 From: emile at fcfw.fenx.com (Emile van Sebille) Date: 16 Jul 2001 09:00:25 -0500 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Jul 16) Message-ID: Pythonic Quote of the Week: In a post titled 'An Unspeakable Act', Daniel Klein does what people do on Usenet and tells us of a Python vs Java discussion he entered into on another group: This person says that dynamically typed languages produce bug-ridden programs and that there are no reliable large applications (especially network apps) written in Python and that it is just used for small to medium scripting. I know better but I don't have any proof. ... Prompting James Logajan to remind us of the subtle details of usenet life outside of c.l.py Look, you have got off on the wrong foot. You are trying to think logically. That gives the other person a leg up on you. (But you admit that you know better without proof, so you aren't totally out-matched.) Follow the discussion starting at http://groups.google.com/groups?th=42a29c22b0f4873a,14&start=0&ic=1 Guido announces Python 2.1.1c1 - a bugfix release candidate for Python 2.1. One fixed "bug" deserves special attention: like Python 2.0.1, Python 2.1.1 is GPL-compatible! Expect the final release next week. http://groups.google.com/groups?ic=1&q=msgid:mailman.995047446.5368.clpa-moderators at python.org Andrew M Kuchling explains how to become one of the people who develop Python. If you've wondered how Python evolves or would like to contribute, this is a good starting point. http://www.amk.ca/python/writing/python-dev.html Marc-Andr? Lemburg announces updated versions of his mxCommercial product (mxODBC), mxBase extensions, and a set of mxExperimental python extensions each destined for inclusion in one of the former two. http://groups.google.com/groups?ic=1&q=msgid:mailman.995047446.5366.clpa-moderators at python.org http://groups.google.com/groups?ic=1&q=msgid:mailman.995047446.5365.clpa-moderators at python.org http://groups.google.com/groups?ic=1&q=msgid:mailman.995047446.5367.clpa-moderators at python.org Robin Dunn releases version 2.3.1 of wxPython, a blending of Python and the wxWindows gui toolkit. http://groups.google.com/groups?ic=1&q=msgid:mailman.995047446.5364.clpa-moderators at python.org Michael Stroeder introduces PyWebLib 1.0.2 - a set of modules for web programming tasks. http://groups.google.com/groups?ic=1&q=msgid:mailman.994764060.20463.clpa-moderators at python.org Steven Knight launches SCons, a make replacement written in Python. SCons is currently in active development, with the goal of an alpha release some time later this year. The current developers are actively recruiting anyone else who would like to contribute. http://groups.google.com/groups?ic=1&q=msgid:mailman.994903681.24367.clpa-moderators at python.org In the "Why don't you remember Zager and Evans" department: Roman Suzi wonders what programs written to survive the ages would look like. http://groups.google.com/groups?ic=1&q=msgid:mailman.994509911.11785.python-list at python.org Thomas Heller posts a recipe that shows how to set up things to launch the debugger automatically in Python 2.1 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65287 Marc-Andr? Lemburg introduces a PEP that proposes to use the PEP 244 statement "directive" to make the encoding used in Unicode string literals u"..." (and their raw counterparts ur"...") definable on a per source file basis. http://groups.google.com/groups?ic=1&q=msgid:mailman.995062883.31329.python-list at python.org Mark Poinot provides a report on the Libre Software Meeting Python Track held earlier this month in Bordeaux. http://groups.google.com/groups?ic=1&q=msgid:mailman.994840578.17876.python-list at python.org Terry Reedy provides a good summary of how language changes that break existing code impact the community http://groups.google.com/groups?ic=1&q=msgid:wuN27.13377$Y6.4240331 at news1.rdc2.pa.home.com ... prompting Guido to reconsider plans to change the behavior of integer division http://groups.google.com/groups?ic=1&q=msgid:cplmlvh6dx.fsf at cj20424-a.reston1.va.home.com Carsten Gaebler discovers an inconsistency in how readline and readlines react to an empty file, with Quinn Dunkan submitting the patch to make it right. http://groups.google.com/groups?ic=1&q=msgid:3B482C44.6E6EB163 at snakefarm.org Tim Daneliuk asks for an explanation of Python's singleton tuple syntax. http://groups.google.com/groups?ic=1&q=msgid:3B4CA0A8.20B53230 at tundraware.com A.M. Kuchling formalizes an approach which describes a format for a database of Python packages installed on a system in PEP 262. Could this be the start of dynamic module updates? http://python.sourceforge.net/peps/pep-0262.html Edward Jason Riedy provides links and discussion on fully arbitrary precision changes in relation to Python. http://groups.google.com/groups?ic=1&q=msgid:9igdps$o1u$1 at agate.berkeley.edu For the Zope crowd: This should only sound foreign to the uninitiated, but even if you don't zope yet... Here's a How to set up Blark Feature Boxes FOR CMF Blark Creators. http://www.zope.org/Members/jeffsasmor/blark_featureboxes ... and this will definitely sound foreign (except to the martellibot)... There's a new site dedicated to Zope, but you'll need to read it yourselves to get more information... ;) http://www.zope.it/ ....Martijn Faasen releases Formulator 1, an extensible framework that eases the creation and validation of web forms. http://www.zope.org/Members/faassen/Formulator ... and an update on the EuroZope meeting at LinuxTag in Stuttgart, located part way down the page at http://www.eurozope.org//index_html/mpNews?sNwsItem=20010709 Continuing Foreign Python sightings... Cristian Echeverria tells of a new website: Python News in Spanish - Noticias de Python en Espa?ol at http://www.chevenet.com/ http://groups.google.com/groups?ic=1&q=msgid:9iq577$km4p5$1 at ID-44371.news.dfncis.de Waitress: Well, there's egg and bacon; egg sausage and bacon; egg and spam; egg bacon and spam; egg bacon sausage and spam; spam bacon sausage and spam; spam egg spam spam bacon and spam; spam sausage spam spam bacon spam tomato and spam... http://www.pythonline.com/spamclub/signup.shtml ======================================================================== 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 mestesso100 at yahoo.com Wed Jul 25 13:22:27 2001 From: mestesso100 at yahoo.com (FunkyTritone) Date: 25 Jul 2001 10:22:27 -0700 Subject: Help: Install python-2.1-3 on RedHat 7.1! Message-ID: <71550321.0107250922.3a8fd0bf@posting.google.com> Hi there, I just tried to install python-2.1-3 on RedHat 7.1 and I got lost in a RPM maze. Basically I have to upgrade stuff like readline and libcrypto that are needed by a bunch of other software. Is there any way to have a clean install of this beast without breaking the whole system? It shouldn't be that hard!!! $> rpm -Uvh python-2.1-3.i686.rpm python-devel-2.1-3.i686.rpm openssl-0.9.6b-3.i586.rpm ncurses-ext-5.2-4.i686.rpm readline-4.2-6.i686.rpm gmp-2.0.2-15.i686.rpm ncurses-5.2-4.i686.rpm error: failed dependencies: gmp = 3.1.1 is needed by gmp-devel-3.1.1-3 libgmp.so.3 is needed by librep-0.13.3-1 libgmp.so.3 is needed by sawfish-0.38-1 readline = 4.1 is needed by readline-devel-4.1-9 libreadline.so.4.1 is needed by ftp-0.17-7 libreadline.so.4.1 is needed by librep-0.13.3-1 libreadline.so.4.1 is needed by guile-1.3.4-12 libreadline.so.4.1 is needed by openldap-clients-2.0.7-14 libreadline.so.4.1 is needed by pilot-link-0.9.5-2 libreadline.so.4.1 is needed by postgresql-7.0.3-8 libreadline.so.4.1 is needed by postgresql-devel-7.0.3-8 libreadline.so.4.1 is needed by postgresql-server-7.0.3-8 libreadline.so.4.1 is needed by cdecl-2.5-17 libreadline.so.4.1 is needed by bc-1.06-2 libreadline.so.4.1 is needed by dump-0.4b21-3 libreadline.so.4.1 is needed by amanda-2.4.2p2-1 libreadline.so.4.1 is needed by amanda-client-2.4.2p2-1 libreadline.so.4.1 is needed by ext2ed-0.1-23 libreadline.so.4.1 is needed by fvwm2-2.2.4-9 libreadline.so.4.1 is needed by gnuplot-3.7.1-12 libreadline.so.4.1 is needed by amanda-server-2.4.2p2-1 libreadline.so.4.1 is needed by mysql-3.23.36-1 libreadline.so.4.1 is needed by parted-1.4.7-2 libreadline.so.4.1 is needed by postgresql-tcl-7.0.3-8 libreadline.so.4.1 is needed by postgresql-tk-7.0.3-8 libreadline.so.4.1 is needed by units-1.55-9 libreadline.so.4.1 is needed by x3270-text-3.2.14-1 python = 2.0-9mdk is needed by tkinter-2.0-9mdk openssl = 0.9.6-9 is needed by openssl-perl-0.9.6-9 openssl = 0.9.6-9 is needed by openssl-python-0.9.6-9 openssl = 0.9.6-9 is needed by openssl-devel-0.9.6-9 libcrypto.so.1 is needed by bind-utils-9.1.0-10 libcrypto.so.1 is needed by slrn-0.9.6.4-2 libcrypto.so.1 is needed by cyrus-sasl-1.5.24-17 libcrypto.so.1 is needed by links-0.95-2 libcrypto.so.1 is needed by openldap-2.0.7-14 libcrypto.so.1 is needed by autofs-3.1.7-14 libcrypto.so.1 is needed by nss_ldap-149-1 libcrypto.so.1 is needed by openldap-clients-2.0.7-14 libcrypto.so.1 is needed by pine-4.33-8 libcrypto.so.1 is needed by sendmail-8.11.2-14 libcrypto.so.1 is needed by fetchmail-5.7.4-4 libcrypto.so.1 is needed by gq-0.4.0-2 libcrypto.so.1 is needed by lynx-2.8.4-9 libcrypto.so.1 is needed by mutt-1.2.5i-9 libcrypto.so.1 is needed by openssh-2.5.2p2-5 libcrypto.so.1 is needed by openssh-clients-2.5.2p2-5 libcrypto.so.1 is needed by pidentd-3.0.12-4 libcrypto.so.1 is needed by balsa-1.1.1-3 libcrypto.so.1 is needed by kdebase-2.1.1-8 libcrypto.so.1 is needed by samba-common-2.0.7-36 libcrypto.so.1 is needed by samba-client-2.0.7-36 libcrypto.so.1 is needed by openssh-server-2.5.2p2-5 libcrypto.so.1 is needed by php-imap-4.0.4pl1-9 libcrypto.so.1 is needed by php-ldap-4.0.4pl1-9 libcrypto.so.1 is needed by bind-9.1.0-10 libcrypto.so.1 is needed by ucd-snmp-4.2-12 libcrypto.so.1 is needed by ucd-snmp-utils-4.2-12 libcrypto.so.1 is needed by am-utils-6.0.5-1 libcrypto.so.1 is needed by auth_ldap-1.4.7-2 libcrypto.so.1 is needed by imap-2000-9 libcrypto.so.1 is needed by licq-1.0.2-3 libcrypto.so.1 is needed by openldap-servers-2.0.7-14 libcrypto.so.1 is needed by stunnel-3.13-3 libcrypto.so.1 is needed by samba-2.0.7-36 libcrypto.so.1 is needed by mod_ssl-2.8.1-5 libcrypto.so.1 is needed by kdevelop-1.4.1-2 libcrypto.so.1 is needed by samba-swat-2.0.7-36 libcrypto.so.1 is needed by slrn-pull-0.9.6.4-2 libcrypto.so.1 is needed by squid-2.3.STABLE4-10 libcrypto.so.1 is needed by xemacs-21.1.14-10 libcrypto.so.1 is needed by kdelibs-2.1.2-1 libcrypto.so.1 is needed by openssl-python-0.9.6-9 libssl.so.1 is needed by slrn-0.9.6.4-2 libssl.so.1 is needed by links-0.95-2 libssl.so.1 is needed by openldap-2.0.7-14 libssl.so.1 is needed by autofs-3.1.7-14 libssl.so.1 is needed by nss_ldap-149-1 libssl.so.1 is needed by openldap-clients-2.0.7-14 libssl.so.1 is needed by pine-4.33-8 libssl.so.1 is needed by sendmail-8.11.2-14 libssl.so.1 is needed by fetchmail-5.7.4-4 libssl.so.1 is needed by gq-0.4.0-2 ... ) From peter at engcorp.com Wed Jul 25 00:09:47 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 25 Jul 2001 00:09:47 -0400 Subject: control-C not responding, short example program References: <3b5d7220.664033@news.newsguy.com> Message-ID: <3B5E468B.C0A6152D@engcorp.com> "Owen F. Ransen" wrote: > > If you put this in a module and test it: > > def ForLoopTest (NumLoops) : > for Year in range (1,NumLoops) : > for Century in range (1,NumLoops) : > Months = Year*12 > > you'll find that ForLoopTest (10000) will apparently > halt 500Mhz Windows 98 machine. It simply does not > respond to control-C. Is there a way of doing this > or do I just have to live with it? Are you running from the DOS command line? Are you executing the above function via a call like this? if __name__ == '__main__': ForLoopTest(10000) I put these in a file test.py and ran "python test.py" from the DOS prompt. Hitting Ctrl-C after a few seconds produced this: C:\>py test.py Traceback (most recent call last): File "test.py", line 7, in ? ForLoopTest(10000) File "test.py", line 4, in ForLoopTest month = year * 12 KeyboardInterrupt C:\> So, it works for me. (Win98 first release, on a Hitachi PC with a Pentium 233 MMX. Nothing special.) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From jkraska1 at san.rr.com Mon Jul 23 11:52:13 2001 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 23 Jul 2001 15:52:13 GMT Subject: Future division patch available (PEP 238) References: <9jfjd6$ad4$2@newshost.accu.uu.nl> <7u6nltoqdnqjjdiquu6ngtaruflhvbvdl5@4ax.com> Message-ID: On 23 Jul 2001 10:33:08 +0200, Martin von Loewis wrote: >I don't think there is any argument about that: the only question is >how to spell integer division; in the future, it will be spelled '//'. I personally think this should be "div" in synergy with "divmod" (which already exists). We don't need to be robbin' no operators from smalltalk. C// From nospam at newsranger.com Mon Jul 2 01:56:14 2001 From: nospam at newsranger.com (Haris Lekatsas) Date: Mon, 02 Jul 2001 05:56:14 GMT Subject: problem with sending email Message-ID: <22U%6.3997$Kf3.32727@www.newsranger.com> I have a problem running the script below on FreeBSD. When I run it from the UNIX prompt it runs fine and it sends a file (bigtextfile) of any size to the recipient address. Whenever a run the exact same script from a web browser as a CGI script it will send only about 17K of the bigfile and not the whole thing. I tried many different files and all of them get cut off at around 17K. It seems on other OS this problem does not appear. Any ideas why this is happening would be appreciated. Thanks! Haris Lekatsas #!/usr/bin/env python import socket, smtplib server = smtplib.SMTP() server.connect('localhost') server.helo('localhost') msg = "From: " + "Haris Lekatsas " + "\012" msg = msg + "To: " + "Haris Lekatsas " + "\012" msg = msg + "Subject: " + "subject" + "\012" fd = open('bigtextfile', 'r') text = '' while 1: line = fd.readline() if not line: break text = text + line fd.close() msg = msg + '\012' + text tmp_output = server.sendmail("lekatsas at jayway.com", "lekatsas at ee.princeton.edu", m sg) print "Content-type: text/html\n\n" print "Mail sent!" From paulp at ActiveState.com Mon Jul 23 19:10:10 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Mon, 23 Jul 2001 16:10:10 -0700 Subject: PEP0238 lament References: <00867F2E.N22121@rsmi.com> Message-ID: <3B5CAED2.80B9CF3C@ActiveState.com> This issue is constantly presented as some sort of dichotomy between "regular" programmers" and newbies. But really it is more of a dichotomy between those originally trained on typed languages and those on dynamically typed languages. The other languages in the Python category (Perl, Ruby, JavaScript, ...) all make a different choice for division and the choice is uncontroversial. Python is the only one of the languages that has a constant battle on the issue. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From jwbaxter at spamcop.com Thu Jul 26 01:13:02 2001 From: jwbaxter at spamcop.com (John W. Baxter) Date: Wed, 25 Jul 2001 22:13:02 -0700 Subject: PEP0238 lament References: Message-ID: <250720012213029878%jwbaxter@spamcop.com> In article , Guido van Rossum wrote: > Thanks for the suggestion. I think I'll do it this way: Python 3.x > will be the first incompatible version, Python 2.x will require > __future__ statements or other explicit ways to indicate that the > programmer wants the new feature. > > For less disturbing changes like nested scopes or generators (which > would break only very small amounts of old code), we can introduce the > new feature for real in the next release (e.g., nested scopes will be > standard in 2.2, I expect generators will become standard in 2.3), but > for devastatingly code-breaking changes like division, I'll wait until > 3.0 before it becomes the law. Thank you, Guido... I am quite content after reading that and some of your other comments. I've been skipping much of the division discussion today, and reading only your messages in some of the threads, like this one. Yesterday, I was upset. But the world seems different today. Except for the cat, who was sleeping on my other office chair last evening, and is sleeping on my other office chair this evening. I haven't been able to get him at all interested in PEP238. Cheers, John From aahz at panix.com Mon Jul 2 18:46:44 2001 From: aahz at panix.com (Aahz Maruch) Date: 2 Jul 2001 15:46:44 -0700 Subject: Python for air traffic control? References: <9hlfbn$6ok$1@nereid.worldonline.nl> Message-ID: <9hqtkk$b5a$1@panix6.panix.com> In article , William Park wrote: > From: Russ (18k11tm001 at sneakemail.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. > >Of course, you idiot... Is there some reason you're calling Russ an idiot? Let's try to keep comp.lang.python flamefree, please. -- --- 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'm not tense, i'm just terribly, terribly alert" --unknown From bokr at accessone.com Sat Jul 7 04:41:51 2001 From: bokr at accessone.com (Bengt Richter) Date: Sat, 07 Jul 2001 08:41:51 GMT Subject: Comment on PEP-0238 References: <3dd77drkea.fsf@ute.cnri.reston.va.us> <9i5guj$7kg$1@panix6.panix.com> Message-ID: <3b46c563.1265175986@wa.news.verio.net> On 6 Jul 2001 16:17:39 -0700, aahz at panix.com (Aahz Maruch) wrote: >In article <3dd77drkea.fsf at ute.cnri.reston.va.us>, >Andrew Kuchling wrote: >>Guido van Rossum writes: >>> >>> 3. A revision later, we change all plain integer divisions to be an >>> error, *forcing* folks to use div() or use the future statement to >>> specify floating point division. >> >>Step 3 strikes me as a bit odd; does that mean documentation for that >>release will have to say "applying the / operator to integers is an >>error, full stop"? And then in the next release the docs will again >>have to be changed to say that integer division now works? IMHO step >>3 should be dropped; one release with a warning every time integer >>division is attempted should be sufficient. > >I'm in agreement with Guido that at least two releases are necessary >(I also agree that it could be two warning releases). But I think >Guido's step 3 (if used) should be changed to the semantically equivalent > > In Python 2.4, integer division with the '/' operator raises an > exception. This exception can be caught as usual, but the > programmer should prepare for the next release of Python by either > using the div() function or by using the future directive to get > floating point division. > >(Calling it an error is technically imprecise; an exception isn't >*necessarily* an error.) > True, but in this situation, if you are going to modify code by wrapping with try-except to catch integer divisions, you might as well fix the code? OTOH, if you wanted a facility to make existing code run the way you want, maybe a divHook could be put somewhere so you could define a temporary div with assertions about the arguments, and logging of anomalies, etc., or whatever you needed, in a single tweak. >>> from __future__ import float_division >>> from __future__ import real_division >>> from __future__ import new_division >>> from __future__ import division >> >>'float_division'. There's no type corresponding to "real", nor is >>that terminology used anywhere in the docs; 'new_division' and >>'division' strike me as unclear. > >Ditto. Agree on the last two, but if there's a better real type than float coming in the future, '/' would presumably produce it as a result. In that case real_division would anticipatorily make sense, ISTM. I can live with div(x,y) and if so, mod(x,y) does seem to make for symmetry. BTW, will '%' as an integer op go away too, by symmetry? From machin_john_888 at hotmail.com Fri Jul 6 02:38:32 2001 From: machin_john_888 at hotmail.com (John Machin) Date: 5 Jul 2001 23:38:32 -0700 Subject: "All your byte are belong to us! " (TM) (was Re: There's got to be an easy way to do this (fwd)) References: Message-ID: <92ae279c.0107052238.4d498376@posting.google.com> Lulu of the Lotus-Eaters wrote in message news:... > Still dying to win the performance prize, I believe Skip Montanaro's > performance tip brings the general filter stategy back up to winning > status (including James Logajan 'traditional' function) > > def str_join2(iters): > has = {0:1,1:1,2:1,3:1,4:1,5:1,6:1,7:1,8:1,9:1}.has_key > for i in iters: > "".join([x for x in '(123)/456-7890' if has(x)]) > > def flt_lmbda3(iters): > isdigit = {0:1,1:1,2:1,3:1,4:1,5:1,6:1,7:1,8:1,9:1}.has_key [snip] Sigh. Looks like it's going to be a long hot [northern hemisphere] summer. D:\junk>type mertz.py def str_join2(iters): has = {0:1,1:1,2:1,3:1,4:1,5:1,6:1,7:1,8:1,9:1}.has_key for i in iters: result = "".join([x for x in '(123)/456-7890' if has(x)]) return result def str_join2_fixed(iters): has = {'0':1,'1':1,'2':1,'3':1,'4':1,'5':1,'6':1,'7':1,'8':1,'9':1}.has_key for i in iters: result = "".join([x for x in '(123)/456-7890' if has(x)]) return result print repr(str_join2(range(1))) print repr(str_join2_fixed(range(1))) D:\junk>python mertz.py '' '1234567890' Unfortunately, the routine that doesn't do the "All your byte are belong to us!" caper is going to be a bit slower; that's what you have pay for correctness. Hey, what a wonderful title for a book on text processing :-) In any case, the fastest routine available in standard Python would have to be one based on the suggestion in an earlier post from Tim Peters, namely to use source_string.translate(identity_map_string, chars_to_delete). Note that translate() is O(m+n) where n = len(source_string) and m = len(chars_to_delete). The O(m) comes about from the fact that chars_to_delete is unstructured and has to be made into a map on each call -- if it wasn't you'd have O(m*n). You can get better, with a precomputed map, but only by jumping into C. Some more observations: (1) The various solutions using re do poorly because re.sub is written in Python, not C, as /F pointed out a week or so ago. (2) You can knock 20% to 25% off the re times by using "[^0-9]+" instead of "[^0-9]" (3) Most contestants could squeeze out a little more performance by moving attribute lookups outside the loop -- like this: nulljoin = "".join for x in y: result = nulljoin(etc etc) (4) Getting away from standard-issue Python, mx.TextTools.setstrip() looked at first glance like a goer but that turned out to be a snare and a delusion -- as its doc makes plain, it "strips" in the same way as standard Python strip(), lstrip() and rstrip(): only at the ends of the string, not in the middle; IOW, "some your byte that you would like to belong to us are not". Perhaps if MAL is reading this, he might consider adding a setremove() to his next version. Regards, John From johnroth at ameritech.net Sat Jul 7 20:14:42 2001 From: johnroth at ameritech.net (John Roth) Date: Sat, 7 Jul 2001 17:14:42 -0700 Subject: Comment on PEP-0238 References: Message-ID: "Tim Peters" wrote in message news:mailman.994532533.10229.python-list at python.org... > I want to make a pitch for naming it idiv() instead. The "i" should > strongly remind that the result is an integer, something "div" says only to > former Pascal programmers. Seems a Positive Good to me if, e.g., > > idiv(5.0, 3.0) > > returned 1 too; i.e., that idiv(i, j) mathematically return floor(i/j). I like it - my mind had been going in that direction: idiv, fdiv and rdiv to label the desired output type. > Alternative: Given the point about dumbdbm above, the missing half is a > builtin to return (mathematically) ceiling(i/j) too. A very direct approach > to both is to forget div/idiv and introduce two-argument builtins > > floor(i, j) # return floor of mathematical quotient > ceiling(i, j) # return ceiling of mathematical quotient > > instead. They should also have 1-argument flavors, corresponding to the > current math.floor and math.ceil. This would emphasize that the real point > to all this stuff is computing floors and ceilings, not really about the > numeric types of division arguments (that's always been a red herring!). I think that's missing the point. The current integer division rules aren't a real problem to the experianced - it's just one more special case that's the same as some languages, and different than others. It's a problem for the novice and the occasional programmer. Going on about floor and ceiling is perhaps mathematically useful (in fact, no perhaps about it) but it does nothing for the novice or occasional user. Replacing / completely with idiv, fdiv and (eventually) rdiv would force anyone trying to divide to come to grips with what they wanted as a result type. In any case, the "natural" result of dividing two integers is a rational, not an approximate real (i.e. float). John Roth > > but-perhaps-some-herrings-are-too-tasty-to-forego-ly y'rs - tim > > From nperkins7 at home.com Sun Jul 29 18:27:33 2001 From: nperkins7 at home.com (Nick Perkins) Date: Sun, 29 Jul 2001 22:27:33 GMT Subject: REPOST: Re: Try floating the Back Orifice's dumb PGP and Willy will recycle you! References: Message-ID: <8$-_-%_%-$-%$-%_%$@news.noc.cabal.int> I laughed at the first one of these I read, thinking it might be the result of a python program, but now I have noticed that they are popping up on other newsgroups, too, all from different names. Once is funny. Twice is spam. I have seen four or five today. "Timothy Gibson" wrote in message news:FDC34627.2CE8C0C7 at edefod.net... > If you'll recycle Gilbert's printer with keypads, it'll biweekly > interface the thought. Sometimes Alexandra will get the robot, and if > Samantha wistfully meets it too, the programmer will collaborate > outside the fast cybercafe. My extreme PERL won't disconnect before I > push it. He will engulf halfheartedly if William's plotter isn't > bizarre. Go cry a protocol! When will you save the chaotic > retarded zipdisks before Pilar does? Jeff wants to know seemingly, unless > Chester infects machines within Evan's administrator. Until > Jeff defiles the RAMs stupidly, Ann won't moan any solid cafes. > Where Frederick's discarded LAN outwits, Robette facilitates > in back of loud, plastic CIAs. Otherwise the terminal in Jonnie's > librarian might prepare. Try typeing the Back Orifice's dry > admin and Sherry will close you! Who shoots undoubtably, when > Martin dreams the disgusting firewall in the mail server? Don't try to > exclude the stacks wanly, eliminate them deeply. As badly as > Robette reloads, you can negotiate the operator much more strongly. > > > ========= WAS CANCELLED BY =======: Path: news.uni-stuttgart.de!rz.uni-karlsruhe.de!akk.uni-karlsruhe.de!newsfeed01.sul.t-online.de!newsfeed00.sul.t-online.de!t-online.de!join.news.pipex.net!pipex!cass.news.pipex.net!pipex!cspc1n11e.baplc.com!news-hub.cableinet.net!blueyonder!internal-news-hub.cableinet.net!news1.cableinet.net.POSTED!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.stanford.edu!hatchetman.killfile.org!not-for-mail Message-ID: Control: cancel Subject: cmsg cancel From: tskirvin at killfile.org Sender: "Nick Perkins" Approved: tskirvin at killfile.org Newsgroups: at.test,uk.test,alt.test,news.test Organization: Killfiles, Unlimited X-Cancelled-By: tskirvin at killfile.org X-Original-From: "Nick Perkins" X-Original-Posting-Host: 156.207.41.102 X-Cancel-ID: 343<#DW3"DQ5L3K/2:$*:SBM0GC7(C4 at CT57+"<"%M/=VU|#WZBA] Reply-To: "Nick Perkins" Lines: 2 Date: Tue, 31 Jul 2001 08:52:27 GMT NNTP-Posting-Host: 62.30.137.31 X-Complaints-To: http://www.blueyonder.co.uk/abuse X-Trace: news1.cableinet.net 996569547 62.30.137.31 (Tue, 31 Jul 2001 09:52:27 BST) NNTP-Posting-Date: Tue, 31 Jul 2001 09:52:27 BST From cgale1 at _remove_home.com Sat Jul 28 09:38:03 2001 From: cgale1 at _remove_home.com (Van Gale) Date: Sat, 28 Jul 2001 13:38:03 GMT Subject: Deposing Dictators References: Message-ID: <%ez87.128332$%a.5630144@news1.rdc1.sdca.home.com> "Tim Peters" wrote in message news:mailman.996304554.3545.python-list at python.org... > Time to move into the 21st century, Dirck! This alternative is often > overlooked: > > http://www.cobolscript.com/ Oh my god. I thought I would get a laugh checking this link, but the feeling I had instead was more like terror :( I had flashbacks from when I had to write a COBOL program that had varying memory requirements. I was happy to find and use an "experimental dynamic memory allocation" library, but then had to rip it back out again when the project manager said, "I don't understand that." I bet that same bastage is making some poor programmer use cobolscript now. Oh my god. From bckfnn at worldonline.dk Wed Jul 18 16:45:04 2001 From: bckfnn at worldonline.dk (Finn Bock) Date: Wed, 18 Jul 2001 20:45:04 GMT Subject: ANN: Second alpha release of Jython-2.1 Message-ID: <3b55f3ff.47954715@mail.wanadoo.dk> I am happy to announce the second alpha release of Jython 2.1. Jython is a Java implementation of the Python programming language. It allows users to compile Python source code to Java byte codes, and run the resulting bytecodes on any Java Virtual Machine. It is a very seamless and smooth integration with Java: from Python you have complete access to all Java libraries, can build applets, can integrate with Java beans, and can subclass Java classes in Python and vice versa. Like Python, and unlike Java, Jython can also be used interactively: just type some Jython code at the prompt and see the results immediately. A java installer is available for download at the Jython website: http://www.jython.org/ Installation on version 2.1a2 is similar to version 2.0. Further information and tips on installation is available at: http://www.jython.org/install.html Jython 2.1 aims to be feature compatible with Python 2.1 and among the new feature are: - Nested scopes - The display hook A complete list of changes and differences are available here: http://www.jython.org/NEWS.html A list of fixed bugs can be found here: http://sourceforge.net/tracker/?group_id=12867&atid=112867 Change the Status input box to "Closed" and the Group input box to "Fixed in 2.1a2" and press the "Browse" button. Bugs can be reported to the bug manager on SourceForge: http://sourceforge.net/bugs/?group_id=12867 Cheers, the jython-developers From bill-bell at bill-bell.hamilton.on.ca Tue Jul 3 17:57:44 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Tue, 3 Jul 2001 17:57:44 -0400 Subject: ADODB.RecordSet bummer ( was Re: Python and DB support (was: Re: Is Python Dead?)) In-Reply-To: <994188218.395.92602.l8@yahoogroups.com> Message-ID: <3B420798.24863.4D12A66@localhost> [Martelli's address not included since many list members may already know it.] Alex Martelli wrote, in part: > you CAN write rs.Fields("FieldName").Value ... [and] ... I believe > ADO (and much more so, COM:-) deserves a far better language than > Visual Basic... Python, for example!-). Yup, me too FWIW. So, as one of this list's most longstanding newbies, I decided to give the combination a spin. In VBA it's common to coin the cliche: with myRecordSet .edit .fields('myField') = 42 .update end with Unfortunately, >>> import win32com.client >>> rs = win32com.client.Dispatch("ADODB.RecordSet") >>> rs.ActiveConnection = "DSN=WebPASS" >>> rs.Open("[URLs]") >>> rs.Fields("myField") = 42 Traceback (SyntaxError: can't assign to function call Or, is this because I forgot my medication this morning? Bill Bill Bell, Software Developer From tim.one at home.com Mon Jul 23 21:25:41 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 23 Jul 2001 21:25:41 -0400 Subject: PEP0238 lament In-Reply-To: Message-ID: [Stephen Horne] > But Perl had a good try... > > I'm told "1" / 3 gives 0.333333333333333333 Near the end of the group discussion I mentioned before, to try to get consensus on *something* I asked whether anyone was in favor of Python automagically converting strings to numbers "in arithmetic contexts". I thought I was joking -- and turns out I was . Nobody spoke in favor of that. Then we went to the all-conference lunch, and I happened to sit next to a Python newbie fresh from Perl. He hadn't been at the numeric discussion. His first question was "hey! how come I have to convert my strings to ints when I add? I didn't have to do that in Perl!". Arghghghghgh. nothing-new-under-the-snake-ly y'rs - tim From qrczak at knm.org.pl Mon Jul 23 08:43:07 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 23 Jul 2001 12:43:07 GMT Subject: 2.2 features References: Message-ID: Mon, 23 Jul 2001 08:55:40 GMT, Nick Perkins pisze: > Isn't there anything in 2.2 that deserves even a fraction of the discussion > going on about div? (which has been beaten to death 9 times) > > getset(), staticmethod(), classmethod(), etc... I must say that the current state of type/class unification is so complex that I don't understand the details, all these slots and wrappers and types, and why 5 .__new__(list, '42') == 42 for example. I home that the following piece of documentation is temporary! Isn't this backwards incompatible? Won't it break existing code? It would, if we changed the method resolution order for all classes. However, in Python 2.2, the new lookup rule will only be applied to types derived from built-in types, which is a new feature. Class statements without a base class create "classic classes", and so do class statements whose base classes are themselves classic classes. For classic classes the classic lookup rule will be used. (To experiment with the new lookup rule for classic classes, you will be able to specify a different metaclass explicitly.) We'll also provide a tool that analyzes a class hierarchy looking for methods that would be affected by a change in method resolution order. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From sholden at holdenweb.com Wed Jul 11 11:06:09 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 11 Jul 2001 11:06:09 -0400 Subject: Bug in rfc822 References: <2ih27.49242$he.3402812@e420r-atl1.usenetserver.com> <9ihnv5$e2v$1@macareux.ens-lyon.fr> Message-ID: <8UZ27.41897$F%5.2532623@e420r-atl2.usenetserver.com> "Emmanuel Jeandel" wrote in message news:9ihnv5$e2v$1 at macareux.ens-lyon.fr... > If someone is playing with rfc822, i'm interested ! > > I'm writing a small script that does statistics about mailboxes : > it writes for each sender (respectively receiver) the number of mail > he sends to you (resp. receives from you), and the total size of mails, > size meaning : i drop all html code, attachments (I use multifile > to consider only the first part of a message) and > drop all lines beginning with '>' . If someone > is interested the program can be located in > http://www.ens-lyon.fr/~ejeandel/mailstat > (python 1.5, but I think it is 2.0 compliant) > syntax: mailstat r namesofthemailboxes for parsing inboxes > mailstat w .... for parsing outboxes > you can also use mailstat r20 to parse only the mail from the last 20 days > (I know that the parsing of the command line is very weak, but i don't > want to lose my time doing this in a more pretty way) > > Playing with rfc822 is good, but i think mailbox.py has also several > problems. When you do mailbox.next(), the function return a rfc822.Message > but i wanted to use my class MyMessage, so i have to rewrite : > > class MyUnixMailbox(mailbox.UnixMailbox): > def next(self): > while 1: > self.fp.seek(self.seekp) > try: > self._search_start() > except EOFError: > self.seekp = self.fp.tell() > return None > start = self.fp.tell() > self._search_end() > self.seekp = stop = self.fp.tell() > if start <> stop: > break > return MyMessage(mailbox._Subfile(self.fp, start, stop)) > > Do you know of any prettier solution ? > I've come across the same impedance mismatch myself, and adopted more or less the same solution. It would clearly be nice to be able to pass the mailbox's __init__() method an (optional, defaulting to rfc822.Message) class which that mailbox would then use when it was creating messages. The class would obviously need to comply with (a subset of) the rfc822.Message interface. Maybe this upwardly-compatible solution could be adopted for the rfc2822 library? regards Steve -- http://www.holdenweb.com/ From chrishbarker at home.net Mon Jul 30 14:56:46 2001 From: chrishbarker at home.net (Chris Barker) Date: Mon, 30 Jul 2001 11:56:46 -0700 Subject: Newbie Q - Py for Linux on Disk?? References: <554a464b.0107280303.1c0be0f6@posting.google.com> Message-ID: <3B65ADEE.3CFD173@home.net> Gerhard H?ring wrote: > On 28 Jul 2001 04:03:37 -0700, Dick Van Kirk wrote: > >Please tell me where I can purchase Python for Linux on disk that I can > >quickly and easily install ?? > If you want an easily installed Python, you can just buy a copy of any major > Linux distribution if you don't have one already. Any one that I know of has > Python included. yes, but many of them seem to be pretty old versions: 1.5.2 in general. I think ActiveStae will sell you a CD, if you don' thave the bandwidth to download. http://aspn.activestate.com/ASPN/Downloads/ActiveCD -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 tatiana at exatas.unisinos.br Wed Jul 18 20:05:35 2001 From: tatiana at exatas.unisinos.br (Tatiana Evers) Date: Wed, 18 Jul 2001 21:05:35 -0300 Subject: Problems Message-ID: <001b01c10fe6$88c7e160$39a5100a@cg22898> Hi, I try to compile NT example for embedding Python in C. This example is in Source(...\Pyton-2.1\Pc\example.nt), but when I Build the error happens below Compiling... example.c Linking... LINK : fatal error LNK1104: cannot open file "python21_d.lib" Error executing link.exe. example_d.dll - 1 error(s), 0 warning(s) What can I do ? Thanks ;o) Tatiana Evers --------------------------------------------------------------- Tatiana Figueiredo Evers Mestranda em Computa??o Aplicada (Computa??o Gr?fica) UNISINOS - S?o Leopoldo - RS tatiana at exatas.unisinos.br www.inf.unisinos.br/~tatiana From junkster at rochester.rr.com Sun Jul 1 17:17:32 2001 From: junkster at rochester.rr.com (Benjamin Schollnick) Date: Sun, 01 Jul 2001 21:17:32 GMT Subject: Odd problem with converting string to Hex? References: Message-ID: I haven't tried this.... But it certainly makes sense... I was assuming, incorrectly it appears, that Python was storing it as a string of 3 or so characters.... After all, that's what the Print command was displaying.... I had never considered that it was being stored as a "list of characters", array, or whatever you'd like to call it.... Although, I want to stress STR(data....), didn't give a HEX PRINTABLE result.... I'll try this, and hopefully all will be well.... Thanks for the assistance! - Benjamin In article , "Steve Holden" wrote: > "Benjamin Schollnick" wrote in ... > > Folks, > > > > This is odd.... or at least I think it is.... > > > > Using Python v2.1.... > > > > Here's a snippet of the data: > > > > ('.1.3.6.1.2.1.2.2.1.6.2', '\x00\x90\x83H\x11\x0f'), > > ('.1.3.6.1.2.1.2.2.1.6.1', '\x00\x90\x83H\x11\x0f'), > > ('.1.3.6.1.2.1.2.2.1.2.4', 'RF Upstream Interface') > > > > I've tried using: > > > > eval (data[1]) > > hex (data[1]) > > str(data[1]) > > > > What gets returned is: > > > > Unknown - Mac? ---> ??H > > Hex: Long: > > > Let's get this straight. Your data records MAC-level addresses as six-byte > strings, and you want to represent each address as a set of byte values, in > hex, separated by dashes. OK so far? > > > Which os definetly not what I'm looking for.... I'm attempting to > > decode this in pure hexadecimal... > > > > I suspect it's due to the "\x" in the string, but I can't pull up the > > documentation, since when I tried I wasn't getting a response from > > python.org..... > > > Nope. There *is* no"\x" in the string. Look: > > >>> d = ('.1.3.6.1.2.1.2.2.1.6.2', '\x00\x90\x83H\x11\x0f') > >>> len(d[1]) > 6 > > Each \xXX (where the XX are hex digits) is made into a single 8-bit > character by the Python interpreter. The "H" is also a character. Let's look > at the decimal values of each character: > > >>> [ord(x) for x in d[1]] > [0, 144, 131, 72, 17, 15] > > Given the hex values in your data this seems reasonable. > > > Conceptually I'm trying to output it, similiar to: > > > > 00-90-83-11-0f Assuming I'm reading the returned data properly. > > That appears to be the problem: you assumed that Python was storing > everything inside the single quotes as individual bytes, when in fact the > hex escape sequences are interpreted as the string is constructed. > > Getting the hex values is relatively easy using string formatting: > > >>> ['%02x' % ord(x) for x in d[1]] > ['00', '90', '83', '48', '11', '0f'] > > All you have to do to get what you want is join this list of strings with > dashes. I tend to favor the string methods for this kind of thing, though > some say it seems counterintuitive: > > >>> "-".join(['%02x' % ord(x) for x in d[1]]) > '00-90-83-48-11-0f' > > Hope this helps. > > regards > STeve > -- > http://www.holdenweb.com > > > From aleaxit at yahoo.com Fri Jul 13 12:01:37 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 13 Jul 2001 18:01:37 +0200 Subject: LAMBDA IS IT USELESS? References: Message-ID: <9in61201nuf@enews1.newsguy.com> "Suchandra Thapa" wrote in message news:slrn9ktu24.8c3.ssthapa at hepcat.telocity.com... ... > The lambda can be a way to avoid the need to define and name trivial > functions that get used in only one place. And this, in Python, is the ONLY thing that is specific to lambda. > However, the lambda function > is a also a way to dynamically create functions as well as a way of > composing two functions together. ...which you can perfectly well do with other callables besides lambda forms -- as long as you don't mind naming them. > For example, suppose you need to > apply a scaling factor to a list but the scaling factor depends on > user input. In this case, with lambda you can do a with > lambda x: x * s where the value of s depends on the user input. Also, And without lambda you can do it with a def: def mpy(x): return x*s # and now use mpy wherever you'd use your lambda If x is visible inside the lambda (nested-scopes are active) it will be identically visible inside mpy. If you need to 'freeze' s's value, you will supply an s=s defaulting-parameter identically to the lambda or to the def. The ONLY difference is that lambda generates an anonymous function (and is an expression), while def generates a named function (and is a statement). > suppose you have two image filters and you want to create a new filter > that applies the first filter then the second one. Then using lambda, > you can just use lambda x: filter2(filter1(x)). And without lambda you can do it with a def: def combined_filter(x): return filter2(filter1(x)) with all the other considerations being the same as above. > Incidentally, you can use lambda to do a bunch of different things including > reducing the number of parameters a function takes (currying). E.g. The modest amount of currying you can do with a lambda, you can just as well do with a def. def gives more powerful currying because you can have *args and **kwds in a def, which lambda does not support. See for example the entry on currying in the Python Cookbook: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52549 and notice that not one of the entries uses lambda: there's a class and a couple of variant of closures (obtained with def, NOT with lambda: I don't think you could reach this level of generality with a lambda in Python, given its limitations!). > suppose foo takes x, y, and z then lambda x, y:foo(x, y, 4) returns a function > that takes only two paramters. > Basically, think of lambda as a way of applying mathematical operations > like +, /, * as well as a few others to functions. I suggest one should instead think of lambda ONLY as what it is: a way to leave particularly-simple functions (those that can fit in a single expression) unnamed (in a way that is syntactically an expression). There is no other added value of lambda wrt def in Python, and there are several aspects where lambda _subtracts_ value... Alex From fschaef at ces.clemson.edu Wed Jul 4 21:32:02 2001 From: fschaef at ces.clemson.edu (Schaefer, F.) Date: Wed, 04 Jul 2001 18:32:02 -0700 Subject: Emacs parseable Python - Error output Message-ID: <3B43C391.58F060B3@ces.clemson.edu> Dear Python Community, Is there a way to produce error output with python, that can be processed by emacs' compile-mode ? This way it would be possible to jump quickly to the position where the error occured. Thanks, Frank -- From donn at drizzle.com Mon Jul 23 00:24:58 2001 From: donn at drizzle.com (Donn Cave) Date: Mon, 23 Jul 2001 04:24:58 -0000 Subject: PEP0238 lament References: None Message-ID: <995862297.667165@yabetcha.drizzle.com> Quoth "Tim Peters" : ... | Of course, but computer numerics is a massive exercise in picking the | general rules you want to preserve at the expense of others, and trading all | that off against pragmatics too. Not losing information silently is also a | Very Good General Rule, and even 745 binary fp arithmetic is better at | meeting that one than current "/". So would it make sense to also change the >> and << operators to rotate shift? I mean, I sure wouldn't find that more useful, but it does conserve information that the current shifts lose. Donn Cave, donn at drizzle.com From tim at vegeta.ath.cx Mon Jul 16 22:43:34 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Tue, 17 Jul 2001 02:43:34 GMT Subject: OO misconceptions References: <9ir1l7$3ja$1@panix2.panix.com> <9irfbc11jaq@enews1.newsguy.com> <3B538E16.65394C9D@engcorp.com> Message-ID: Me parece que Peter Hansen dijo: > Tim Hammerquist wrote: > > My only regret is that so many people in this NG are so violently > > anti-Perl. I always thought that if someone as cynical, stubborn, and > > arrogant as I am can love both languages, anybody could. > > I wouldn't have said "violently". That is to say, I haven't actually > *killed* anyone for using Perl... yet. * runs screaming * AAAAGH! > And I consider my cynicism, stubbornness, and arrogance to be right > up there with the best of them. (In fact, my absolutely _unparalleled_ > arrogance is _certain_ to be my own downfall, and _nothing_ you could > say would convince me otherwise. ;-) I make it a point never to argue the existence of hubris. ;) > Nevertheless, I feel compelled to say that I believe there may be > applications for which Perl is the better language, but I'm fairly > sure (a) I'd have an argument against _almost_ any example proposed, > and (b) the few I might not argue against would likely be "better in > Perl" only because of some ugly situation such as maintaining > compatibility with a legacy system, supported by programmers who > know only Perl and don't want to change, and an application already > working and therefore not in need of maintenance of any kind. > > Any other application, and I would probably say Python was a > better choice... This is where our opinions (on both languages) differ, and where we might as well agree to disagree? > > My apologies to the group at large. > > Tim Hammerquist > This group is scary in its degree of both tolerance and forgiveness. > (Hey, they even let me stay here.. so far. :) I am grateful for this. -- The iMac comes in five colors. Who cares from a technical standpoint? But they're obviously selling like crazy... -- Linus Torvalds From joonas.paalasmaa at nokia.com Wed Jul 11 06:30:07 2001 From: joonas.paalasmaa at nokia.com (Joonas Paalasmaa) Date: Wed, 11 Jul 2001 10:30:07 GMT Subject: evalstr References: Message-ID: <3B4C2A0E.60AA094@nokia.com> Shannon --jj Behrens wrote: > > Hello All, > > I wrote a useful C module for doing string > interpolation. I find it indespensible when working > with large blocks of triple-quoted text. When working > with large blocks of triple-quoted text, nothing else > is quite as convenient. Here's the Python doc: [lots of text snipped] > Please forgive my arrogance, but I think that it might > even be useful enough to be included as a standard > module. If, not perhaps you guys might have some > suggestions as to what I can do with it. You may > download the entire packages from: > > I prefer the following method for evaluations inside strings. >>> class Eval: def __getitem__(self, key): return eval(key) >>> foo = 3.0 >>> spam = 5.0 >>> print "%(foo/spam)s" % Eval() 0.6 >>> print "%(foo/spam).55f" % Eval() 0.5999999999999999800000000000000000000000000000000000000 >>> From erno-news at erno.iki.fi Mon Jul 16 15:00:30 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 16 Jul 2001 22:00:30 +0300 Subject: list[] = var => list.append(var) (phpstyle) References: <4e2ddb70.0107141310.3c7ca355@posting.google.com> <9iqfge0gba@enews1.newsguy.com> <9iqlgi$kbg9g$1@ID-11957.news.dfncis.de> Message-ID: [reformatted for your reading pleasure] In article <9iqlgi$kbg9g$1 at ID-11957.news.dfncis.de>, "Emile van Sebille" writes: || "Alex Martelli" wrote in message || "Nick Perkins" wrote in message || news:LF447.476898$eK2.98947068 at news4.rdc1.on.home.com... ||| I think it should be neet if it would be possible to append a variable ||| to a list by just using ||| list_var[] = var_to_append ||| It works that way in PHP and I think it's nice. ||| ||| Any comments? || list_var += var_to_append || || (which is how you express this today in Python) is equivalent || and shorter. Python does NOT go out of its way to provide || a zillion ways to write the same, identical thing. | Alex is right as long as var_to_append is already a list. not quite: >>> l1 = [1] >>> l2 = [2] >>> l1 += l2 >>> l1 [1, 2] vs. >>> l2.append(l1) >>> l2 [2, [1]] | For non-lists though you can also do | list_var += 1, | or, | list_var += (1,) hmm, does the sequence protocol really include __add__ing arbitrary sequences? one would think lists would support it too if that was the case. -- erno From vAbazarov at dAnai.com Sun Jul 29 12:53:57 2001 From: vAbazarov at dAnai.com (Victor Bazarov) Date: Sun, 29 Jul 2001 16:53:57 GMT Subject: Unusual minidom behaviour: Part Deux References: Message-ID: "Martin von Loewis" wrote... > "Victor Bazarov" writes: > > > No, I am reading all the Python output and if there were any, > > I'd have seen it. > > In that case, I recommend to put a number of print statements into the > library modules that you suspect to be causes of the problem, and > trace that way what they are doing. If you can identify the call that > is hanging (i.e. the function you call that doesn't return), please > let us know. Didn't I already? __import__ is hanging. It doesn't let another thread to start and it doesn't return anything. Victor -- Please remove capital A's from my address when replying by mail From new_name at mit.edu Sat Jul 14 23:42:16 2001 From: new_name at mit.edu (Alex) Date: 14 Jul 2001 23:42:16 -0400 Subject: Need help with "global" variables References: Message-ID: In python, "global" doesn't mean what you think it means. It means global to the current module. The only way to make a binding global over an entire program is to stick it in the __builtin__ module. However, there is probably a better design for your program that doesn't need so many global variables. Alex. From johnca at DIESPAMmac.com Wed Jul 18 18:04:08 2001 From: johnca at DIESPAMmac.com (John Abbe) Date: Wed, 18 Jul 2001 15:04:08 -0700 Subject: Python CGI speed on MacOS X References: Message-ID: In article , johann at leporello.berkeley.edu wrote: > John Abbe writes: > > > I'm running MacOS X on a PowerBook G3 400MHz, and have Python 2.1 > > installed (from http://tony.lownds.com/macosx/). > > I've got the same computer, and I do notice Python being a bit more > pokey than it should be. I suspect some weird intereaction between > the Apple-patched gcc compiler and the Python source. Maybe the 10.1 release of OS X will help. Anyone else able to offer insights? -- We've been waiting seven years for real Mac on Unix. Get the most out of it! Links & tips for learning, and to get OS X up and running: http://www.ourpla.net/guiunix/GettingXGoing.html From Sibylle.Koczian at Bibliothek.Uni-Augsburg.de Tue Jul 24 10:39:45 2001 From: Sibylle.Koczian at Bibliothek.Uni-Augsburg.de (Sibylle Koczian) Date: Tue, 24 Jul 2001 16:39:45 +0200 Subject: Language change and code breaks References: Message-ID: <3B5D88B1.774A4D70@Bibliothek.Uni-Augsburg.de> piet at cs.uu.nl wrote: > > >>>>> Guido van Rossum (GvR) writes: > > GvR> But it's still open for debate whether the problem here is Windows or > GvR> Unix! All programming languages and file systems used to be > GvR> case-insensitive, until the designers of Unix and C decided that it > GvR> was too much work to write and use a case-insensitive comparison > GvR> routine. > > This is not true. Algol 60 was case-insensitive from the beginning. By > design, as Algol 60 was designed the way it is in spite of the difficulties > it would give its implementors. > -- But that's exactly what he says! Algol 60 was before C, as far as I know, and case-insensitive as was normal at the time. -- ---- 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 aquarius at kryogenix.org Tue Jul 24 08:03:51 2001 From: aquarius at kryogenix.org (Aquarius) Date: Tue, 24 Jul 2001 12:03:51 GMT Subject: Exec and namespaces Message-ID: <9jjo5b$jn3$1@giles.kryogenix.org> I've got a CGI which reads a file and then execs its contents. The file defines a function, and that function can't find itself to call recursively; it gets a NameError. Example: [ aquarius at giles ] /home/httpd/kryogenix.org/current/web $ cat foo.cgi #! /usr/bin/python import sys sys.stderr = sys.stdout print "Content-type: text/html\n\n" def main(): fp = open("foo.txt") exec(fp.read()) main() [ aquarius at giles ] /home/httpd/kryogenix.org/current/web $ cat foo.txt def bar(quux=None): if quux == "test": print "Hello, world!" else: bar("test") bar("nothing") [ aquarius at giles ] /home/httpd/kryogenix.org/current/web $ python foo.cgi Content-type: text/html Traceback (innermost last): File "foo.cgi", line 13, in ? main() File "foo.cgi", line 11, in main exec(fp.read()) File "", line 8, in ? File "", line 6, in bar NameError: bar My question here is: is there anything I can do about this? I assume that you can't call bar() from inside bar() because it only knows about two namespaces, global (which main() is in) and the "inside-bar()" namespace, and bar() itself is in neither. I've tried this with both 1.5.2 and 2.0.1 and there doesn't appear to be any different (aside from the wording of the NameError changing to "There is no variable named 'bar'" under 2.0.1, which I assume is the same thing). Aq -- I wish I understood namespaces -- "The grand plan that is Aquarius proceeds apace" -- Frank Miller, "Ronin" From db3l at fitlinxx.com Wed Jul 25 18:13:27 2001 From: db3l at fitlinxx.com (David Bolen) Date: 25 Jul 2001 18:13:27 -0400 Subject: importing modules References: <3b5f38c5.112013116@news.libero.it> Message-ID: dedalus at yifan.net (Duilio Foschi) writes: > >Where did you get this from? > > http://www.hvision.nl/~ivnowa/newsite/Python/Python-DX/python-dx.html > > "Hans Nowak's Python-DX is a version of Python for 32-bit DOS. > Python-DX is equivalent to Python 1.5.2, but Hans no longer maintains > it, so it's doubtful that Python 1.6 will be supported. " > > > what shoud I do ? Notice that below the download section on that page it says: "NOTE: These are only the binaries (executable file)! You will also need the standard library. I suggest you grab the latest version from http://www.python.org ... there's also lots of documentation there. You might want the source distribution, too, if only for the useful demo and example programs." This zip file only has the python executable. You still want the "lib" directory contents from the standard Python 1.5.2 distribution. It seems to work fine with a normal Python 1.5.2 library (although I'm not quite sure about some of the modules with a longer than 8.3 filename). You may need to tweak site.py (or just set PYTHONPATH in your environment) to be sure that it can find the library files. The WPY archive DOS version (accessible from the python.org DOS pages at http://www.python.org/download/download_dos.html) also have a pylib.zip file that has a zipped copy of the library files, including a DOS-8X3 directory for handling those with longer than 8.3 names. -- -- 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 rnd at onego.ru Wed Jul 4 15:59:13 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 4 Jul 2001 23:59:13 +0400 (MSD) Subject: PEP: Procedure for Adding New Modules (please comment) In-Reply-To: <9hvqhr$gj2$1@newshost.accu.uu.nl> Message-ID: On 4 Jul 2001, Martijn Faassen wrote: >Hi folks, ... > In the case where no head maintainer can be found (possibly > because there are no maintainers left), the integrators will issue > a call to the community at large asking for new maintainers to > step forward. If no one does, the integrators can decide to > declare the contribution deprecated as described in PEP 4. ... This is too quick, IMHO: some libraries/modules could be actual for years even without any maintainers. (Yes, I hope Python to be *that* stable). So, probably there is a need to add a special category of unmaintained modules and ship them with the Standard Library as long, as they are useful and runnable. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Wednesday, July 04, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Mediocrity requires aloofness to preserve it's dignity" _/ From michael at rcp.co.uk Tue Jul 31 10:08:22 2001 From: michael at rcp.co.uk (Michael Abbott) Date: Tue, 31 Jul 2001 14:08:22 +0000 (UTC) Subject: Typing system vs. Java References: <3B66B3A2.F47BA3E2@engcorp.com> Message-ID: Peter Hansen wrote in news:3B66B3A2.F47BA3E2 at engcorp.com: > Michael Abbott wrote: >> >> I for one would like to see a strongly typed variant of Python: if for >> nothing else, I'd like to be able to compile my code. > > How would that let you compile your code? Lack of compile-time > type checking is hardly the only thing making it difficult to > develop a Python compiler. Hmm. Well, it's interesting to look at the byte code interpreter source and to consider just how much time and effort is spent in working out what the types of operands are and therefore which particular operation to invoke. You can't avoid that without static typing of some sort. > More to the point, why would you want to compile your Python code? > > If for packaging reasons, there are effective alternatives in > the form of, for example, py2exe. > > If for performance, the better approach is perhaps to profile your > code, then rewrite the performance-critical portions as C > extensions. Then you have pretty much the best of both worlds. Possibly, possibly. Perhaps I'm old fasioned, and too concerned about efficiency. I know that processor speeds have increased by a factor of 1,000 or so in the last couple of decades or so, but it gives me the creeps to see just how much code is executed to implement such simple expressions as 1+2 or f(x). I'm concerned to write efficient and secure systems which handle high volumes of data reliably. I believe that Python has three weaknesses, but unfortunately these weaknesses are also at the heart of its strength: 1. No static type checking means that a very large class of errors (including undeclared identifier access) cannot be caught until run time. 2. Efficient compilation is not possible, because operators and function calls cannot be compiled to anything simpler than the existing byte code interpreter's current interpretation. 3. There is no data hiding. >> Let me just observe this: statically typed Python would need to be a >> different language from standard Python, though hopefully close enough >> to interoperate and have the same name. > > It would be interesting, perhaps, to see how well such a beast > would be adopted by the programming community. I can just see > the "marketing war" triggered as both sides try to promote > their own version of Python as the One True Way to program... > I think it's a pretty safe bet that most people prefer dynamic types. Writing statically typed code is harder. I doubt that statically typed Python would be a competitor: I see it as more of a niche solution. Also, it's pretty clear that the three weaknesses I've just complained about are simultaneously part of the strength of Python. 1. No static type checking means that it is not necessary to work out a type description (which may be very complex) and it is easy to modify existing code to change its behaviour. It also means, often, that when a type error does occur there can be useful run time information about the cause of that error. 2. The edit and run cycle of Python is very slick and easy to use. 3. Of course, the lack of data hiding means that developers have more access to the internals of libraries, and there is no arguments about whether certain methods should be hidden or exposed. Finally, it is possible to do some very clever things with the dynamically adaptive type structure of Python and it will be very difficult to capture many of these features in a strict static type system. From annis at biostat.wisc.edu Wed Jul 11 16:50:10 2001 From: annis at biostat.wisc.edu (William Annis) Date: 11 Jul 2001 15:50:10 -0500 Subject: Pickle translation References: Message-ID: "Fredrik Lundh" writes: > William Annis wrote: > > So, are there any tools to translate 1.5.2 pickles to 2.x > > versions of the pickle format? > > import pickle > > (1.5.2, 1.6, 2.0, and 2.1 all use the same pickle format) Then pickle is bugged somewhere. I have a giant (1.2M) pickle file which keeps the state of everything my monitoring system is keeping track of, including moderately complex Holt-Winters time series models. When I start the daemon that does all the work with python1.5.2, it loads the pickle fine. When I try to start it with python2.1 I get this: Traceback (most recent call last): File "bin/momd", line 83, in ? kserv = load(f) ValueError: invalid \x escape -- 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 mal at lemburg.com Thu Jul 12 14:56:01 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Thu, 12 Jul 2001 20:56:01 +0200 Subject: ANN: eGenix.com mx COMMERCIAL Extension Package 2.0.3 Message-ID: <3B4DF2C1.ADE9C4DA@lemburg.com> ________________________________________________________________________ ANNOUNCING: eGenix.com mx COMMERCIAL Extension Package for Python Version 2.0.3 Full Source Python extensions providing important and useful services for Python programmers. ________________________________________________________________________ WHAT IS IT ?: The eGenix.com mx COMMERCIAL Package for Python is part of the eGenix.com mx Extension Series for Python, a collection of professional quality software tools which enhance Python's usability in many important areas such as ODBC database connectivity, fast text processing, date/time processing and web site programming. This commercial package includes the popular mxODBC extension which allows users to connect to just about any database on the market today from Windows and Unix. By providing a consistent interface on all supported platforms, it provides a perfect base for writing cross-platform database programs and utilities. ________________________________________________________________________ WHAT'S NEW ? The mxODBC documentation now also includes details on how to write products using mxODBC which are then wrapped into standalone applications using Thomas Heller's py2exe utility. The RPM packaging scheme was reworked and Cygwin support was added. As always we are providing precompiled versions of the package for Windows and Linux as well as sources which allow you to install the package on all other supported platforms. ________________________________________________________________________ SPECIAL OFFER theKompany.com has licensed the eGenix.com mx Commercial Package (which includes mxODBC) for inclusion in their brand new Qt-based Python IDE BlackAdder. It allows developing portable GUI-based database applications which run on Windows and Linux platforms without any change to the source code. BlackAdder includes a 1 CPU license for this package at no extra cost, so you may want to check out their great new product. See http://www.lemburg.com/files/python/eGenix-mx-Extensions.html#BlackAdder for details. ________________________________________________________________________ EGENIX.COM MX COMMERCIAL PACKAGE OVERVIEW: mxODBC - Generic ODBC 2.0-3.5 interface for Python mxODBC is an extension package that provides a Python Database API compliant interface to ODBC capable database drivers and managers. In addition to the capabilities provided through the standard DB API it also gives access to a rich set of catalog methods which allow you to scan the database for tables, procedures, etc. Furthermore, it uses the mxDateTime package for date/time value interfacing eliminating most of the problems these types normally introduce (other in/output formats are available too). mxODBC allows you to interface to more than one database from one process, making inter-database interfacing very flexible and reliable. The source version includes a varity of preconfigured setups for many commonly used databases such as MySQL, Oracle, Informix, Solid, SAP DB, Sybase ASA and ASE, DBMaker and many more. The precompiled versions for Windows and Linux include the interfaces to the standard ODBC manager on these platforms to allow for a more easily configurable setup. More details are available at: http://www.lemburg.com/files/python/mxODBC.html ________________________________________________________________________ WHERE CAN I GET IT ? The download archives and instructions for installing the packages can be found at: http://www.lemburg.com/files/python/ Note that in order to use mxODBC you will also need to install the eGenix.com mx BASE package which can be downloaded from the same location. ________________________________________________________________________ WHAT DOES IT COST ? mxODBC comes with a licenses which allows non-commercial use at no charge, but places a moderate fee on commercial users. Special licensing setups are available for commercial product developers. Please see http://www.lemburg.com/files/python/eGenix-mx-Extensions.html#mxCOMMERCIAL for details. The package comes with full source code. ________________________________________________________________________ WHERE CAN I GET SUPPORT ? Commercial quality support for these packages is available from eGenix.com Software GmbH. Please see http://www.lemburg.com/files/python/eGenix-mx-Extensions.html#Support for details about the eGenix support offerings. ________________________________________________________________________ REFERENCE:

eGenix.com mx COMMERCIAL Package 2.0.3 - eGenix.com mx COMMERCIAL Interface 2.0.3 with distutils support and precompiled binaries for Windows and Linux. (12-Jul-2001) ________________________________________________________________________ Enjoy, -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From bokr at accessone.com Sun Jul 22 18:03:30 2001 From: bokr at accessone.com (Bengt Richter) Date: Sun, 22 Jul 2001 22:03:30 GMT Subject: PEP0238 lament References: Message-ID: <3b5b3d9e.148520871@wa.news.verio.net> On Sun, 22 Jul 2001 14:22:21 -0400, "Tim Peters" wrote: >[Arthur_Siegel at rsmi.com] >> ... >> If I was told that experinced programmers might >> appreciate this change for any possible reason - >> I'd be quiet as a mouse. > I'd call myself experienced, though not yet with Python (though I fancy my other experience gives me a leg up on most Python newbies). I am generally so adaptable it's almost a problem, so I'll have no big problem with '//' after I accept that this is Rome, and I should do as the Romans do. It's certainly not going to put me off Python ;-) >Not all experienced programmers agree. At the last Python Conference, I >moderated a 40-some person group discussion on conceivable changes to >Python's numeric model, not advocating but keeping the participants from >killing each other . The meaning of integer division wasn't the >focus, but naturally came up. By show of hands, about 3/4ths of the >participants agreed that 3/4 should not return 0, but rather *something* x >such that x*4 had a better chance of being confused with 3 than with 0. >There was no consensus on exactly what 3/4 should return -- rational or HW >float or decimal float were the most popular alternatives. > >It shouldn't be so hard to understand why. The current integer division >loses information silently and without a trace. Combined with that Python The thing is, current floating point operations also (sometimes, not always, just as with integer ops) lose "information silently and without a trace." Just less noticeably, for the most part, if you sanitize output. Which leads me to wondering if exactness would be a more approachable concept for CP4E than details of numeric representation alternatives. For many 'float' is about as relevant to their desired computing experience as 'hypoid' is to their commuting experience. Why not keep both hidden under the hood (without welding it shut, of course) ? >is not a statically typed language, there's simply no telling what e.g. > >def velocity(distance, time): > return distance / time > >will compute by inspection. This isn't about esoteric user overloading of >"/", it's about ordinary arithmetic on builtin numeric types, and many >experienced Python programmers have testified over the years to being burned >in practice by stuff exactly that simple. > I believe you. BTW, is there an efficient type assertion that doesn't go away with optimization, that one could use to refuse wrong-type arguments? >I expect that either way is easy enough to *teach*, but I don't accept ease >of teaching as a primary goal: I'm much keener on semantics that, once Glad to hear that. Worst IMHO is when teachers teach what is actually wrong to children or the otherwise innocently ignorant, with the rationale that the real truth is too complicated, and even letting on that there is a real truth will just be confusing. That not letting on part is the real evil. Of course, many teachers are themselves the product of this methodology, and pass it on unawares. I wonder what K-12 teachers will say about Python float ;-/ Maybe there should be guidelines for teaching what is not understood, so that bright kids don't get cynical too fast. >*learned*, are hard to forget or to stumble over. Even if such semantics >are 100x harder to teach at first, fine by me: you spend the rest of your >life living with the consequences. I wish the definition of continuity were >easier to teach too, but that doesn't mean I'll settle for an easier >definition that doesn't actually work . > You teach that? How many are you, anyway? ;-) From bit_bucket5 at hotmail.com Wed Jul 25 19:36:34 2001 From: bit_bucket5 at hotmail.com (Chris Stromberger) Date: Wed, 25 Jul 2001 23:36:34 GMT Subject: How to telnet to other unix machines and grep log files etc? References: Message-ID: On 25 Jul 2001 17:22:12 GMT, quinn at regurgitate.ugcs.caltech.edu (Quinn Dunkan) wrote: >On 25 Jul 2001 08:42:44 -0700, Chris wrote: >>Relative unix newbie. Would like to write a python script to do what >>I do manually--telnet to two different unix machines from a third unix >>machine. Grep through some log files, gather the grep results from >>the different machines and spit them out. I think I need to do >>something with popen, or popen2, or ??? I don't know where to start. >>Any pointers much appreciated. > >This is a shell task: > >(ssh machine1 'grep foo /sys/log/bar'; > ssh machine2 'grep baz /sys/log/faz') >results > >Create an RSA key with no passphrase if you don't want to have to type >passwords all the time. I went ahead and tried this, and it works a charm! Thanks for the suggestion! I read the ssh man page and was able to create the rsa key w/o passphrase. Thanks very much. -Chris From guido at python.org Wed Jul 25 01:39:10 2001 From: guido at python.org (Guido van Rossum) Date: Wed, 25 Jul 2001 05:39:10 GMT Subject: PEP238 and zope References: <3B5DE0F7.9070001@nospiced.ham.devis.com> Message-ID: Tom Jenkins writes: > We're a zope shop. Its quite possible that the work we do now will be > still in use for many years (not guaranteed but we still use code now > that we wrote 2 years ago - before it was zope ;) ) > > We use Python Methods in Zope... python snippets stored directly in > zope's zodb. grepping *.py won't find any of these snippets. I don't > believe zope will surface any warnings that PEP238 stipulates (tho I may > be wrong). How do we code _now_ so as to minimize our pain? I find it hard to believe that you use much division is Zope scripts, but if you do, use divmod(x, y)[0] for int division and x*1.0/y for float division. However, Zope typically comes with its own Python version, so all you need to do is not upgrade the Zope version you are using. Also, I believe that Zope is typically much more aggressive in breaking old code, so you wouldn't want to upgrade your Zope anyway if you had a lot of old code around that you couldn't afford to maintain. --Guido van Rossum (home page: http://www.python.org/~guido/) From aahz at panix.com Mon Jul 9 09:27:25 2001 From: aahz at panix.com (Aahz Maruch) Date: 9 Jul 2001 06:27:25 -0700 Subject: PEP scepticism References: Message-ID: <9icbft$okp$1@panix6.panix.com> In article , Guido van Rossum wrote: >"Tim Peters" writes: >> [Robin Becker] >>> ... >>> Dictators often assume they know best, but observation shows them >>> to be uniformly wrong. >> >> Heh. Replace "Dictators" with "Humans", and I expect the truth-value of >> that assertion would be unaffected. >> >> BTW, in case newcomers are wondering, Guido didn't become BDFL by >> assassinating his predecessor, nor does he maintain Absolute Power by force >> of arms. Although he's been thinking about it . > >The PSU has Robin's name and email address. Robin: be afraid, be very >afraid. It is time that an example be set! "Who killed Cock Robin? I, said the sparrow With my bow and my arrow I killed Cock Robin." -- --- 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 "How come we choose from just two people for President but more than 50 for Miss America?" --AEN From cliechti at mails.ch Sat Jul 28 22:56:46 2001 From: cliechti at mails.ch (chris liechti) Date: 29 Jul 2001 04:56:46 +0200 Subject: FEEDBACK WANTED: Type/class unification References: Message-ID: Guido van Rossum wrote in news:cp66cd12yp.fsf at cj20424- a.reston1.va.home.com: > Note that if you have concerns about backwards incompatibilities, the > best thing you can do is point them out ASAP. I want to ensure that > 2.2 (final) is as compatible with 2.1 as possible, while still > providing the new exciting features that type/class unification makes > possible. I like what i see in the intro and PEPs. especially the examples for the dictionary make sense. the __get__ and __set__ for attributes sound interesting.. my colegue who is a delphi programmer can not understand that other languages don't have these...maybe this makes it easier for me to persuade him to use python :-) why 2.2? this would also fit in a 3.0 along with a unified number system and true division. this would make a clean cut and a new better "python 3.0" would be the choice for new projects and beginners. as you pointed out, in perl there was a similar cut from 4 to 5 (well python won't be very incompatible, just some modules need an update). will this also allow to replace the default generators for builtin types/type-classes? i mean that i can replace "int", "float", "complex",... with my own factories, say to implement my own number tower with rationals (if they weren't included anyway). something like that: -------- class rational: #intentional small caps first letter to make it #look like the other factories ("int", "long",...) def __init__(self, numerator, denumerator): self.numerator, self.denumerator = numerator, denumerator def __int__(self): return self.numerator / self.denumerator def __div__(self, divisor): return rational( self.numerator, self.denumerator*divisor ) ... #plus all the other operators that make it a useful number object class Myint(int): def __div__(self, divisor): return rational(self.value, divisor) ... #same as Myint for complex,float,long,.... __builtins__.int = Myint __builtins__.long = Mylong ... #then in use: a = 1/2 #this should use the "Myint" factory for "1" #and "2" because the default "int" was replaced #above print type(a) #should say"", in detail an #instance of "Rational" -------- this would also allow a change for the fixed point numeric arithmetic some people want for their caclculations with money. but i don't see that as a type which should be included in python itself but rather added by the people who need it realy. PS: the link in http://python.sourceforge.net/peps/pep-0253.html under "References" is broken. actually the "" HTML tag is misplaced. maybe your PEP to HTML script needs to learn about "," in URLs.. ;-) -- chris From phawkins at spamnotconnact.com Fri Jul 20 13:57:36 2001 From: phawkins at spamnotconnact.com (phawkins at spamnotconnact.com) Date: 20 Jul 2001 13:57:36 -0400 Subject: Partition Problem References: <3B4FBEA0.D5A6DC8A@engcorp.com> <9ioru22pc9@enews4.newsguy.com> <3B5042C2.F821D916@engcorp.com> Message-ID: >>>>> "PH" == Peter Hansen writes: PH> Alex Martelli wrote: >> >> free.it.python, actually, so the time isn't wasted -- the newsgroup is >> working just fine:-). PH> Brilliant! "Free IT - use Python". I like it! Nonsense, he's fomenting zoo escapes. PH> -deliberately-misinterpreting-ly yr's, -likewise-ly yr's, Patricia -- Patricia J. Hawkins Hawkins Internet Applications, LLC From mnenadov at stclairc.on.ca Tue Jul 31 23:13:03 2001 From: mnenadov at stclairc.on.ca (Mark Nenadov) Date: Wed, 01 Aug 2001 03:13:03 GMT Subject: smtp authorization...how to? References: <3b675617.48549445@news.mailops.com> Message-ID: <20010731.232003.620145550.12797@d150-169-166.home.cgocable.net> In article <3b675617.48549445 at news.mailops.com>, "chajadan" wrote: > I started pokin' around in the smtplib and tried sending an e-mail. My > smtp server requires a username and password, yet there is no method for > either of these. That I saw. Is there an available module that > incorporates these, or a simple way to extend smtplib? > Any pointers would be great. This URL (http://groups.yahoo.com/group/python-list/message/68346), will be useful to you. It seems someone posted to the group with a fix to the same problem as you have. Download the smtplib.py file that the person attached. I tried it out on the version of Python that I am running (2.1) and it appears to have the same problem, try the URL I gave you, it should help. -- ~Mark Nenadov (author/editor for http://www.coffeecode.com) From philh at comuno.freeserve.co.uk Sat Jul 7 06:37:39 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Sat, 7 Jul 2001 11:37:39 +0100 Subject: Postgres support References: <5174eed0.0107061058.5446dac9@posting.google.com> Message-ID: On 6 Jul 2001 11:58:58 -0700, Edward Wilson wrote: >This is exactly what I have been talking about for *years* now. > >Python will only appeal to scientific developers researching the >"impossible to do" until it handles databases on a first class scale. >Oh, and another point, ODBC is dead. Microsoft has already abandand >it for OLEDB a COM based library. References to ODBC need not apply. >What is needed are RAW Native Drivers at the C/C++ level. > >Python needs a ready to use cross database module which handles >Oracle, DB2, SQL-Server, Sybase, and Informix. Good idea. I hope to see your sample implementation soon... -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From fett at tradersdata.com Thu Jul 12 12:39:43 2001 From: fett at tradersdata.com (fett at tradersdata.com) Date: Thu, 12 Jul 2001 12:39:43 -0400 (EDT) Subject: Newbie Question: Regular Expressions Message-ID: <200107121639.f6CGdhJ30999@vela.tradersdata.com> I have a really dumb program that i would like to make smarter. I need to take a file on my hard drive and filter out everything except for the standings which are written in it. I have tried to use regular expressions with no success, but i still think that they are probably the best way. I created the following simple fix, but it is unreliable if the data changed posistions. input = open('rawdata', 'r') S = input.read() print S[4021:6095] Output : League Standings American League EAST W L PCT GB HOME ROAD EAST CENT WEST NL L10 STRK Red Sox 43 29 .597 - 23-15 20-14 23-13 8-7 6-6 6-3 6-4 L2 Yankees 41 31 .569 2.0 21-15 20-16 19-11 12-9 5-7 5-4 6-3 W2 Blue Jays 35 38 .479 8.5 18-20 17-18 14-13 6-7 11-13 4-5 5-5 W3 Orioles 34 39 .466 9.5 20-20 14-19 15-17 9-12 6-5 4-5 5-5 L1 ........( it continues with all the standings) Also could you tell me if its possible to download the data from the web-page in python so that it doesnt even have to deal with opening the file. -- Daniel Hammond Get your free e-mail account today @ Raleigh NC http://sabacctable.zzn.com The United States of America ------------------------------------------------------------------- From JamesL at Lugoj.Com Fri Jul 20 12:04:08 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Fri, 20 Jul 2001 09:04:08 -0700 Subject: Case Insensitivity (was Language change and code breaks) References: <%%G57.15495$Cy.1928702@news1.rdc1.az.home.com> Message-ID: <3B585678.4EB2E16C@Lugoj.Com> Konrad Hinsen wrote: > Did anyone ever do a study on this? All I have seen is > anecdotical evidence (including mine, of course). Could we get input > from someone who does Python teaching sufficiently regularly? I'm not sure one needs to limit the input to just teachers who regularly teach Python (although if so, then Mark Lutz may be a good one to ask). Sheila King in another post on this thread has relevant experience to relate. Several years ago, Mark Lutz came to the company I was consulting at to teach Python to a group of about 6 programmers and sometime-programmers, I don't recall case sensitivity coming up as an issue. I DO recall indentation being a problem for one fellow who took a while to learn to be less sloppy about making his lines in a block of code all start at the same column. There were other conceptual hurdles, but not case sensitivity. With no evidence showing that such an incredibly disruptive change would lead to a corresponding incredible advantage, I'm really wondering why this issue is still being debated. P.S. It WOULD break a lot of the code I've written, having adopted the ASN.1 naming conventions where instance names differ from type names only by the case of the first letter. From mwh at python.net Wed Jul 4 05:30:58 2001 From: mwh at python.net (Michael Hudson) Date: 04 Jul 2001 10:30:58 +0100 Subject: Comment on PEP-0238 References: <3B3BE855.A6223E70@3-cities.com> <7ef50c46.0107020554.31cc948b@posting.google.com> <7ef50c46.0107030657.2e0fc92b@posting.google.com> <9ht7ki$pao$1@nntp6.u.washington.edu> Message-ID: Donn Cave writes: > Maybe there should have been a "div" operator in Python, but it > strikes me as rather monomorphic (antonym of polymorphic?) unless we > have a more general notion in mind than just integer arithmetic. We need a EuclideanDomain type! > But it's awfully late for that anyway. Yes. Cheers, M. ...who would be perfectly happy with >>> 4 / 5 TypeError: integers are a ring, moron! but doesn't think this has much chance... -- Java sucks. [...] Java on TV set top boxes will suck so hard it might well inhale people from off their sofa until their heads get wedged in the card slots. --- Jon Rabone, ucam.chat From tangell at kicker.com Thu Jul 12 01:32:16 2001 From: tangell at kicker.com (T Angell) Date: 11 Jul 2001 22:32:16 -0700 Subject: Light Speed Socket Connections Message-ID: I wrote some code to test how long it takes to make socket connections and ran it against several hosts around the world, here are some sample times: socket time: 0.0047459602356 socket time: 0.00469899177551 socket time: 0.00404000282288 socket time: 0.00537407398224 Someone in another newsgroup suggested that was probably just the time it took the o/s to fire off a SYN packet and never waited for the result. So, I thought I'd post the Python code here to see what I'm doing wrong. The o/s is Red Hat 7.0. Note: the results I posted above are all from result = "OK" responses, so I know it's getting past the second connect() def trySocket( host, port, timeout ): result = "" s = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) t1 = time.time() try: s.setblocking( 0 ) s.connect( ( host, port ) ) except: r, w, e = select.select( [], [s], [], timeout ) if w: try: s.connect( ( host, port ) ) result = "OK" except socket.error, reason: result = reason[1] else: result = "Timeout" s.close() delay = time.time() - t1 return result, delay Thanks. From pierre at saiph.com Mon Jul 30 06:41:49 2001 From: pierre at saiph.com (Imbaud Pierre) Date: Mon, 30 Jul 2001 12:41:49 +0200 Subject: Python 2 times slower than Perl References: <8f41cfd.0107171238.6ff33b9b@posting.google.com> <170720011359545210%mday@apple.com> <87n163mfdc.fsf@elbereth.ccraig.org> Message-ID: <3B6539ED.8AD853FB@saiph.com> Skip Montanaro wrote: > > Christopher> I can't speak for Perl, but Python definately does not > Christopher> evaluate the expression at compile time. This is a problem > Christopher> I've had with Python. I wish that when given the -O option > Christopher> the compiler would do constant subexpression elimination. > > It's rare in normal Python code to actually see a constant expression > computed inside a loop. Fortunately, it would appear most folks aren't that > dumb, so while you can take steps to eliminate them, there aren't generally > going to be very many to eliminate. What about a constant used only by a function, which function can be called in loops? When performance is important, I use to define such constants in the module, out of the function definition: I trade readability for performance. smart optimisation (evaluate not at compile time, but once at runtime) sure wud help. -- Pierre Imbaud 12 Rue des Bosquets 91480 Quincy Sous S?nart France Tel: 01 69 00 94 57 Fax 09 47 From warp10 at hushmail.com Thu Jul 12 05:35:53 2001 From: warp10 at hushmail.com (domi) Date: Thu, 12 Jul 2001 11:35:53 +0200 Subject: ConfigParser and inifile Message-ID: <9ijr1q$29sq$1@news.lf.net> Hello All, could someone solve this problem? I would like to tell ConfigParser to parse an ini-file from one section to the other. The ini-file looks like this: [section1] name:... group:... [section2] name:... group:... [section3] name:... group:... Now if I let the ConfigParser parse this ini-file like this: for section in config.sections(): ...(do something) the parser doesn't step thru section1 to section2 and so on. I need the given sequence in the ini-file. Thanks, domi From loewis at informatik.hu-berlin.de Thu Jul 26 04:04:37 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 26 Jul 2001 10:04:37 +0200 Subject: Unusual minidom behaviour: Part Deux References: Message-ID: "Victor Bazarov" writes: > Further digging led me to the C source module that contained some > comment "this is to prevent two threads from importing the same > module at the same time returning incomplete module" (or something > like that). I didn't try to comprehend the C source, sorry. > Although it may not be so difficult, I prefer to leave fixing to > those for whom the system is an open book. Even if you didn't understand the source, it would have been nice if you had indicated what source you were looking at; I could not find any occurrence of "this is to prevent" in the entire Python source code. > Understanding that Python thread mechanism does not use the OS > thread mechanism This is a misunderstanding: the Python thread mechanism does use the OS thread mechanism > and with all due respect to the creators and contributors, I would > like to ask, "Has anybody experienced similar situation with more > than one thread competing for the same module?" I'm out of context here: a situation similar to what? Regards, Martin From peter at engcorp.com Fri Jul 13 21:34:54 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 13 Jul 2001 21:34:54 -0400 Subject: Long Python programs! References: Message-ID: <3B4FA1BE.F754E02E@engcorp.com> James_Althoff at i2.com wrote: > > Again, we are shipping production code with > 100,000 lines of Jython and > neither "Lack of type safety" (by this I assume you mean "compile-time, > static, type checking") nor "lack of forcing variable names to be declared > before use" were problems for us. So, though I am not against the general > notion of making it possible to detect errors as early as possible (e.g., > at compile time) I don't see today's Python as being unsuitable for large > program. In fact, I see Python as being *very* suitable for large > programs. And I say this from the perspective of having already written > large program using Python. :-) Jim, your code size is well above what we've produced so far, although we're working hard to catch up (in a manner of speaking... obviously we aren't measuring our success by lines of code produced: we use Python!). I know I could benefit from more information about your development environment, the application under development, and the lessons you've learned in reaching this stage -- especially in the area of automated testing. Would you be able and willing to provide any background on your company's work on this project? I'm certainly not the only one interested. (I understand your company might consider this proprietary and not be willing to share. I'm expecting to face the same situation when the time is ripe for reporting on my own team's success with Python, but I fully expect to beat people about the mouth and ears until they understand that bringing something back to the open source community is part and parcel (morally speaking) of using their products in the first place.) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From jwbaxter at spamcop.com Sun Jul 22 22:59:36 2001 From: jwbaxter at spamcop.com (John W. Baxter) Date: Sun, 22 Jul 2001 19:59:36 -0700 Subject: PEP0238 lament References: <3B5B3676.40F39389@alcyone.com> Message-ID: <220720011959361323%jwbaxter@spamcop.com> In article , Moshe Zadka wrote: > > I agree. It's turning an otherwise fairly strongly (but dynamically) > > typed language on its head. If I want type-changing operations, I'll do > > them explicitly. > > Be sure to tell math.cos that...it has been "silently" turning integers > into floats for years. Not really the same thing, because within the range of int (on most machines so far), no information is lost (always assuming we mean double when we say float, which we seem to). Also unlikely, in that the argument is in radians, and 1 radian (or 1.0 radian) isn't a particularly interesting value (at least for the things I do..."broad on the starboard quarter" would be my more typical approximation, although it's perhaps a half point off). By the way, in .../lib/module-math.html (I keep my own copy on my end of my 56K frame connection), it is not stated whether the input to sin() (and the others where it applies) is degrees or radians. An experiment is necessary, or a reference to my rapidly waning C knowledge or a visit to the C standard (which I'd rather not do, for reasons of marginal sanity). >>> math.sin(1) 0.8414709848078965 is a conclusive experiment...which I had to run before making the "also unlikely" claim. --John From kseehof at neuralintegrator.com Tue Jul 31 07:16:23 2001 From: kseehof at neuralintegrator.com (Ken Seehof) Date: Tue, 31 Jul 2001 04:16:23 -0700 Subject: 2.2 features References: Message-ID: <00aa01c119b2$3c866bc0$6501a8c0@pacbell.net> From: "Guido van Rossum" > I love it. 'x in type' as a shorthand for isinstance(x, type). > Checked into CVS! Very cool. While you're at it, how about mapping "in" to "has_key" for mapping objects? >>> 'parrot' in {'parrot': 'dead'} 1 >>> 'dead' in {'parrot': 'dead'} # obviously "in" refers to keys, not values 0 BTW, thanks again for the awesome language. I hereby revoke the title ".*[dD]ictator". I dub thee "Fearless Leader". Your loyal, trusting subject, Ken Seehof From James_Althoff at i2.com Tue Jul 10 20:12:03 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Tue, 10 Jul 2001 17:12:03 -0700 Subject: Long Live Python! Message-ID: Paul Prescod wrote: >Java has of course outgrown its initial niche but it is hardly fair to >compare Python to a language backed by Sun, IBM, etc. If Python had that >kind of backing it would be as big or bigger than Java too. On the other hand, Jython actually helps Python take *advantage* of Java's popularity. So Java and Python can both "win" together. Jim From m.faassen at vet.uu.nl Mon Jul 23 15:27:52 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 23 Jul 2001 19:27:52 GMT Subject: Language change and code breaks References: <9j50tq01k6r@enews3.newsguy.com> Message-ID: <9jhtro$ap4$2@newshost.accu.uu.nl> Alex Martelli wrote: [snip] >> Don't encourage sloppy habits: require case sensitivity. > First time I heard that Pascal "encourages sloppy habits" -- with all > the valid criticisms one can level at it, this one seems ridiculous. Have you worked with Pascal code? It's not too pretty to copy and paste code that uses BEGIN and END into a piece of code that doesn't use that convention and uses 'begin' and 'end'. Of course when I dealt with such a thing I'd change the case-spelling to make it consistent, but I didn't like it much to have to do that at all. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From mday at apple.com Fri Jul 13 13:14:28 2001 From: mday at apple.com (Mark Day) Date: Fri, 13 Jul 2001 10:14:28 -0700 Subject: Newbie list question References: <13c69f60.0107130843.5cd7dc38@posting.google.com> Message-ID: <130720011014283887%mday@apple.com> In article <13c69f60.0107130843.5cd7dc38 at posting.google.com>, Matthew Alton wrote: > >>> foo = ['a', 'b', 'c'] # We have a list named 'foo.' Excellent. > >>> bar = foo # bar points to foo. Or does it? > >>> baz = foo[:] # baz is a copy of foo. > >>> foo > ['a', 'b', 'c'] > >>> bar > ['a', 'b', 'c'] > >>> baz > ['a', 'b', 'c'] # So far, so good. > >>> del foo[2] # Get rid of 'c' in foo and, therefore in > bar (?) > >>> foo > ['a', 'b'] # 'c' is gone from foo... > >>> bar > ['a', 'b'] # ... and also from bar, as expected. > >>> baz > ['a', 'b', 'c'] # baz, the copy, is unaffected. Also as > expected. > >>> foo = foo + ['c'] # Add 'c' back to foo. > >>> foo > ['a', 'b', 'c'] # 'c' is back. Good. > >>> bar > ['a', 'b'] # ??? What the... ??? Where is 'c'? > >>> baz > ['a', 'b', 'c'] # baz still unaffected, of course. > >>> The statement: foo = foo + ['c'] creates a brand new list from the contents of foo and the list ['c'] and assigns the new list to foo. If you had instead done: foo.append('c') then it would have changed the list that foo and bar were both pointing at. -Mark From nperkins7 at home.com Thu Jul 26 12:55:57 2001 From: nperkins7 at home.com (Nick Perkins) Date: Thu, 26 Jul 2001 16:55:57 GMT Subject: a break for comprehensions References: <9jpadd$s5k$1@news.duke.edu> <3B6031C3.6010707@nospiced.ham.devis.com> Message-ID: "Tom Jenkins" wrote in message news:3B6031C3.6010707 at nospiced.ham.devis.com... > Kevin Lacker wrote: > > > Can you do this: > > > > answer = [] > > for x in my_list: > > if not is_good(x): > > break > > answer.append(process(x)) > > > > with a list comprehension somehow? I'm starting to dislike explicit for > > loops just for the purposes of constructing another list from a current one. > > > do you mean like this? > >>> def even(x): > ... return int(divmod(x,2)[1]) == 0 > ... > >>> a = [1, 2, 3, 4, 5, 6, 7] > >>> b = [z for z in a if not even(z)] > >>> print b > [1, 3, 5, 7] > >>> c = [z for z in a if even(z)] > >>> print c > [2, 4, 6] > >>> > > oops sorry just saw that you had process(x) in there... lets try it: > > >>> def process(x): > ... return str(x) > ... > >>> process(1) > '1' > >>> c = [process(z) for z in a if even(z)] > >>> print c > ['2', '4', '6'] > >>> > > hmmm, seems to work for me (python 2.1) > This misses the point of the original post. Notice the 'break' in the original for-loop version. The idea is to return consecutive elements, up to, but not including, the first element which does not meet the condition. ie. lst = [0,2,4,5,6] evens = [0,2,4] I don't think list comprehensions can do this. Here's a generator approach to the problem: from __future__ import generators def conditional_iter(lst,cond): for item in lst: if cond(item): yield item else: raise StopIteration mylist = [0,2,4,5,6] def even(num): return not (num%2) for num in conditional_iter(mylist, even) print num From sam at ddmweb.com Mon Jul 30 16:12:00 2001 From: sam at ddmweb.com (Sam Penrose) Date: Mon, 30 Jul 2001 13:12:00 -0700 Subject: FEEDBACK WANTED: Type/class unification Message-ID: <01073013291201.00729@frock.ddmweb.com> Guido van Rossum wrote: > Correct on both counts again. >> One minor suggestion: >> I think it would help if you set a convention for the name >> of the first argument in classmethods. Like self for standard >> methods. Well, even self can "work" here, too. > I think 'self' would be confusing. I'd like to propose 'cls'. How about an English word or phrase in lieu of YATATL (yet another terse acronym to learn)? Insofar as "self" derives from the notion of an instance, we want somethign that derives from the notion of one's classification. The GNU-based Roget's Thesaurus at suggests for "class" : division, category, categorema[obs3], head, order, section; department, subdepartment, province, domain. kind, sort, genus, species, variety, family, order, kingdom, race, tribe, caste, sept, clan, breed, type, subtype, kit, sect, set, subset; assortment; feather, kidney; suit; range; gender, sex, kin. I like order, genus, and kind. On balance I guess "kind" seems best: short, appropriate, and not a term I've noticed used in the corners of the language I deal with. From emile at fenx.com Sun Jul 15 02:32:44 2001 From: emile at fenx.com (Emile van Sebille) Date: Sat, 14 Jul 2001 23:32:44 -0700 Subject: accessing the clipboard in windows and/or linux References: <3b511bae.1235716@news.mailops.com> Message-ID: <9irdlk$k562u$1@ID-11957.news.dfncis.de> Check Alex's post http://groups.google.com/groups?ic=1&q=msgid:8t3m1n025h1%40news2.newsguy.com I found it by going to groups.google.com and searching for python win32 clipboard. HTH, -- Emile van Sebille emile at fenx.com --------- "chajadan" wrote in message news:3b511bae.1235716 at news.mailops.com... > I want to be able to access the clipboard for Windows, and also linux. > Using python of course. > > If you know how, please pass this knowledge on to me. > > Thanks =) > > --chajadan From loewis at informatik.hu-berlin.de Wed Jul 25 13:53:33 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 25 Jul 2001 19:53:33 +0200 Subject: Distributed computing using SOAP. What about speed ? References: Message-ID: "Thomas Weholt" writes: > Does anybody have any thoughts about SOAP, especially SOAPpy ( it looks very > nice, simple to use ), and potential speed issues? If speed is an issue, I would recommend against SOAP. If you use CORBA, you can get very efficient implementations. Even the least efficient ones (e.g. Fnorb) will easily out-pace SOAP any time. Regards, Martin From ssthapa at classes.cs.uchicago.edu Thu Jul 5 11:47:29 2001 From: ssthapa at classes.cs.uchicago.edu (Suchandra Thapa) Date: Thu, 05 Jul 2001 15:47:29 GMT Subject: Python for air traffic control? References: <9hlfbn$6ok$1@nereid.worldonline.nl> <9hrj3q$cj1@news1.gtech.com> <9htebs$ck2@news1.gtech.com> <3b46521a.1325485@127.0.0.1> Message-ID: Sherpa Dave wrote: >Suggest you read up on NASA's programming methodology. If there's a group >that comes as close to perfect programming as is humanly possible, it's >that gang. > >(Despite their occasional metric<>imperial foulups...) The metric/imperial mistake was in code written by a different group. The group you are referring to does the shuttle code while the mars missions were probably done by a group at JPL. -- ---------------------------------------------------------------------------- | 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 grumble at usa.net Tue Jul 10 15:04:17 2001 From: grumble at usa.net (jcm) Date: 10 Jul 2001 19:04:17 GMT Subject: Python speed References: Message-ID: <9ifjjh$1e3$1@news.mathworks.com> Pete Shinners wrote: ... > for doing a MUD, the language speed is not going to have > much noticeable effect, since network speed is far slower > than any of the languages can handle. This isn't necessarily true. If you have a lot of objects with state that changes often (wandering monsters, etc), computation-speed can become an issue. From aetodd at wm.edu Thu Jul 5 12:44:54 2001 From: aetodd at wm.edu (Andrew Todd) Date: Thu, 05 Jul 2001 12:44:54 -0400 (EDT) Subject: import syntax In-Reply-To: References: Message-ID: <994351494.3b4499864e286@webmail1.wm.edu> This isn't terribly important, but wouldn't it be nice if you could do the following... from module import a and b instead of having to write... from module import a from module import b I don't know what sort of implications such and addition might have, but it would be nice. Andrew ~ elecfish aetodd at wm.edu From avv at quasar.ipa.nw.ru Tue Jul 31 16:53:26 2001 From: avv at quasar.ipa.nw.ru (Alexander V. Voinov) Date: Tue, 31 Jul 2001 13:53:26 -0700 Subject: C/Cygwin/Python References: Message-ID: <3B671AC6.A21B6C6D@quasar.ipa.nw.ru> Hi Jason, Jason Tishler wrote: > Yes, but only if your extension does not require Posix semantics (i.e., > only the standard C runtime stuff). > > IIRC, you want something like the following: > > python setup.py build_ext --compiler=cygwin > > Note that I usually only build Cygwin Python extensions, Do you mean that your extensions are compatible with the standard win32 Python installation, which is built with VC? As I recall the whole point of special instruction for no-cygwin python extension was that only in this case they can be loaded into the standard python.exe and you do not have to recompile the whole distribution. Is this right (meaning that you do compile the whole distribution)? Alexander From tjreedy at home.com Tue Jul 24 11:42:45 2001 From: tjreedy at home.com (Terry Reedy) Date: Tue, 24 Jul 2001 15:42:45 GMT Subject: PEP0238 lament References: <9jhbfj$79s$1@pea.uk.research.att.com> <9jjfts$9k2$1@pea.uk.research.att.com> Message-ID: > I return to my question. Suppose Python 2.2 is released with this > __future__ division. Now suppose I must maintain some code which can > run on Python 2.0, 2.1 and 2.2, which needs integer division. The answer [revised] I gave yesterday in 'Re: A way to accomodate language changes': [In general, do not use new meanings] For the proposed division change, the 'new' meanings will be int/int and float//float. So write float(int)/int and floor(float/float) instead. Only write int//int or float/float. With the tokenizer module, it will then be easy to change all instances of int//int to int/int (old meaning). [Skip Montano already posted a program for the other direction; changing it to go back is trivial.] It should even even be possible to have package installers check sys.version and do this conversion on site as needed. For newly written code, the harder problem will be to not use any of the other neat new features [like iterators/generators], which mostly *cannot* be automatically back converted. From nperkins7 at home.com Mon Jul 9 00:28:55 2001 From: nperkins7 at home.com (Nick Perkins) Date: Mon, 09 Jul 2001 04:28:55 GMT Subject: Help With map() *He says while pulling his hair out* References: Message-ID: "EricIDLE" wrote in message news:pM927.657463$166.13605776 at news1.rdc1.bc.home.com... > Ok first off I have a wee problem with one of the examples in my book it is > as follows: > > s="12.19.6.7.12" > ls = string.split(s, '.') > md = map(string.atoi, ls) > > Ok. well the problem is basically the whole thing. I know s="12.19.6.7.12" > is just defining the varible 's' with the numbers. But my first problem is > after string.split in its argument I know what the S means but I dont know > what the '.' means does that mean to remove all the periods? > The second problem is that I dont quite grasp the map() function what > exactly does it do, In its argument it says in lamens terms "Turn the string > ls into intergers" my problems is wasent it always intergers? I mean the > varible ls contains ['12', '19', '6', '7', '12'] arent those intergers they > are numbers. Any ways if you could reply answering all the questions in > whole or maybe just a few of em' it would be great. > > Thanks. > > You should use the command prompt to play around with things that you are not sure about. ( if you don't, already ) The type(x) function is very useful, as is the dir(x) fuction. Also, a single underscore can be used to capture the result of the last operation (see end of example). Along with 'book learnin', interactive 'playing around' is the best way to develop a clear picture of types and reference semantics, etc. Plus, it's fun! eg.: >>> s = "12.19.5.7.12" >>> print s 12.19.5.7.12 >>> type(s) >>> import string >>> result = string.split(s,'.') >>> print result ['12', '19', '5', '7', '12'] >>> type(result[0]) >>> result2 = map(string.atoi,result) >>> print result2 [12, 19, 5, 7, 12] >>> type(result2[0]) >>> string.atoi('12') 12 >>> type(_) ..etc.. From bokr at accessone.com Wed Jul 4 17:56:47 2001 From: bokr at accessone.com (Bengt Richter) Date: Wed, 04 Jul 2001 21:56:47 GMT Subject: Converting from long integer to read-only buffer References: <3b42780c@news.ucsc.edu> Message-ID: <3b438ab1.1053541883@wa.news.verio.net> On 3 Jul 2001 18:57:32 -0800, Ben Andrew Fulton wrote: >I'm currently working on a module to control a piece of hardware over the >serial port of a Mac. The command packets are currently manipulated within >the the module as long integers so that I can twiddle individual bits. >However, when I send them out the serial port they need to be converted >into a read-only buffer (or perhaps a string [although of course, str() >is not the answer]) for the ctb (communications toolbox) to accept them. >Is there a module out there that can do a straight long int --> read-only >buffer conversion? struct, array, and binascii all seem inadequate to the >task unless I write my own helper function, which I suppose I will have to >if I can't figure anything else out in the next day or so. > >Thanks, > >-->ben fulton > You could write something more efficient, but for a quick test try: >>> nOut = 15 >>> cmdPkts = 65*2L**64/255 # 65 is A and /255 repeats in binary ;-) >>> sOut = ''.join([chr((cmdPkts>>k*8)&0xff) for k in xrange(nOut)]) >>> sOut 'AAAAAAAA\x00\x00\x00\x00\x00\x00\x00' where nOut is the size of your output string in bytes (15 arbitrary here) cmdPkts is the long integer you have, above with test pattern sOut is the output string Note the order of the string. It is little-endian, taking the LS byte from the long first. Maybe another example is better: >>> cmdPkts = 0L >>> for x in xrange(ord('a'),ord('z')+1): ... cmdPkts = (cmdPkts<<8)|x ... >>> nOut = 28 >>> sOut = ''.join([chr((cmdPkts>>k*8)&0xff) for k in xrange(nOut)]) >>> sOut 'zyxwvutsrqponmlkjihgfedcba\x00\x00' The z is first because it was or-ed into cmdPkts at the LSB position. I chose 28 length to show the padding effect. HTH From gerhard.nospam at bigfoot.de Sun Jul 1 12:59:09 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Sun, 1 Jul 2001 18:59:09 +0200 Subject: Unix Scripting Host References: <9hnaat$284$02$1@news.t-online.com> <9hneb9$ca0$00$1@news.t-online.com> Message-ID: On Sun, 1 Jul 2001 17:08:45 +0200, Thorsten Roskowetz wrote: >"Gerhard H?ring" wrote: >> On Sun, 1 Jul 2001 16:00:18 +0200, Thorsten Roskowetz wrote: >> >You might want to look at KDE's DCOP. >> >> Well, I did already. It looks cool and I even got the KSpread >> example to work, but it's tied to C++ and Qt. > >Not entirely true. There are DCOP bindings for C (dcopc) and Python >(AFAIK only proof of concept at the moment) and even a XML-RPC to DCOP >bridge (KXMLRPC) which could be used from Python, Java, Perl or any >other language that provide an XML-RPC implementation. >There are even native java bindings to DCOP in developement. Sorry for not being clear. I have just finished rebuilding the kdebindings and PyQt RPMs for Python 2.1 to try out the Python examples. They work fine so far. What I meant was that the DCOP server AFAIK can currently only be written in C++. I also couldn't find anything that describes the APIs that are exported via DCOP, but I'd better ask for this in a KDE group. 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 guido at digicool.com Thu Jul 19 16:44:06 2001 From: guido at digicool.com (Guido van Rossum) Date: Thu, 19 Jul 2001 16:44:06 -0400 Subject: Language change and code breaks In-Reply-To: Your message of "Thu, 19 Jul 2001 13:49:57 MDT." <6957F6A694B49A4096F7CFD0D900042F27D55F@admin56.narex.com> References: <6957F6A694B49A4096F7CFD0D900042F27D55F@admin56.narex.com> Message-ID: <200107192044.f6JKi6T18790@odiug.digicool.com> > TRuE, tHe ExPRESsiVity oF ThE lANGuaGE is ProBAbLY nOt cRipPled, > hOWEvEr, tHere ARe SigNIficantLy FeweR ideNtIFIeRs AVaILABlE whICh mEAns > iT is LESs eXPRessIvE. IN pArTicULar, cOMmON Idioms liKE naMiNg CLASseS > stArTiNg WiTh UppER cASE lETtERS, AND instaNCeS OF THose cLAsSes > begINNiNG with A lOwER caSE LettER CaN NO LongeR Be usED. Very funny (not). You misunderstood the intention. The programming environment should be case-preserving, and automatically correct identifiers to use the same case as used when they were defined. > AS fAR aS thE Size Of thE VARious camPs, I haVE YeT tO sEe a coMPeLLinG > aRGuMeNt thAT THE grOup of noN-pRoGRaMmeRS THat WILl taKe up > pRoGRAmmInG, ANd wiLL DO sO in PYTHon InsTEad oF VisUal BasiC, Is any > LARGeR Than The groUp of ProgRAmmERs. With your atttude, it will never happen. --Guido van Rossum (home page: http://www.python.org/~guido/) From jkraska1 at san.rr.com Wed Jul 11 02:46:55 2001 From: jkraska1 at san.rr.com (Courageous) Date: Wed, 11 Jul 2001 06:46:55 GMT Subject: Python speed References: <9ifjjh$1e3$1@news.mathworks.com> <3B4B562F.77C1B79@yahoo.com> <9ifo90$4hh$1@news.mathworks.com> Message-ID: <7ftnktk6m1t3nhrud5qs7nbsj2r9u7lthp@4ax.com> > Using this engine on a PII 266 running RedHat 6.1, 400 >wandering monsters (with nothing else going on in the mud) will peg >the cpu. So _MUCH_ has been unsaid about the complexity of the algorithms in use inside your MUD. Have you profiled it? Where does the CPU time go, and why? C// From jochen at riekhof.de Fri Jul 20 12:40:23 2001 From: jochen at riekhof.de (Jochen Riekhof) Date: Fri, 20 Jul 2001 18:40:23 +0200 Subject: ActivePython ASP comobject.getCOMObject() does not work References: <9j6tac$b96$00$1@news.t-online.com> <3B576D8C.9080705@ActiveState.com> Message-ID: <9j9mtn$e9f$07$1@news.t-online.com> > Any COM [out] parameter will be returned from the method since in Python > parameters are passed by value rather than by reference (we won't talk > about object references). Hum, interesting, but do you know why does it return the connect-string in my case? Ciao ...Jochen From db3l at fitlinxx.com Fri Jul 27 17:44:31 2001 From: db3l at fitlinxx.com (David Bolen) Date: 27 Jul 2001 17:44:31 -0400 Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <9jnt9p$qhe$1@newsy.ifm.liu.se> Message-ID: Robin Becker writes: > well I have at least one extension that requires 32 bit unsigned as > inputs. Under existing python I can manipulate myself around bit 31 > problems with ease (using negative numbers or hex). It seems it > will/might be a bit more complicated if this pep goes through. I'm sure > there are others who have explicit int size requirements. Effectively > removing ints takes away ease of external communication in at least some > cases. If implemented cleanly, it may even make live easier for your extension, depending on how its functions process input, since they'll all still come in as PyObject's. For example, if your extension uses PyArg_ParseTuple to convert to the Python value to your internal 32 bit unsigned storage, it'll probably still continue to do so, automatically taking into account any unification within the Python core. In fact one could imagine the "l" format (which presumably you're using now since 'int' wouldn't be a portable ubit32 format in your C extension) would automatically handle all of integers, longs, or integral floats behind the scenes. You'd then do a final sanity check to ensure the value was within 32-bits, but presumably you do that now as well. If, instead, you're using "i" today and just giving it a pointer to an 'unsigned int' variable, you're already being a bit risky in your extension coding, but that should presumably continue to work as well, and presumably Python would complain when trying to convert a number that wouldn't fit into the platform 'int'. -- -- 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 root at rainerdeyke.com Sat Jul 28 21:22:31 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Sun, 29 Jul 2001 01:22:31 GMT Subject: PEP 238 (revised) References: Message-ID: Here is an alternate numerical model: '1.0' is a fixed point number with one digit to the right of the decimal place. '1.00' is a fixed point number with two digits to the right of the decimal place. '1e-1' is a fixed point number with one digit to the right of the decimal point. '1e1' is a fixed point number with negative one digits to the right of the decimal point. Conceptually, integers are fixed point numbers with zero digits to the right of the decimal place. Internally, each number could be represented as two integers (longs): one 'base' and 'exp', such that the value of the number is 'base + 10 ** exp'. '-exp' is the number of digits to the right of the decimal point. For addition (and subtraction), the number with fewer digits to the right of the decimal point is padded with zeros. Addition is therefore an exact operation: 1.00 + 1.0 => 1.00 + 1.00 => 2.00 For multiplication, the resulting number has digits to the right of the decimal point equal to the sum of the number of digits to the right of the decimal point in its operands. Multiplication is therefore an exact operation: 0.1 * 0.1 => 0.01 1.00 * 1.0 => 1.000 There is no way to represent arbitrary ratios in this numerical model. Division is therefore defined as a truncating operation (towards negative infinity). All multplication operations can be inverted with division, so the number of digits to the right of the decimal point of 'a / b' is the number of digits to the right of the decimal point of 'a' minus the number of digits to the right of the decimal point of 'b': 0.01 / 0.1 => 0.1 1.000 / 1.0 => 1.00 5 / 2 => 2 This numerical model has several advantages over Python's current model. It has none of the dangers of floating points and rationals. It is easy to understand. It works consistently on all computers without depending on the underlying C library. It unifies integer division with "real" division. Its primary disadvantages are speed, incompatibility with third party libraries, and its tie to the decimal system. My goal here is not to replace Python's existing numerical model, or even to add a new numerical model alomgside it. If I really wanted this model, I could easily implement it myself by creating a Python class. I do have one question however: if I implement this numerical model and PEP 238 is accepted, which division operator should I overload for my division operation (as defined 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 guido at python.org Fri Jul 27 15:59:16 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 27 Jul 2001 19:59:16 GMT Subject: PEP 238 (revised) References: <3B61B7E4.5C6DFF01@Lugoj.Com> Message-ID: James Logajan writes: > Andrei Kulakov wrote: > > > > Guido van Rossum wrote: > > > > > > The correct work-around is subtle: casting an argument to float() > > > is wrong if it could be a complex number; adding 0.0 to an > > > argument doesn't preserve the sign of the argument if it was minus > > > zero. > > > > When is 0 different from -0? > > When doing ones-complement arithmetic. Not too many machines use that > anymore, and the ones that did (or do) should have comparison logic to > consider -0 == 0. The CDC Cyber series used ones-complement. IEEE 754, the floating point standard in use in virtually all current hardware, mandates that -0.0 be distinguishable from 0.0, in order to be able to represent the sign of degenerated underflow results. (Or so I understand, having been educated in IEEE 754 through numerous discussions with Tim Peters, but not by reading the standard. If I'm wrong, Tim will surely correct me. :-) I don't know of a portable way to generate -0.0 in Python; on my Linux box, simply writing -0.0 does it, but not on my Windows box. --Guido van Rossum (home page: http://www.python.org/~guido/) From barry at zope.com Tue Jul 24 23:28:47 2001 From: barry at zope.com (Barry A. Warsaw) Date: Tue, 24 Jul 2001 23:28:47 -0400 Subject: PEP0238 lament References: <5sdnlt072hm6hp17nluu6f0fqq4bvr6mj8@4ax.com> <916olt0p3kciv0evmotdg6jev9bl29l57i@4ax.com> <3B5C52EA.9430255E@alcyone.com> Message-ID: <15198.15599.440633.982702@anthem.wooz.org> >>>>> "ph" == phil hunt writes: ph> How about having two executables, 'oldpython' and 'newpython' ph> which correspond to -Dold and -Dnew. ph> Furthermore, since 'oldpython' is the same as the existing ph> 'python', let's rename it 'python'. How is this different than how Python already installs (on Unix anyway). % ls /usr/local/bin/python* /usr/local/bin/python* /usr/local/bin/python2.0* /usr/local/bin/python1.6* /usr/local/bin/python2.1* % /usr/local/bin/python Python 2.1.1 (#1, Jul 20 2001, 13:48:37) [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2 Type "copyright", "credits" or "license" for more information. >>> % /usr/local/bin/python2.1 Python 2.1.1 (#1, Jul 20 2001, 13:48:37) [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2 Type "copyright", "credits" or "license" for more information. >>> % /usr/local/bin/python2.0 Python 2.0 (#14, Feb 15 2001, 23:45:39) [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2 Type "copyright", "credits" or "license" for more information. >>> Modulo the micro-release number, which is guaranteed to only include patches (but no guarantee that such patches won't break your code :), why not just symbolically link oldpython -> python2.0 and newpython -> python2.2 ? Or just make sure that your old applications, for which you cannot afford even the possibility of code breakage, always and explicitly use python1.5 or whatever? -Barry From thomas.heller at ion-tof.com Fri Jul 20 03:18:55 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Fri, 20 Jul 2001 09:18:55 +0200 Subject: doctest References: Message-ID: <9j8m10$n1t3p$1@ID-59885.news.dfncis.de> "Tim Peters" wrote in message news:mailman.995574273.21136.python-list at python.org... > [Thomas Heller, on doctest] > > The latest version from Python's CVS tree however does > > not run any more under Python 1.5.2. > > Is there an uptodate version available which is backward > > compatible? > > I expect the incompatibility is shallow, introduced when someone charged > thru the std libraries changing all uses of the string module into string > methods. If you'd like to change that back again and check it in, fine by > me -- there was no intent here to be incompatible (or compatible either, for > that matter ). > Thanks to cvs update -j 1.3 -j 1.2 and manually fixing the two or threee conflicts it was easy, with _one_ exception: There is a 'from __future__ import generators' line, which makes sense for 2.2, but throws SyntaxError in 2.1 and 2.0, and ImportError in 1.5.2. Unfortunately it cannot be wrapped by try: except: because it must occur at the beginning of the file. Any idea? Thomas From eppstein at ics.uci.edu Sun Jul 29 13:49:52 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Sun, 29 Jul 2001 10:49:52 -0700 Subject: Deposing Dictators References: <%ez87.128332$%a.5630144@news1.rdc1.sdca.home.com> <5e8bd451.0107290049.27bb9e0e@posting.google.com> Message-ID: In article <5e8bd451.0107290049.27bb9e0e at posting.google.com>, kp87 at lycos.com (kevin parks) wrote: > So my girlfriend wants to know why python has to have the worst > animals and why we can have bunnies or little dinosaurs. That rabbit's got a vicious streak. It's a killer. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From stevecanfield at my-deja.com Fri Jul 20 08:43:35 2001 From: stevecanfield at my-deja.com (Steve Canfield) Date: 20 Jul 2001 05:43:35 -0700 Subject: popen problem with spaces in directory-ARRGHHHH! References: <603e1b49.0107191344.42808306@posting.google.com> Message-ID: <603e1b49.0107200443.d32524f@posting.google.com> Okay. I'm a little frustrated. Earlier, I wrote in message news:<603e1b49.0107191344.42808306 at posting.google.com>... > If I open up a command prompt and type in the following: > C:\>"e:\visual studio\ss.exe" status "$/My Project" > I get back a bunch of text showing which files are checked out. > > If I open a Python interpreter and type: > >>> import os > >>> os.popen(r'"e:\visual studio\ss.exe" status "$/My > Project"').readlines() > [] > I get an empty list. Since I first posted this I have tried a few more things. The FAQ mentions bugs in popen and suggests win32pipe.popen. I tried it and it seems to behave exactly like os.popen. One thing that didn't work (and I don't want to have to do this) is using the short (8.3) version of the directory names: >>> import os >>> os.popen(r'e:\visual~1\ss.exe status "$/My Project"').readlines() ['$/My Project:\n', 'file1.cpp Steve etc... Is this a bug in os.popen, win32pipe.popen, or (more likely) am I missing something really obvious here? Please help! I really don't want to have to be restricted to short file names. Thanks, steve From myles at geocities.com Mon Jul 23 22:41:13 2001 From: myles at geocities.com (Myles) Date: Tue, 24 Jul 2001 12:41:13 +1000 Subject: PEP0238 lament References: Message-ID: <3B5CE049.8F274BD@geocities.com> Stephen Horne wrote: > > On Mon, 23 Jul 2001 17:05:34 -0500, wrote: > > >> 1/2 == 0.5: > >> Perl -- untyped, thus irrelevent > >> LISP -- academic language only > >> Pascal -- the Ada folks thought it was wrong > >> Modula 2+ -- Minority languages > >> JavaScript -- dumbed down language > >> 1/2 == 0: > >> Visual BASIC -- most used language 3 yrs running > >> C -- what need I say? > >> C++ -- ditto > >> Java -- ditto > >> Ada -- intentionally changed the Pascal practice > >> VBA -- most used non-programmer language [snippery snip] > VB is based on BASIC, which has a variable history but which in the > early days generally did 1/2 -> 0.5, and generally *changed* it later > on. Ermm, fact correction : not on the VB and VBA I have available to me. VB (admittedly v.4): x = 1 \ 2 MsgBox (x) gives 0.5 VBA (in Excel 97): Worksheets("Sheet1").Activate Worksheets("Sheet1").Range("B5").Activate ActiveCell = 1 / 2 gives 0.5 A quick peek through the helpfiles for both reveals that integer division for the "most used language 3 yrs running" and for the "most used non-programmer language" actually uses a different operator "\" for integer division, in a similar manner to the proposal for Python ! :-) We now return viewers to the main argument : "Are the benefits worth breaking backward compatibility, and will the change process in place be sufficient to manage this ?" Regards, Myles. From tim.one at home.com Sun Jul 8 19:14:56 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 8 Jul 2001 19:14:56 -0400 Subject: Confusion about dictionaries - keys use value or identity? In-Reply-To: Message-ID: [Steve Holden] > We are talking about has_key here, right? RIght. > I was simply trying (perhaps rather too hurriedly, as it turned out) > the fact that strings if unequal lengths could not be equal, and only > equality is required when indexing a dictionary. Good point, and I hadn't fully realized the context. Things are still subtler than you may think, though. > Without looking at the code I'm presuming that actually some fairly > crafty hashing algorithm is used to test for the presence of a > particular key. Yes. > But when more that one entry hashes to the same bucket, That doesn't matter: the full hash codes are compared first no matter how few buckets, and it's extremely rare in practice for the full hash codes of unequal strings to be equal (the odds are about 1 in 2**32, confirmed by many test runs on both "typical" and contrived strings). That is, it's not ending up in the same bucket that matters, it's having identical hash codes: no comparison is done unless the full hash codes are equal (BTW, string objects cache their hash codes, so a given string object never *computes* its hash code more than once no matter how often you-- or the internals --apply hash() to it). > I hope the lengths are checked before character-by-character comparison > goes ahead ... you know the details, I don't, so I'm not going to press > this issue any further. The lengths aren't checked first in 2.1 or earlier, in part because before rich comparisons were added, it was impossible for the string-compare routine to *know* that == vs != was the only interesting outcome. There is code in current CVS to check the lengths first, but because string hash code equality is so rare I'm dubious that bothering with the length-check is actually a win (string compare from dicts will almost never be called unless the strings are in fact equal, so the "lengths equal?" check almost always says "yes" in this context). > And no, I haven't forgotten that strings are only a subset of the > possible keys. Python has forgotten it, though . That is, under the covers, dicts with nothing but string keys use a different lookup routine than dicts with at least one non-string key. Dicts with string keys are optimized in many subtle ways. From mertz at gnosis.cx Thu Jul 5 17:42:00 2001 From: mertz at gnosis.cx (Lulu of the Lotus-Eaters) Date: Thu, 05 Jul 2001 17:42:00 -0400 Subject: There's got to be an easy way to do this (fwd) Message-ID: Still dying to win the performance prize, I believe Skip Montanaro's performance tip brings the general filter stategy back up to winning status (including James Logajan 'traditional' function) def str_join2(iters): has = {0:1,1:1,2:1,3:1,4:1,5:1,6:1,7:1,8:1,9:1}.has_key for i in iters: "".join([x for x in '(123)/456-7890' if has(x)]) def flt_lmbda3(iters): isdigit = {0:1,1:1,2:1,3:1,4:1,5:1,6:1,7:1,8:1,9:1}.has_key for i in iters: filter(isdigit, '(123)/456-7890') def traditional(iters): for i in iters: result = "" for c in '(123)/456-7890': if c in digits: result = result + c RESULTS: - 500- str_join str_join2 flt_lmbda2 flt_lmbda3 traditional 5 : 0.10 0.07 0.10 0.06 0.08 10 : 0.21 0.15 0.21 0.10 0.16 50 : 1.04 0.73 1.02 0.57 0.79 From jkn at nicorp.f9.co.uk Mon Jul 16 04:43:07 2001 From: jkn at nicorp.f9.co.uk (Jon Nicoll) Date: 16 Jul 2001 01:43:07 -0700 Subject: windows port access References: <3b520bcb@news.cybertours.com> Message-ID: <8351bb33.0107160043.3b1b1e51@posting.google.com> Hi Bryan Have a look at http://www.nicorp.co.uk/download/ Which contains my files for writing to a Parallel/LPT port. It is buildable under both Windows (95, 98, ?ME?, Not NT or W2000) and Linux. It is in need of updating for Python 2.x, and in its current state you'll need a bit of knowledge to get it working, but the basics are all there jon Nicoll "Bryan Brannigan" wrote in message news:<3b520bcb at news.cybertours.com>... > I am looking for a way to send data to certain ports on a custom ISA card. > The card is addressed as 280h. Is this possible with Python? Is the code > compatible with Linux as well? > > Bryan From guido at python.org Tue Jul 31 23:58:11 2001 From: guido at python.org (Guido van Rossum) Date: Wed, 01 Aug 2001 03:58:11 GMT Subject: 2.2 features References: <9k7il0$7dv$1@panix2.panix.com> <3dd76gv9vw.fsf@ute.cnri.reston.va.us> Message-ID: Andrew Kuchling writes: > +1 on ripping 'x in int' out of CVS. Done. > Like children, it's sorta cute at first glance but becomes annoying > after longer acquaintance and contemplation. Were you born fully developed? I hope not for your mom. :-) --Guido van Rossum (home page: http://www.python.org/~guido/) From guido at python.org Thu Jul 26 17:24:07 2001 From: guido at python.org (Guido van Rossum) Date: Thu, 26 Jul 2001 21:24:07 GMT Subject: Toppling the numeric tower References: Message-ID: David Eppstein writes: > In article , > Guido van Rossum wrote: > > > > (2) should isintegral() return true for algebraic integers that are not > > > rational integers? > > > > Sorry, you lost me there. What are these? > > Roots of polynomials with integer coefficients, leading coefficient = 1. > E.g. the golden ratio 1+sqrt(5)/2 is a root of the polynomial > x^2-x-1, so it is an algebraic integer. When mathematicians want to > specify that a number is what you would call an integer, in the context of > algebraic numbers, they say "rational integer" to be more specific. Neat. Then to answer the question, I would think that isintegral() should not include the algebraic integers, since to most folks those aren't integers at all (they're definitely not part of the set Z). --Guido van Rossum (home page: http://www.python.org/~guido/) From daniel.dittmar at sap.com Mon Jul 16 06:18:30 2001 From: daniel.dittmar at sap.com (Daniel Dittmar) Date: Mon, 16 Jul 2001 12:18:30 +0200 Subject: command substitution References: Message-ID: <9iuf1n$6tm$1@news1.wdf.sap-ag.de> > I was looking for a solution like in bash, which let you put the standard > output of a command in a variable(in bash, you can do it like OUT=`ls` or > OUT=$(ls) ). import commands var = commands.getoutput ('ls') Daniel From peter at engcorp.com Sun Jul 29 00:38:01 2001 From: peter at engcorp.com (Peter Hansen) Date: Sun, 29 Jul 2001 00:38:01 -0400 Subject: XML for meta-information (was Re: Deposing Dictators) References: <9jmjne$q54$1@wisteria.csv.warwick.ac.uk> Message-ID: <3B639329.65EE0546@engcorp.com> Dirck Blaskey wrote: > > "Steve Horne" wrote: > > ... > > 1. A lot of the ideas turn out not to be for a programming language > > as such at all. Rather, it combines the ideas of literate programming > > with a kind of replacement for make. An XML notation would allow > > source code in a range of languages to be packaged in a linked set of > > XML files with documentation, detailed specification of the build > > process and explicit requirements for the run-time and build-time > > environment. It would allow you to specify, for instance, that the > > source code for this C++ module contains a constant structure derived > > according to xxx principles (for the documentation) and can be > > generated by running yyy script in zzz version of Python (or > > whatever). > > Unless you have compelling reasons for using XML, I would suggest > the alternative of using Python itself as the meta-language. I think there are always compelling reasons for using XML. XML is not code -- it's data. Python is for expressing algorithms 'n such. XML is perfect (well, maybe not quite) for meta- information, or at least as perfect as we've come up with to date. I like Steve's idea above, although it sounds like it might be a little "monolithic" if one didn't take care to keep the pieces separate. Of course with XLink there's no reason the pieces of information relating to a single module all have to be in the same physical file. I've been thinking for a while (as I'm sure many have) that the current use of simple text files for source code is remarkably primitive compared to the overall state of computing. It seems like it's time to turn things "inside out", and put source inside XML files as merely one part of the picture. Build instructions for "make" or "pyscons" tools would be kept inside. Specifications, test cases, etc, would also be available in nicely organized packaging. Now we have only text editors, which grab an entire file and present a simplistic line-oriented view of it, possibly knowing enough about the content (as described by the file extension: how primitive!) to do something useful with it other than just display it. In the future, structured editors would be able to work not only with the source content, but other kinds of information contained in the same file. If they didn't understand the information, they would ignore but preserve it (as XML tools should do). Sort of reminds me of Opendoc... but built around a modern web-standard and inherently more suitable to the kinds of work programmers need to do. > Maybe I don't fully understand your intended use of XML, but > it gives me a good opportunity to go off on a tangent, as well. > (Hmm... Maybe it's time to change the subject: line?) Done. (You don't have to ask, either. :-) > XML is a bit hard on the eyes (quite unlike Python). Well, that might be more a condemnation of the tool being used to view the XML than of XML itself. XML, while designed to be easy to edit in text editors, was not designed specifically to be "easy on the eyes". The designers would likely have said that it is not XML's job to specify a presentation format for itself. XML is content, end of story. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From db3l at fitlinxx.com Tue Jul 10 20:29:23 2001 From: db3l at fitlinxx.com (David Bolen) Date: 10 Jul 2001 20:29:23 -0400 Subject: Newbie asks(2): How to do this line of C in Py? References: Message-ID: "Steve S.L. Wong" writes: > if sscanf(command,"%c%d",&c,&d) != 2 { > } You seem to be posting a lot of one line translation requests - are you trying to get a program translated to Python one line at a time? If so, perhaps you could just post the whole thing and we'd have a shot at it in one pass and save some electrons :-) -- -- 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 Tue Jul 31 00:07:19 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Mon, 30 Jul 2001 21:07:19 -0700 Subject: Changing the Division Operator -- PEP 238, rev 1.12 References: <00899E06.N22121@rsmi.com> Message-ID: <3B662EF7.72725C09@ActiveState.com> Arthur_Siegel at rsmi.com wrote: > >... > > Isn't it clear that the thread that it is all quite necessary to meet the > programming > language specification requirements of people who don't actually program (is > there > another definition of non-programmer that I am missing) - is an incitement, > not an explanation. Two issues: * the real target for the newbie-friendliness is new programmers not non-programmers. A language that is good for new programmers has a lot of rules that they can easily remember and few pitfalls that they have to store away in their heads. * if newbie-friendliness were the only issue, it would be probably not enough. But even competent programmers can make non-robust code if there is a big gap between the division statement and the provision of an integer where a float is expected -- and even if there is NOT a big gap. Python's slicing rule is ALSO not very newbie friendly at first. But slicing is done so often and the rule is relatively easy to remember. In the long run it very seldom causes bugs. Division is not like that in my experience. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From Randy.L.Kemp at motorola.com Tue Jul 3 09:18:51 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Tue, 3 Jul 2001 08:18:51 -0500 Subject: FTP client module Message-ID: Does Python have an FTP client module, like FTP::Net, which is part of libnet on www.cpan.com for Perl? If so, is it part of the core Python package, or do I have to download it? If I need to get it, what is the website? From r_olson at sandiego.edu Tue Jul 3 23:01:20 2001 From: r_olson at sandiego.edu (Rick Olson) Date: 3 Jul 2001 20:01:20 -0700 Subject: Newbie Radiobutton question Message-ID: Hi-- I'm trying to run the following from IDLE: from Tkinter import * root=Tk() x=IntVar() x.set(2) Radiobutton(root, text='a',value=1,variable=x).pack(anchor=W) Radiobutton(root, text='b',value=2,variable=x).pack(anchor=W) With Red Hat Linux (Python 1.5.2, IDLE .4) it runs fine the first time. I get the window and the second radio button is selected. If I close the window and try to run it again by immediately clicking on F5 the window and buttons appear, but nothing is selected. If I click on the buttons they work properly. Even closing the window with the program, reopening the file and running won't cause the buttons to be selected. I need to close IDLE, and restart it. With Win2K (Python 1.6.1, IDLE .6) it runs every time. I'm a linux neophyte, but will figure out how to upgrade whatever is necessary. Is this a Python problem, and IDLE problem, a Red Hat problem or a user problem? Is there anything else that I am likely to need to change (e.g. tcl installation)? Thanks in advance-- Rick Olson From sholden at holdenweb.com Tue Jul 3 12:14:44 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 3 Jul 2001 12:14:44 -0400 Subject: Redirecting input? References: Message-ID: >From the Python 2.0 Library Reference Manual: """6.11 getpass -- Portable password input The getpass module provides two functions: getpass ([prompt]) Prompt the user for a password without echoing. The user is prompted using the string prompt, which defaults to 'Password: '. Availability: Macintosh, Unix, Windows. getuser () Return the ``login name'' of the user. Availability: Unix, Windows. This function checks the environment variables $LOGNAME, $USER, $LNAME and $USERNAME, in order, and returns the value of the first one which is set to a non-empty string. If none are set, the login name from the password database is returned on systems which support the pwd module, otherwise, an exception is raised.""" getpass() looks like what you need. regards Steve -- http://www.holdenweb.com/ "fbasegmez" wrote in message news:bb93d188.0107030727.516741b4 at posting.google.com... > How do you redirect commands to a Unix process initiated from a Python script? > For example: > > import os > > runcmd='rlogin othersystem' > os.system(runcmd) > password='mypassword' > #now I would like to input my password here > #obviously os.sytem(password) does not work. > ??? > > Regards, > > Fahri From phawkins at connact.com Fri Jul 20 17:00:43 2001 From: phawkins at connact.com (phawkins at connact.com) Date: 20 Jul 2001 17:00:43 -0400 Subject: python and applications References: Message-ID: >>>>> "ts" == tyler spivey writes: ts> could you write a fast mud in python? ts> having a lot of monsters like dikumuds do? ts> how many blind programmers use python? and is python just a toy language? ts> can it do more or as much as c? could you create a roguelike in it? ts> I am blind myself. My experience is that Python is very nice for programming by voice using speech recognition (I use Dragon NaturallySpeaking) because it has so much less in the way of punctuation. This means that spoken python is much more similar to English than are other computer languages. I suspect this would also be good for blind programmers using text-to-speech. As others have mentioned, you would need to have a solution to the whitespace indentation issue. Patricia -- Patricia J. Hawkins Hawkins Internet Applications, LLC From qrczak at knm.org.pl Sat Jul 28 19:04:43 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 28 Jul 2001 23:04:43 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <3b60d65e.219212588@news.eircom.net> Message-ID: Sat, 28 Jul 2001 22:10:23 GMT, Guido van Rossum pisze: >> I would not make 5/2-3/2 usable as a sequence index. My style is more >> "typeful". But you decide. > > I am not at all sure! This should definitely be added as an open > issue to the rationals PEP. Well, I was on a walk today and thought that maybe you are right about that unification :-) The sure thing is that inexact numbers won't be allowed where a precise value is needed to determine validity - too bad if "error in the program"-kind of exception depends on rounding errors. Arguments for unifying ints with rationals: - Since 2 == 2/1 and maybe str(2/1) == '2', it reduces surprises where objects seem equal but behave differently. - / can be freely used for integer division when I *know* that there is no remainder (if I am wrong and there is a remainder, there will probably be some exception later). Arguments against: - When I use the result of / as a sequence index, it's usually an error which should not be hidden by making the program working for some data, since it will break for other data. - (this assumes that after unification int and rational would be different types:) Types should rarely depend on values. It's easier to reason when the type of a variable is known: I know how I can use it. I can determine that something is an int and expect that other objects used in this place will be ints too. - (this assumes the same type for them:) Int is a good type in itself, not to be mixed with rationals. The fact that something is an integer should be expressible as a statement about its type. Many operations require ints and don't accept rationals. It's natural to think about them as about different types. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From skip at pobox.com Tue Jul 10 13:01:03 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 10 Jul 2001 12:01:03 -0500 Subject: File processing In-Reply-To: <994742167.67214@yabetcha.drizzle.com> References: <9id5p9$8r62@interserv.etn.com> <994742167.67214@yabetcha.drizzle.com> Message-ID: <15179.13519.617537.403177@beluga.mojam.com> Donn> That's cool, but you might be interested to see if tail on your Donn> platform supports a positive index (bet it does): It works, but with no discernable effect % tail +1 dnd.txt > dnd.txt.short % wc -l dnd.txt* 1015 dnd.txt 1015 dnd.txt.short 2030 total Donn> In the unlikely event it doesn't, sed '1d' is a safe bet. Even better: % sed -e 1d < dnd.txt > dnd.txt.short % wc -l dnd.txt* 1015 dnd.txt 1014 dnd.txt.short 2029 total Learn somethin' every day... Skip From vincent_a_primavera at netzero.net Fri Jul 13 07:25:09 2001 From: vincent_a_primavera at netzero.net (Vincent A. Primavera) Date: Fri, 13 Jul 2001 11:25:09 +0000 Subject: Javascript + Python... Message-ID: <3B450513001C4964@mail.san.yahoo.com> (added by postmaster@mail.san.yahoo.com) Hello, Does anyone know if there are ways to have JavaScript(client side...) "communicate" with Python(server side...) via variables(environmental?) etc...? Thank you, Vincent A. Primavera From bokr at accessone.com Wed Jul 4 15:25:51 2001 From: bokr at accessone.com (Bengt Richter) Date: Wed, 04 Jul 2001 19:25:51 GMT Subject: Comment on PEP-0238 References: <3B3BE855.A6223E70@3-cities.com> Message-ID: <3b433fbf.1034355294@wa.news.verio.net> On Fri, 29 Jun 2001 02:10:09 GMT, "Robert J. Harrison" wrote: >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. > 1) I like the current overloading of "/" 2) I think 'type' is a misnomer re float 3) I suspect the subject of coercions and conversions will churn on a while before a really clean rationale emerges. Additional comments: 1) I like being able to write integer expressions concisely. I like it that +-*/% operating with integers results in integers (and is presumably implemented with efficient CPU features not using floating point anywhere). I do think of integers as a special subset of real numbers, but I don't want them treated as real when I want to do integer arithmetic. If novices need help with the concepts of integer operations, a 10-minute interactive tutorial should be enough. It would be a disservice to them to present numbers as if integers were not special in any way. What the best notation is is a different issue. Personally, I prefer an overloaded '/' to a special '//', and I don't mind adding a decimal point to indicate non-integer. 2) To me, floating point is a special representation format for a special subset of rational numbers. One could argue that it should be treated as a hidden implementation issue whether and how floating point hardware is used to represent numbers of whatever type. I.e., you could have the concept of an optimal number representation which varied dynamically as values changed for a 'number' or 'real' type. PEP 240 (Adding a Rational Literal to Python) might then be a PEP to choose the appropriate optimal representation for ddd.ddd, and the type could be number or real, deprecating float. If you wanted to extend the idea of optimal representation even further (where optimality preserves exactness?) you could consider what I'd call deferred-evaluation-literal-expressions (DELEs). A possible representation would be a tuple identifying an operation and arguments. The rational type is an example of sorts: ('/',numerator,denominator). ('**',2,('/',1,3)) would let you represent the cube root of 2 exactly. And so forth. BTW, if Python numbers get an exact/inexact attribute as in scheme, I hope Python doesn't arbitrarily force exact=false on all numbers represented in floating point. 3) In numeric as opposed to strictly integer context, I would think the goal is to preserve exactness. I think I would be for PEP 237 (Unifying Long Integers and Integers) on that basis. Conceivably there might be a coercion from floating point (rational) to integer-pair rational to preserve exactness, but there are so many ways to represent numbers that maybe they should all be hidden from the language definition. From tjreedy at home.com Tue Jul 3 01:48:24 2001 From: tjreedy at home.com (Terry Reedy) Date: Tue, 03 Jul 2001 05:48:24 GMT Subject: Comment on PEP-0238 References: <3B3BE855.A6223E70@3-cities.com> <7ef50c46.0107020554.31cc948b@posting.google.com> <3B412444.3D7774A7@cosc.canterbury.ac.nz> Message-ID: "Greg Ewing" wrote in message news:3B412444.3D7774A7 at cosc.canterbury.ac.nz... > Terry Reedy wrote: > > > > Example: a school has 4 > > first grade classrooms and 82 new first graders. If we split the students > > evenly among the classrooms, how many in each? The correct answer is 20 > > with 2 left over, not 20.5. > > I'd say the correct answer is neither of those -- it's > (21, 21, 20, 20). Leaving the two remaining pupils > uneducated is not an option that I'd expect any > decent school to consider. :-) Of course, in this particular situation. But the question of what to do with remainders (set them aside or allocate somehow) is dependent on recognizing that there is or should be a remainder to think about, which was the main thrust of my post. The proper allocation procedure depends on the particular situation and the units the number represent, which gets to the point I made later in the post. Terry J. Reedy From mnenadov at stclairc.on.ca Sun Jul 22 16:48:07 2001 From: mnenadov at stclairc.on.ca (Mark Nenadov) Date: Sun, 22 Jul 2001 20:48:07 GMT Subject: Help with PDF References: <20010721.071302.1704365084.1761@d150-169-166.home.cgocable.net> <3b598d0f.252655609@news.t-online.de> Message-ID: <20010722.170022.2058657199.10918@d150-169-166.home.cgocable.net> In article <3b598d0f.252655609 at news.t-online.de>, "Dinu Gherman" wrote: > On Sat, 21 Jul 2001 11:01:04 GMT, "Mark Nenadov" > wrote: > >>The best solution for Python and PDF that I have found is PDF-Lib >>(www.pdflib.com). I have used it with Python, and it also work with a >>wide variety of other languages. > What do you mean by "best"? ;-) > Dinu > What do I mean by best? Exactly what I said... "The best solution .... that I have found". I haven't tried ReportLab yet, so I can't make a judgement on that yet... but PDF Lib is the best one that I have used so far. ~Mark Nenadov (author/editor for http://www.coffeecode.com) From aleaxit at yahoo.com Tue Jul 31 08:32:42 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 31 Jul 2001 14:32:42 +0200 Subject: Typing system vs. Java References: Message-ID: <9k68hd024df@enews4.newsguy.com> wrote in message news:mailman.996538497.304.python-list at python.org... > > On Tue, 31 Jul 2001, Peter Milliken wrote: > > > I have used a very strongly typed language (Ada), I haven't tried Haskall or > > Ocaml as one repondent mentioned, but I claim that with Ada, 95-98% of > > "normal" bugs are out of my programs once I get the compiler to produce > > executable code. The only bugs that are left are the purely logic bugs. > > Only 2-5% of your bugs are purely logical!? While I'd agree that once your > compiler produces executable code the bugs left are of the logical > variety, that number seems incredibly low (or the number of bugs you What do you mean by "logical" in this context? On some keyboards I have the '+' and '-' symbols on the same key (one shifted, one unshifted), so I sometimes have a typo where I use '+' where I mean '-' or vice versa. No compiler I know catches this kind of bug. Yet it's clearly a common typo, not anything having to do with conceptualization. Fortunately, unit-testing catches this (and most other typos) quite effectively:-). Alex From peterh at sapros.com Sun Jul 8 20:30:52 2001 From: peterh at sapros.com (Peter Haight) Date: Sun, 08 Jul 2001 17:30:52 -0700 Subject: 'Member not found.' problem with win32com.client. Message-ID: <200107090030.f690UqN68386@wartch.sapros.com> I'm trying to use the automation interface to the Windows Installer stuff and am having a problem. I used 'makepy.py' on 'Microsoft Windows Installer Object Library (1.0)' which created a nice interface file, but it doesn't quite work. First of all, it looks like the COM object doesn't support GetTypeInfo so I have to make the classes manually, but I'm also getting a 'Member not found.' error when I call some methods. I can kind of get around this by not using the wrapper module, but then I was getting the same error for 'error.StringData(1)'. Now as you can see in my work-around version, I can fix that by wrapping error. Here's my code: --------------- import shutil import win32com.client import win32com.client.gencache template_installer_name = 'EmptyInstaller.msi' project_installer_name = 'test.msi' shutil.copy(template_installer_name, project_installer_name) wininst = win32com.client.gencache.GetModuleForProgID("WindowsInstaller.Installer") o = wininst.Installer(win32com.client.Dispatch("WindowsInstaller.Installer")) db = o.OpenDatabase(project_installer_name, win32com.client.constants.msiOpenDatabaseModeTransact) query_str = "select from Directory where DefaultDir = 'SourceDir' and Directory_Parent = ''" try: view = db.OpenView(query_str) except: error = o.LastErrorRecord() for field_num in range(1, error.FieldCount + 1): print error.StringData(field_num) ------------- Here's the traceback I get when I run it: ------------- Traceback (most recent call last): File "winstall.py", line 18, in ? error = o.LastErrorRecord() File "c:\programs\lang\python\win32com\gen_py\000C1092-0000-0000-C000-000000000046x1033x1x0.py", line 357, in LastErrorRecord ret = self._oleobj_.InvokeTypes(0xa, LCID, 1, (9, 0), (),) pywintypes.com_error: (-2147352573, 'Member not found.', None, None) ------------- Here's the method in the generated module file: ------------- # Result is of type Record def LastErrorRecord(self): ret = self._oleobj_.InvokeTypes(0xa, LCID, 1, (9, 0), (),) if ret is not None: ret = win32com.client.Dispatch(ret, 'LastErrorRecord', '{000C1093-0000-0000-C000-000000000046}', UnicodeToString=0) return ret ------------- Here's how I'm working around it ------------- import shutil import win32com.client import win32com.client.gencache template_installer_name = 'EmptyInstaller.msi' project_installer_name = 'test.msi' shutil.copy(template_installer_name, project_installer_name) wininst = win32com.client.gencache.GetModuleForProgID("WindowsInstaller.Installer") o = win32com.client.Dispatch("WindowsInstaller.Installer") db = o.OpenDatabase(project_installer_name, win32com.client.constants.msiOpenDatabaseModeTransact) query_str = "select from Directory where DefaultDir = 'SourceDir' and Directory_Parent = ''" try: view = db.OpenView(query_str) except: error = o.LastErrorRecord error = wininst.Record(error) for field_num in range(1, error.FieldCount + 1): print error.StringData(field_num) From runyaga at thisbox.com Mon Jul 2 03:01:19 2001 From: runyaga at thisbox.com (alan runyan) Date: Mon, 02 Jul 2001 07:01:19 GMT Subject: Is Python Dead? References: Message-ID: <3%U%6.114072$lq1.30289756@typhoon.austin.rr.com> > What exactly is "good database support?" I haven't had a problem. I think this is mostly due to the lack of centralization of python software (ala CPAN). I believe there are stable python modules to access pretty much any database: oracle, odbc, sybase, bsdb (sleepycat), solid, postgresql, etc... I thought python's database support was weak, but when i needed it it always came through. > I'm not a Zope user myself, but from what I've read about both PHP > and Zope, it appears they are pretty much even in capability (hopefully > an expert on the subject will comment here). I'm far from an expert, but.. I do have an opinion. From what I've seen in PHPland, ZOPE compares pretty much feature-for-feature and then some!. ZOPE is a larger more comprehensive framework than any PHP 'framework' that exists (including eGrail or phpGroupware). Remember: PHP is a web programming language. Python is a general purpose language. ZOPE is a python framework. IMHO, Zope has suffered popularity because it refuses to embed python (code) into the presentation layer (unlike PHP). Also ZOPE is 100% object-oriented. PHP isnt OO and reusibility is garnished from lots of #includes (where as ZOPE has access to Pythons lib and ZOPE accessories and there is hooks into using Perl from ZOPE also.. so you get Perl's DB support as well). PHP is faster, but it doesnt stack up in reusability, speed of development, or flexibility (Python as you mentioned, we all consider to be the best language on the net ;) in language design. also, the ZODB is being wheened off of ZOPE dependency and is starting to show signs of Standalone distribution. this is a __HUGE__ win for Python -- a trivially easy to use object database. > > Python needs better leadership in areas of its growth. Python is truly > the > > best language in use today, except it still isn't very useful for the > > largest solution sector, database access, and information presentation > (web, > > or otherwise). uhm. I completely disagree. information presentation I believe is fully covered by Python, nothing (that I know of) comes close to the bredth of GUI support in Python: QT, GDK, wxPython, TkInter, ?FOX?, and there are others! oh including Swing via Jython. On the web scene there is healthy competition: WebWare (which is modelled after Java's Servlet design), ZOPE (which is a highly evolved framework that comes with a transactional object database), Quixote and quite a few others. HTMLGen. I believe mod_snake (?) is being kept up. There is a hook into the Ars Digita system via Python. I believe you can present information using python in a myriad of ways -- its your choice ;) ~runyaga From eldavo at shell4.ba.best.com Tue Jul 10 19:02:31 2001 From: eldavo at shell4.ba.best.com (David White) Date: Tue, 10 Jul 2001 23:02:31 +0000 (UTC) Subject: python2.1 install problem on redhat 7.1 Message-ID: <9ig1i7$95b$1@nntp1.ba.best.com> Hello, I'm trying to install python2.1 on redhat 7.1 i686. I'm using the RPM and I get a dependency error: 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 so I installed the following rpm -iv ftp://speakeasy.rpmfind.net/linux/PLD/current/PLD-1.0/i686/PLD/RPMS/openssl-0.9.6a-4.i686.rpm which gives me /usr/lib/libcrypto.so.0.9.6.1 /usr/lib/libssl.so.0.9.6.1 but I still have that dependency error. So the question is, what's the right way to resolve this situation? thanks, dave white From robin at jessikat.fsnet.co.uk Wed Jul 18 04:30:07 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Wed, 18 Jul 2001 09:30:07 +0100 Subject: viewcvs rlog error References: <74f2f0e9.0107171115.25248606@posting.google.com> Message-ID: <2QbsjKAPkUV7Ew7J@jessikat.fsnet.co.uk> In article , Robin Becker writes >In article , Robin Becker > writes >>In article <74f2f0e9.0107171115.25248606 at posting.google.com>, Jeanie M. >>Schwenk writes >>>I just installed viewcvs 0.7 and it gives python exceptions if the >>>directory has any files in it. Not terribly useful. It appears to >>>be some kind of rlog error but I can't duplicate it from the command >>>line so I must assume it's something to do with the python scripts. >>>I'm new to python so any useful suggestions would be nice. >>> >>>Traceback (most recent call last): >>> File "/opt/viewcvs0.7/lib/viewcvs.py", line 2514, in run_cgi >>> main() >>> File "/opt/viewcvs0.7/lib/viewcvs.py", line 2477, in main >>> view_directory(request) >>> File "/opt/viewcvs0.7/lib/viewcvs.py", line 1091, in view_directory >>> fileinfo, alltags = get_logs(full_name, rcs_files, view_tag) >>> File "/opt/viewcvs0.7/lib/viewcvs.py", line 1035, in get_logs >>> raise 'error during rlog: '+hex(status) >>>error during rlog: 0x7f00 >>I'm getting the identical error after struggling a bit with my freeBSD >>system. I'll have to go back to 0.5. >OK it seems we need to install rlog, to get this to work. alternatively as in my case I needed to set up the right path for rcs_path in the viewcvs.conf -- Robin Becker From philh at comuno.freeserve.co.uk Mon Jul 9 09:02:36 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Mon, 9 Jul 2001 14:02:36 +0100 Subject: license suggestions? References: Message-ID: On Sun, 8 Jul 2001 19:44:52 -0500 (CDT), Chris Watson wrote: > > >> This seems really strange to me. So you are saying you can integrate it >> into any proprietary product without problems? You can intergrate it into >> perl, python etc with their various licenses. Why do you specifically not >> want anyone to integrate it with GPL code but allow everything else? > >Strange? Not that I dont know where this will end up but how is wanting to >keep the GPL (which would add restrictions to my code that *I* did not >place on it) from infecting my licensed code strange? Because you're happy to have your code infected by proprietary code. Consider: You write program Y, licensed by the BSDL Person P writes code C, which incorporates Y. The executable C+Y is licensed under a proprietary shrinkwrap license. Person Q writes code D, which incorporates Y. D is GPL'd. A 4th person, R, can do some things with C+Y. But R can do asll those things, and more with D+Y. So if the restrictions on D+Y are bad, why are the (larger) restrictions on C+Y not also bad? This is a genuine question BTW. > I release everyone >can choose their OWN licenses. I have NO problem with that. The thing's I >have problems with are the fact that A) you can GPL BSD licensed code. Not really. The BSDL'd version still exists. If I merely take some BSD code and don't change it, I'm not the copyright holder so I can't change the license. If I change the code, so the result is partly my work, then I can license the result in any way that's compatible with the BSDL. So I could GPL it if I wanted. >terms. Nothing more or less. You can do whatever you wish with the code. Make >it binary only and keep your secret modifications secret, release them with >source, whatever you wish. You just can't add any restrictions to my code. The GPL doesn't as I understand it. But it could add restrictions on someone else's code that they wrote but that links to your code. Is that OK by you? -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From gs at styrax.com Fri Jul 6 15:09:03 2001 From: gs at styrax.com (Garry Steedman) Date: Fri, 6 Jul 2001 19:09:03 +0000 Subject: Maintaining the Python FAQ In-Reply-To: Message-ID: <3B460CCF.2924.33315027@localhost> maybe this would be a good time for someone to think about writing a nifty FAQ product for Zope? cheers, g On 6 Jul 2001, at 15:50, Guido van Rossum wrote: Subject: Re: Maintaining the Python FAQ From: Guido van Rossum Organization: Excite at Home - The Leader in Broadband http://home.com/faster To: python-list at python.org Date sent: Fri, 06 Jul 2001 15:50:35 GMT > Oleg Broytmann writes: > > > On Fri, 6 Jul 2001, Guido van Rossum wrote: > > > Hm. To what extent is the current FAQ wizard a problem for its > > > > For me the biggest problem is not the FAQ Wizard, but FAQ.html - > > it is > > too big. 270K is too big for the Net. Let us split it intopages. > > Huh? The FAQ wizard gives you plenty of ways to access individual > items or sections. Why would you ever download the whole FAQ? > > --Guido van Rossum (home page: http://www.python.org/~guido/) > -- > 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 chris.gonnerman at newcenturycomputers.net Mon Jul 16 09:18:02 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Mon, 16 Jul 2001 08:18:02 -0500 Subject: Writing xbase .dbf files with Python ? References: Message-ID: <006b01c10df9$c468b9e0$0101010a@local> I downloaded the latest version (1.1.3) and did not find the pyshapelib-* directory where you described it. What version are you looking at? ----- Original Message ----- From: "Sean True" > There is pretty good support for .dbf files in a component of GDAL > (http://www.remotesensing.org/gdal/). > > "GDAL - Geospatial Data Abstraction Library > GDAL is a translator library for raster geospatial data formats that > is released under an Open Source license. As a library, it presents a > single abstract data model to the calling application for all > supported formats." > > The key here is that .DBF is the standard format for storing > geographically linked data attributes in one of the GIS industry > standard formats (shapefile). You can find the relevant pieces, which > are a C library and a SWIG wrapper in the source distribution for > GDAL in the location \gdal\frmts\shapelib\pyshapelib-0.1, for a fairly > recent release. I use the functions for both reading and writing. > This wrapper is not intertwined (much!) with the rest of GDAL. > > Works for me but ... YMMV. > > Sean True > WebReply.Com, Inc. > > > -- > http://mail.python.org/mailman/listinfo/python-list > > From europax at home.com Sun Jul 15 19:06:17 2001 From: europax at home.com (Pugsley) Date: Sun, 15 Jul 2001 23:06:17 GMT Subject: Need help with "global" variables/resolved References: Message-ID: Thanks for the posts and emails. Yes I now realize that Python modules are not like linked C modules. I took some advice from the ng archive and put all of my globals into a dummy class. I can then just pass the name of the class to wherever I need it. Rob. In article , "Pugsley" wrote: > I'm converting a number crunching program from C to Numeric Python, and > I'm really getting stuck on how to deal with global variables. > > For example, there are about 30 variables that are defined in the main > program that I want to be global and available in the functions in the > modules. (the modules are seperate files that I import). A simple > example would be: > > def foo(arg1, arg2): > > global bar1, bar2, bar3, etc. > > result= bar1+bar2+bar3+ arg1+arg2 > > return result > > > > But all I get are errors stating that the global variables have not been > defined. This behavior seems to run counter to what is implied in some > books that I've been reading. > > What am I doing wrong? Thanks, Rob. From chris.gonnerman at newcenturycomputers.net Mon Jul 16 09:12:58 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Mon, 16 Jul 2001 08:12:58 -0500 Subject: windows port access References: <3b520bcb@news.cybertours.com> <3B522E98.BAAA9E93@engcorp.com> Message-ID: <005b01c10df9$245a4cc0$0101010a@local> ----- Original Message ----- From: "Peter Hansen" > If you look back through the last two days' worth of postings for subject > "parallel port?!?" you should find something to help. Yes, it is possible, > no the result is not compatible (but you could always write a higher level > wrapper to make it so). Unfortunately what Bryan is asking is not what you are answering. He wants to access the I/O port 0x280, which he states is assigned to a "custom ISA card" which (I assume) is not using the standard parallel port interface, nor serial, etc. and for which he evidently has no driver. Under Linux, this can be done in C by following the instructions in the "IO Port Programming mini-HOWTO" (check any Linux portal, i.e. linux.com, for this document). Doing it in Python using the first method given (routines in ) would require writing a custom module in C. The second method given (using /dev/port) is doable in a pure-Python implementation. What Bryan hasn't told us is whether or not he needs interrupt support and whether or not the interface protocol is time-sensitive; user-space access to such a device is doomed to failure in most cases, and a kernel driver is required instead. Under Win32 I'm not sure what the procedure is, but I suspect a VxD file will be needed. Bryan, please tell us a bit more about the device you are trying to control, and perhaps we can help you. > Bryan Brannigan wrote: > > > > I am looking for a way to send data to certain ports on a custom ISA card. > > The card is addressed as 280h. Is this possible with Python? Is the code > > compatible with Linux as well? > > > > Bryan > > -- > ---------------------- > Peter Hansen, P.Eng. > peter at engcorp.com > -- > http://mail.python.org/mailman/listinfo/python-list > > From steve at lurking.demon.co.uk Sat Jul 21 17:17:21 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Sat, 21 Jul 2001 22:17:21 +0100 Subject: Is anybody coming from Pascal? References: Message-ID: On Sat, 21 Jul 2001 07:05:13 +0100, edmund at ngetal.fsnet.co.uk (Edmund Strangely) wrote: >I conclusion, and in reviewing this post, I seem to have been rambling a >bit (it's a bit late/early in the day) but I'd be interested to get a >response from anybody else who rates Mr Wirth, and in how any such people >finding the transition. I'd also be curious to hear from anybody who has >tried object Pascal. I've used a number of languages, including both Pascal and Modula 2. Pascal was also among the first few languages I learned - after various versions of BASIC, couple of assembler languages, and a variant of Forth. I even learned Ada before I made significant use of C or C++, though I worked professionally with C before I worked with Ada. I first learned Python at a time I was professionally using Ada, and when I was still learning C++ (my current main language for professional use). On the / or div issue, I agree with some things and disagree with others. I disagree with having separate / and div operators, for instance, because this is a simple case of operator overloading - when I use complex numbers, vectors, matrices and so on I don't want to revert to using functions instead of operators, and I don't want to learn another set of operator names. Ada is, in many ways, a language in the Pascal/Modula 2 tradition, and one of the big improvements it has over Pascal is that it supports operator overloading and drops the div operator. OTOH, I do prefer the Ada mod and rem operators to the C % operator for several reasons... 1. C does not define whether % is a mod or rem. A mod operator never returns a negative number, whereas a remainder may give a negative result. Because this is undefined in the standard, different compilers do different things with respect to the sign in this case. The reason for the different definitions is because modulo arithmetic is arithmetic done in a wraparound range of integers 0..(base-1) and has not negative numbers, whereas the remainder in division does logically have a negative result. 2. The mod and rem names are explicit in what they mean. The % operator looks like it should be something to do with percentages. Python has cleaned up the first problem (by defining that % returns the remainder, which may be negative) but not the second. In fact, python overloads % with a completely different additional functionality which IMO can only increase the confusion (plus I think the % operator is not quite right anyway - the markers in the string should specify the subscript of the item in the list, as well as the formatting). Also, I'm not happy with the Python definition of integer division, and of the remainder... """ The modulo operator always yields a result with the same sign as its second operand (or zero) """ As far as I'm concerned, this is plain wrong. If I do the following... quotient = -3 / 2 remainder = -3 % 2 I expect quotient = -1 and remainder = -1 I get quotient = -2 and remainder = 1 Either version maintains the basic remainder law - given... quotient = a / b remainder = a % b You can still rely on... (quotient * b) + remainder == a I just think integer division should round towards zero - not strictly downwards. These are small issues though, and issues that vary enough from one language to the next that any multi-lingual programmer should have the sense to check before using these facilities. My overall opinion is that Modula-2 and Ada are excellent languages in many ways, though Ada programmers tend to have a style based on pedantic following of rules rather than on what is genuinely readable - a mindset that comes from the military background, I suppose. Pascal in its standard form is too simplistic to be a serious general-purpose language, and single-vendor updates such as Delphi *are* single-vendor products, irrespective of their success. C and C++ easily defeat Ada in their ability to express a lot of functionality quickly and consisely, though they lose on reliability and (with the still common obfuscation tradition) sometimes on readability. At first sight, my criticism of Delphi being a single-vendor non-standard product seems also to apply to Python - but it's not true. In reality, Python has a single standards authority (Guido van Rossum) - but you are not limited in the way that single vendor products limit you. This is because anyone can contribute to the development. If you really feel it is necessary, you can download the source and port it to other platforms or add whatever features you want, and distribute your own alternative implementation. This has happened a lot - jPython and embedded/stackless Python being the cases that spring to mind. The Python community is a centre of excellence - not a cage made of regulations and limitations. Single vendor products clearly restrict freedom and are therefore unAmerican ;-) - though I'd much rather keep Borland and dump Microsoft. From mikeb at mitre.org Tue Jul 10 14:02:05 2001 From: mikeb at mitre.org (Mike Brenner) Date: Tue, 10 Jul 2001 14:02:05 -0400 Subject: Credit card processing on the web Message-ID: <3B4B431D.4F578833@mitre.org> Steve Holden ... credit card transaction ... socket-based with mx/amkCrypto to implement the Blowfish encryption Michal Wallace wrote: I have a library for dealing with online payments through the web at http://sourceforge.net/projects/payment/ .. There's no web page or documentation for it yet, but the code is quite small and hopefully readable... There's also some unit tests.. It works with Authorize.net and verisign and requires M2Crypto. Michal, Sourceforge reports that no code has been uploaded yet. I am very interested in learning how to connect to banks, credit card machines, etc., for eCommerce purposes. From steve at lurking.demon.co.uk Mon Jul 23 21:28:48 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Tue, 24 Jul 2001 02:28:48 +0100 Subject: PEP0238 lament References: Message-ID: On Mon, 23 Jul 2001 17:05:34 -0500, wrote: As we agree on the final conclusion, going through this again is probably merely annoying, but there are some things I want to set straight. >> 1/2 == 0.5: >> Perl -- untyped, thus irrelevent >> LISP -- academic language only >> Pascal -- the Ada folks thought it was wrong >> Modula 2+ -- Minority languages >> JavaScript -- dumbed down language >> 1/2 == 0: >> Visual BASIC -- most used language 3 yrs running >> C -- what need I say? >> C++ -- ditto >> Java -- ditto >> Ada -- intentionally changed the Pascal practice >> VBA -- most used non-programmer language > >Now, I *could* argue with you. I could say that VB, C++, >and Java are just imitating C, and thus you only have 2 In the C++ and Java case Yes - they *stayed* with the existing system despite the fact that particularly for Java, they are different languages and free to change - and Sun were specifically seeking ways to tidy up the language and make it clearer, simpler and less error prone yet they kept division as it is. VB is based on BASIC, which has a variable history but which in the early days generally did 1/2 -> 0.5, and generally *changed* it later on. Notice how any case where language designers have made a deliberate change, the only way they change is towards 1/2 -> 0? >I could say that mere put-downs of excellent languages >like LISP and Modula 3 (and other languages, like JavaScript) I'm not putting them down - they are all excellent and important languages as I said. But if we are considering what most people are going to expect after coming to Python from other languages, we *have* to acknowledge both the relative scales of use, and the experience implicit in the way language families have evolved over time. We also have to consider the languages reputations for clarity etc - a much shakier and porobably losing issue if you compare C family with Pascal family languages - but looking at the evolution of that specific aspect is a pretty strong indicator reguardless of the wider nastiness of C and BASIC derived languages (and yes, my main language IS C++). LISP doesn't aim to be a language for mainstream applications - it does what it set out to do extremely well (if cryptically) and it's success in its target fields is the very reason we have close derivatives like scheme, besides many principle-borrowering languages, today (but it's *still* a wierd choice for editor scripting ;-). Wirths languages don't have users on the same scale as C et al, which is a great shame as they are far superior languages (bar their wierd view on division ;-) - but those user bases are still pretty secure with good reason. The continued existence of Pascal in the form of Delphi is, to me, a freak of history - Delphi as a Modula 3 based language would have been a far superior thing, especially if it adhered to the relevant language standard, but Borland had Turbo Pascal to hand at the time and a huge community of users that it chose not to discard by breaking their existing code and experience - thus Pascal is still here despite being a freak of history, whereas the far superior Modula series have much smaller user bases. Sound familiar ;-) >On this point I'm holding my ground. I do NOT belive that >int division is "the same thing" (with different domain). For >instance a VERY IMPORTANT feature of "division" is that >(A / B) * B == A, and "integer division" doesn't maintain Neither does float division. (1.0/3.0)*3.0 -> 0.99999999999999 (for decimal floats - similar binary principles apply). That difference is small enough to be hidden until it's too late to fix - much rather the blatantly obvious bug than the subtle hidden one. This is exactly the kind of issue that is supposed to be bread-and-butter to numerics programming, BTW, and exactly the kind of thing students should be taught to be aware of. >this. Another clear way to tell that "integer division" is >different from "division", is to see that they give different >answers... 25 3 == 8, while Yes - and matrix division gives different answers again. Do we want a different operator for that too? The real people to ask are mathemeticians - they have accumulated thousands of years of experience, and they represent integer and float (and symbolic and finite field and matrix and so on) division using exactly the same selection of operators. We can't use the same representation until we finally drop ASCII as our source file format and switch to XML with user-configurable presentation for standardised entities (oops, fantasy world again) - but we can follow the same principle that thousands of years of the worlds mathematicians experience - and several decades of the bulk of the worlds programmers experience - have clearly indicated to be the preferred choice. Division is essentially the same thing irrespective of the data type. There are *much* better reasons than these not to change division, but they are certainly good enough to show that 1/2->0 is an extremely strong contender for the belt - not some pretender that can simply be ignored - and that even if the change goes ahead, and even when the bugs are fixed and everyone has forgotten the agony of PEP0238 - there are very good reasons to believe that Python will *NOT* be better for the change, but that it will be *worse*. I cannot prove that the change is for the worse, but I have raised very good reasons to consider it highly likely and I have proved that scepticism over PEP0238 is valid - both because and irrespective of backwards compatability. And I have explained my position with regard to my past Python advocacy and the very difficult position this is going to leave me and other advocates in. How do the pro-PEP0238 people react? Lets see... 1. Some continue to refer to float division specifically as "correct" division - not as a preference, a convenience for particular applications or a crutch for students. By implication, mine and other peoples rationally stated opinions are *incorrect* and we're stupid for even thinking them. 2. Others write off strength-of-feeling as irrationality and same-old-usenet, and they state that these are the same old arguments as if a viewpoint that is repeatedly and emphatically raised by many people with rational arguments is somehow inherently invalid. 3. The most important people have simply said very little bar a few easily countered viewpoints that they seemingly have no intention to bother discussing further. They have spoken and that is the end of it. Let's take a guess for tomorrow... 4. If you don't like the message, keep on flinging mud at the messenger. Anyone resent the insult? - so why should I take it? From josegomez at gmx.net Thu Jul 19 08:24:34 2001 From: josegomez at gmx.net (josegomez at gmx.net) Date: Thu, 19 Jul 2001 12:24:34 +0000 (UTC) Subject: Python/VTK tutorial? Message-ID: <9j6ji2$lcs$1@hermes.shef.ac.uk> Hi, I was looking for a decent vtkpython tutorial. However, I seem to stumble into TCL/TK tutorials all the time. Does such a beast exist? I would have thought that coupled with NumPy, VTK in Python should be phenomenally popular... Any help much appreciated, Jos? -- Jos? L G?mez Dans PhD student Tel: +44 114 222 5582 Radar & Communications Group FAX; +44 870 132 2990 Department of Electronic Engineering University of Sheffield UK From m.faassen at vet.uu.nl Sun Jul 22 17:14:36 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 22 Jul 2001 21:14:36 GMT Subject: PEP0238 lament References: Message-ID: <9jffns$hma$1@newshost.accu.uu.nl> Tim Peters wrote: > [Arthur_Siegel at rsmi.com] >> ... >> If I was told that experinced programmers might >> appreciate this change for any possible reason - >> I'd be quiet as a mouse. > Not all experienced programmers agree. At the last Python Conference, I > moderated a 40-some person group discussion on conceivable changes to > Python's numeric model, not advocating but keeping the participants from > killing each other . The meaning of integer division wasn't the > focus, but naturally came up. By show of hands, about 3/4ths of the > participants agreed that 3/4 should not return 0, but rather *something* x > such that x*4 had a better chance of being confused with 3 than with 0. > There was no consensus on exactly what 3/4 should return -- rational or HW > float or decimal float were the most popular alternatives. > It shouldn't be so hard to understand why. [snip Tim's reasons] The audience was entirely self-selected; they were people with an interest in numeric models. Did Guido ask for a show of hands in the big session afterwards? I don't recall; I kind of suspect the outcome would've been different. > The current integer division > loses information silently and without a trace. Combined with that Python > is not a statically typed language, there's simply no telling what e.g. > def velocity(distance, time): > return distance / time > will compute by inspection. There's no telling what: def add_stuff(a, b): return a + b will compute by inspection either, though. Are we complaining about that? (yeah, I know the inverse operation is rather hard to define for string addition :) [snip] Of course I claim no expertise in this matter whatsoever. :) For working with pixels in GUIs and such, integer division can be a useful thing, though. 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 Jul 6 15:37:43 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 06 Jul 2001 19:37:43 GMT Subject: Comment on PEP-0238 References: <3B45F133.7050206@erols.com> Message-ID: "Edward C. Jones" writes: > I suggest including a program that will read Python code and tell > the user where all the "/" divisions are in the code. That's easy enough: import sys, tokenize for filename in sys.argv[1:]: def tokeneater(type, token, start, end, line, filename=filename): if token == "/": print "%s:%d:%s" % (filename, start[0], line), tokenize.tokenize(open(filename).readline, tokeneater) Unfortunately, this doesn't tell you which / operators are ever applied to *integer* arguments -- no program looking only at the source can determine that. That's what the warnings are for. --Guido van Rossum (home page: http://www.python.org/~guido/) From damien.doligez at inria.fr Tue Jul 3 11:37:49 2001 From: damien.doligez at inria.fr (Damien Doligez) Date: 3 Jul 2001 15:37:49 GMT Subject: Announce: ICFP programming contest Message-ID: <9hsosd$lq6$1@ites.inria.fr> We are pleased to announce: The Fourth Annual ICFP PROGRAMMING CONTEST July 26-29, 2001 http://cristal.inria.fr/ICFP2001/prog-contest/ Convinced your favorite programming language provides unbeatable productivity? Convinced you and your friends are world-class programmers? If so, we're providing you the opportunity to prove it! We are pleased to announce the Fourth Annual ICFP Programming Contest to be held in conjunction with the 2001 International Conference on Functional Programming (ICFP 2001). All programmers are invited to enter the contest, either individually or in teams; we especially encourage students to enter. You may use any programming language (or combination of languages) to show your skill. On Thursday, July 26, 2001 at 15:00 UTC, we will publish a challenge task on the Web site and by e-mail to registered participants. Teams will have until Sunday, 29 July 2001, 15:00 UTC (72 hours) to implement a program to perform this task and submit it to the contest judges. We've designed the contest for direct, head-to-head comparison of language technology and programming skill. We have a range of prizes for the winners: cash awards, special student prizes, and, of course, unlimited bragging rights. For more information about the contest, prizes, and registration, point your browser to: http://cristal.inria.fr/ICFP2001/prog-contest/ For more information about ICFP 2001, see: http://cristal.inria.fr/ICFP2001/ -- Damien Doligez, Luc Maranget, Pierre Weis From jonschull at yahoo.com Sat Jul 28 20:49:03 2001 From: jonschull at yahoo.com (Jon Schull) Date: 28 Jul 2001 17:49:03 -0700 Subject: doctest x idle problem? References: Message-ID: in message news:, Alex quoted Tim... > > This won't be solved in general by magic until someone contributes > > code to launch "Run Script" in a fresh process; but that's not always > > what you'll want either. > and then Alex said ... >I could have a look at > fixing that (just a matter of repeating the reloads until the dependancy > graph stabilizes) and folding it into IDLE. > This sounds like a good idea to me. There seems to be an element of social engineering in the python language, and community, which seems to be an important part of its success. There's a lot of leverage to be had in building it right into the tools. ....................................................................... P.S. Then Tim said, >it's-life-it-sucks-ly y'rs - tim So I'll quote Richard Dawkins in Unweaving the Rainbow: "We are going to die, and that makes us the lucky ones. Most people are never going to die because thay are never going to be born." From mlh at idi.ntnu.no Sun Jul 1 16:15:48 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Sun, 1 Jul 2001 22:15:48 +0200 Subject: problems with class initiation References: Message-ID: <9ho0dl$ri0$1@tyfon.itea.ntnu.no> "I?igo Serna" wrote in message news:mailman.994017363.31520.python-list at python.org... [snip] > I suppose the error comes due to Main class hasn't finished its > initiation when 'app.prefs.a' is executed so app is None in that moment. The assignment isn't finished, so app is indeed None. Instead of relying on global variables, you should supply app as a parameter to the constructor of Second, IMO... Thus: class Second: def __init__(self, app): return self.init_fn(app) def init_fn(self, app): return app.prefs.a class Main: def __init__(self): self.prefs = Preferences() self.fns = [] self.fns.append(Second(self)) ... or something like that. (The design seemed slightly confusing to me, but I think this should work, at least :) -- 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 kirschh at lionbioscience.com Tue Jul 10 07:43:51 2001 From: kirschh at lionbioscience.com (Harald Kirsch) Date: 10 Jul 2001 13:43:51 +0200 Subject: import namespace issues References: <9iei5205pn@enews3.newsguy.com> Message-ID: "Alex Martelli" writes: > "Harald Kirsch" wrote in message > news:yv2lmlxgnji.fsf at lionsp093.lion-ag.de... > > QUESTION 2: > > Is there a detailed description somewhere in the docs about the > > namespaces (or dictionaries) used/created/shuffled during an import? > > I think the documentation for __import__ is pretty clear about > it, "the standard implementation does not use its locals argument > at all, and uses its globals only to determine the package context > of the import statement". I sometimes find that the python docs seem to expect some prior knowledge about `obvious behaviour' from the reader and consequently are a bit terse. Therefore I believed the above statement only after having read the code :-) Harald. -- ----------------+------------------------------------------------------ Harald Kirsch | kirschh at lionbioscience.com | "How old is the epsilon?" LION bioscience | +49 6221 4038 172 | -- Paul Erd?s *** Please do not send me copies of your posts. *** From tjreedy at home.com Mon Jul 16 17:18:03 2001 From: tjreedy at home.com (Terry Reedy) Date: Mon, 16 Jul 2001 21:18:03 GMT Subject: Partition Problem References: <3B4FBEA0.D5A6DC8A@engcorp.com> <9ioru22pc9@enews4.newsguy.com> <3B5042C2.F821D916@engcorp.com> <9itb14$2oi$1@newsg1.svr.pol.co.uk> <9iv5e9$bru$1@newsg1.svr.pol.co.uk> Message-ID: "Donovan Hide" wrote in message news:9iv5e9$bru$1 at newsg1.svr.pol.co.uk... > Hi, > thanks for the input, newsgroups are great! After scratching my head > last night, I came up with a non-recursive algorithm which works for > specific values of k (6 in the following example), as follows: > from math import * > > def P(n,k): > res=[] > for a in range (n-k+1,int(ceil(n/k)-1),-1): > for b in range(a,0,-1): > for c in range(b,0,-1): > for d in range(c,0,-1): > for e in range(d,0,-1): > for f in range(e,0,-1): > if (a+b+c+d+e+f)==n: > res.append([a,b,c,d,e,f]) > > return res Since k is fixed at 6 by the implementation, you really should *not* pretend otherwise by putting it in the argument list. Call this P6(n) and add "k=6" as the first line. [Or, check that k is 6 on input and "raise ValueError, 'arg k must be 6' " if not.] This nested for-loop solution will run much faster if you trim the branches as soon as possible instead of just at the end after generating each of the n**k leaves. After > for b in range(a,0,-1): add if (a+b+4) <= n: # in P(20,6) 15+2(or larger) cannot yield a solution. etcetera. This is the branch-and-bound principle. A better lower limit than 1 (-1=0 in range) will also help. Even better, do for b,c,d,e,f what you (almost) did for a: make the range exact. Start by defining remain_x as the amount (of the original n) that remains to be partitioned *before* we assign a value to x. remain_a = n remain_b = n-a = remain_a - a remain_c = n-a-b = remain_b - b ... remain_f = ... = remain_e - e # this is the only possible value for f, no loop needed # if we proceed correctly, it will also be <= e, no test needed Also let kx = . One upper limit for x is remain_x - (kx-1) since each part after x will be at least 1. Another, for monotinicity downward, is the value of the preceeding part, if any. So the upper limits for the range statements are a: remain_a - (k-1) b: min(remain_b - (k-2), a) ... e: min(remain_e - (k-5), d) Letting kx = , the lower limit for x, again for monotinicity, is remain_x/kx + (remain_x % kx > 0). Subtract 1 for range statement. (remain_x - 1)/kx gives the same answer (after the subtraction). [Note: since n/k is int, int(ceil(n/k)-1) = int(float(n/k)-1) = n/k-1 which is 1 low for 20,6; int(ceil(float(remain_x)/kx)-1) should give correct answer as above, but float math is unnecessary.] Putting this altogether gives us def p6(n): k = 6 res=[] i = 0 remain_a = n for a in range (remain_a-(k-1), (remain_a-1)/k,-1): remain_b = remain_a - a for b in range(min(a,remain_b-(k-2)),(remain_b-1)/(k-1),-1): remain_c = remain_b - b for c in range(min(b,remain_c-(k-3)),(remain_c-1)/(k-2),-1): remain_d = remain_c - c for d in range(min(c,remain_d-(k-4)),(remain_d-1)/(k-3),-1): remain_e = remain_d-d for e in range(min(d,remain_e-(k-5)),(remain_e-1)/(k-4),-1): res.append([a,b,c,d,e,remain_e-e]) i=i+1 return res,i [Note: since partitions are fixed sequences, they should better be returned as tuples.] Outfitting your P with a similar counter, both give a list of 90 lists and we get >>> P(20,6) == p6(20) 1 As for speed, P(50,6) takes 100 seconds on my machine (5427 partitions) while p6(50) and even p6(70) (26207 partitions) take less that a second to start printing. P(70,6) would probably take hours to do the same. Computing exactly what you want with nothing wasted is always best. To solve this problem for any k using this approach, we could write a program that will write and compile the python code for a particular value of k (using x1 to xk instead of a to whatever). [The underutilised ability to do this sort of thing is a Lisp-like quality of Python.] The new generator facility is a natural for combinatorial problems like this. Terry J. Reedy From rnd at onego.ru Wed Jul 18 16:50:07 2001 From: rnd at onego.ru (Roman Suzi) Date: Thu, 19 Jul 2001 00:50:07 +0400 (MSD) Subject: how to save strings to a temporary buffer? In-Reply-To: <9j4kia+hmtu@eGroups.com> Message-ID: On Wed, 18 Jul 2001 ed_tsang at yahoo.com wrote: >How can I save string to a tempororay buffer and then write it to a >file afterwards? > >I have a function that output a formatted string each time it is >called; but instead of open a file and write it each time; I would >like to save these strings to a , may be a tmeporory buffer, and then >write it to a file when everythign is completed... how cna I do that? >thansk > You can specify buffer size in open() to the size you want. This will have the effect you want. f = open("file", "w", 100000) ... f.flush() # when you want to write buffer to disk ... f.close() Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Wednesday, July 18, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Hard work never killed anyone, but why chance it?" _/ From guido at digicool.com Fri Jul 6 12:24:31 2001 From: guido at digicool.com (Guido van Rossum) Date: Fri, 06 Jul 2001 12:24:31 -0400 Subject: Maintaining the Python FAQ In-Reply-To: Your message of "Fri, 06 Jul 2001 20:14:41 +0400." References: Message-ID: <200107061624.f66GOWa18105@odiug.digicool.com> > 1. Because it is the first link a user sees on the frontpage of > www.python.org and on http://www.python.org/doc/ That's easily fixed! > 2. Because I prefer static files instead of running CGIs on your server. > Just to lesser the load. You're too kind. And it's quite unnecessary: the CGIs run on a separate machine that actually has more CPU power than the main server! --Guido van Rossum (home page: http://www.python.org/~guido/) From cpsu at larc.ee.nthu.edu.tw Mon Jul 9 01:41:04 2001 From: cpsu at larc.ee.nthu.edu.tw (Chyr-Pyng Su) Date: Mon, 09 Jul 2001 13:41:04 +0800 Subject: Tkinter and printf in C ... References: <3B455B5D.544A2EF5@larc.ee.nthu.edu.tw> <9Jh17.38316$he.2456932@e420r-atl1.usenetserver.com> <3B48076E.B16ACF5B@larc.ee.nthu.edu.tw> Message-ID: <3B4943F0.35F0FADA@larc.ee.nthu.edu.tw> > OK, I was running a little too fast. The "self" in the code I showed you > referred to the object whose class implementation I had extracted the code > from, so you all you need to know is that is was the parent of the > Pmw.ScrolledText object in which I was rendering text. > > Suppose that the error message returned by the wrapped C function has been > stored in st. To create a Text widget in a separate top-level window and > display the message in it, you would do (something like: warning, untested): > > msgWindow = Toplevel(height=350, width=500) > msgWindow.columnconfigure(0, weight=1) > msgWindow.rowconfigure(0, weight=1) > t = Text(msgWindow) > grid(t, row=0, column=0, sticky=N+E+W+S) > t.insert(END, st) > > I have here assumed that like most Tkinter programmers you have used "from > Tkinter import *", and that you are using (or are prepared to use) the grid > geometry management. > > Does this make it any clearer? > > regards > Steve > -- > http://www.holdenweb.com/ :> I know 'self', but the question is 'index' . The following code segment is what I really interesting. That is, how to catch the message that transfer from wrapped c function. strmes = self.index.Message(self.MsgSet[int(self.msgList.curselection()[0])][0]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ message = mimecntl.MIME_document(strmes) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ for hdr in ("from", "date", "subject", "to", "cc"): try: hdrline = message[hdr] t.insert(END, "%s: %s\n" % (string.capitalize(hdr),hdrline)) except KeyError: pass >From my experiment, Using Pmw package to write my GUI, the dumped message from C will popup a error message dialog, but this won't happen when I implement GUI in original Tkinter package. Could you explain the MsgSet.. MIME_document... these functions.. or tell me where to find related document that describe those mechanism, so that I can study it. I can't find these stuff in Pmw or Tkinter document... :p Thanks.... -- ?????? Su, Chyr-Pyng o888o V o888o VLSI Design, Testing and Fault Tolerance Lab. o8 ~__ __ 8o EE. National Tsing Hau Univ. Taiwan 88o ooo o88 o 8^ ^8 o E-Mail: cpsu at larc.ee.nthu.edu.tw /- 88_____88 -\ WWW: http://larc.ee.nthu.edu.tw/~cpsu _\ qioip /_ From tim.one at home.com Sat Jul 28 03:14:49 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 28 Jul 2001 03:14:49 -0400 Subject: Deposing Dictators In-Reply-To: Message-ID: [Dirck Blaskey] > I would much rather get the source instead of the executable, > at least then you have a chance when it breaks, for whatever reason. > > I'm aware that this kind of code exists, but personally I don't > consider it the normal case, nor would I find myself faced with COBOL. > The closest equivalent I can come up with: I still run into people > using dBase III. Time to move into the 21st century, Dirck! This alternative is often overlooked: http://www.cobolscript.com/ When that site was just getting started, Guido sent them a congratulatory msg about what a wonderfully well-done joke it was. Turns out they weren't kidding -- and boy, was his face red . compute loop_counter = loop_counter +1 will-probably-run-unchanged-until-universal-heat-death-ly y'rs - tim From grahamd at dscpl.com.au Fri Jul 27 05:55:47 2001 From: grahamd at dscpl.com.au (Graham Dumpleton) Date: 27 Jul 2001 02:55:47 -0700 Subject: Distributed computing using SOAP. What about speed ? References: <3B5FC733.5186D588@tundraware.com> <3B60EEA0.70BC492A@tundraware.com> Message-ID: Tim Daneliuk wrote in message news:<3B60EEA0.70BC492A at tundraware.com>... > A gracious Graham Dumpleton wrote: > > > > I will look at your paper. You may want to look further at the Python > > manual for OSE and you might see it ain't quite what you first had in > > mind. > > I guess I should clarify something. In order to have "transactional > correctness" you have to have a reliable transport somewhere in the > stack below the transactional elements (or transport reliability has > to be synthesized at the transactional layer - a really bad idea). In the end, I think we are perhaps talking from the perspective of trying to address different problem domains. Ie., apples vs oranges. So I am not sure how much consensus we will get. Anyway, you have given me some more stuff to read and ponder. Now to clarify a bit about OSE and what I originally mean't when I said "connected". Firstly, the distributed ability of OSE isn't in any way dependent on SOAP, XML-RPC or any other RPC over HTTP protocol. Thus, it isn't relying on having to create connections for every message being sent around. In the simplest model for using OSE, and probably most easily understood, you have a central message exchange process. Each client creates a connection to that server process and keeps it connected. This server process acts as the means of message passing between processes. This is just like a lot of MOM software such as stuff from Tibco and BEA, and stuff like JMS. Thus what I mean't by "connected" was that processes maintain a socket connection at all times giving them the ability to route messages to other processes without the cost of creating a connection each time. As with the normal model for using many MOM type packages, so long as processes are up and running, you are ensured that the message will get through to its target. This is done without needing an explicit concept of message queues as active entities are modelled as service objects. Thus, you send a message direct to the service you are interested in and don't need this separate concept of message queues as a proxy. Because message queues aren't used, there isn't any concept of persistance. Ie., that a service can receive messages that were sent when it wasn't running isn't possible with OSE. There isn't actually any reason however that persistent message queues can be added on top of what is there and at some point that may well be done. Having such a feature at the lowest levels just makes implementation complicated. Where as you are coming from an area where every single message may have to be accounted for, even when failures occur, I have come from an area more in the real time data monitoring area. Ie., monitoring telco equipment for the purpose of raising alarms when problems occur. Thus, you tend to be monitoring the current state of things. In such a system, if you had persistent message queues it could actually be quite bad. If a large failure occurred and your monitoring systems went down as well, when it comes back up, you don't necessarily want to then have to process all the historical data before you can get to see where things are right then. Different requirements, different approaches to the problem. In this area, the publish/subscribe features are actually more important than that of request/reply. Personally, I think this idea of using XML-RPC or SOAP over the Internet if you want reliablity isn't a good idea. I believe these protocols can be useful in the setting of a corporate network but within quite constrained ways. If someone tells me they want something which provides gauranteed reliability etc, then I will be the first to tell them to go use software from the likes of Tibco, BEA or IBM. From A.COSICO at CGIAR.ORG Tue Jul 17 20:57:53 2001 From: A.COSICO at CGIAR.ORG (Cosico, Alexander) Date: Tue, 17 Jul 2001 17:57:53 -0700 Subject: pythonscript & asp Message-ID: <7010D1188B34D511824000C04FBCEE3F17B5EA@irriphx2.irri.cgiar.org> Hi to all, I'm quite new to Python. I would like to know if it's possible to run Python (Pythonscript?) within active server pages? We're using Win2k/IIS 5.0 for intranet at work. What do I need to install and configure on our web server to make this work? Could anyone point me in the right direction to some references? Thanks for any info. Cheers, Alex From ajs at ix.netcom.com Wed Jul 18 21:41:10 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Wed, 18 Jul 2001 21:41:10 -0400 Subject: Language change and code breaks Message-ID: <000b01c10ff3$e4e0eca0$a9e1fea9@carol> >I still have the same end goal, but I believe there must be a way to >obtain it without too much disturbance. Case-sensitivity, for >example, may be a tool feature rather than a language feature, or it >may be a user option or a language-level choice. (Not that I've >figured out exactly how to do this, but TeachScheme makes this an >option.) Note that case-sensitivity is also controversial: the Alice >folks found it a problem, but the VPython folks have not confirmed >this (while they did confirm the integer division trap). But it should be noted, in fairness, that neither the Alice or VPython anecdotals were made in the context of teaching programming. VPython's (of which I happen to be a fan) findings were in the context of a class in physics. I don't recall hearing either issue raised by anyone using Python to teach or to learn programming concepts. There have been a number of reports from learning novices - including my own - that the issues are, in context, negligible. Difficult for someone in my position to ignore the hand in front of my face. Guido's more recent post at least gives some insight into his deeper thinking. Seems to me many of us would agree that we prefer a language with a minimum of affection. Many of us feel, I believe, that case insensitivity is such an affection. Guido seems to be saying that he views it otherwise - that it is case sensitivity that is an affect. Which to me is the beginning of a real discussion. Not meaning to be nasty at all, but these issues have been on the table for quite some time - and I do think it a tactical error to try to trump deeper discussion by pointing to selective anecdotal reports from near random sources, taken out of any meaningful context, that happen to support a predilection. Sorry to harp. ART From grante at visi.com Wed Jul 25 12:51:09 2001 From: grante at visi.com (Grant Edwards) Date: Wed, 25 Jul 2001 16:51:09 GMT Subject: maths in programming References: Message-ID: In article , Des Small wrote: >"Native_MetaL" writes: > >> Hello im new to programming and i have some questions about Maths in >> programming >> >> 1 what type of Maths is used in programming > >Very little, in practice. The kind of discrete maths taught in >Computer Science courses is not that widely used in practice. IMO, writing programs is primarily "writing". If you're good at writing, you can program. If you can write clearly and correctly in one language (e.g. English) and understand that language's grammar and syntax, then you can learn to write in another language (even a programming one). >> 2 how good do you have to be at maths to program Not very. >> 3 dose all programing have complex maths No -- very few programs have complex maths. >> 4 are all programmers Expert's with maths >> 5 do you need to be an expert with maths to get Employment in >> programming No -- you need to be an expert at programming, and you need to understand the subject about which you are writing programs. If you write math programs you need to understand math. If you write process control programs, you need to understand process control. If you write telephony programs, you need to understand telelphoney. However, most employers realize that they will need to train new programmers in the application-specific knowlege areas. -- Grant Edwards grante Yow! It's OKAY -- I'm an at INTELLECTUAL, too. visi.com From robin.garner at iname.dot.com Thu Jul 26 21:30:24 2001 From: robin.garner at iname.dot.com (Robin Garner) Date: 27 Jul 2001 11:30:24 +1000 Subject: [OT] Number theory [Was: A use for integer quotients] References: <3B5C5665.8D41D1F1@tundraware.com> <3B5C749A.59F97320@tundraware.com> <3b602afa.930850@nntp.sprynet.com> Message-ID: ullrich at math.okstate.edu (David C. Ullrich) wrote in news:3b602afa.930850 at nntp.sprynet.com: > On Thu, 26 Jul 2001 00:01:15 +1000, "michael" > wrote: > >>> But strictly >>> speaking the Integer 2 and the Real Number 2 are different entities. >> >>So strictly speaking, Z (the set of integers) is not a subset of R (the >>set of reals)? > > Strictly speaking yes, but nobody _ever_ speaks this strictly > (except in contexts like the present). > What I was getting at was that the integer 2 (as an element of the ring of integers) is different to the real number 2 (as an element of a field). As a real number, 2 has a multiplicative inverse, whereas as an integer it does not. (and as an element of Z_5 it does etc etc) As sets (and from the p.o.v. of analysis), Z is a subset of R, but as algebraic entities there is a distinction. Robin From thomas at xs4all.net Tue Jul 17 10:34:14 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 17 Jul 2001 16:34:14 +0200 Subject: ImportError: No module named _socket In-Reply-To: <3B5427B5.5040005@bath.ac.uk> References: <3B5427B5.5040005@bath.ac.uk> Message-ID: <20010717163414.M5396@xs4all.nl> On Tue, Jul 17, 2001 at 11:55:33AM +0000, Iain Hallam wrote: > I've only just started using Python and attempted the default install on > a Solaris 2.6 box here at university. Everything seemed to work OK > (considering I was only testing it by running "Hello World!" type > programs) and the sysadmin kindly installed it system wide. > I've just downloaded the ping modules by Jeremy Hylton, and they import > the socket module. All well and good - it's in > /usr/local/lib/python2.1/socket.py - but the line that imports _socket > fails. Could someone tell me where I can find this module in our > install, please? It should be in /usr/local/lib/python2.1/lib-dynaload/, as '_socketmodule.so'. Chances are it really is there (I assume you're running either 2.1 or 2.1.1) but that the permissions are wrong. This can happen if you have a restrictive umask while installing Python (which is a good idea, granted.) You can fix it by making the files readable for everyone ('chmod a+r *'). The directory should have the right permission already (0755, or 'drwxr-xr-x') I think, but it doesn't hurt to check, of course. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From peter at engcorp.com Tue Jul 10 01:59:51 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 10 Jul 2001 01:59:51 -0400 Subject: BASIC or Python? References: <3d157fa0.0107051904.7ec368b8@posting.google.com> <0t_17.14670$Fk7.131382@news.indigo.ie> Message-ID: <3B4A99D7.5E4935EB@engcorp.com> Rainy wrote: > > On Tue, 10 Jul 2001 02:17:31 GMT, Gerry Quinn wrote: > > In case anyone is fooled, here's an example from the tutorial at > > www.python.org, which also has a FAQ on what Python is for: > > > >>>> for n in range(2, 10): > > .. for x in range(2, n): > > .. if n % x == 0: > > .. print n, 'equals', x, '*', n/x > > .. break > > .. else: > > .. print n, 'is a prime number' > > .. > > > > Now some people may very well find that lovable, but I certainly don't. > > Note how the clever language design means that the 'else' must be > > level-indented with the 'for'. [snip] > > Isn't this an example of how python's indentation is a *good* thing? > > In python, above code causes an error, a programmer goes and corrects it. > No harm done. Actually, harm would be done. The above code is actually correct Python, since some loop constructs such as for and while can take an 'else' clause which executes under certain conditions. Output if a programmer "corrects" the above: 3 is a prime number 4 equals 2 * 2 5 is a prime number 5 is a prime number 5 is a prime number 6 equals 2 * 3 7 is a prime number 7 is a prime number 7 is a prime number 7 is a prime number 7 is a prime number 8 equals 2 * 4 9 is a prime number 9 equals 3 * 3 Output of the uncorrected version: 2 is a prime number 3 is a prime number 4 equals 2 * 2 5 is a prime number 6 equals 2 * 3 7 is a prime number 8 equals 2 * 4 9 equals 3 * 3 On the other hand, using this code as an example of why indentation is a Bad Thing is silly, since most languages against which Python is compared in discussions of block delimiters do not have this kind of 'else' clause... -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From aramanat at optonline.net Thu Jul 5 21:34:44 2001 From: aramanat at optonline.net (Arun Ramanathan) Date: Fri, 06 Jul 2001 01:34:44 GMT Subject: tkinter event object question Message-ID: <3B4540C5.60005ABE@optonline.net> Is there a way by which I can determine which tkinter widget actually generated the event. Example if I had two buttons b1 and b2 initialized as shown below and bound to the event handler callme. ------------------------------- from Tkinter import * root = Tk() def callme(event) print "santa is coming" # is there a way I can find out which button # generated the event in the event handler? b1 = Button(root,text='b1') b1.bind("",callme) b1.pack() b2= Button(root,text='b2') b2.bind("",callme) b2.pack() root.mainloop() ------------------------------ Thanks, Arun From bernhard at intevation.de Mon Jul 2 14:37:06 2001 From: bernhard at intevation.de (Bernhard Reiter) Date: 2 Jul 2001 18:37:06 GMT Subject: PEP scepticism References: Message-ID: <9hqf0i$f1dia$3@ID-89274.news.dfncis.de> In article , writes: >> Maybe I am a hypocritical sceptic, but I have the impression that >> some feeping creatureism is introduced into Python. >> Examples are: >> - augmented Assigments >> - Lists comprehensions >> - Simple Generators >> On the other hand this is excatly the danger I want to warn you about. >> It is a social reason for being careful: >> 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. My editor helps me saving the few more keystrikes, but I found just as with intendation-grouping that I could write better code without augmented assignment. And there are ambigious cases (as discussed elsewhere). > 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. I had a hard time grasping it myself. Do you have teaching experience on this one? > Simple Generators -- this, too, is elegant and simple to > understand. Maybe we should bring in field tests with beginners. :) I feel the other way round, but we probably both are not right persons to judge this. > If we keep your advice in mind, > maybe we can continue that record. Yes, hopefully. 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 guido at python.org Wed Jul 25 16:06:19 2001 From: guido at python.org (Guido van Rossum) Date: Wed, 25 Jul 2001 20:06:19 GMT Subject: PEP0238 lament References: <5sdnlt072hm6hp17nluu6f0fqq4bvr6mj8@4ax.com> <916olt0p3kciv0evmotdg6jev9bl29l57i@4ax.com> <3B5C52EA.9430255E@alcyone.com> <3b5f0a37$1@hpb10302.boi.hp.com> Message-ID: "Daniel Fackrell" writes: > Would this unified number system somehow still be able to provide the > functionality that ints provide with regard to bitwise operations? There > may be other problems that arise as well, but I'm too much of a newbie to > point them out at this time. Yes, all bitwise operations are defined on longs, and they would work the same. This means some semantic changes for << (which loses bits "shifted out" with ints but not with longs) and it would be somewhat difference for negative numbers, but all the basic shifting and masking operations would all be accessible. Also, masking everything with 0xffffffff after the operation should give back the old 32-bit int semantics. --Guido van Rossum (home page: http://www.python.org/~guido/) From aahz at panix.com Fri Jul 27 16:45:09 2001 From: aahz at panix.com (Aahz Maruch) Date: 27 Jul 2001 13:45:09 -0700 Subject: Language change and code breaks References: <3B5DF282.87266DA2@earthlink.net> Message-ID: <9jsjsl$g22$1@panix2.panix.com> In article , Guido van Rossum wrote: > >I have changed my mind. I think that if I had to start over, I would >indeed try my hands at a case-insensitive language aimed at teaching >programming to beginners, with tools to enforce case consistency. >Given that nobody else who currently uses Python thinks this is a good >idea, I then settled on a case-sensitive language with case-preserving >tools. But now I think neither is worth fighting for. I second Terry's comment: I think that if you produced a high-quality toolset, no fighting would be needed. Indeed, that is the measure of the quality of Python itself; for all that we like needling the Perlers, I think there is very little actual "fighting" to drive Python's acceptance in the world. Sometimes good does win mostly on its own merits. -- --- 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 Fortune cookie: Watch your relations with other people carefully, be reserved. From bobh at hslda.org Wed Jul 18 09:25:39 2001 From: bobh at hslda.org (Robert) Date: 18 Jul 2001 06:25:39 -0700 Subject: WINDOWS PROGRAMMING References: Message-ID: <4a249347.0107180525.237e117f@posting.google.com> > How we do "WINDOWS PROGRAMMING" with Python? > - making the windows > - create the controls > - etc > - etc > - etc > HELP... > Please. John Grayson's book is great "Python and Tkinter programming" Mark Hammond & Andy Robinson "Python Programming on Win32" If you go with a different toolkit (Qt, wxPython) then you just have to rought it out with the tutorials given. Mr. Rempt (sp?) is in the process of writing a book on PyQt which will fill that great need. Hope this helps... Bob From steve at lurking.demon.co.uk Sun Jul 29 19:12:56 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Mon, 30 Jul 2001 00:12:56 +0100 Subject: Deposing Dictators References: <9jmjne$q54$1@wisteria.csv.warwick.ac.uk> Message-ID: <8b49mt47r0vfllhedcv0inj10h3pac9k8o@4ax.com> On Sat, 28 Jul 2001 20:28:28 -0700, "Dirck Blaskey" wrote: >Unless you have compelling reasons for using XML, I would suggest >the alternative of using Python itself as the meta-language. > >Maybe I don't fully understand your intended use of XML, but >it gives me a good opportunity to go off on a tangent, as well. >(Hmm... Maybe it's time to change the subject: line?) > >XML is a bit hard on the eyes (quite unlike Python). >I've been using Python as a meta-language, and it's kind of a neat twist. I only see XML as a human readable language as a last resort, I agree. And I *have* used something *based* on Python as a meta-language for some time - I use it to generate source code for scanners, parsers and various data structures for instance. The thing about XML, though, is that it doesn't require Python. After years of Python advocacy, that is suddenly very important. There aren't many good XML editors around, I'll admit, but in principle a tool to edit the XML could be created and I intend to keep the level of tags required to an absolute minimum anyway - rather like a dull HTML page. I have thought of using XML as a more detailed semantic description of source code as well, however. It occurred to me that XML could fairly cleanly represent an AST (ie parse tree), and that with an appropriate set of elements it could be used as an intermediate file for source code translation. That is, create Perl-to-XML and XML-to-Perl and Python-to-XML and XML-to-Perl, and given a standard *semantic* representation in XML you could translate many programs and you could reliably tell where semantics cannot be directly translated. Such a file could also act as the scripting equivalent of an executable, or a (dynamic or static) precompiled library file - you would only need one interpreter regardless of the source language used, and because it explicitly names the semantic a major change of the semantics related to a particular syntax in any source language would be irrelevant. In the context of the current division issue, the XML would simply support 'div', 'integerdiv' and 'realdiv' elements - it's the source codes job to be concise and readable, not the XMLs. The files would be big, but with compression probably no too big. Other benefits of XML are that I get the ability to infer the input files character set and easily work with unicode for free (relevant if Java or Jython source code is used, for instance), and that the parser is already written so I can worry about the logic straight away. Practical editing of large XML files is tomorrows problem ;-) From tim.one at home.com Fri Jul 20 02:00:13 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 20 Jul 2001 02:00:13 -0400 Subject: Distributing a Python app In-Reply-To: Message-ID: [Tim] > FYI, I'm seriously looking at switching the PythonLabs Windows > installer over to Inno ... [David Bolen] > Wasn't there something or other you mentioned it couldn't quite do > that the current Wise stuff does when this last came up? Yes, it couldn't (and still can't) do stuff conditionally on NT/2000 depending on whether the user has Admin privileges. They're required to add HKLM registry entries; the Wise script backs off to HKCU if Admin privileges are required on the box and the user doesn't have them, and pops up a dialog box telling the user that's going to happen, giving them an early chance to abort if that's not what they want. So if we take this route we require Admin privileges; or write to HKCU all the time instead; or ship two distinct Windows installers. no-choice-is-attractive-including-the-status-quo-ly y'rs - tim From aleaxit at yahoo.com Tue Jul 17 04:05:44 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 17 Jul 2001 10:05:44 +0200 Subject: OO misconceptions References: <9ir1l7$3ja$1@panix2.panix.com> <9irfbc11jaq@enews1.newsguy.com> <3B538E16.65394C9D@engcorp.com> Message-ID: <9j0rko025gf@enews3.newsguy.com> "Tim Hammerquist" wrote in message news:slrn9l7a8r.rpe.tim at vegeta.ath.cx... ... > > > My only regret is that so many people in this NG are so violently > > > anti-Perl. I always thought that if someone as cynical, stubborn, and > > > arrogant as I am can love both languages, anybody could. ... > > and (b) the few I might not argue against would likely be "better in > > Perl" only because of some ugly situation such as maintaining > > compatibility with a legacy system, supported by programmers who ... > > Any other application, and I would probably say Python was a > > better choice... > > This is where our opinions (on both languages) differ, and where we > might as well agree to disagree? I wasn't part of this discussion, but since, for once, there does seem to be a chance for a fair-headed, non-flaming comparison, I'd be loath to see it fizzle out with an "agree to disagree" when no technical issues have been discussed (it seems to me). Declaring my bias: I am "violently anti-Perl" myself, mostly because I wrote a *LOT* of Perl code (and helped others write it, and maintain it, and maintained a lot myself, etc, etc). If Python wasn't around, I'd probably still be doing so (and hating it) for lack of viable alternatives. Since discovering Python, I moved to Python all code I had in Perl. When asked for help, advice, &c, about maintaining Perl, studying Perl, &c, my invariable answer today is "do it in Python instead". It seems to me that the niches of applicability for Python and Perl are totally overlapping: I cannot think of application areas where Perl would be preferable, except, I guess, if there were deployment constraints, such as those above-quoted or similar ones (e.g., say you're allowed to use mod_perl but NOT mod_python & similar Apache mods, then it might be unfeasible to do certain things in Python; or, similarly, if there was some crucial module already existing for Perl and it was unfeasible to port it for Python). Similarly, I cannot think of application areas where Python could make sense but Perl wouldn't, except, again, for possible deployment constraints (need to use Jython, or Numeric, etc etc). So what are those "application areas where Perl is clearly preferable to Python", and vice versa, that make it worthwhile to use both languages for new development (not just maintenance of legacy stuff that one prefers not to port)? Are you just referring to deployment constraints ("I'm not allowed to use mod_python but mod_perl IS allowed", &c) or is there something deeper that I'm missing? Alex From jsal at oce.nl Mon Jul 23 04:11:02 2001 From: jsal at oce.nl (Marco Salden) Date: Mon, 23 Jul 2001 10:11:02 +0200 Subject: Any Suggestions for an Editor with MS-Windows ? References: <92757716C8BFF476.D432477A795DB759.E2FB05E062137965@lp.airnews.net> Message-ID: <3B5BDC16.3A348DF6@oce.nl> Try Vim (VI Improved) for Windows. You may find all you need at http://www.vim.org/ . I am using it for about half a year now and before that used Ultra Edit, TextPad etc but wouldn't want to turn back again... Vim supports Python syntax and I think even an embedded interpreter is available for it (not sure...). Good luck, Marco zeke wrote: > Am almost half way through the manual and getting ready for the easy > job of bringing over some basic files (yea, right). Currently using > Ultra Edit but having doubts about it. > zeke From sholden at holdenweb.com Tue Jul 31 16:39:30 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 31 Jul 2001 16:39:30 -0400 Subject: sockets and classes References: <20010731161148.05170.00001954@ng-fw1.aol.com> Message-ID: "TheDustbustr" wrote in message news:20010731161148.05170.00001954 at ng-fw1.aol.com... > Having quite a bit of trouble with sockets and classes lately. I am writing an > IRC bot, heres the trouble code: > > #BEGIN CODE BLOCK > import socket, string, sys, errno, thread > HOST = 'liberty.nj.us.dal.net' > PORT = 7000 > NICK='Dustin2' > REAL='Ima Bot' > QUITMSG='Bye' > IDENT='hacker' > > class Irc: > def __init__(self, host, port): > self.host = host > self.port = port > > def connect(self): > print 'Connecting to %s:%s' % (self.host, self.port) > self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > self.sock.connect((self.host, self.port)) > > def sendcmd(self, cmd): > self.sock.send(cmd) > > irc=Irc(HOST, PORT) > irc.connect() > > print "Sending USER" > irc.sendcmd('USER %s localhost localhost :%s\n' % (IDENT, REAL)) > print "Sending NICK" > irc.sendcmd('NICK %s\n' % NICK) > print "Sending JOIN" > irc.sendcmd('JOIN #Dustin1') > #END CODE BLOCK > > I don't get error messages while executing irc.sendcmd(), but it doesnt work. > I should recieve a response fromt he server after sending USER and NICK, then > another response after sending JOIN. But, I get nothing. Whats up!? > PS: This is my first attempt to program using classes, and perhaps I'm not > doing it right? > You seem to be doing OK, but ask yourself how you would *know* about the response, when nothing in your code actually reads the socket to see what's coming back? In the general case you need to be able to recognise the end of a response, and I don't know enough about IRC to help you with that, but try scattering the odd recv() call in your code to see whether the host is sending responses. The fact that you aren't seeing error messages is at least encouraging! regards Steve -- http://www.holdenweb.com/ From sholden at holdenweb.com Wed Jul 11 11:14:38 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 11 Jul 2001 11:14:38 -0400 Subject: Keys To The Kingdom References: Message-ID: <90_27.41956$F%5.2534438@e420r-atl2.usenetserver.com> "Mike Brenner" wrote ... > Alex wrote: > the code below works on unix (freebsd) and IDLE on win2k, but not python itself > on win2k... > > while 1: > try: > x = raw_input().upper() > print x > except KeyboardInterrupt: > print "Leaving Dodge...\n" > break > > -------- > > This code works for me on Python 2.1 with windows extensions and wxpython, for all 96 graphic characters. Erm, so you're using PythonWin? > > It beeps for all control characters except control c, control z, and control v. > Control c is set up to copy. > Control v is set up to paste. > Control z is set up to undo. > > None of the arrows, control keys, or function keys have any of their special functions or print anything to the little screen that pops up for input. > Was this an attempt at humor which went over my head? If not, try repeating your experiment with the command-line interpreter... Nah, I must just be suffering from SOH failure. :^) regards Steve -- http://www.holdenweb.com/ From bedge at troikanetworks.com Mon Jul 23 14:56:49 2001 From: bedge at troikanetworks.com (Bruce Edge) Date: Mon, 23 Jul 2001 11:56:49 -0700 Subject: int() built-in and hex "0x..." strings References: <20010723.110751.1143408282.18374@troikanetworks.com> Message-ID: <20010723.115544.2086206725.32232@troikanetworks.com> In article , "Marcin 'Qrczak' Kowalczyk" wrote: > Mon, 23 Jul 2001 11:07:57 -0700, Bruce Edge > pisze: > >>>>> int('0x80') > >> Is there another int() type lib func that I should use instead? > > int('0x80', 0) == 128 > int('80', 0) == 80 groan, thanks. -Bruce. From cribeiro at mail.inet.com.br Sun Jul 1 11:55:40 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Sun, 01 Jul 2001 12:55:40 -0300 Subject: data from Acces to Excel In-Reply-To: <3B3E2352.20405.443D2D7@localhost> References: <993876187.1194.36282.l9@yahoogroups.com> Message-ID: <5.0.2.1.0.20010701124151.02762530@mail.inet.com.br> "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? I've done the opposite - importing from Excel to Access. I had to make it using Visual Basic for other boss-related reasons, but it is possible to make it using Python, using exactly the same techniques. I could not use any of the wizards, as some people suggested, because I needed to get data that was scattered in several worksheets to build a single database. Both Access and Excel are able to expose their objects using a very similar interface called DAO, that uses a DB metaphor - you have tables and cursors to walk in them. In the case of Excel, using the automation interface, it is also possible to access all the data using native objects - Worksheets, Ranges and Cells are the main objects. Your job is just to open the Worksheet object, giving commands to get or set the contents of the desired cells using Range objects. All this can be done through Excel's automation interface. The nice thing about doing this in Python is that it is pretty easy to prototype. You can actually do a lot of stuff in the interactive mode, which mnakes development of this kind of tool very easy. Fire up Python, and give it a try. There are some tutorials on the automation feature using Python and Excel; do a search on Google and you'll find them. Carlos Ribeiro From db3l at fitlinxx.com Thu Jul 26 19:52:34 2001 From: db3l at fitlinxx.com (David Bolen) Date: 26 Jul 2001 19:52:34 -0400 Subject: Building a minimal Python 2.2 for Windows References: Message-ID: "Terry Reedy" writes: > "Morten W. Petersen" wrote in message > news:Pine.LNX.4.21.0107261804050.25190-100000 at bcryachts.atsat.com... > > Hia, > > > > I've just tried to build a small Python distribution that will fit > on a > > floppy disc (to do some cleanups on the filesystem without starting > > windows itself); however, the message python22.dll is needed.. > > > > ..now, I've just copied a couple of files from the install > directory, > > files like python22.exe and certain .py and .lib files, can't find > the > > python22.dll file though.. > > > > Any ideas? > > Try /windows/system for python22.dll and python22.lib (don't know if > you need the latter) The python22.dll file will be in the system (or system32 depending on Windows release) directory, but the python22.lib is installed into the "libs" subdirectory off of the Python installation root. And no, you don't need that to run Python - only to link against extensions. However, for the original purpose stated, if you're running this before Windows has been started, then you're most likely in DOS (whether real DOS or a Win95/98/Me DOS 7.x'ish thing), and I don't think the Windows version of Python will run natively there. And at that point, python22.dll isn't the only DLL you're going to need, as it references a bunch of system DLLs. So you may want to look into a DOS Python (there was some recent discussion about it here on the newsgroup). -- -- 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 jerry.olup at gd-es.com Thu Jul 12 09:44:29 2001 From: jerry.olup at gd-es.com (Jerry Olup) Date: 12 Jul 2001 06:44:29 -0700 Subject: 'import' error in csh Message-ID: Howdy all, I am using py 1.5.2 on sunos 5.6. When I run this code (snip below) from csh, I get the following errors: import: command not found badly placed ()'s When I run the code from the interpreter, however, it runs just fine. >>> import xilcorelib Any ideas? I searched the group and found a '97 thread (Strange import error ... how?), but no conclusions therein. # !/usr/bin/local/python import re, string, os # regexp, string handling, system calls # xilinx core library parse script. # # ... other drivel # # file opening and sizing. compfile = open('vhdl_analyze_order', 'r'); outfile = open('xilinxcorelib_comp.tcl', 'w') list_lines = compfile.readlines() linecount = len(list_lines) # Thanks much, Jerry From pih at oek.dk Wed Jul 18 04:21:41 2001 From: pih at oek.dk (Peter I. Hansen) Date: Wed, 18 Jul 2001 10:21:41 +0200 Subject: freeBSD 4.2 + Python2.1 References: Message-ID: <3B554714.EAA32155@oek.dk> Robin Becker wrote: > I'm trying to install Python2.1 and the package seems to install fine, > but it seems that _socket.pyd is linked against libssl.so.2 which I > don't have. Attempts to upgrade openssl are refused as openssl is part > of the 'base' system. Am I really forced to upgrade the whole operating > system? > -- > Robin Becker No, you can just download a new openssl (from openssl.org) and install it. /Peter From gyromagnetic at excite.com Sat Jul 28 20:48:00 2001 From: gyromagnetic at excite.com (gyromagnetic) Date: 28 Jul 2001 17:48:00 -0700 Subject: getting the culprit from an exception Message-ID: <4620daca.0107281647.4a84a5c8@posting.google.com> Hi, I'm a relative newbie to Python. Is it possible to determine the member of a list that caused an exception when using a 'mapped' function? As an example, suppose I have a list of items, some of which may not be numbers and I would like to determine the first one that is not a number. I might use try: new_list = map(float, mylist) except ValueError: print "The item %s in mylist is not a number." % (my_item) How do I get 'my_item'? I realize that I can use "except ValueError, x:" and then perhaps pull a piece out of x.args, but I'm sure there must be a better method. Any help is appreciated. -Brad By the way, I don't have Python handy, so I'm not sure if ValueError would be the proper exception in this case, but it should illustrate the point. From alf at leo.logilab.fr Mon Jul 16 10:30:30 2001 From: alf at leo.logilab.fr (Alexandre Fayolle) Date: Mon, 16 Jul 2001 14:30:30 +0000 (UTC) Subject: Most efficient solution? References: Message-ID: On Mon, 16 Jul 2001 09:19:09 -0400, Jay Parlar wrote: >List B consists of my "stopwords", meaning, the words I don't want included in my final version of list A. So what I need to >do is check every item in list A, and if it occurs in list B, then I want to remove it from the final version of A. My first thought >would be: > >for eachItem in A: > if eachItem in B: > A.remove(eachItem) > You may get some speedup by making B a dictionary, and using has_key() to see if the word is there. This should get you a O(log(n)) instead of O(n) inside the loop. To gain further performance, use filter to skim A. C = {} for item in B: C[item]=None A = filter(lambda e, dic = C: dic.has_key(e), A) Cheers, Alexandre Fayolle -- LOGILAB, Paris (France). http://www.logilab.com http://www.logilab.fr http://www.logilab.org Narval, the first software agent available as free software (GPL). From sholden at holdenweb.com Tue Jul 31 15:20:09 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 31 Jul 2001 15:20:09 -0400 Subject: Arg decoding with a template? References: <4oA97.5883$9i1.519137@e420r-atl1.usenetserver.com> Message-ID: "David Bolen" wrote in message news:ulml5sz7m.fsf at ctwd0143.fitlinxx.com... > Dale Strickland-Clark writes: > > > "Steve Holden" wrote: > > Oh no I didn't. Which is to say, the message would make more sense with the above attribution deleted, since all (now double-) quoted comments are Dale's. > > OK, I've had a good look at this now. > > > > It's hideous! > > > > It's no wonder that people get fed up with computers if they get > > given a user interface that expects pointless dashes all over the > > place. > > > > You simply can't use this routine to code a nice arg string. > > I suppose that's a matter of taste. Certainly in the Unix domain, > from whence this arose, where virtually everything was traditionally > done via the command line, all command line utilities parse their > command lines in exactly this way, it's extremely consistent and > trying to do other manual approaches actually makes the non-conformant > application stand out as such. > I got the impression that Dale was concerned his users wouldn't like the Unix-like command lines that getopt requires. > In effect, such command line parsing is a standard interface, much as > under Windows, there's standard UI elements in its GUI. It's also > (unlike a GUI) designed as much for efficiency and flexibility as > looks. > Yeah, well I'm sure nobody thought otherwise ;-) > You'll find that it's a flexible interface for something that has to > deal with a textual command line. Try designing a CLI parser that has > optional arguments, arguments with and without values even with > multi-character options, spacing and order insensitive, and so on, and > you'll find yourself replicating much of the getopt behavior. > > Personally, since DOS/Windows command line applications never really > formed such consistency (IMO), and at least for me I find "-" less > glaring on the command line than "/", I find the use of a getopt > conformant command line to be nice as well as consistency > cross-platform. > There is, of course, a history for both "-" and "/", and in point of fact TOPS-10 was using "/" for command switches (as ISTR they were called) before Unix was around. Wrote the command line processor for a TOPS-10 SPITBOL compiler, and a switch with a value used a colon separator, as in sbl /code:sixbit myprog.sbl and this usage was later extended to VMS, where it did sterling service for years. It's all a matter of what you're used to, and getopt just proves that people can get used to almost anything ... I suspect, without any evidence, that CP/M, and later MSDOS, used the "\" as a path separator so they could have hierarchical file stores and still use the "/" for switches (options). > I don't know what particular user interface you are looking to serve, > so if you're comparing this to some GUI interface to obtain > parameters, that's not apples to apples. But if you're working > strictly with a command line, I wouldn't necessarily jettison getopt > summarily. > I tend to use getopt because it's there, and it's easier than re-inventing the command line processor. but-that-doesn't-make-it-beautiful-ly y'rs - steve -- http://www.holdenweb.com/ From tundra at tundraware.com Mon Jul 23 15:10:01 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 23 Jul 2001 19:10:01 GMT Subject: A use for integer quotients References: <3B5BC73B.2D52E5E2@alcyone.com>, <3B5BA29B.E08FEEE9@alcyone.com>, <3B5C5665.8D41D1F1@tundraware.com> Message-ID: <3B5C749A.59F97320@tundraware.com> Marcin 'Qrczak' Kowalczyk wrote: > > 23 Jul 2001 17:00:01 GMT, Tim Daneliuk pisze: > > > - This is not "incorrect" arithmetic. *It is 3/4 == .75 that is incorrect* > > because the precision of the result exceeds the precision of the operands. > > It doesn't exceed if the result is a rational. Operands and the result > are all exact here. > > -- > __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ > \__/ > ^^ SYGNATURA ZAST?PCZA > QRCZAK Not formally, AFAIK. For example, 3 with no decimal point following could be anything from 2.5 to 3.4. If I remember correctly, to be fussy about it, you would need to specify 3.00/4.00 to get 0.75 or am I missing something or misremembering my ancient maths courses ;) ? More importantly, the thing everyone is talking about here is an integer operation yielding a real (float) result. Isn't this kind of a "no-no" amongst mathematicians? Maybe I'm wrong here... -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From paul at boddie.net Tue Jul 31 12:12:29 2001 From: paul at boddie.net (Paul Boddie) Date: 31 Jul 2001 09:12:29 -0700 Subject: Python & wxPython on Solaris 2.6 References: Message-ID: <23891c90.0107310812.7af309d6@posting.google.com> "Doug Farrell" wrote in message news:... > I'm not sure where to go from here and I'm looking for some help. Can anyone > direct me on how I might get Python and wxPython to work on the Solaris 2.6 > platform? I'm trying to evangelize at the office to get people to use > Python rather than Unix shell scripts for our scripting programming > language. I managed to get wxPython working on Solaris some time ago, although I no longer use Solaris machines for development work, and I therefore don't know how hard it is to build wxPython for such machines now. You should take a look at the wxPython Web site, and get some advice from the mailing lists: http://www.wxpython.org As for the version of make you use, I found it easier to install GNU make and just use that for most projects. It's not the ideal solution, and I'll confess to using GNU-specific features in my own Makefiles, but at least the documentation is readily available, if somewhat badly structured. Paul From niemeyer at conectiva.com Tue Jul 31 19:03:02 2001 From: niemeyer at conectiva.com (Gustavo Niemeyer) Date: Tue, 31 Jul 2001 20:03:02 -0300 Subject: 2.2 features In-Reply-To: <200107311705.NAA16444@cj20424-a.reston1.va.home.com>; from guido@zope.com on Tue, Jul 31, 2001 at 01:05:06PM -0400 References: <15206.48884.18637.676324@beluga.mojam.com> <200107311705.NAA16444@cj20424-a.reston1.va.home.com> Message-ID: <20010731200302.K19610@tux.distro.conectiva> > > Guido> I love it. 'x in type' as a shorthand for isinstance(x, type). > > Guido> Checked into CVS! > > > > How about 'x in type' as a shorthand for 'issubclass(x, type)' if x is a > > type or class instead of an instance? > > No, that would be ambiguous. A subclass is not an instance. A class > or type represents a set of instances, so 'in' is justified in a > sense. I'm a little bit confused also. A class/type is a set of instances, but at the same time, an instance is built from a set of classes/types, right? This way, what would be correct? "x in type" or "type in x"? -- Gustavo Niemeyer [ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ] From peter.milliken at gtech.com Tue Jul 3 18:25:50 2001 From: peter.milliken at gtech.com (Peter Milliken) Date: Wed, 4 Jul 2001 08:25:50 +1000 Subject: Python for air traffic control? References: <9hlfbn$6ok$1@nereid.worldonline.nl> <9hrj3q$cj1@news1.gtech.com> Message-ID: <9htgsb$ck3@news1.gtech.com> "Russ" <18k11tm001 at sneakemail.com> wrote in message news:bebbba07.0107031040.593143f8 at posting.google.com... > "Peter Milliken" wrote in message news:<9hrj3q$cj1 at news1.gtech.com>... > > Funny, I thought all of the April Fool jokes were out on the 1st April, did > > this one get delayed (badly) somewhere along the line? > > > > Python is a fine language for quick and dirty prototyping. For banging out > > applications that are going to run in an environment where it isn't going to > > matter if the program crashes, but it is certainly not something I would put > > forward for something like Air Traffic Control. > > > > This is a joke, right? > > If that's your idea of a joke, you have a strange sense of humor, but > I appreciate your post anyway. If your claims about Python are even > close to the truth, I need to know. > Well, I indicated that I was hoping it wasn't a joke, so I think it is safe to assume that I don't think the idea of an ATC written in Python funny, I think the rest of my post bore that out, so if you still think I thought it was then I would like you say that you have misunderstoof me :-). Perhaps if you are seriously looking into possible languages to use for writing an ATC then you might be better off looking for some research information about the relative merits of different languages rather than asking a fairly obvious question in a news group that will only be read by adherents of a particular language :-). I say "obvious" here because you will find only Python lovers here. I love Python but I wouldn't use it to write an ATC. The choice of languages for implementing various applications is sometimes extremely suspect. I suspect that often it comes down to something like one or more of the following reasons: "I know X, it is a good language" "I can get programmers more easily in language X than language Y" "We currently have programmers who know language X" I am not necessarily saying that choosing a language based upon the above reasons is wrong, but it is hardly approaching the problem from an engineering standpoint. There is literature available that compares the relative merits of languages. To make an informed decision you really should do some research and find out what information is available to help you make the decision. The more information the better informed the decision. I am sure as an aerospace engineer, you do studies into the various alternatives for your design, why should choosing a programming language be any different? > > > > Based upon Gerrit's observations, which I fully endorse, anybody who doesn't > > use the most strongly typed language they can find for an application like > > Air Traffic Control, has to put it mildly, rocks in their head :-). > > As I indicated in my original post, the lack of type checking does > concern me. However, as I wrote in a later post, I also suspect that > this concern is overblown. I am not a computer scientist or even a > full-time programmer, so I don't pretend to be an expert in this area. > I am an aerospace engineer, and I do some programming in support of my > own research (but I am a Python beginner). > There are studies that indicate that productivity in strongly typed languages is higher (2:1 in one study I read - unfortunately, they are "thin" on the ground because you need two identical ability teams doing the same application in two different languages to get meaningful comparisions - but it has been done and that was the result) than loosely typed languages. > Consider the type checking in C or C++, for example. Suppose that a > function takes several ints (or any other type) as arguments, and > suppose the calls of the function all pass ints in the correct slots. > The compiler will be perfectly happy. Does that assure that the > arguments are passed correctly? Of course not. It is a necessary but > not sufficient condition for correctness. The arguments could be > completely out of order, and the compiler wouldn't have a clue. Agreed, but one of my original points was about programmer ability. A strongly typed language will only *help*, there is no sure fire cure to generate a correct and workable program. Any *help* that you can get from your development environment (strongly type compilers vs loosely typed etc) will at the end of the day provide more chance that your application will be successful. There is no one single factor that anyone can point to and say "if you do that or use this" then you will be successful in your application. Witness the efforts in quality control/CMM around the world. These are all attempts at providing an infrastructure that will increase a projects chances of being successful, nothing else. Unfortunately, language choice is a very sensitive issue, and generally doesn't come down to any rational factors - a lot of times it is "because I like it" or "this is the newest, popular language, if I learn that one then I can enhance my employment prospects" :-). Of course, you *could* write an ATC in Python. You could write one in assembler too, but nobody is offering that up! So, I beleive the same reason you wouldn't write an ATC in assembler applies to why you would write one in Python - there are better tools for the job. That's all I'm trying to say here. Python is a good language. All languages have their strengths and weaknesses. Some are better than others for different application domains. Python is not a good choice for an ATC :-). > > Now consider argument passing by keyword in Python. The order of the > arguments no longer matters. Sure, the wrong type of arguments could > still be passed in, but it seems to me the probability is less than > getting the wrong object of the right type in C++. In C++, the > complier only checks the type of the argument, but Python checks the > actual NAME of the argument. The name is more specific than the type. > This assumes that your coding standing inforces passing arguments by name - just try staffing an ATC project and enforcing a coding standard. There will be many programmers who "don't like the standard" and will do anything to get around it. You generally catch these people through code review only and often too late! :-). Python doesn't enforce this, personally I believe it is a good feature and I use it frequently - but not all of the time :-) > In C++, the function calls all get checked automatically at compile > time, but Python doesn't check them until run time. That is a valid > concern, but hardly a show-stopper. I understand that PyChecker can be > used for static checking. I actually think the core Python language > should have an option to do static checking, but as long as some > product is available to do it, the issue is not major. > PyChecker is still very imature and some things it will never (poor word to use, since if someone wants to put in the effort, nothing is impossible :-)) be checked by it. It will only ever be an aid. The ability of Python to dynamically "change its behaviour on the fly" is one of its strengths but also a weakness from the point of view of ensuring correctness and reliability in such an application domain. > > Don't get me wrong, Python is a nice language and you could probably do the > > job with it with enough time and effort. But as an earlier respondent said, > > you would literally have to test it to death and then some! i.e. because of > > the lack of type checking there could be a single line of code somewhere > > that has never been run that could cause catastrophic failure of the > > application (architectural design *might* mitigate this but it gets back to > > the people factor - something I don't trust :-)). At least with a strongly > > typed language, even if a line of code has never been run, you are > > reasonably assured that when it does run it won't crash due to a variable > > being mispelled or mis-used. > > As I said, static type checking is a must, but it can already be done > in Python. So I think your concerns, although valid, are way > overblown. By the way, people in the commercial software industry have > no idea about the amount of testing that will go into the ATC > application we are talking about. Their concerns are completely > different, of course. If they tested their software even one-tenth as > much as this application will be tested, they'd go out of business. I > get a kick out of people who think that a few programmers can hack out > some code and just slap it into an operational ATC system (not to > imply you think that, of course). As I said above, static checking is not possible (unless I missed something? always happy to be corrected :-)), so my concerns are not "overblown", but as you say, "valid". I have worked in the defence industry for almost my entire career (many of our "commercial" friends just blew big raspberries here :-)), so I am under no allusions as to the amount of testing done in either the commercial world (where I am now) or the aerospace world :-) Personally I am happy with the amount testing done in the commercial world - good job security, they need legions of maintenance programmers :-). The defence companies have been leaving my local area, so rather than move with them I looked for the place with the highest prospects of job security - found it in maintaining a system that was written in C - lots of work! :-) > > > Of course, I could at this point say I would never venture into air space > > controlled by such as system, but I know it would never get off the ground > > (so to speak :-)) because to do it in Python would mean it would never pass > > acceptance testing - sure you could code it just as fast (if not faster) > > than most other languages used for this application area but you would be in > > the test phase forever - or at least until the customer cancelled the > > contract :-). So keep dreaming :-) > > You may be right that Python is not the right language, but I don't > think you've made a convincing case. > > Russ Well, if you need more information, email me directly Russ - I'm more than happy to help. The issue can be confusing with all of the Python lovers on the list :-) Goodluck, Peter From chrishbarker at home.net Thu Jul 5 14:47:22 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 05 Jul 2001 11:47:22 -0700 Subject: Time for a Python "distribution" ? was:Not enough Python library development References: Message-ID: <3B44B63A.BB507CBF@home.net> Hi all, I've been thinking about this for a while, and been meaning to post, but this thread got me rolling again. It seems many folks are faced with the same problem I have, which is that my programs rely on a number of modules that are not part of the standard library. For example, I recently upgraded to 2.1, and had to download and install: Python, Numeric, mxTools, wxPython, and PIL. I needed to do this for both Linux and Windows, and might have to do the Mac soon (no wx yet :-( ). Guido had made it pretty clear that merging all these modules (and more) into the standard library is impractical for a number of reasons. Unfortunately, not having all the major modules available for a single source really is a big limitation. Not only do people like me have to spend a whole lot more time installing stuff, developers are limited as to what they can expect a Python installation to include. This means that you either don't use what would be a useful module, or you are faced with distributing a bunch of extra stuff with your module or program. An example is the Numeric package: there have been re-writes of tkPlotCanvas so that "it doesn't require Numeric", and wxPython is unable to include some nice optimizations for receiving data from Numeric arrays because Robin doesn't want to have another dependency his users will need to deal with. My proposal is to create a Python "Distribution" that includes a large collection of what are becoming standard modules, but are maintained by folks other than the core Python team. I'm modeling this idea on the Linux Distributions: the kernel developers don't make any effort to package up Linux as a useful system; other organizations do that. There are now a lot of them, and some are substantial commercial enterprises, but it all started with SLS and then Slackware, etc. It really wouldn't even be that much work: Each of us has already done it for our own systems. Put a small group together, get a web site, and we'd be rolling. I'm really not looking to do anything more extensive than the old "Python on Linux" pages, except that it wouldn't be just Linux, and we would try to maintain a fairly constant list of supported modules. I'd be willing to do some of the coordinating, and maintain at least a portion of the Linux section. I could even offer some of my personal web space, but it probably should be on Sourceforge or at python.org, or something central with a catchy title. The short version is that I'd like people to be able to say that their program or module runs on "Comprehensive Python 2.1", which can be downloaded from "http://ComprehensivePython.org". At that web site would be a easy way to download a whole package for a couple of flavors of Linux, Windows, Macintosh, other *nixs, etc. If there is a least a small group of people interested, send me a note, and lets get started on the organization details. -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 rcameszREMOVETHIS at dds.removethistoo.nl Thu Jul 26 11:00:07 2001 From: rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz) Date: Thu, 26 Jul 2001 15:00:07 GMT Subject: Changes for easy recognition of 3.0 demos and examples References: <3b5fb4e8.441629229@wa.news.verio.net> Message-ID: Bengt Richter wrote: > Some possibilities... > > 1. spam should be replaced in all contexts by spom > 2. it's just resting. > 3. '/' should be pronounced 'over' or 'zorro' > 4. '//' should be pronounced 'swish' or 'clang' > 5. foo, bar, baz may be rendered oho, aha, znord > 6. ... > 6. 'Luxury Yacht' should be pronounced 'Throatwobbler Mangrove' Robert Amesz (still wondering how you missed *that* obvious one...) From JamesL at Lugoj.Com Wed Jul 25 11:44:11 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Wed, 25 Jul 2001 08:44:11 -0700 Subject: Threads in Python version 1.5, thread doesn't start until calling process dies References: Message-ID: <3B5EE94B.1EBA28FF@Lugoj.Com> That does look odd. What operating system are you using? And when you say 1.5, do you mean 1.5 or 1.5.2? Ken Tabacchi wrote: > > I am having some trouble with a threadded process in Python version > 1.5. It seems that the thread does not start until the calling > process has died. The thread starts immediately when the following > program is run under Python version 2.1. [ Elided. ] From chat at linuxsupreme.homeip.net Mon Jul 2 13:06:54 2001 From: chat at linuxsupreme.homeip.net (Chad Everett) Date: 2 Jul 2001 12:06:54 -0500 Subject: Python--eclectic or ubiquitous References: <5174eed0.0107020747.6836d160@posting.google.com> Message-ID: On 2 Jul 2001 08:47:06 -0700, Edward Wilson wrote: > > I have decided to troll the comp.lang.python group. Will you help me? > Please don't feed the trolls! -----= 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 Mon Jul 16 09:21:49 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 16 Jul 2001 09:21:49 -0400 Subject: connect in SMTPlib References: Message-ID: Look in the Vaults of Parnassus, and use timeoutsocket to handle such scket timeouts in a more friendly way. regards Steve -- http://www.holdenweb.com/ "Rajkumar S." wrote in message news:mailman.995224946.25425.python-list at python.org... > Hi all, > > I am writing cgi program to send a mail of all the selection made by > the user to admin. The from addr and to addr are fixed in the script. > One of the probable error that I see is that of the SMTP server being > down. Their are no exceptions defined for the connect(). So the script > bombs when the connect fails and gives the 500 error. > > Can the script be made more robust esp when faced by a down SMTP > server? > > raj > > #!/usr/local/bin/python > import smtplib > import string > import cgi > > fromaddr = "xxx " > toaddrs = "xxx " > > thankyou = '''Content-Type: text/html\n\n > > Thank You! > > Thank you !! > > ''' > > error = '''Content-Type: text/html\n\n > > We are sorry > > We are extremely sorry that an error had occured while sending mail. > ''' > > form = cgi.FieldStorage() > formkeys = form.keys() > > > > > msg = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % (fromaddr, toaddrs, order)) > line = msg + line > > server = smtplib.SMTP('localhost') > > try: > server.sendmail(fromaddr, toaddrs, line) > except smtplib.SMTPException: > print error > server.quit() > server.quit() > print thankyou > > From duncan at NOSPAMrcp.co.uk Wed Jul 25 06:42:40 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Wed, 25 Jul 2001 10:42:40 +0000 (UTC) Subject: Language change and code breaks References: <9j7gv8$9mg@dispatch.concentric.net> <3B5DF101.9B2E4631@earthlink.net> Message-ID: Guido van Rossum wrote in news:cpofq9a858.fsf at cj20424- a.reston1.va.home.com: > > But never mind, I'm giving up on making *Python* case-insensitive. > The hostility of the user community is frightening. I think at this point a polite 'thank you' is due from the user community. It might be an idea though to change some of the error messages when a NameError or AttributeError is uncaught if a name could have matched with different case (although I'm not sure how much overhead this might cause). NameError: name 'x' is not defined could become: NameError: name 'x' is not defined, nearest match was 'X' or AttributeError: C instance has no attribute 'Foo' could become: AttributeError: C instance has no attribute 'Foo', did you mean 'foo'? -- 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 michael.g.abbott at ntlworld.com Wed Jul 25 09:34:47 2001 From: michael.g.abbott at ntlworld.com (Michael Abbott) Date: Wed, 25 Jul 2001 13:34:47 GMT Subject: PEP0238 lament References: <3B5B37B9.4D7A80CD@Lugoj.Com> <3B5E1E79.A5C8CEF6@engcorp.com> Message-ID: Peter Hansen wrote in news:3B5E1E79.A5C8CEF6 at engcorp.com: > Michael Abbott wrote: >> > > You've forgotten the *one* type of programming which appeared > (at least to me) to be the inspiration for this in the first place: > > 4. Newbie programs > Mmm. True. However, a point that was made earlier (which I think you're agreeing with) was that the real future of Python rests on its professional use. I'm all in sympathy with helping the beginning programmer, but to be honest I think there are only two sensible options: 1. Let beginners start with a simplified language. My fourth programming language (after some weird version of BASIC on data entry sheets, FORTRAN and BCPL) was ALGOLW, which can only be described as crippled, and Pascal was written with a similar intent. These are quite good teaching languages. 2. Let beginners fight with a real language. Depends on who they are and what help they can get. I'm not a great fan of dumbing down a real language to help beginners (unless it's a run-time option, which in reality is switching on option 1). This little diatribe is really aimed against the case folding proposal. Of course, I'm not a teacher, I'm paid for writing software, so this may affect my opinions :^) From s713221 at student.gu.edu.au Thu Jul 26 07:15:16 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Thu, 26 Jul 2001 21:15:16 +1000 Subject: int(a), b = divmod(x, y) References: Message-ID: <3B5FFBC4.D67DB7@student.gu.edu.au> Bruce Sass wrote: > > How nasty would it be to allow one to do... > > >>> int(a), b = divmod(5.01, 2) > >>> print a, b > 2 1.01 > > ...instead of the current... > > >>> int(a), b = divmod(5.01, 2) > SyntaxError: can't assign to function call > > On the surface, it looks as simple as postponing the function call > until after the assignment. Would it be a one-time hit when the > pseudo-ops are generated, a runtime performance issue that would > affect all function calls, just too hairy to implement, or something > else? > > - Bruce Others have given reasons why/why not. Would this do what you wanted to do? a = int(divmod(5.01,2)[0]) Or are you specificially after integer a, with b at the same time? -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From robin at illusionsexeculink.com Tue Jul 3 08:47:03 2001 From: robin at illusionsexeculink.com (robin at illusionsexeculink.com) Date: Tue, 03 Jul 2001 08:47:03 -0400 Subject: Template processing References: Message-ID: <9ef3kt84nrhb33lhf2jn9hrqij5v07d44p@4ax.com> Lutz Schroeer wrote: > I want to do some _simple_ template processing. Which is the best package to > use (except Zope and except writing it myself ;-))? Don't know about "best" but my Wasp gives you functionality like ASP/JSP/PHP with the ability to either pre-compile templates into static HTML or dynamically compile them through CGI. New enhancements come out approximately monthly. Version 1.24 is stable and available here: http://www.execulink.com/~robin/wasp/readme.html Works cross-platform, cross-OS, and cross-version (minimum 1.5.2). Hope it fits the bill. ----- robin robin at illusionsexeculink.com media artist / remove illusions to reply information architect www.execulink.com/~robin/ Isolation tank paves way to execute an attack. From roy at panix.com Mon Jul 9 10:53:32 2001 From: roy at panix.com (Roy Smith) Date: 9 Jul 2001 10:53:32 -0400 Subject: Confusion about dictionaries - keys use value or identity? References: Message-ID: <9icghc$8er$1@panix6.panix.com> Tim Peters wrote: > The good news is that this part isn't true: all versions of Python have > always maintained an internal compiled-regexp cache, mapping regexp strings > to their compiled forms, much like the one you sketched building "by hand" > later. Current Python maintains a cache of 100 pairs. Wow, that's awesome. You might want to update the library reference to mention this. It would keep people like me from running off on pointless efficiency-hack tangents :-) > The great *advantage* to this is that you wouldn't be so reluctant to > exploit re.VERBOSE mode if the regexps were compiled at module > level. I've never tried VERBOSE mode; I'll give it a shot, thanks. > There's one huge difference: FORMAT statements were identified by > meaningless integers Meaningless? Whatcha talking about? We used to encode all sorts of meaning into the line numbers. The 1100's would be one kind of input, the 1200's would be another, and so on. If you want meaningless line numbers, did you ever try ratfor? :-) From peter.milliken at gtech.com Tue Jul 3 19:07:12 2001 From: peter.milliken at gtech.com (Peter Milliken) Date: Wed, 4 Jul 2001 09:07:12 +1000 Subject: Python for air traffic control? References: <9hrj3q$cj1@news1.gtech.com> <9hrnub$9a2$1@panix3.panix.com> <9hsu54$t38$1@panix3.panix.com> Message-ID: <9htjhb$ck4@news1.gtech.com> > >> > >>Suppose that the only language choices are between C/C++ and > >>Python, and that the real-time resolution requirement is on the > >>order of one second. Which would you choose and why? > > Sorry, won't answer because it is not a realistic situation i.e. the choice wouldn't be between C/C++ and Python :-). > >The one thing about Python that would give me pause is the > >dynamic memory management. But, I'd have the same concerns if > >the C/C++ program used malloc/free. > > Precisely. Actually, I'd have greater concerns with C/C++, because at > least in Python I'd have a reasonable degree of confidence in what > happens when memory gets exhausted. The language specifications for safety critical applications almost always (I say that because I have only seen a couple :-)) preclude the use of dynamic memory constructs altogether! They do this because of the concerns you express. Peter From ancientorder1 at nocrap.home.com Mon Jul 2 23:52:17 2001 From: ancientorder1 at nocrap.home.com (john-g) Date: Tue, 03 Jul 2001 03:52:17 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: I want to see if I am doing this right... This is some simple text extolling the wisdom of usenet trolls. This is my new signature: ***** This was posted with the express permission of ***** ********************************************************** ** HIS HIGHNESS BRENT KOHLER LORD AND MASTER OF USENET WHILE HE WAS GIVING ME A HUMMER ** ********************************************************** *********** He is a simple servant of my phallus (it's small but bugger than his) *********** ---- am i doing this right? thanks, -- to send email to me remove "nocrap." from my address From chrishbarker at home.net Tue Jul 24 19:38:55 2001 From: chrishbarker at home.net (Chris Barker) Date: Tue, 24 Jul 2001 16:38:55 -0700 Subject: Backward compatibility environments (was Future division patch available) References: <9jfjd6$ad4$2@newshost.accu.uu.nl> <7u6nltoqdnqjjdiquu6ngtaruflhvbvdl5@4ax.com> <23891c90.0107230531.4fb02b12@posting.google.com> <3B5DEA88.553AF758@home.net> <3B5E003B.B242DC35@alcyone.com> Message-ID: <3B5E070F.681F0979@home.net> Erik Max Francis wrote: > Agreed. Let's try categorizing the Python environments which will have > different ramifications for a backward-incompatible change: > > 1. First and easiest is code that is in active use which can be changed > in place after an upgrade to Python 238 (what I'll use to refer to a > version of Python which implements PEP 238 and/or requires PEP 238's > semantics). > > 2. Code that is established and in long-term use which is not in active > use but which still has resources that can be thrown at it to update it. > > 3. Code that is established and in longer-term use but which is not in > a position to be fixed by the original engineers, either because it has > been passed around repeatedly or because it is, say, at a client side > that no longer has any contact with the original company (presumably > because pre-238 Python has been so reliable that there was no need :-). > > 4. Code which may be in use and up to date but which is not trivially > available in editable source form and/or from which compatibility > warnings may not be easily found, such as stowed in a database or in > > 5. Code running in very special environments in which the ramifications > of PEP 238 may not even make sense. What does always-float division > mean on an architecture that does not support floats of any kind (say, > on an architecture with no FPU and with limited space so that software > emulation was deemed wasteful)? You forgot: 6. Code taht is being curretnly maintained, but which needs to run on both old and new versions of the interpreter. -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 stroeder.com Thu Jul 5 05:42:55 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Thu, 05 Jul 2001 11:42:55 +0200 Subject: Python for air traffic control? References: <9hlfbn$6ok$1@nereid.worldonline.nl> <9hrj3q$cj1@news1.gtech.com> <9htebs$ck2@news1.gtech.com> <9i0cjt$ck9@news1.gtech.com> Message-ID: <3B44369F.5521A9A7@stroeder.com> Peter Milliken wrote: > > Many programmers, when they first meet a strongly typed language (such as > Ada, but there are others) have a great deal of difficulty, because they are > used to having a lot more "freedom" from the languages they are used to. But > once you get past the barrier of producing correct code then it offers a > great freedom - 90% of your "typical" bugs are found by the compiler at > compile time rather than during unit testing :-). I always try to explain this to C/C++ freaks which even blame Java being too strict. These discussions usually ends with their "hacker attitude" shining through. I once read a statistic that 80% of the german car drivers think of themselves that their capabilities as a driver are above average. That's also the problem with "real men" programming e.g. C/C++. They think of themselves they are above average... Ciao, Michael. From rnd at onego.ru Thu Jul 12 13:31:44 2001 From: rnd at onego.ru (Roman Suzi) Date: Thu, 12 Jul 2001 21:31:44 +0400 (MSD) Subject: Can anyone offer a suggestion? In-Reply-To: <9ikgpq$j1cff$1@ID-11957.news.dfncis.de> Message-ID: On Thu, 12 Jul 2001, Emile van Sebille wrote: >I've been writing a business math class that allows for multiple precision >accuracy, and in testing stumbled on this behavior: > >>>> from BNum import BNum as bn > >>>> ab = bn('1.2340000') >>>> cb = bn('123.45') >>>> ab >1.2340000 >>>> ab * cb >152.3373000 >>>> (ab*cb).disp(2) >'152.34' >>>> print '%8.2f' % ab*cb >151.84 >+++++++++++++++++++++??????! What about putting parens around ab*cb? print '%8.2f' % (ab*cb) >>>> print 1.234 * 123.45 >152.3373 >>>> print ab*cb >152.3373000 >>>> print float(ab*cb) >152.3373 >>>> print '%8.2f' % float(ab*cb) > 152.34 >>>> print '%8.2f' % ab*cb >151.84 >>>> print str(ab*cb) >152.3373000 > >How is the argument being coerced for inclusion? I would have thought >float(), but apparently not. > >Any hints appreciated. (Otherwise I'll have to try to find it in the >source! ;-0) Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Thursday, July 12, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Misfortune: The kind of fortune that never misses." _/ From com-nospam at ccraig.org Fri Jul 20 14:21:19 2001 From: com-nospam at ccraig.org (Christopher A. Craig) Date: 20 Jul 2001 14:21:19 -0400 Subject: Case insensitivity In-Reply-To: <3B5867E8.6B8751F8@Lugoj.Com> References: <3B5867E8.6B8751F8@Lugoj.Com> Message-ID: <87bsmfsbq8.fsf@elbereth.ccraig.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 James Logajan writes: > Well, if you "correct" that to myVaraible you would still be in error, > because you accidentally exchanged "ia" with "ai" in addition to changing > "V" to "v". Python will not inform you about about some typos, whether > case-related, dropped characters, exchanged characters, or added characters. Actually, he intentionally exchanged "ia" with "ai". If you re-read his post you will see that he was describing a programming method by which he finds typographical errors by intentionally using upper case in variable names and typing them in lowercase when he uses them. He then expects the IDE to change his case and knows that he made a typo if it doesn't. I'm not sure this is all that useful of a programming paradigm (I wouldn't want to use ugly MixedCase just to find errors faster), but it would not be supported by any current Python IDE I know of. - -- Christopher A. Craig "How does a project get to be a year late? - -- One day at a time" - Frederick Brooks, Jr. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: Processed by Mailcrypt iEYEARECAAYFAjtYdp8ACgkQjVztv3T8pzupFQCfchm3Ru5NTkGUYEmc4n+tvDJe O88AnjGYXQBi0Ue+f+qtTnwzrPlgrhIT =YYVf -----END PGP SIGNATURE----- From mcherm at destiny.com Wed Jul 18 14:01:00 2001 From: mcherm at destiny.com (Michael Chermside) Date: Wed, 18 Jul 2001 13:01:00 -0500 Subject: Language change and code breaks Message-ID: <3B55CEDC.69C25977@destiny.com> Roman (ironicly): > > Windows is case-insensitive and thus "easy to use" only before one needs > > to put web-pages on the real (UNIX) web-server. Then they understand all > > the troubles with mised case, national-charset filenames, abbr~ted > > filenames, local file references "C:\Mydocs\lalala", bmp-images etc. GvR: > But it's still open for debate whether the problem here is Windows or > Unix! > I'm very surprised to hear this. Yes, I've taught lots of beginners, and I've found that they often complain about the case sensitivity. But I tell them that "Computers are EXTREMELY literal", and "you must be VERY precise when programming", and they get it. I also get complaints (not so many) about the computer not understanding a mis-spelled system call. It seems to me that whether the language requires case sensitivity or not, it is still very poor style to vary the capitalization of a given identifier. It's kind of like indentation... and (in Pascal, C, Basic, and other non-Python languages) I mark my student's programs WRONG if they don't use consistant indenting. Don't encourage sloppy habits: require case sensitivity. Besides... if you make identifiers NOT case sensitive, then when they try opening files or URLs and find that those ARE... they'll REALLY have problems. -- Michael Chermside From oliphant.travis at ieee.org Tue Jul 10 18:59:55 2001 From: oliphant.travis at ieee.org (Travis Oliphant) Date: Tue, 10 Jul 2001 22:59:55 +0000 Subject: getting argument names from a function References: <6%F27.4784$yh2.453987@weber.videotron.net> Message-ID: <9igmbt$akk$1@news.xmission.com> > On Tue, 10 Jul 2001, dan wrote: > > > def aFunction(arg1, arg2): > > print arg1, arg2 > > > > is there a way I can get to the arguments of aFunction (i.e. 'arg1' and > > 'arg2')? > > > > I've tried dir(..) on the function object and subsequent object and > > can't find what I'm looking for. Is it possible to do what I want? > > In Python 2.1 the inspect module provides easy access to the introspection facilities of Python. >> apply(inspect.formatargspec, inspect.getargspec(aFunction)) will return aFunction(arg1, arg2) I just found this facility myself and am using it to add a simple help command to SciPy (www.scipy.org) -- Travis Oliphant, Ph.D Assistant Professor Electrical and Computer Engineering Brigham Young University Provo, UT 84602 (801) 378-3108 oliphant.travis at ieee.org From phillip at transwitch.co.za Mon Jul 30 10:11:35 2001 From: phillip at transwitch.co.za (phillip) Date: 30 Jul 2001 07:11:35 -0700 Subject: switching between frames Message-ID: <74cc9702.0107300611.7ae0c578@posting.google.com> Hi, I have a GUI that displays the contents of a properties file and allows for a user to edit the values and rewrite the file. But I have more that one file and want to display the values on a frame and then click a button to display the contents of the other file. When I try to insert the new labels and entry widgets they just append themselves to the previous frame. I also tried to start up new frames, but they just layered themselves on top of each other. Is there a way to set the visiblity of the frames so that i can control which frame a user is seeing? Phill From qrczak at knm.org.pl Mon Jul 23 17:48:57 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 23 Jul 2001 21:48:57 GMT Subject: A use for integer quotients References: <3B5BC73B.2D52E5E2@alcyone.com> <3B5BA29B.E08FEEE9@alcyone.com> <3B5C5665.8D41D1F1@tundraware.com> <3B5C749A.59F97320@tundraware.com> <415pltcn73cga0lmvtmgdn3vb02f7d28kr@4ax.com> Message-ID: Mon, 23 Jul 2001 22:34:07 +0100, Stephen Horne pisze: >>No no no. '3.' i.e. a floating point number with that value could be >>anything in that range. '3' means exactly the integer 3, no approximation >>at all. > > A mathematician is free to use '3' to represent a real - the fact that > it is real is implicit in the context. Compilers and interpeters > aren't able to determine that, so integers and floats have different > notations even when the represent equivalent values. When we are considering exactness, value is not the only thing that matters. 3 and 3. have the same value and the primary difference is that 3 is integer, discrete, exact, where 3. is real, analog, continuous, fuzzy. > We can't exactly match mathematics here, but we don't have to go so > far as having different symbols for integer and float division - > mathematics uses the same set of symbols for both operations allowing > the context choose the operator. I've never seen / as integer division in mathematics. The only notation I know is | a | | - | |_ b _| i.e. floor(a/b). Even an operator for modulo is rarely used at all. More common are congruences x === y === z (mod m) where === denotes three horizontal lines. If modulo is used directly, it's 'x mod y'. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From tjreedy at home.com Sat Jul 28 18:42:09 2001 From: tjreedy at home.com (Terry Reedy) Date: Sat, 28 Jul 2001 22:42:09 GMT Subject: Language change and code breaks References: <9j7gv8$9mg@dispatch.concentric.net> <3B5DF101.9B2E4631@earthlink.net> Message-ID: <5dH87.41002$EP6.10002172@news1.rdc2.pa.home.com> "Terry Reedy" wrote in message news:wdo87.35525$EP6.9091573 at news1.rdc2.pa.home.com... stuff that was not completely clear. The following is a completely re-writen replacement. Deletion Criteria, v.2 On 2001 July 10, I classified changes into deletions, additions, and replacements. The functional definition of a deletion is that it breaks code in the forward direction only (some old code no longer works, new code works even under old language rules [1]). Similarly, additions break backwards, replacements in both directions. Pure deletions in Python have been rare; 'access' removal is the only one I have noticed. I propose that a feature should only be deleted (without a more than compensating replacement) when it is rarely used and not considered useful even when it is. 'Cleanup' and the like seem insufficient reason to break code more than rarely or to eliminate a useful construct. Some few days thereafter, Guido injected into the discussion a proto-proposal to delete case sensitivity from Python. This proposal soon dominated this thread. If the implementation were to reject names that differ only in case from a previously bound name, it would be a program-history-dependent deletion. If it were to forbid one case from all names, it would be program-independent. If the implementation were to treat upper and lower case as the same, the change would be a semantic substitution that adds the 'feature' of seeing all 2**len case variants of a spelling as the same word. This identification would mute the breakage of old code by shifting its overt appearance elsewhere, if anywhere. It would also introduce breakage in the reverse direction. While it would sometimes be correct in new code, and therefore maybe a benefit, it would also sometimes be wrong, even in new code. The resulting non-identification of a bug at its point of introduction would be a detriment. To me, turning the deletion into replacement by adding buggy intent inference makes it even worse. So I discount this alternative. Since Guido appeared to accept the content of my essay and then proposed something that to me strongly violates a seeming obvious guideline contained therein, I was and am puzzled. I first conjured the idea that the proposal was a troll designed distract attention from the division proposal while he finished 2.2a1 and rewrote the PEP. Since that seems false, I think maybe he and others might actually have a less stringent guideline for deletions. Or maybe I have altogether missed some subtle, non-obvious-to-me point to the proposal. If the second idea is true, I invite presentation of such alternative deletion criteria for discussion. For the purpose of such a discussion, I suggest setting aside the controversial case proposal (which is *not* the prime focus of this posting) and using a hypothetical such as the following: ''' PEP: Deprecating Underscore In natural language, underscores (underlines) are usually seen as text decorations or space markers rather than as characters in themselves. Thus, their inclusion with letters and digits in names is confusing to beginners and jarring to some experienced programmers. In private and class magic names, the jar serves a purpose. Not so in normal public names. A. The intermittant appearance of _ in commonly used built-in function names (has_key, raw_imput, but {get/set/has}attr) is especially problematical. Because _ has no pronunciation, it is easy to omit when thinking, speaking, and writing. How many Pythoneers actually think or say 'has underscore key' instead of the buggy-when-written 'haskey'? So lets remove _ at least from built-in function names. B. (Radical alternative) Lets go all the way and delete _ from all public names. This will, in effect, remove 'underscore sensitivity' from Python by ceasing to distiguish between '' and '_'. Objection: Even moderate proposal A would break lots of code. ''' What deletion criterion should any such proposal meet to overcome the objection and be accepted? What burden-of-proof should it meet? Terry J. Reedy [1] For this article, at least, this definition views a program as including all modules that it depends on, including those normally bundled with the interpreter as built-ins. 'Back-compatibility' assumes that a program is carried back intact. In practice, this may mean wrapping an old version of a built-in to make it look like the new version the program expects. When identifiers change, it will mean so. From stepken at little-idiot.de Wed Jul 11 07:31:38 2001 From: stepken at little-idiot.de (Guido Stepken) Date: Wed, 11 Jul 2001 13:31:38 +0200 Subject: Is Python Dead? Long Live Python! References: Message-ID: <3b53fda0$0$151$9b622d9e@news.freenet.de> Kemp Randy-W18971 wrote: > So an interesting question is raised. If PHP and Ruby are gaining > acceptance because they address business needs, what needs to be done to > carry Python in that direction? And while Java may be slow, Sun pushing > it > for business solutions also gives that language acceptance. How can > Python become as popular as Perl, Java, or PHP? I have been teaching python to kids ...12 years old .... they really had fun ... that's the (only) reason for the extreme growing acceptance for python over java or perl or php .... python will be #1 in 2 years .....expecially for huge projects .... reards, Guido Stepken From christopherjmcmillan at eaton.com Mon Jul 9 17:01:29 2001 From: christopherjmcmillan at eaton.com (Chris McMillan) Date: Mon, 9 Jul 2001 17:01:29 -0400 Subject: File processing Message-ID: <9id5p9$8r62@interserv.etn.com> Hello all! I'm trying to write a script that will open a file, delete the first line, and then save the file with the same name. Can someone please point me in the right direction? Thanks! Why am I doing this you may ask: I have tens of data files that I need to strip the first line before I can process it in Matlab. So, I dream of a script that opens every file in a directory, deletes the first line, ..... Thanks, Chris From alf at pisces.logilab.fr Mon Jul 30 09:53:39 2001 From: alf at pisces.logilab.fr (Alexandre Fayolle) Date: Mon, 30 Jul 2001 13:53:39 +0000 (UTC) Subject: ANN: xmldiff 0.1.1 Message-ID: Hi, Logilab released today our first beta of xmldiff. It's version 0.1.1 but is fully functionnal. As you already guessed, xmldiff figures out the differences between two XML trees in the same way that diff does it for text files. Homepage: http://www.logilab.org/xmldiff/ More Info: http://www.logilab.org/xmldiff/HELP.txt Download: ftp://ftp.logilab.org/pub/xmldiff/ It's still a bit slow, but it works and gives correct results. As usual all comments and ideas are welcome. Happy XML-diff'ing ! Alexandre Fayolle -- LOGILAB, Paris (France). http://www.logilab.com http://www.logilab.fr http://www.logilab.org Narval, the first software agent available as free software (GPL). From tim.one at home.com Mon Jul 23 22:51:03 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 23 Jul 2001 22:51:03 -0400 Subject: proposed language change to int/int==float (was: PEP0238 lament) In-Reply-To: <15196.14524.979058.576152@beluga.mojam.com> Message-ID: [Skip Montanaro] > ... > I really don't understand the problem with teaching people new to > Python right from the get-go that when you divide two ints it works > like grade school long division. I'm burned out on the repetition here. It's not a question of being hard to teach. It's largely that it's never sensible for x = y / z buried in the middle of some routine to do truncating division if y and z happen to be ints but best-possible division if they happen not to be ints. It's this damage to polymorphism that hurts people in real life, and we've had years of testimony about that on c.l.py (even in this incarnation of the debate, although it's hard to find unless you read every msg). This isn't a question of teaching the rules, it's that the specific rule here is essentially braindead in a language without static type declarations. If you read nothing else, read Guido's few messages on the topic. He covers it all succinctly and accurately (and generally declines to get sucked into endless repetition -- but why a point needs to be made 500 times on Usenet is beyond me). > ... > You're pissing off a fairly significant fraction of the language's > existing constituency in hopes of attracting some non-programmers > to the language who may not come anyway for various other reasons. I don't detect any trace of that hypothesized motive in Guido. He wants to repair what he has come to believe is a serious design error, and is wrestling with ways to get that done. What a remarkably different world it would be if people tried to help . From dinu at reportlab.com Fri Jul 13 08:24:25 2001 From: dinu at reportlab.com (Dinu Gherman) Date: Fri, 13 Jul 2001 12:24:25 GMT Subject: design patterns in python References: <3b2786d5$1_3@newsfeeds> Message-ID: <3b4ee55f.102689870@news.t-online.de> On Wed, 13 Jun 2001 11:49:14 -0400, "raskol" wrote: >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 Well, there used to be a Python Pattern-SIG: http://www.python.org/sigs/pattern-sig/ At some point Guido shot it down, because it was too silent and, in fact, it wasn't producing anything useful like a Python Catalog of Python Idioms, Pattern and Frameworks, which, in retrospect, it should have had as a real mission statement, I guess. Back then it was said that pattern issues were discussed in a sufficient manner on comp.lang.python. I'm still not so happy with that, because this is a place to get easily lost, but YMMV and there are other sigs with only very few messages per month. Hmm, maybe someone wants to get it going again?! Dinu -- Dinu C. Gherman dinu at reportlab dot com http://www.reportlab.com ................................................................ "The only possible values [for quality] are 'excellent' and 'in- sanely excellent', depending on whether lives are at stake or not. Otherwise you don't enjoy your work, you don't work well, and the project goes down the drain." (Kent Beck, "Extreme Programming Explained") From garabik-news at spam.melkor.dnp.fmph.uniba.sk Sat Jul 21 11:06:24 2001 From: garabik-news at spam.melkor.dnp.fmph.uniba.sk (Radovan Garabik) Date: 21 Jul 2001 15:06:24 GMT Subject: Is anybody coming from Pascal? References: Message-ID: <9jc5pg$6bq$1@sunnews.cern.ch> Edmund Strangely wrote: : Hello, : I've been lurking here for a while while working my way through 'Learning : Python'. So far only a few things have pissed me off with it. I was just : wondering, is anybody else coming from Pascal? Or Modula2/3? The book I am I came from solid Turbo Pascal background on MSDOS to linux, made a few C programs and then discovered python : reading kind of assumes that you are coming from C, and as I understand it : Python is written in C which is why it shares some of the same : conventions. Python is my first object orientated language. Pascal was my me too : second programming language (after BASIC on a spectrum) and although I me too : sort of learned C later, I still prefer Pascal. I personally like it more me too : than C for a few reasons. I don't think that I should have to worry about : how many bytes precisely my variables are stored in. (And I like BASIC : even better in this respect, in that integers and fp numbers are : automatically converted, and strings will grow and shrink as required (as : in Python seemingly)). I don't like the fact that in Python if me too :>>>a=5 :>>>b=2 :>>>#and then :>>>c=a/b :>>>#then :>>>c : 2 : in Pascal if you *want* modulo arithmetic (which is not normally the case : ) then you have DIV and MOD. I like having a distinction between functions this I feel is a big design mis-decision in python. I liked div and mod (/ as integer division is UGLY and having % instead of mod just goes against main python principle, readibility) : and procedures, for purely aesthetic reasons (I think having loads of : function names followed by () just looks ugly, procedures don't give it looks ugly, but since in python everything is reference, you somehow have to tell the interpreter where to perform a call. I got used to it quickly. : return values). Python only has functions, but I can forgive it that. But : the one thing above all that I think Pascal has over C (and which Python : shares) is that you can nest your procedures/functions! Most of my Pascal : programs had a mere few lines in the 'main' body of the program and the : rest would be large functions and procedures each with their own : sub-procedures and sub-functions with their own sub-sub units etc. it was nice, and (unlike python) did not impose runtime penaly. I un-learned to use nested function in python because of this. Shame. : When I : first started on C I just couldn't *believe* that you couldn't nest : functions, and just had to put them one after the other! You call that : structured programming? Nobody calls programming in C structured :-) : I conclusion, and in reviewing this post, I seem to have been rambling a : bit (it's a bit late/early in the day) but I'd be interested to get a : response from anybody else who rates Mr Wirth, and in how any such people : finding the transition. I'd also be curious to hear from anybody who has What I miss from pascal are arrays and enumerated types. Lists are not the sameas arrays, NumPy is clumsy and unreadable and not part of language. Enumerated types were really nice and allowed you to concentrate on the logic behind the program, not on the program by itself (and were compiled pretty effectively). Having to simulate them by strings or classes in python is just not the same. Also the nested scopes problem in python is something at which I stared in disbelief. How can a programming language have _this_ mess about scopes and claim to be logical and readable? Pascal was perfect in this respect. You can chooe between call by reference or call by value in pascal. Python has internally only the former, but for the programmer the overall effect looks like it arbitrarily uses sometimes the former, sometimes the latter. Yuck. : tried object Pascal. I tried (at the time of TP 5.5) First I had troubles getting the concept of OO, then I did not see much value in it, and quickly abandoned it, until I discovered python. Ideal language for me would be (together with above-mentioned) pascal-like, with python syntax, typed (allows effective compilation), with (turbo)pascal and python types combined (char, byte, unicode char, int, longint (double the size of int), int16, int32, int64 - to explicitly tell the size, these are needed e.g. for network applications, real, double, rational, infinite long (python-like), list/tuple, dictionary, string, boolean (yes!), complex), pascal-like arrays, do..while loop, pascal-like for a:=something to b step c loop, python-like for i in something loop, python-like OO, and, of course, with python-like variety of external modules :-) -- ----------------------------------------------------------- | 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 christopherjmcmillan at eaton.com Tue Jul 10 14:53:57 2001 From: christopherjmcmillan at eaton.com (Chris McMillan) Date: Tue, 10 Jul 2001 14:53:57 -0400 Subject: File processing References: <9id5p9$8r62@interserv.etn.com> <01b001c1091f$c9c74340$0e4ab43f@kens> Message-ID: <9ifima$8r69@interserv.etn.com> When I run my script, below, it complains after the line f = open(fname, 'r') saying that it expected string, list found. I believe this happens because of what the glob command returns, but I'm not sure how to fix it. FYI - I'm running Python 2.0 on Windows NT. Thanks in advance for your help! Chris import os import glob for fname in glob.glob('M:\\python\\*.dat'): fname = glob.glob('M:\\python\\*.dat') f = open(fname, 'r') lines = f.readlines() f.close() f = open(fname, 'w') f.writelines(lines[1:]) f.close() From Randy.L.Kemp at motorola.com Tue Jul 10 11:59:14 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Tue, 10 Jul 2001 11:59:14 -0400 Subject: Is Python Dead? Long Live Python! Message-ID: Excellent idea. If folks are paying $4.95 per minute for psychic advice, then a Python 900 number would work. Heck, we could even get creative here. Write a Python program to randomly generate some psychic advice, and open a second psychic line for $4.95/minute. You could even have the same line, and answer like this. Caller: Ring, Ring. Hello. Is the Guru in? Respondent: Are you calling the Python Guru or the Python psychic. Caller: I want the Python psychic. -----Original Message----- From: Benjamin.Altman [mailto:benjamin.altman at noaa.gov] Sent: Tuesday, July 10, 2001 10:14 AM To: python-list at python.org Subject: Re: Is Python Dead? Long Live Python! Lindstrom Greg - glinds wrote: > 3. No Support! At least no 900 number to call for a per minute fee. Doesn't > seem to matter that in the past couple of years I have never had to wait > over a day to get a answer to a question. Perhaps we would feel better if > there were someone we could sue. I am sure plenty of people would be willing to charge per minute to give Python advice - just a matter of offering the service to get some suckers.. I mean companies to take it up. From nospam at nospam Fri Jul 13 12:28:27 2001 From: nospam at nospam (Rufus V. Smith) Date: Fri, 13 Jul 2001 12:28:27 -0400 Subject: Undefining functions and classes References: <3B4EFA40@operamail.com> Message-ID: <3b4f284a$0$170@wodc7nh6.news.uu.net> "Skip Montanaro" wrote in message news:mailman.994889900.29132.python-list at python.org... > > Vesselin> Does anyone know how to undefine a function or class in Python > > Try > > del func > > -- > Skip Montanaro (skip at pobox.com) > (847)971-7098 > D'oh! From akuchlin at mems-exchange.org Tue Jul 31 11:04:27 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 31 Jul 2001 11:04:27 -0400 Subject: Python Threads on Linux References: Message-ID: <3dsnfdjg1w.fsf@ute.cnri.reston.va.us> Ronan.Viernes at onsemi.com (Ronan Viernes) writes: > 1. Is it normal for threads on LINUX to have their own process id > thereby displayed in "ps -ef"? In AIX/HP, this is not the case right? Correct; Linux threads have different PIDs because of how the kernel treats them. The fork() system call which creates a new process is essentially a special case of the clone() system call that creates a new thread, but that distinction doesn't matter to a Python programmer. --amk From brian at sweetapp.com Sun Jul 29 14:35:15 2001 From: brian at sweetapp.com (Brian Quinlan) Date: Sun, 29 Jul 2001 11:35:15 -0700 Subject: Language Niches (long) In-Reply-To: <3B644D52.9434E699@ActiveState.com> Message-ID: <000201c1185d$35e77170$445d4540@D1XYVL01> "Moore's law is slowly making type declarations irrelevant..." -- Paul Prescod Nice :-) I've got to remember that one. From guido at python.org Sat Jul 21 10:16:36 2001 From: guido at python.org (Guido van Rossum) Date: Sat, 21 Jul 2001 14:16:36 GMT Subject: RELEASED: Python 2.1.1 References: <+TaezWAGrHW7Ewyz@jessikat.fsnet.co.uk> Message-ID: Robin Becker writes: > what makes the .tgz increase from 4275323 to 6187808? By mistake, the Mac source tree was included. since from now on it will be included in all source releases, I propose to call this a feature. ;-) --Guido van Rossum (home page: http://www.python.org/~guido/) From sheila at spamcop.net Sun Jul 22 14:23:21 2001 From: sheila at spamcop.net (Sheila King) Date: Sun, 22 Jul 2001 18:23:21 GMT Subject: subclassing Exceptions References: <9ihklt8u0vvh1aa0mg6tadbmjo9mot47e0@4ax.com> <3b5a69a3$0$320$6e49188b@news.goldengate.net> <9jee61$2ac$1@slb6.atl.mindspring.net> Message-ID: On Sun, 22 Jul 2001 07:46:25 +0500, Tom Bryan wrote in comp.lang.python in article <9jee61$2ac$1 at slb6.atl.mindspring.net>: :Sheila King wrote: : :> OK, interesting. I didn't realize you could make an exception without :> subclassing it. So, I tried this script: : :Neither did I, but you probably don't want to do that. Right. :One reason to subclass from a common Exception base class is so :that exceptions can be caught based on inheritence. Also, since :there's a common exception base class, all exceptions have common :behavior that you'd have to recode if you didn't subclass. You know, late last night/early this morning, that just kind of slipped past me. But it makes perfect sense (of course). :> Well, I am interested in further enlightenment on this topic...? : :I believe that the intent is for all exception classes to subclass from :Exception or one of its sublcasses. I think that a common idiom is for :a module to declare its own base exception class. Then, it can declare :many subclasses of *that* Exception subclass to use internally. People :using the module can simply catch the base FooException unless they :have a good reason to get more specific. Basically, they called code :in your module, and it blew up. Often, that's as much as they can say, :and the error message attached to the exception *should be* enlightening :enough to troubleshoot the problem. Thanks. This is exactly the type of stuff that I am currently working with and need to know about. :For example, [excellent code for stack class with exceptions, snipped] :Of course, this advice might be slightly off. Python's exception stuff looks :a lot like the Java exception stuff, and I've done a lot more Java. It looked awfully good to me. I'm subclassing some of the mail modules, like rfc822 right now, and also another project working with RGB vs. Hex color values and the correct way of writing my own Exceptions for these modules has been preventing me from getting very far into it, since I keep pausing and wondering how to handle it, and my overview of the entire module is affected by how I want to handle this. Thanks, -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From rupe at metro.yak.net Fri Jul 6 18:55:36 2001 From: rupe at metro.yak.net (Rupert Scammell) Date: 6 Jul 2001 15:55:36 -0700 Subject: Is there a K&R on Python? References: <3B42EEAD.9EE4E7A7@divalsim.it> Message-ID: <79179cf5.0107061455.19093036@posting.google.com> Nicola Musatti wrote in message news:<3B42EEAD.9EE4E7A7 at divalsim.it>... > Hallo, everybody. > I'm looking for a Python book to use as a desktop reference on the core > language (rather than the library, available modules, third party > toolkits, etc), neither a tutorial nor something meant for language > lawyers only. Something analogous in style to Kernighan & Ritchie's "The > C Programming Language" would be perfect. Any suggestions? > > Cheers, > Nicola Nicola, First off, don't bother with Mark Lutz's larger book, "Programming Python" (http://www.oreilly.com/catalog/python2/). It's big, but intended to teach the language, and not act as a reference. However, do get Mark's "Python Pocket Reference" (http://www.oreilly.com/catalog/pythonpr/). It's a great, concise little volume for looking up standard functions, and remembering which operations are legal for which datatypes. No frills, no fluff, and as the title implies, pocket sized, so lots of useful modules aren't discussed. Far and away the best Python book that I've seen is David Beazley's "Python Essential Reference" (http://www.newriders.com/books/title.cfm?isbn=0735709017), published by New Riders. I can't speak highly enough of this book. Wonderfully concise, great usage examples, and covers many of the important modules that Mark Lutz's Pocket Reference lacks. If you only get a single book on the language, this is the one. --- Rupert From rnd at onego.ru Wed Jul 18 12:56:42 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 18 Jul 2001 20:56:42 +0400 (MSD) Subject: PEP: Defining Python Source Code Encodings In-Reply-To: <3B559B71.C08C6145@lemburg.com> Message-ID: On Wed, 18 Jul 2001, M.-A. Lemburg wrote: >Here's an update of the pre-PEP. After this round of comments, the >PEP will be checked into CVS (provided Barry assigns a PEP number, >hi Barry ;-) > This PEP proposes to introduce a syntax to declare the encoding of > a Python source file. The encoding information is then used by the > Python parser to interpret the file using the given encoding. Most > notably this enhances the interpretation of Unicode literals in > the source code and makes it possible to write Unicode literals > using e.g. UTF-8 directly in an Unicode aware editor. I have not understood: will Unicode encoding be directly allowed or only ASCII-compatible encodings (like UTF-8)? >Problem > > In Python 2.1, Unicode literals can only be written using the > Latin-1 based encoding "unicode-escape". This makes the > programming environment rather unfriendly to Python users who live > and work in non-Latin-1 locales such as many of the Asian > countries. Programmers can write their 8-bit strings using the > favourite encoding, but are bound to the "unicode-escape" encoding > for Unicode literals. Isn't it time for better gettext support in Python? Then for i18n-enabled programs, encodings will belong to .mo, .po or whatever called files... >Proposed Solution > > I propose to make the Python source code encoding both visible and > changeable on a per-source file basis by using a special comment > at the top of the file to declare the encoding. > > To make Python aware of this encoding declaration a number of > concept changes are necessary with repect to the handling of > Python source code data. >Scope > > This PEP only affects Python source code which makes use of the > proposed magic comment. > Without the magic comment in the proposed > position, Python will treat the source file as it does currently > to maintain backwards compatibility. This is what I like most. Will optimization be mentioned here? Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Wednesday, July 18, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Hard work never killed anyone, but why chance it?" _/ From sholden at holdenweb.com Mon Jul 2 11:25:42 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 2 Jul 2001 11:25:42 -0400 Subject: Comment on PEP-0238 References: <3B3BE855.A6223E70@3-cities.com> <7ef50c46.0107020554.31cc948b@posting.google.com> Message-ID: <3m007.28573$zT1.1522313@e420r-atl3.usenetserver.com> "Paul Prescod" wrote in ... > "Robert J. Harrison" wrote: > > > >... > > The current coercion rules are simple, easy to grasp, and consistent > > with how most people are taught arithmetic. > > That is simply not true. Most people do not expect these four > expressions to yield different results: > > 1.0/3.0 > 1/3 > 1.0/3 > 1/3.0 > > If you were taught this in school, it must be "new math". > Actually, in my case it's "old fart programming". You've got a floating-point arithmetic unit? You're lucky. I remember, when I were a lad, we 'ad to take the digits ... [drools into beard & continues to mumble]. But, in fact, I don't think it's that unreasonable to expect binary operations on integers to be closed over the integers, and devil take the overflows and fractional remainders. This may, however, sinly be a result of my having done it that way in countless programming languages over the years. I have seen the discussions about what "most people" expect, and remain unconvinced. Since I'm not going to be doing the implementation, though, I don't grumble *too* much. I do, however, worry about possible code breakage. I think that changing integer arithmetic will cause many more users of existing program to be confused than newbies who have ot understand the present rules. Sometimes you just have to say "that's the way things are". > >... > > 2) Integers should be treated as a distinct type from reals with > > automatic coercion only as necessary (with the current rules). > > What is "necessary"? Why is automatic coercion *ever* necessary? Only to > simulate the mathematics we are taught in primary school where the above > statement are all equivalent. > > > For instance, the new proposal sensibly does not suggest that lists > > should support real indices, > > That might well be an implication of PEP 228. > > http://python.sourceforge.net/peps/pep-0228.html > Of course dictionaries already treat equivalent numeric values as equal keys, hence: >>> d = {1: "Hello, Paul"} >>> d[1.0+0j] 'Hello, Paul' However, anyone relying on exact equality of floating-point values is likey to be disappointed at some stage unless they know *exactly* what they're doing. Then, they'll just be occasionally surprised :-) > > however simple expressions such > > as a[i/3] would have to be coded as a[int(i/3)] or a[i//3] > > in order to be sure to avoid a type error. > > You mean that you would have to say exactly what you mean according to > the new syntax. That's hardly a legitimate argument against the syntax. > "If you add a 'function' keyword, I would have to precede my function > calls with it." Well, yeah, that's the point of adding new syntax. If reals are allowed as list/tuple subscripts then i[1.0] will be valid, but i[1.1] will (I hope) not. Peronally I can't help feeling that "Subscript not exact integer value" might also be a little hard for newbies to cope with. Let alone "Subscript value is not exact" even when the recorded value *is exactly* integral. Still, I don't have to implement all this stuff, so if the development team think it's worthwhile then that's fine. Just trying to point out a few gotchas, which probably won't even be previously unconsidered. regards Steve From quinn at retch.ugcs.caltech.edu Sat Jul 28 14:33:33 2001 From: quinn at retch.ugcs.caltech.edu (Quinn Dunkan) Date: 28 Jul 2001 18:33:33 GMT Subject: 2.2 features References: Message-ID: On Sat, 28 Jul 2001 02:02:40 GMT, Guido van Rossum wrote: >Kirill Simonov writes: > >> It would be nice to have 'in' operator for types: >> >> assert (num in int) >> assert (msg in str) This implies (at least to me) that 'in' would be a general shorthand for 'isinstance'. But then I would sort of expect '3 in [1,2,3,4]' to behave like 'isinstance(3, [1,2,3,4])' Or you could just say that type objects implement a __contains__ method that does an isinstance. But if classes and types are unified, that would get in the way of classes that define __contains__. You'd have to think of it as a class method (or a metaclass method), which is in a different namespace than instance methods. Or something. It's a nice syntax, but it seems a bit confusing to me. From tim.one at home.com Wed Jul 11 19:02:00 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 11 Jul 2001 19:02:00 -0400 Subject: Comment on PEP-0238 In-Reply-To: <3B4BF3C5.419FEC0D@cosc.canterbury.ac.nz> Message-ID: [Tim] > If you want to turn every + - * / etc into a long-winded function > call ... [Greg Ewing] > No, I don't want to do that, obviously. That's good to know. > But I also wouldn't like to see a piece of implicit state controlling > the number of digits I get out of arithmetic operations. If precision is adjustable, seems to me it's "usually explicit" (which you just said you don't want) or "usually implicit" (which you just said you don't want). If you have another idea, let's hear it -- but remember I said at the start that the issue can't be wished away. BTW, if you're running on a Pentium box, there's a piece of implicit state controlling the number of digits (bits) you get out of every fp operation. How much of a burden has that been to you? My guess is "none", and, if so, why assume it would be worse for decimal fp? > I've had experiences with that in Hypertalk, all of them bad. Haven't used it, and didn't find any reference docs on the web that admitted to such a thing in Hypertalk; seemed to imply it handled 19-digit arithmetic, with a numberFormat property to control (only) *display* precision. So, sorry, but this broth is too thin to choke on . From robin at jessikat.fsnet.co.uk Mon Jul 16 09:59:52 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Mon, 16 Jul 2001 14:59:52 +0100 Subject: Win2k Tkinter checkbuttons References: Message-ID: In article , Ulrich Gortz writes >Robin Becker writes: > >> I'm having problems with menu checkbuttons under python2.1 running under >> win2k sp2. When I pop up a menu containing a ticked item I don't see all >> of the tick. When the mouse passes over the checkbutton the tick >> suddenly gets fully displayed. > >I have exactly the same problem (see also >http://www.g0ertz.de/tkinter.html ); I don't know how to fix it. > >Ulrich > yes the problem your images show are identical to mine. I know this doesn't have to happen as I have native Tk apps which do/don't show it and so far as I can tell by dumping out the menu properties in both cases there isn't anything seriously different about them as far as colours/font/fontsizes etc. I have a vague feeling it might be related to the update speed. -- Robin Becker From wqh-2 at 263.net Tue Jul 31 21:52:39 2001 From: wqh-2 at 263.net (sdf) Date: Wed, 1 Aug 2001 09:52:39 +0800 (CST) Subject: how to know whether the item in a diretory is a file/directory Message-ID: <3B6760E7.19039@mta6> I want to process all the files in a diretory,and ignore the subdirectorys in it ,I use os.listdir() to list all the items,but I do not know whether the selected item is a file __________________________________________ DVD??????????10?? http://shopping.263.net/category02.htm ?????????????????????? http://shopping.263.net/category10.htm From guido at python.org Tue Jul 31 13:51:27 2001 From: guido at python.org (Guido van Rossum) Date: Tue, 31 Jul 2001 17:51:27 GMT Subject: 2.2 features References: <15206.48884.18637.676324@beluga.mojam.com> Message-ID: Kirill Simonov writes: > It is better to change type comparison, e.g. > (A >= B) == issubclass(A, B) Hm, people would forever be mixing up whether it was A <= B or A >= B. :-( --Guido van Rossum (home page: http://www.python.org/~guido/) From maxx at easynews.com Fri Jul 27 12:54:02 2001 From: maxx at easynews.com (maxx at easynews.com) Date: Fri, 27 Jul 2001 16:54:02 GMT Subject: Deposing Dictators References: <9jmjne$q54$1@wisteria.csv.warwick.ac.uk> <3b602daf.1623450@nntp.sprynet.com> Message-ID: On Fri, 27 Jul 2001 00:12:55 +0100, Robin Becker wrote: >In article , Gareth McCaughan > writes >.... >>More: to be benevolent is to *try* to act in a way >>consistent with the person's best interests[1], even >>if in fact you're wrong. So even if Guido is as >>horribly wrong as some people here say he is about >>what their best interests are, that's no reason to >>think he isn't benevolent. >... >We all know lightning is God's way of telling us to shut up. Of course >God is benevolent no matter how appalling the universe gets. The >opposite of benevolent is malevolent. When our quick-sorts go wrong it >will be as a result of a benevolent act by a caring designer. Why is it, whenever someone believes that they know what is the best and only "truly right" way for the rest of us, they invoke the name of their favorite creator? Is it perhaps because they do not actually have anything to contribute, but feel that they must be heard anyhow? From DavidA at ActiveState.com Fri Jul 20 15:23:10 2001 From: DavidA at ActiveState.com (David Ascher) Date: Fri, 20 Jul 2001 12:23:10 -0700 Subject: Python, C++, Java, Smalltalk, Eiffel,... References: <9is8rm$46d$1@panix3.panix.com> <9iv7ae$gs0$1@nntp6.u.washington.edu> <9j63lk$ogp$1@newsfeed.th.ifl.net> <3d4rs74t5d.fsf@ute.cnri.reston.va.us> Message-ID: <3B58851E.5FFA4844@ActiveState.com> Andrew Kuchling wrote: > I'm a bit doubtful that the CLR will really be suited for languages > other than C# or VB. Sure, with some hammering you can compile Python > to CLR, just as you can compile it to Java bytecodes, but there seems > to be a sizable performance hit, judging by a message from David > Ascher archived at > http://aspn.activestate.com/ASPN/Mail/Message/638072. I think you're being overly pessimistic. As I said in that post, getting Python to work well on the CLR requires changes either to the CLR or to Python (or a lot of work). None of those are impossible, though. I'm still hopeful that someone will solve some of the optimization problems for Python using type analysis. Also, Jython shows that even with a performance hit, Python on a VM is a very useful thing. So, Python on the CLR could still be useful, even if it's not as fast as native-python. > I suspect .NET's multilanguage will turn out to be a feature used more as a > selling point than in practical use. In the short term, probably. Longer term, I think it's up to us, the various language communities, to see how we can rise to the challenge. =) -- David Ascher ActiveState New! ASPN - ActiveState Programmer Network Essential programming tools and information http://www.ActiveState.com/ASPN From quinn at yak.ugcs.caltech.edu Fri Jul 20 20:52:46 2001 From: quinn at yak.ugcs.caltech.edu (Quinn Dunkan) Date: 21 Jul 2001 00:52:46 GMT Subject: basic python-unix question References: Message-ID: On Thu, 19 Jul 2001 12:46:03 +0100, phil hunt wrote: >Because BSD doesn't like ``ps ef''? Or because there's a problem >with os.system()? The bsd "ps" command doesn't take the same flags. And some linux "ps"s will guess bsd or sysv depending on whether the options are preceeded with a '-', but will guess wrong on the above. Add in vendor extensions and GNU extensions and random other compatibility hacks, and it's pretty out of control. From steve at lurking.demon.co.uk Sun Jul 22 07:55:29 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Sun, 22 Jul 2001 12:55:29 +0100 Subject: Future division patch available (PEP 238) References: Message-ID: On 22 Jul 2001 09:55:50 GMT, Marcin 'Qrczak' Kowalczyk wrote: >Sun, 22 Jul 2001 09:35:27 +0100, Stephen Horne pisze: > >> And as it happens, I remember my first experience with Pascal led >> to the question "why does Pascal need two division operators when >> BASIC works perfectly well with one?" > >The Basic I used didn't have integer division at all, which is hardly >an improvement. I've used at least a dozen versions of BASIC in my time, and they all supported integer division using the / operator - one freaky exception does not make a rule. >All arithmetic operators and functions like divmod, except /, have the >property that the value of the result, as long as it's not an error, >depends only on the values of arguments - not on their types. Not true. 1 + 1 == 2 1.0 + 1.0 == 2.0 1L + 1L == 2L (1+1j) + (1+1j) = (2+2j) All arithmetic operators operate in a way that depends on the data types of their arguments - they use that data type to define the set of values they are operating in, and they return a result of the appropriate type. There is automatic casting, of course, such as... 1.0 + 2 == 3.0 But you get the same thing in C, C++, BASIC, Java, I think Pascal, and many others. It is a convenience - it does not make integers equivalent to floats. Python is more strongly typed than many of these languages - it merely applies its typing rules at run-time and based on the data, not the container. I see no reason good reason to weaken Python by discarding strong typing. I stand by my earlier case - when working with integers, 2 / 3 == 1 remainder 1. Integer operations should have integer results. If you had five children and three prospective foster mothers, how would you allocate them - 1.6667 children to each parent? Of course not. You'd allocate one each to start with, then worry about what to do with the remaining two. This dealing with the remainder is quite common. For instance, in dealing with money your are dealing with integer multiples of the smallest denomination - pennies in the UK, cents in the US or whatever. You can't give someone a third of a penny, so you have to deal with the remainder as a separate issue. >My taste suggests the following: > >- div and mod should be operators which return components of divmod. > divmod works as currently. I would like a 'mod' operator, I admit, but it wouldn't be the same as the current '%' operator (and the mod part of divmod) because they provide the remainder - not the modulo - which is different when the arguments include negative numbers. I'd therefore like 'mod' and 'rem' - like Ada - so I could choose which meaning I want without having to do extra checks. I also prefer the explicit names rather than '%' which - strangly enough - looks like it should relate to percentages for me. It is, however, far too late to worry about such changes. New keywords for div and mod may sound good, but I wonder how many people have written code like... (div, mod) = divmod(x, y) >- / applied to ints or longs should return the exact result as a rational. Support for rationals is a good idea, but I'd prefer to see them as a separate type. When working with rationals or floats or whatever, you should get a result appropriate to that type. > % should remain only in its sprintf meaning. > >- When rationals and floats are mixed, the result is a float. Any float is merely an alternative representation of a rational, whether it is a binary float or a decimal float. For example... 0.0001 == 1/10000 Wherever you put the point, it is a simple matter to derive an integer numerator and denominator to represent a particular float exactly as a rational - even when the exponent (the * base**n part) is included. Not every rational can be represented as a float, however - at least not in a given base. For example, 1/3 cannot be perfectly represented as either a binary or decimal float. Logically, operations with mixed float and rational arguments should give rational results - the float argument can be accurately converted, and the result is less likely to have lost precision. The only real values that cannot be represented exactly as rationals are irrational numbers - such as pi, sqrt(2) and e. These values equally cannot be represented exactly as floats. In real life, of course, approximations are normally good enough. Of course, this then opens a major can of worms - rational versions of trig functions and similar would not be realistic, and therefore you'd get lots of implicit conversions from floats to rationals (rationals being more general than floats) only to have to convert back again for the trig functions, and so on. And of course the float->rational argument is only so far formed. A very large positive or negative float - using, as floats do, an exponential representation - may represent some values which cannot be represented in a given implementation of rationals, even though any float has an exact rational representation in theory - floats are very good at allowing large values by limiting the precision. Being vague about the data type just causes more and more problems. >- Given the above assumptions, I'm not sure what literals like > 1.2 should produce. All possibilities have reasons: rationals, > floats, or decimal floats. Anyway, the question is what should be > the default, because other possibilities can be formed by using > a letter suffix. I would either let 1.2 mean a rational and 1.2f > a float, or 1.2 a float and 1.2r a rational. More probably the > former. Decimal floats should not be necessary: they are inexact > like binary floats and slow like rationals. Floats are not slow on modern hardware. Slower than integers perhaps, but not slower than long integers. Long integers are implemented by software algorithms, whereas float operations are done by a single highly optimised CPU instruction. Rationals will be slow because they will also have to be implemented by software and, to get maximum benefit, should have long integers as the numerator and denominator. From qrczak at knm.org.pl Fri Jul 27 06:13:55 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 27 Jul 2001 10:13:55 GMT Subject: PEP: Defining Python Source Code Encodings References: <9jmp05$47j$1@animus.fel.iae.nl> Message-ID: 25 Jul 2001 17:35:33 +0200, Carel Fellinger pisze: > Me being stupid, I wonder how I'm going to access goodies hidden in > foreign alfabet scripts. Say GooodyScript.py is encoded in Japanese > and I'm to use the classes and functions in them that have Japanese > names, how am I supposed to call them in my Dutch encoded script? I suspect that if foreign characters are allowed in identifiers, the recommended practice would be to make each feature available under an ASCII name too. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From Tom_Good1 at excite.com Thu Jul 26 12:04:34 2001 From: Tom_Good1 at excite.com (Tom Good) Date: 26 Jul 2001 09:04:34 -0700 Subject: Static method and class method comments References: <9jn382$lqf$1@license1.unx.sas.com> Message-ID: Kevin.Smith at sas.com (Kevin Smith) wrote in message news:<9jn382$lqf$1 at license1.unx.sas.com>... > I am very glad to see the new features of Python 2.2, but I do have a minor > gripe about the implementation of static and class methods. My issue stems > from the fact that when glancing over Python code that uses static or class > methods, you cannot tell that a method is a static or class method by looking > at the point where it is defined. Here is the example given on the Python web > site. > > class C: > def foo(x, y): > print "classmethod", x, y > foo = classmethod(foo) > > It is clear that 'foo' is a class method simply because the classmethod() call > is only two lines away. It is not so clear when 'foo' is a 100 line method. [snip] I would also use the fact that 'foo' has no 'self' parameter as a clue that it is a class method. I realize that naming it 'self' is an artificial convention, but it is followed so often that I feel pretty safe using it as an at-a-glance guideline. Tom From kens at sightreader.com Mon Jul 30 19:50:53 2001 From: kens at sightreader.com (Ken Seehof) Date: Mon, 30 Jul 2001 16:50:53 -0700 Subject: The best gui library for newbies. References: Message-ID: <001901c11952$78992680$6501a8c0@pacbell.net> "David A." wrote: > H~i I program in python for some time now. And I would like to beegin doing > some gui's and other graphical programming. The thing I want to know is wich > one is the best gui toolkit for python when you are a newbie? Wxpython, > tkinter?? Whatis important for me is easy of use and well documented!! this > is what I am looking for. > > Thank you for any help in advance!!! wxPython. And the first thing to do after you download it is RTFD - Run The Freakin Demo! www.wxpython.org In addition the the regular documentation, which is good and complete (except for the fact that it is really C++ documentation instead of python documentation), you should check out wxPyWiki (a community driven documentation system). http://wxpython.org/cgi-bin/wiki If you are creating dialogs, you also should get wxDesigner, a really awsome dialog editor: http://www.roebling.de/ (unfortunately, this site seems to be having problems right now) - Ken Seehof From skip at pobox.com Wed Jul 11 16:55:45 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 11 Jul 2001 15:55:45 -0500 Subject: Pickle translation In-Reply-To: References: Message-ID: <15180.48465.868266.498677@beluga.mojam.com> William> So, are there any tools to translate 1.5.2 pickles to 2.x William> versions of the pickle format? I wasn't aware that 2.x couldn't read pickles created by 1.5.2. I just tried a simple example without any problem (sorry, 1.6 is as far as I go back on my local machine): % python1.6 Python 1.6 (#1, Jul 10 2001, 17:24:51) [GCC 2.96 20000731 (Linux-Mandrake 8.0 2.96-0.48mdk)] on linux2 Copyright (c) 1995-2000 Corporation for National Research Initiatives. All Rights Reserved. Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam. All Rights Reserved. >>> class foo: ... pass ... >>> a = foo() >>> a.x = 1 >>> b = ["a",1,(0,1,2)] >>> t = (a,b) >>> d = {"key":t} >>> d {'key': (<__main__.foo instance at 8239bf8>, ['a', 1, (0, 1, 2)])} >>> import pickle >>> f = open("pickle.dat", "w") >>> pickle.dump.__doc__ >>> pickle.dump(d, f) >>> f.close() >>> % python2.1 Python 2.1.1c1 (#13, Jul 10 2001, 17:30:38) [GCC 2.96 20000731 (Linux-Mandrake 8.0 2.96-0.48mdk)] on linux2 Type "copyright", "credits" or "license" for more information. >>> class foo: ... pass ... >>> import pickle >>> d = pickle.load(open("pickle.dat")) >>> d {'key': (<__main__.foo instance at 0x82319cc>, ['a', 1, (0, 1, 2)])} I see a comment in the pickle lib ref manual section about a change to pickle's behavior that was introduced in 1.5b2 (significantly before 1.5.2), but nothing about 1.5.2->2.x incompatibilities. Can you be more specific about what's not working for you? -- Skip Montanaro (skip at pobox.com) (847)971-7098 From howard at eegsoftware.com Wed Jul 11 14:10:48 2001 From: howard at eegsoftware.com (howard at eegsoftware.com) Date: Wed, 11 Jul 2001 18:10:48 GMT Subject: extra TK window in embedded app Message-ID: <3b4c96a8.8931442@news-server.socal.rr.com> I have embedded Python 2.0 into a Windows app. (BTW: Forget the examples/manual. You MUST define argv with PySys_SetArgv() or you get an exception on trying to create a Tk() object. Of course, under Windows the stderr message goes in the bit bucket. Is there any way to make a debugging window to capture stderr/stdout? It seems to me I have seen this duscussed......somewhere) When I trying running a (Tkinter +PMW) script, I get not only the window I expected but another empty window. I don't get this extra window when running from the command line or from a (Pythonw) shortcut. I assume that it is something in Tk/Python that is creating a toplevel window by default. Any clues on how to inhibit this? Howard Lightstone EEGSoftware howard at eegsoftware.com From akuchlin at mems-exchange.org Sun Jul 8 23:46:24 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: Sun, 8 Jul 2001 23:46:24 -0400 Subject: Package DB: strawman PEP Message-ID: <20010708234624.A30892@ute.cnri.reston.va.us> It seems time to bite the bullet and actually begin designing and implementing a database of installed packages. As a strawman to get a focused discussion started, here's a draft of a PEP, with lots of XXX's in it. Followups to the Distutils SIG, please. --amk PEP: XXX Title: A Database of Installed Python Packages Version: $Revision: 1.1 $ Author: A.M. Kuchling Type: Standards Track Created: 08-Jul-2001 Status: Draft Post-History: Introduction This PEP describes a format for a database of Python packages installed on a system. Requirements We need a way to figure out what packages, and what versions of those packages, are installed on a system. We want to provide features similar to CPAN, APT, or RPM. Required use cases that should be supported are: * Is package X on a system? * What version of package X is installed? * Where can the new version of package X be found? XXX Does this mean "a home page where the user can go and find a download link", or "a place where a program can find the newest version?" Perhaps both... * What files did package X put on my system? * What package did the file x/y/z.py come from? * Has anyone modified x/y/z.py locally? Database Location The database lives in a bunch of files under /lib/python/install/. This location will be called INSTALLDB through the remainder of this PEP. XXX is that a good location? What effect does platform-dependent code vs. platform-independent code have on this? The structure of the database is deliberately kept simple; each file in this directory or its subdirectories (if any) describes a single package. The rationale for scanning subdirectories is that we can move to a directory-based indexing scheme if the package directory contains too many entries. That is, instead of $INSTALLDB/Numeric, we could switch to $INSTALLDB/N/Nu/Numeric or some similar scheme. XXX how much do we care about performance? Do we really need to use an anydbm file or something similar? XXX is the actual filename important? Let's say the installation data for PIL is in the file INSTALLDB/Numeric. Is this OK? When we want to figure out if Numeric is installed, do we want to open a single file, or have to scan them all? Note that for human-interface purposes, we'll often have to scan all the packages anyway, for a case-insensitive or keyword search. Database Contents Each file in $INSTALLDB or its subdirectories describes a single package, and has the following contents: An initial line listing the sections in this file, separated by whitespace. Currently this will always be 'PKG-INFO FILES'. This is for future-proofing; if we add a new section, for example to list documentation files, then we'd add a DOCS section and list it in the contents. Sections are always separated by blank lines. XXX too simple? [PKG-INFO section] An initial set of RFC-822 headers containing the package information for a file, as described in PEP 241, "Metadata for Python Software Packages". A blank line indicating the end of the PKG-INFO section. An entry for each file installed by the package. XXX Are .pyc and .pyo files in this list? What about compiled .so files? AMK thinks "no" and "yes", respectively. Each file's entry is a single tab-delimited line that contains the following fields: XXX should each file entry be all on one line and tab-delimited? More RFC-822 headers? AMK thinks tab-delimited seems sufficent. * The file's size * XXX do we need to store permissions? The owner/group? * An MD5 digest of the file, written in hex. (XXX All 16 bytes of the digest seems unnecessary; first 8 bytes only, maybe? Is a zlib.crc32() hash sufficient?) * The file's full path, as installed on the system. (XXX should it be relative to sys.prefix, or sys.prefix + '/lib/python?' If so, full paths are still needed; consider a package that installs a startup script such as /etc/init.d/zope) * XXX some sort of type indicator, to indicate whether this is a Python module, binary module, documentation file, config file? Do we need this? A package that uses the Distutils for installation will automatically update the database. Packages that roll their own installation XXX what's the relationship between this database and the RPM or DPKG database? I'm tempted to make the Python database completely optional; a distributor can preserve the interface of the package management tool and replace it with their own wrapper on top of their own package manager. (XXX but how would the Distutils know that, and not bother to update the Python database?) Deliverables Patches to the Distutils that 1) implement a InstallationDatabase class, 2) Update the database when a new package is installed. 3) a simple package management tool, features to be added to this PEP. (Or a separate PEP?) References [1] Michael Muller's patch (posted to the Distutils-SIG around 28 Dec 1999) generates a list of installed files. Acknowledgements Ideas for this PEP originally came from postings by Greg Ward, Fred Drake, Mats Wichmann, and others. Copyright This document has been placed in the public domain. Local Variables: mode: indented-text indent-tabs-mode: nil End: From new_name at mit.edu Mon Jul 2 11:58:10 2001 From: new_name at mit.edu (Alex) Date: 02 Jul 2001 11:58:10 -0400 Subject: Python--eclectic or ubiquitous References: <5174eed0.0107020747.6836d160@posting.google.com> Message-ID: > After five years of following Python, I haven’t seen much > improvement in the areas that seem to be the most natural fit for > Python: Commercial quality database support and robust web server > modules. What database do you want to access? I thought the database support was adequate, though I must admit I haven't used it extensively. Have you seen this page? http://www.vex.net/parnassus/apyllo.py/973100124 And wrt web servers, you might want to google for mod_python. I haven't used it extensively either, though. I've used zope more, which you might also want to have a look at. Alex. From thomas at xs4all.net Tue Jul 3 10:18:41 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 3 Jul 2001 16:18:41 +0200 Subject: newbie apply() question In-Reply-To: <3b415332.96563631@news.supernews.com> References: <3b415332.96563631@news.supernews.com> Message-ID: <20010703161841.T8098@xs4all.nl> On Tue, Jul 03, 2001 at 06:09:41AM +0000, xtian at hyperactive.co.nz wrote: > Hey - I feel like the Martellibot - that was long. That's funny.... I thought this *was* a martellibot posting -- I usually don't check a message's sender/poster until halfway through the email, if at all, and it wasn't until your signature that I realized you weren't the m-bot :-) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From aahz at panix.com Tue Jul 3 18:11:19 2001 From: aahz at panix.com (Aahz Maruch) Date: 3 Jul 2001 15:11:19 -0700 Subject: Eiffel better than Python ? References: <9hsf0c0210e@enews1.newsguy.com> Message-ID: <9htfu7$cb1$1@panix6.panix.com> In article , Dublanc, David wrote: > >What is exactly weak typing ? I believed that Python was weak typing ! perl -e "print '1' + '1'" perl -e "print 1 . 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 "I'm not tense, i'm just terribly, terribly alert" --unknown From loewis at informatik.hu-berlin.de Sun Jul 1 07:28:54 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 01 Jul 2001 13:28:54 +0200 Subject: Unix Scripting Host References: Message-ID: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) writes: > The closest thing I could find was XPCOM from the Mozilla project. I > thought that KDE2 or GNOME might offer this already, but I didn't > find anything (except the relatively heavyweight CORBA approach). If you wanted to create a scripting host API for Unix, I'd suggest that CORBA is just right for the problem. It will allow to integrate arbitrary interpreters using separate processes; all you need is a CORBA implementation for the scripting language - which is available for the major ones. It also allows you to integrate the interpreter in-process for those selected languages that support binary plug-ins, with minimal changes to the host. Regards, Martin From phd at phd.fep.ru Tue Jul 3 10:49:26 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Tue, 3 Jul 2001 18:49:26 +0400 (MSD) Subject: I'd Like to Contribute to an Open Source Project In-Reply-To: <3b41d693$1_7@news5.uncensored-news.com> Message-ID: On 3 Jul 2001, Doug Fort wrote: > I have some time on my hands. It seems like a good opportunity to do some > noncommercial Python programming. Like my hero TV's Frank on MST3K, I'm > more suited to be the lackey than the mad scientist. > > I've checked the 'Project Help Wanted' on SourceForge and don't see > anything that really fits. > > Anybody need some Python code on an Open Source project? > > You can see some of my work at http://pyagent.sourceforge.net and at > http://asynchttp.sourceforge.net. Your asynchttp will be exceptionally good addition to my project "Bookmarks Database and Internet robot": http://phd.pp.ru/Software/Python/#bookmarks_db I am longing for an asyncore-based robot! Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From db3l at fitlinxx.com Tue Jul 3 19:16:57 2001 From: db3l at fitlinxx.com (David Bolen) Date: 03 Jul 2001 19:16:57 -0400 Subject: Strange os.popen() behavior References: <3B41F083.55F65C46@snakefarm.org> Message-ID: Carsten Gaebler writes: > Hi there! > > I have a problem with a script that reads the contents of /etc/passwd from > a remote host. It doesn't always seem to read all lines: (...) > If I enter the SSH command in a shell I always get all 969 lines of > /etc/passwd (the file does not change over time). Any clues? You might try also printing out the exit code of the child process (the result from your pipe.close() call) - perhaps the ssh is being interrupted or otherwise losing the connection? Another thought might be to try explicitly coding a readline() loop rather than the single call to readlines() to see if you notice any difference? Perhaps there's some interaction with readlines() and the pipe that makes it think it is done with data too early. -- -- 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 fdrake at cj42289-a.reston1.va.home.com Thu Jul 12 17:37:23 2001 From: fdrake at cj42289-a.reston1.va.home.com (Fred Drake) Date: Thu, 12 Jul 2001 17:37:23 -0400 (EDT) Subject: [maintenance doc updates] Message-ID: <20010712213723.CE4202892B@cj42289-a.reston1.va.home.com> The development version of the documentation has been updated: http://python.sourceforge.net/maint-docs/ Final documentation build for Python 2.1.1 release candidate 1. This version is also available at the Python FTP site: ftp://ftp.python.org/pub/python/doc/2.1.1c1/ From stefan.heimann at web.de Fri Jul 20 15:36:38 2001 From: stefan.heimann at web.de (Stefan Heimann) Date: 20 Jul 2001 19:36:38 GMT Subject: Emacs and ecb with python Message-ID: Hi! Has anyone a patch to use the emacs code browser with python? If not, does anyone knwos how to write a extension for the semantic parser for python (I think this would be the most difficult part of creating such a patch)? I tried the emacs code browser with java and it rocks, but using it with python would be much better... ;-) thanks Stefan From xucs007 at yahoo.com Wed Jul 18 14:55:36 2001 From: xucs007 at yahoo.com (Xu, C.S.) Date: 18 Jul 2001 11:55:36 -0700 Subject: Python 2 times slower than Perl References: <8f41cfd.0107171238.6ff33b9b@posting.google.com> <9j3rvk$26bt$1@norfair.nerim.net> <3B559B30.61A90EA@jam.rr.com> Message-ID: <8f41cfd.0107181055.3b34851a@posting.google.com> Just spent a little time to compare 4 stupid again algorithms (changed a little bit from last time) for both python and perl (codes attached) on two systems (SunOS and Linux): 1. while loop, global variables 2. for loop, global variables 3. while loop, local variables (in function) 4. for loop, local variables (in function) I used `time [1234].p[yl]` to get the time info. The user time is as follows: PII 450MHz, Dell Precision 4100 Desktop, SunOS 5.8 i386 #1 #2 #3 #4 Python 2.1a1: 5.1 3.1 4.5 2.7 Perl 5.005_03: 1.8 1.6 1.7 1.6 PIII 1GHz, MTech 8500 Notebook, i386 Linux (Mandrake 8.0, kernal 2.4) #1 #2 #3 #4 Python 2.0: 2.34 1.38 1.54 0.98 Perl 5.6.0: 0.95 1.22 0.95 1.21 The closest match is on Linux, 0.98 (python#4) vs. 0.95 (perl#1,#3). Python still can't beat Perl, :-( But I will continue to use Python to do uncritical data analysis, :-) P.S. Codes are: ####################### 1.pl: while loop, global var ##################### #!/usr/bin/env perl $i = 0; $j = 0.; while ($i < 1e6) { $j += $i * 2.5; $i++; } print $i, ' ', $j, "\n"; ####################### 1.py: while loop, global var ##################### #!/usr/bin/env python i, j = 0, 0. while i<1e6: j += i*2.5 i += 1 print i, j ####################### 2.pl: for loop, global var ##################### #!/usr/bin/env perl $j = 0.; for ($i=0; $i < 1e6; $i++) { $j += $i * 2.5; } print $i, ' ', $j, "\n"; ####################### 2.py: for loop, global var ##################### #!/usr/bin/env python j = 0. for i in xrange(1e6): j += i*2.5 print i, j ####################### 3.pl: while loop, local var ##################### #!/usr/bin/env perl sub func { $j = 0.; $i = 0; while ($i < 1e6) { $j += $i * 2.5; $i ++; } print $i, ' ', $j, "\n"; } &func; ####################### 3.py: while loop, local var ##################### #!/usr/bin/env python def func (): i, j = 0, 0. while i<1e6: j += i*2.5 i += 1 print i, j func() ####################### 4.pl: for loop, local var ##################### #!/usr/bin/env perl sub func { $j = 0.; for ($i=0; $i < 1e6; $i++) { $j += $i * 2.5; } print $i, ' ', $j, "\n"; } &func; ####################### 4.py: for loop, local var ##################### #!/usr/bin/env python def func (): j = 0. for i in xrange(1e6): j += i*2.5 print i, j func() From steve at lurking.demon.co.uk Mon Jul 23 17:34:07 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Mon, 23 Jul 2001 22:34:07 +0100 Subject: PEP0238 lament References: <916olt0p3kciv0evmotdg6jev9bl29l57i@4ax.com> Message-ID: <9s4pltg7l5r04652q60oqgfu792ha0f1b2@4ax.com> On Mon, 23 Jul 2001 15:41:18 -0400, "Tim Peters" wrote: >Already said I don't care what other languages do here, and, yes, of course >that's my opinion -- like yours is yours. And that's *ALL* I need to prove to show that there is no good reason to implement PEP0238 - the difference between an opinion and a supposedly undeniable fact. From grodet at cochin.univ-paris5.fr Mon Jul 2 06:16:17 2001 From: grodet at cochin.univ-paris5.fr (GN) Date: Mon, 02 Jul 2001 12:16:17 +0200 Subject: =?iso-8859-1?Q?=E0?= vendre Message-ID: <3B4049F0.7068DE7E@cochin.univ-paris5.fr> un ordinateur fait main, fonctionne tr?s bien et n'a jamais eu de probl?me syst?me Facture Prix (F) Bo?tier moyen tour ATX oui 260 Ventilateur pour bo?tier oui 75 Carte graphique ATI xpert play 8 Mo AGP oui 410 Carte son Sound Blaster Live (CREATIVE) oui 410 Carte de d?compression PC-DVD Dxr3 non 590 Carte m?re ASUS P3B-F oui 949 CPU PENTIUM III 450 MHZ UDMA 66 oui 1328 Ventilateur pour Pentium III oui 100 Lecteur DVD 6X PIONNER IDE oui 699 Graveur CD-RW CRX100E non 1499 DD 8.4 Go SEAGATE IDE UDMA 66 oui 788 Lecteur de disquette 3" 1/2 SONY oui 100 M?moire SDRAM 64Mo PC-100 oui 938 M?moire DIMM 128 Mo SDRAM PC-133 oui 485 Haut Parleur Sound Blaster Speakers35 (CREATIVE) non 169 Imprimante HP DESKJET 610C oui 690 Ecran 15" Hewlett PACKARD non 500 Calvier 108 touches Win95-98 oui 99 Souris LOGITECH avec roulette non 265 Total 10354 F Vends: 7000 F ? d?battre Me joindre soit ? mon adresse grodet.n at voila.fr ou grodet at cochin.univ-paris5.fr ou t?l: 06.63.12.41.96 laissez un message et un num?ro de t?l si vous tomez sur le r?pondeur Merci From aleaxit at yahoo.com Wed Jul 18 08:06:01 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 18 Jul 2001 14:06:01 +0200 Subject: OO misconceptions References: <9ir1l7$3ja$1@panix2.panix.com> <9irfbc11jaq@enews1.newsguy.com> <3B538E16.65394C9D@engcorp.com> <9j0rko025gf@enews3.newsguy.com> Message-ID: <9j3u3c030k4@enews4.newsguy.com> "Tim Hammerquist" wrote in message news:slrn9l9k6t.va1.tim at vegeta.ath.cx... > Me parece que Alex Martelli dijo: > > I wasn't part of this discussion, but since, for once, there > > does seem to be a chance for a fair-headed, non-flaming > > comparison, I'd be loath to see it fizzle out with an "agree > > to disagree" when no technical issues have been discussed > > (it seems to me). > > I cling to the philosophy that there is no "better" language and that a > programmer's ability to _use_ it is more important than benchmarks or > syntax. It can be -- while I know of no studies directly targeting this, Prechelt's results do confirm that variations between programmers using the same language are at least as large as variations between median values of metrics for different languages. However, as long as we're talking about plausible as opposed to proven results, it seems to me that it's quite likely that this situation is *temporary*. Consider a programmer who knows Fortran quite well, and Perl not at all. She needs to print all lines in several files that meet certain criteria. It is quite possible that she can hack a Fortran program for the purpose in less time than it would take her to learn enough Perl for the purpose. If this is the last time in her life that she needs such a task performed, it would thus be quite cost-effective for her not to learn Perl at all. But does this line of argument make sense to you? Would it lead you to conclude that "Fortran is preferable to Perl for certain tasks regarding extraction and reporting of lines from textfiles"? That would look to me like a wrong-headed way to frame the situation. It's quite unlikely that a task in a sufficiently wide class, such as this one, presents itself for the first and last time in a programmer's career (*possible*, since the programmer MIGHT die tonight: but, NOT *likely*). Most likely other tasks in similar fields will appear again and again. The programmer who devoted the reasonable amount of effort to keeping her own skills up to date (and ancillary deployment efforts, e.g., downloading and installing a Perl interpreter on a machine that used to have only a Fortran compiler installed) will therefore, most likely, soon be better off than the one who sticks to the tools she is already highly productive with -- *IF* the new tools do indeed present an intrinsic advantage over the already-known alternatives. > For this reason, for a given application, I might reach for > Perl before Python because I have more experience with it. However, I Assuming for the sake of argument that the general class of application is one where Python has intrinsic advantage (as opposed to one where the two P languages are more or less equal, or one where Perl has advantage), this might be short- term sensible but long-term inferior, as above sketched. I.e., you may get your current task done faster, but over a longer period of time still enjoy lower overall productivity. Which is why I believe it's potentially more interesting to unearth the 'general classes of applications' where the intrinsic advantages and disadvantages lie. I suspect many important application categories will show, roughly, a draw, assuming highly developed knowledge of both languages by the same programmer -- at least, this is surely what Prechelt's results suggest (hard to find ANY statistically significant difference between Perl and Python in those tests). But this is like trying to compare two restaurants by listing the huge list of things they have in common; for _comparison_ purposes, finding out that Chez Albert has vastly better Yorkshire Pudding while Da Bodillo shines in deep-fried Camembert dishes is more meaningful, no matter how marginal such culinary details may be in the overall picture of running a good restaurant. > am not content with "just getting by" in a language if I have an > opportunity to learn more (as long as it doesn't piss me off with every > :w:!javac % ... but I won't mention any names ... oops!) A *FAST* Java compiler would surely do wonders for that language's approachability, but that's another issue:-). > > Declaring my bias: I am "violently anti-Perl" myself, mostly > > because I wrote a *LOT* of Perl code (and helped others write > > it, and maintain it, and maintained a lot myself, etc, etc). > > If Python wasn't around, I'd probably still be doing so (and > > hating it) for lack of viable alternatives. Since discovering > > Python, I moved to Python all code I had in Perl. When asked > > for help, advice, &c, about maintaining Perl, studying Perl, > > &c, my invariable answer today is "do it in Python instead". > > I respect your honesty. > Granted, Perl had the longest and steepest learning curve since C++ for Personally, I found Perl the only language with an even steeper and longer learning curve than C++ -- which, I guess, is part of why I'm a C++ Brainbench MVP but definitely *NOT* a Perl one:-). But it's more of an issue of "what are the alternatives". I still don't know of any real alternative to C++ for *its* strengths -- and believe me, I *HAVE* looked -- just consider two daily tasks for me, writing small, fast components that directly interface to system libraries for use as COM servers and as Python extensions: with C++, ATL gives me COM serving, Boost Python gives me Python extensions, the rest of Boost and the C++ Standard Library and lots of other free libraries give me lots of wonderful reusable stuff -- and even mediocre C++ compilers such as Microsoft's give me great performance. Eiffel, O'Caml, Dylan, Modula-3 -- and many others -- tried them all, liked some things, disliked others, but where's all of this indispensable infrastructure, for free, at my fingertips...? While, for Perl, I *HAVE* found an alternative, at long last... if and when I ever find an equally "dominating" alternative to C++ I may have a similarly-violent reaction to it:-). > me. But after grasping the concept of "context" and learning to use > Perl's m// and s/// operators to my advantage, I find I can just > accomplish more faster than with most other languages, even (so far) I was in the same situation 2 years ago, to the day. Which is why I used Perl, even while detesting it -- for many tasks I was more productive with it than with any other language. (I never detested C++ as deeply as I resented Perl -- the design strategy for C++, while crazily ambitious in all it wanted to accomplish, never struck me as wrong-headed as much as the _deliberate_ choice to have as many redundant ways to express the same thing as could fit in a single, poor, over-bloated interpreter program). > with Python. Having come from GW-BASIC, I had slightly less trouble > grasping the whole "curse characters" bit. Having come from APL, then APL2, I had and still have a deep appreciation for what abundant use of special characters can do for you. That's not the real, deep problem for me (and I'm less interested in syntax-sugar aspects than 99% of all programmers, I think). Rather, it's the over-abundance of purported-to-be-"convenient" irregular special-cases that still has me gnashing my teeth in dim memory (I've forgotten as much as humanly possible about the subject over the last two years -- a common after-shock victim reaction, I'm told). > BTW: I have benchmarks (I think fair ones) where regex parsing is faster > than string parsing. I've taken pains to optimize the string parsing > function. I think my point is, whether advocate of regex's or > string-parsing, be willing to see the other's strengths. This might Regular Expressions are one of those subjects where I *wish* there were better solutions, but I'm resigned to there not being any (not sufficiently general ones, etc) -- so I do the best I can in terms of using, teaching, and so on. But when examining a specific case where parsing is needed of course I'm aware of various specific cases where other approaches dominate RE's. Which is why I'd like to be shown the *specific* cases where Perl dominates Python. Knowing of a few, net of transient effects such as a given programmer knowing one and not the other or other deployment issues, would help reconcile me with Perl's existence:-). I can easily see such specific cases where the languages' niches are far enough from each other. If I have a class of problems where logical-programming and backtracking can be used to very good effect, for example, it seems quite reasonable to me that Prolog (or Mercury or Mozart or ...) may be strongly preferable for such problems to languages that are deeply imperative at their core (Perl or Python or C++ or whatever). It's when the niches are very close, that problems seeing the specific areas where one language or the other is preferable loom larger. And I'm not particularly interested in deployment issues, e.g. "Javascript is better because it runs client-side portably" -- that's just because of Netscape's quondam silly decision to invent Yet Another Scripting Language for inclusion in their product; Javascript, *qua* language, doesn't appear to me to have anything to justify its existence (in fact I detest it even more than I detest Perl -- at least Perl is powerful, for all of its complication and awkwardness, while Javascript manages to have the complexity and "ad-hocness" WITHOUT a significant amount of power to show for them...!-). > In web developing, where I can't necessarily convince my clients to use > a host that provides the tools I'd most like to use, Perl is more > readily available than Python, and especially more so than Apparently your clients aren't wedded to NT...? Because in that case you might get VBScript as your sum total of readily available tools... either Perl or Python requiring a download-and-install (worst case for most boxes, today, surely). > mod_p(erl|ython). Python seems to be catching on in a big way, though, > especially with it's standard inclusion in many linux distros. But when > I can't get the tools I'd like, Perl/Python's overlapping applicability > is really a blessing, no? Either that's there, I know I can do what I > need to do. Sure, and if you get proficient in VBScript, you're even more likely to be able to do the job. But meanwhile, I still haven't learned anything about the general application areas where Perl is alleged to enjoy intrinsic advantages over Python -- the purpose of this thread from my personal viewpoint... if somebody knowledgeable in both languages such as you are can't help me ascertain this, who might? Alex From Zeke at xyz.net Sun Jul 22 02:23:48 2001 From: Zeke at xyz.net (zeke) Date: Sat, 21 Jul 2001 23:23:48 -0700 Subject: Any Suggestions for an Editor with MS-Windows ? Message-ID: <92757716C8BFF476.D432477A795DB759.E2FB05E062137965@lp.airnews.net> Am almost half way through the manual and getting ready for the easy job of bringing over some basic files (yea, right). Currently using Ultra Edit but having doubts about it. zeke From tim.one at home.com Wed Jul 25 15:18:02 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 25 Jul 2001 15:18:02 -0400 Subject: PEP0238 lament In-Reply-To: Message-ID: [Terry Reedy] > ... > I recently realized that a seemingly-safe change that gives semantic > meaning to a syntactically valid but previously meaningless construct > (given the state of the vars) will break code that relies on the > previously resulting exception. This is nothing new, and indeed it happens every release: *nothing* can change without risk of breakage. It's not even safe to add a meaning for a sequence of tokens that was previously a SyntaxError, since Python code can dynamically compile strings at runtime and branch based on whether compile() (exec, eval(), etc) raise SyntaxError. Even fixing gross bugs can break "working" code. > ... > Now make seq*seq mean crossconcatenation and the program may break. > This raises the issue of whether an exception, in any particular > circumstance, is defined behavior (which referably should not be > changed) or the result of undefined behavior (which we should feel > free to define). Many such questions have gone unaddressed. For this particular one, exception behavior is rarely spelled out in full by the docs, so it's usually, and speaking strictly, undefined. In practice, like all other changes, one of this ilk gets evaluated on the best-guess likelihood that it will provoke significant breakage. For example, Python will likely never change an OverflowError into a SystemError, but it's not rare for AttributeErrors to turn into TypeErrors, or vice versa, across releases, as objects grow smarter. From nperkins7 at home.com Tue Jul 24 12:02:02 2001 From: nperkins7 at home.com (Nick Perkins) Date: Tue, 24 Jul 2001 16:02:02 GMT Subject: exec considered harmful References: <9jjo5b$jn3$1@giles.kryogenix.org> Message-ID: <_Zg77.543539$eK2.114006347@news4.rdc1.on.home.com> "Aquarius" wrote in message news:9jjo5b$jn3$1 at giles.kryogenix.org... > I've got a CGI which reads a file and then execs its contents. The file > defines a function, and that function can't find itself to call > recursively; it gets a NameError. > > Example: > > [ aquarius at giles ] /home/httpd/kryogenix.org/current/web $ cat foo.cgi > #! /usr/bin/python > > import sys > sys.stderr = sys.stdout > > print "Content-type: text/html\n\n" > > > def main(): > fp = open("foo.txt") > exec(fp.read()) > > main() > > [ aquarius at giles ] /home/httpd/kryogenix.org/current/web $ cat foo.txt > > def bar(quux=None): > if quux == "test": > print "Hello, world!" > else: > bar("test") > > bar("nothing") > > [ aquarius at giles ] /home/httpd/kryogenix.org/current/web $ python foo.cgi > Content-type: text/html > > > Traceback (innermost last): > File "foo.cgi", line 13, in ? > main() > File "foo.cgi", line 11, in main > exec(fp.read()) > File "", line 8, in ? > File "", line 6, in bar > NameError: bar > > My question here is: is there anything I can do about this? I assume > that you can't call bar() from inside bar() because it only knows about > two namespaces, global (which main() is in) and the "inside-bar()" > namespace, and bar() itself is in neither. I've tried this with both > 1.5.2 and 2.0.1 and there doesn't appear to be any different (aside > from the wording of the NameError changing to "There is no variable > named 'bar'" under 2.0.1, which I assume is the same thing). > > Aq -- I wish I understood namespaces > > -- > "The grand plan that is Aquarius proceeds apace" > -- Frank Miller, "Ronin" why exec(), when you can import? I think that people with experience in Perl tend to want to exec() too much. If you have a function in another file that you want to execute, you should make that other file a .py file, and import it. In the old days, we had "GOTO Considered Harmful", today, in Python, I thing we need "exec() Considered Harmful". ( but maybe that's just me.. I have done a fair bit of Python, and *never* used exec() or eval() ) From guido at python.org Fri Jul 27 13:49:09 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 27 Jul 2001 17:49:09 GMT Subject: PEP 238 (revised) References: Message-ID: Paul Foley writes: > > __div__(), __floordiv__(), __truediv__(); > > Will __truediv__ become __div__ again in Python 3.0, or what? Yes. > I wonder whether there's any need to distinguish (classic) __div__ and > __truediv__ for user-defined objects, though; I'd think they should > continue to do what they do now, so you can just leave it __div__. I don't want to make user-defined classes second-class citizens. Certainly not with the type/class unification going on. > > Floor division will be implemented in all the Python numeric > > types, and will have the semantics of > > > a // b == floor(a/b) > > > except that the type of a//b will be the type a and b will be > > coerced into. > > I'm not sure how to parse that. a and b are going to be coerced to > the type of a//b? But what is the type of a//b? That's determined > _by_ a and b, right? Or is it saying the type of a//b will be the > type of a, and b will be coerced to that same type? That's not right. Sorry, the language was a bit off. How about this: Floor division will be implemented in all the Python numeric types, and will have the semantics of a // b == floor(a/b) except that the result type will be the common type into which a and b are coerced before the operation. Also, I'm adding explicit examples for the built-in types (which includes the useful information that this is an error for complex). > > True division for ints and longs will convert the arguments to > > float and then apply a float division. That is, even 2/1 will > > return a float (2.0), not an int. > > What??? Blech! [remainder of thoughtstream censored] > > Actually, I suppose that makes sense if you think float is above > rational in the type hierarchy. To Marcin Kowalczyk: here's an > example of something that has different results! I should add a qualifier: as long as we have no rational type. With a rational type, 1/2 should return a rational under true division. But it certainly should not be 0, because that is classic division, which is going to be phased out. > > - It has been proposed to call // the quotient operator. I like > > this. I might rewrite the PEP to use this if enough people like > > it. (But isn't the assumption that this truncates towards > > zero?) > > Everybody here seems to think "quotient" means an integer?! I don't > think so. I've heard the floor-division result called a "partial > quotient", but I don't know if that's standard terminology. > [Mathematicians?] > > [Actually, I guess it is -- since I haven't sent this yet, I looked it > up in mathematics dictionary, which also calls it a partial quotient] I'm sticking with true division and floor division for now. They are newly introduced terms that are clearly defined at the start of the PEP. > > A. Use x*1.0/y for true division, divmod(x, y)[0] for int > > division. Especially the latter is best hidden inside a > > function. You may also write floor(x)/y for true division if Note that floor here was a typo; I meant float(). > A two arg version of floor would be a good addition; it can produce a > more accurate result than doing a division (in the absence of an > actual ratio type; and more efficiently if you do what ratios) I don't understand why everybody suddenly associates floor with division. It has nothing to do with division -- it is just a mathematical operator that is useful in the exact mathematical definition of integer division. --Guido van Rossum (home page: http://www.python.org/~guido/) From dirck at pacbell.net Thu Jul 19 13:30:03 2001 From: dirck at pacbell.net (Dirck Blaskey) Date: 19 Jul 2001 10:30:03 -0700 Subject: RELEASED: Python 2.2a1 References: Message-ID: <6c8b7eb9.0107190930.508f5014@posting.google.com> Just a bit of: ============== "Three Cheers, good work guys, great stuff!" generators/iterators look terrific. Now you can get some rest! ( at least until the Beta ;) (Don't want y'all to feel under-appreciated.) ===================== def fibonnaci(limit): p,n = 0,1 while 1: yield n p,n = n,n+p if n > limit: break From sholden at holdenweb.com Tue Jul 3 09:45:23 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 3 Jul 2001 09:45:23 -0400 Subject: problem with sending email References: Message-ID: "Haris Lekatsas" wrote in ... > This works thanks! > > Unfortunately it makes my scripts less portable as the path to > sendmail has to be specified (not always at /usr/sbin/sendmail) > but this seems to be the only solution I have so far. > I wonder if python's smtplib is broken. > Certainly not *that* broken. On Windows platforms it sends megabytes of mail for me every month, some of it single messages with 2MB zipfile attachments. Don't currently use it on Unix. I notice in your original code you assemble the message line-by-line, reading from a text file. You could think about a) Putting debug outputs in there to see what message length is being passed to SMPT.sendmail(), or b) Using read() to suck the whole thing in - if line endings are a problem you could use replace() to ensure they are correct. But you really should check what sendmail() is being given, so you know where to look next for the possible error. regards Steve -- http://www.holdenweb.com/ From bsass at freenet.edmonton.ab.ca Thu Jul 26 04:15:07 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Thu, 26 Jul 2001 02:15:07 -0600 (MDT) Subject: proposed language change to int/int==float (was: PEP0238 lament) In-Reply-To: Message-ID: On Thu, 26 Jul 2001, Duncan Booth wrote: > lomax at pumpichank.com (Frank "Cookie Jar" Lomax) wrote in > news:mailman.996073073.17868.python-list at python.org: > > > No, 1 cookie for 2 children always means no cookies for either child, > > lots of crumbs for the dog to lick up, and years of therapy for the > > entire family. > > > > proof-that-integer-division-causes-thousands-of-disfunctional-families- > > per-year-and-must-be-abolished-ly y'rs, - frank > > > > This newsgroup is getting decidedly surreal this morning. the post above > was immediately followed in my newsreader by one beginning: > > > Check out the Cookie module in the Python distribution: > > > > http://www.python.org/doc/current/lib/module-Cookie.html > > > > It includes a simple example of how to use cookies from Python. and if you are using Linux you can have Coffee with your cookies... -----8<----- COFFEE-HOWTO Georgatos Photis, < gef at ceid.upatras.gr> v0.5, 15 January 1998 ____________________________________________________________________ One of the most bothering remarks on software, I have ever heard, is weather this or that thing can make coffee. So, Linux DOES make coffee. And it tastes good, instead! ____________________________________________________________________ ... The main problem is how to control the coffee machine with the computer, so that it will be controlled by software. This generally means an ON/OFF switch implemented as a circuit which controls the coffee-machine's power supply. ... ----->8----- sorry. From cjc26 at nospam.cornell.edu Thu Jul 26 11:40:05 2001 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Thu, 26 Jul 2001 15:40:05 GMT Subject: 2.2 features References: <3B5F0867.7447E5FB@ccvcorp.com> Message-ID: * Tom Good menulis: | | #------ begin code | | def genWhile(g, condition): | """ | run generator g while 'condition' is true. | Condition is a partial expression string such as "< 10" | to be evaluated with g.next() as the left side | """ | while 1: | next = g.next() | if eval("next " + condition): | yield next | else: | raise StopIteration | | #------ end code | | Then you can say, for example: | | >>> g = fib() | >>> [x for x in genWhile(g, "< 50")] | | [1, 1, 2, 3, 5, 8, 13, 21, 34] | | ...to get the Fibonacci numbers that are less than 50. This is neat, but I think passing in a function to test the condition would be cleaner than passing in a string. Like this: def genWhile(g, condition): while 1: next = g.next() if condition(next): yield next else: return [x for x in genWhile(fib(), lambda f: f < 50)] -- Cliff Crawford http://www.sowrong.org/ A sign should be posted over every campus toilet: "This flush comes to you by courtesy of capitalism." -- Camille Paglia From aleaxit at yahoo.com Wed Jul 11 08:55:22 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 11 Jul 2001 14:55:22 +0200 Subject: Bug in __imul__ References: <9ihg33$irjha$1@ID-11957.news.dfncis.de> Message-ID: <9ihics0o27@enews4.newsguy.com> "Emile van Sebille" wrote in message news:9ihg33$irjha$1 at ID-11957.news.dfncis.de... > Does it bother anyone that > a *= 3 + 4 > returns a different value from > a = a * 3 + 4 Can't speak for others, but personally I would be more than bothered (I'd be *astonished* as well as *flabbergasted*) if augmented assignment operators weren't lower-priority than all ordinary binary operators. Alex From niemeyer at conectiva.com Fri Jul 20 09:01:45 2001 From: niemeyer at conectiva.com (Gustavo Niemeyer) Date: Fri, 20 Jul 2001 10:01:45 -0300 Subject: Case insensitivity In-Reply-To: ; from guido@python.org on Thu, Jul 19, 2001 at 08:30:15PM +0000 References: Message-ID: <20010720100145.B27699@tux.distro.conectiva> > easily learn to work with case-insensitive systems. It's possible > that most programmers have case-sensitive minds, but I think that most > non-programmers probably have case-insensitive minds. And > non-programmers are quite the majority. *If* there is any hard [...] > It has been argued that case-sensitivity is a minor wart that's easily > explained. I find that a weak argument. Lots of minor problems can > be explained and gotten used to, but that doesn't mean we shouldn't > try to get rid of them if we can. Historically, this argument has > been used as an excuse for poor compilers or linkers. Maybe we should also allow constructions such as print "hello world" if var is true since that's the way non-programmers think. Indeed, I don't think case-sensitiveness is something that will help non-programmers to get used to the language. You have so many factors to learn when you're starting, case sensitiveness will be just one more behavior of the language (not a wart at all). On the other hand, I think that, if you create a case-insensitive tool or command line option and let users get used to it, it'll take forever to learn how to program in sensitive mode. [...] > what's wrong with that? (If you really feel that being a programmer > makes you part of an elite and you want to keep others out of that > elite, I pity you.) That's not the point at all. [...] > It's been argued that it's convenient to be able to write c = C(), > where C is a class and c is an instance of that class. Surely there > are other conventions we can use. Sure, but I could tell you the same argument you've used when saying that "people can get used to case-sesitive programming" is not enough. It woulnd't be nice to force people using a different (and uncommon?) naming scheme just because they "can" learn. > To me, the only real important question is, how can we introduce > case-sensitivity for novices without breaking the millions of lines of > existing Python code. One option could be: forget it, it's too late. > Another: put the case-insensitivity in the tools. Besides the implementing-partially problem I've introduced above, if you changed the language, you'd get a lot of happy people saying "Alleluia!" and a lot of unhappy people saying "Damn Guido!". :-) -- Gustavo Niemeyer [ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ] From BPettersen at NAREX.com Tue Jul 3 18:47:06 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Tue, 3 Jul 2001 16:47:06 -0600 Subject: No float limits Message-ID: <6957F6A694B49A4096F7CFD0D900042F27D4DD@admin56.narex.com> > From: J?rgen Hermann [mailto:jh at web.de] > > Hi! > > I just stumbled over the fact that there is sys.maxint, but > no sys.maxfloat > and sys.epsfloat. In case anyone thinks this is a valid > addition, I'll come > up with a patch. I could actually have used that yesterday ;-) -- bjorn From aleaxit at yahoo.com Mon Jul 9 17:44:59 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 9 Jul 2001 23:44:59 +0200 Subject: File processing References: <9id5p9$8r62@interserv.etn.com> Message-ID: <9id8he0110c@enews2.newsguy.com> "Chris McMillan" wrote in message news:9id5p9$8r62 at interserv.etn.com... > Hello all! > > I'm trying to write a script that will open a file, delete the first line, > and then save the file with the same name. Can someone please point me in > the right direction? Thanks! There are basically two good architectures for this task: 1. simplest, fastest, most suitable for files that fit in memory (say, up to about 100 or 200 MB on a typical middling machine as sold today): read all lines, write all but the first 2. almost-as-simple, maybe a tad slower, OK for any size file: loop reading lines, each time (except the first) writing the line back to a file that will later be renamed to cover the old one (or, physically to the old file, which however risks damaging it if the power goes midway through...). def allbutone_1(filename): all_lines = open(filename).readlines() open(filename,'w').writelines(all_lines[1:]) Hard to beat for simplicity, isn't it? def allbutone_2(filename): import fileinput for line in fileinput.input(filename,inplace=1,backup='.sav'): if fileinput.filelineno() > 1: print line, As you can see, module fileinput makes the task almost as easy as the simplest approach! You also automatically get a copy of the old file named with a .sav extension -- good cheap insurance against power outings &c; you'd need extra code for that (at least one os.rename!) in version 1. Warning: both functions are untested -- try them out in a sandbox before relying on them on your real data!!! > Why am I doing this you may ask: I have tens of data files that I need to > strip the first line before I can process it in Matlab. So, I dream of a > script that opens every file in a directory, deletes the first line, ..... The fileinput-based approach is GREAT for this, since it ALREADY works, as written, for whatever number of files -- just call it with the list of file as argument 'filename'! glob.glob, sys.argv, or os.listdir -- whatever gives you a list of filenames may serve. Magic, innit...?-) Alex From greg at electricrain.com Tue Jul 17 21:39:12 2001 From: greg at electricrain.com (Gregory P. Smith) Date: Tue, 17 Jul 2001 18:39:12 -0700 Subject: Profiling threads? In-Reply-To: <3B54BD57.5A2A3048@americasm01.nt.com>; from rjohns@americasm01.nt.com on Tue, Jul 17, 2001 at 06:33:59PM -0400 References: <3B54BD57.5A2A3048@americasm01.nt.com> Message-ID: <20010717183912.F28612@zot.electricrain.com> On Tue, Jul 17, 2001 at 06:33:59PM -0400, Johns, Richard [NCRTP:JZ54:EXCH] wrote: > Any suggestions on using profile with threaded programs? I haven't managed > to get the profiler to do anything in a thread yet. Is it a matter of > getting the thread to exit on its own so the profiler can dump its report? While the profiler doesn't appear to support profiling the overall execution of a program regardless of the threads you can profile the performance on individual threads (even at the same time). We use the following function to call the main loop of our worker threads (such as the asyncore select loop and our seperate event queue thread): def _dont_enable_if_you_want_speed_profit(func): result = None p = profile.Profile() try: result = p.runcall(func) finally: if hasattr(func, 'func_name'): tmpfname = tempfile.mktemp() + func.func_name elif hasattr(func, 'im_func') and hasattr(func.im_func, '__name__'): tmpfname = tempfile.mktemp() + func.im_func.__name__ else: tmpfname = tempfile.mktemp() + "unknownfuncname" debug.write("thread finished %s\n", args=(tmpfname,), v=0, vs="debug") p.dump_stats(tmpfname) p = None del p return result Yes, as this implies, you -do- need the thread to exit in order for the profiler to dump its report. I suggest creating a threading.Event object that your thread checks using isSet() periodically to see if it should exit. (or when the thread sleeps it should wait on the event rather than using time.sleep). -- Gregory P. Smith gnupg/pgp: http://electricrain.com/greg/keys/ C379 1F92 3703 52C9 87C4 BE58 6CDA DB87 105D 9163 From thecalm at NOSPAM.btinternet.com Sun Jul 29 08:50:52 2001 From: thecalm at NOSPAM.btinternet.com (G. Willoughby) Date: Sun, 29 Jul 2001 13:50:52 +0100 Subject: What RE would i use to match this whole word? References: <9jv3mi$5lv$1@neptunium.btinternet.com> <20010729003831.2A193BED.NOFFLE@niccolo.ke4.de> Message-ID: <9k10qe$n8n$1@neptunium.btinternet.com> this is the code im using for a 'file file' kinda program: [snip] def search(resultPane, dir, files): searchString = re.compile(str(entryField.get()), re.IGNORECASE) # Get search string for file in files: if searchString.search(file) == "None": calculateResultSize() resultPane.update() else: resultPane.insert(END, os.path.join(dir, file)) calculateResultSize() resultPane.update() def go(): if str(entryField.get()) == "": status.set("No search string has been entered!") else: resultPane.delete(0, END) # Clear the results pane! driveList=string.split(win32api.GetLogicalDriveStrings(),'\0')[:-1] # Get Drives for x in range(0,len(driveList)): os.path.walk(driveList[x], search, resultPane) [snip] when the search is started the string which is taken from the entry field on the form it is passed to the re.compile() function and an os.path.walk is started. but this matches everything! in other words any file that contains any of the characters from the entry field is listed in the results pane. i'm missing something from the re i reckon. any ideas? G. Willoughby "Mirko Liss" wrote in message news:20010729003831.2A193BED.NOFFLE at niccolo.ke4.de... > > On Sat, 28 Jul 2001, G. Willoughby wrote: > > What RE would i use to match this whole word, 'Rasping' > > > > i was using: > > > > searchString = re.compile('Rasping', re.IGNORECASE) but this don't seem to > > be right. Im missing something! any help would be appreiciated! > > Hmm, what about some examples: > > Python 2.1.1 (#4, Jul 25 2001, 10:17:07) > [GCC 2.95.2 19991024 (release)] on linux2 > Type "copyright", "credits" or "license" for more information. > >>> import re > >>> pattern = re.compile('RASping', re.IGNORECASE) > >>> pattern > > >>> pattern.match("rasping racing pong") > > >>> pattern.match("rasping racing pong").group(0) > 'rasping' > >>> pattern.match("Grasping racing pong").group(0) > Traceback (most recent call last): > File "", line 1, in ? > AttributeError: 'None' object has no attribute 'group' > >>> print pattern.match("Grasping racing pong") > None > >>> pattern.search("Grasping racing pong").group(0) > 'rasping' > >>> pattern.search("Grasping racing pong").span(0) > (1, 8) > > I believe the Python Documentation and the FAQ explains > this in more detail. Python reg exps are quite similar > to Perl reg exps, so there's a huge pile of books at > the friendly bookshop in your neighborhood, as well. > > > regards, > > Mirko > From vAbazarov at dAnai.com Thu Jul 26 13:04:46 2001 From: vAbazarov at dAnai.com (Victor Bazarov) Date: Thu, 26 Jul 2001 17:04:46 GMT Subject: Unusual minidom behaviour: Part Deux References: Message-ID: "Guido van Rossum" wrote... > [..] > Victor, we don't have enough information. Are you using Jython, or > are you somehow invoking C-Python from Java? Can you reproduce the > problem in a self-contained example program? I am not using Jython. I am running a regular one (if it's called C-Python, I didn't know) from Java using Runtime.exec("python something.py"). Its version is 2.0 (at least that's what it reports when run with -V). I cannot always reproduce the problem in my _current_ system (it only happens in some runs), much less in a whole another program. In order to write a test program I have to know what to try to reproduce. Should it itself be multi-threaded? How complex should it be? If I don't get the same result, does it mean the problem is in my Java program or is it just a coincidence? (as I wrote before, it does not happen if I run Java program under the debugger instead of simply executing it) You see, it would probably take me as long to create a "self-contained" example as it did to create the system in its current state. One of my colleagues suggested wrapping the call to minidom.parse in a critical section (locking something before, unlocking after), another hint came from you: let the main program sleep after fork. At this point I frankly care only about one thing: to prevent it from happening. Victor -- Please remove capital A's from my address when replying by mail From steve at lurking.demon.co.uk Mon Jul 23 23:33:53 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Tue, 24 Jul 2001 04:33:53 +0100 Subject: Is it possible to build Python without floats (or other unwanted capabilities) References: <3B5BDCB4.A2010560@letterror.com> <3B5C48A0.56D88724@alcyone.com> <7ikoltclv5sjr376ua6m1jlk3a9l1qftju@4ax.com> <3b5c990b.237461111@wa.news.verio.net> <3b5cbf31.247227744@wa.news.verio.net> Message-ID: On Tue, 24 Jul 2001 00:35:49 GMT, bokr at accessone.com (Bengt Richter) wrote: >No, I meant really no floating point, including software. What if you had >zero use for floating point, and wanted the benefit of a small footprint? I see what you mean. I don't know for sure, but given the target applications of stackless Python it's quite possibly something they've addressed. With luck, it's little more than a build option. Beyond that I can't help, I'm afraid. Subject line changed in the hope that someone else can... >I wonder if the implementation is factored to where not using floating point >would let you substitute small exception-raising stubs for otherwise large >(?? usually, floating point carries a lot of baggage along in the C/C++ world) >chunks concerned with floating point. > >Then that could be a make option. I was wondering if someone's been there done that. From NOSPAM.hnguyen421 at NOSPAM.hotmail.com Thu Jul 5 08:07:53 2001 From: NOSPAM.hnguyen421 at NOSPAM.hotmail.com (alphaZeta) Date: Thu, 5 Jul 2001 14:07:53 +0200 Subject: system exec ? References: <9i1er4$mth$1@news.businessobjects.com> <9i1ffe029cm@enews1.newsguy.com> Message-ID: <9i1npl$160$1@news.businessobjects.com> Thanks, I was also planning to use the readlines() method. "Alex Martelli" wrote in message news:9i1ffe029cm at enews1.newsguy.com... > "alphaZeta" wrote in message > news:9i1er4$mth$1 at news.businessobjects.com... > > Hi, > > > > I didn't find any documentation (lib and tut) about how to execute a > program > > in a python script. > > os.system('theprogram') just executes it. What you desire is different: > > > Does anybody know ? > > > > For example : I would like to store in a variable the result of a call to > > the system. > > alike : >>> a = sys.exe("ls -l") > > a = os.popen("ls -l").read() > > may be what you want (but you may also prefer to call .readlines() > instead for example, getting the result as a list of strings, one > per line, rather than as one big string). > > > Alex > > > From steve at lurking.demon.co.uk Sun Jul 22 02:27:48 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Sun, 22 Jul 2001 07:27:48 +0100 Subject: Can I copy a generators state and then backtrack to it if necessary? References: Message-ID: On Sat, 21 Jul 2001 23:41:06 -0400, "Tim Peters" wrote: >[Stephen Horne] >> I don't seem to be getting much response. Please help!!! > >There are only two people who can answer this stuff, and I already did, so >you'll have to try harder to make me feel guilty . Sorry - your reply and my appeal crossed in the post. My message shows a timestamp 10 minutes later than yours, but I composed the appeal off line and besides, these things always take a while to work through the system. Given that I worked out I don't need it after all, and I was wrong about why I thought I'd want it, I don't think there'll be any further appeals ;-) Sorry for hassling you and sorry for asking an ultimately pointless question due to not thinking it through as well as I thought, but thanks for answering. From paulp at ActiveState.com Sat Jul 28 22:16:42 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sat, 28 Jul 2001 19:16:42 -0700 Subject: Unusual minidom behaviour: Part Deux References: Message-ID: <3B63720A.54CA4A66@ActiveState.com> Victor Bazarov wrote: > >... > > How exactly did you find out about that? If one of the threads would > > raise an exception that is not caught, would you see the traceback or > > would it get eaten silently by the calling Java application? > > I don't know the answer to that question. However, I think that > any exception that is not caught in Python code would be caught > in Python interpreter my Java application runs. Is it not true? He didn't ask about whether the *exception* is getting eaten siliently. He asked about the traceback. i.e. the text written to stderr in the event of an exception. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From brian at rk-speed-rugby.dk Sun Jul 22 04:42:41 2001 From: brian at rk-speed-rugby.dk (Brian Elmegaard) Date: 22 Jul 2001 10:42:41 +0200 Subject: Any Suggestions for an Editor with MS-Windows ? References: <92757716C8BFF476.D432477A795DB759.E2FB05E062137965@lp.airnews.net> <3b5a8a87$0$320$6e49188b@news.goldengate.net> Message-ID: "Volucris" writes: > It has PythonWin, a very good editor. If that's what you're looking for. Emacs has a nice python mode. And IDLE works fine with and comes with python itself. -- Brian (remove the sport for mail) http://www.rk-speed.dk http://fiduso.dk http://sunsite.auc.dk/dk-tug \TeX, tak From tjreedy at home.com Fri Jul 27 12:20:24 2001 From: tjreedy at home.com (Terry Reedy) Date: Fri, 27 Jul 2001 16:20:24 GMT Subject: re bad leadership References: <0+yM4IAgmKX7EwIQ@jessikat.fsnet.co.uk> <20010724171838.A21770@xs4all.nl> <4crrlt0jbn9ovvkli3qvhqbc5do3lmpg4j@4ax.com> <%kn77.25759$EP6.6204923@news1.rdc2.pa.home.com> <23891c90.0107250216.2f49e2e6@posting.google.com> <3B5EEED7.C9C7117B@home.net> <23891c90.0107260053.70747d65@posting.google.com> <23891c90.0107270218.34460ea5@posting.google.com> Message-ID: "Paul Boddie" wrote in message news:23891c90.0107270218.34460ea5 at posting.google.com... > "Terry Reedy" wrote in message news:... > > "Paul Boddie" wrote in message > > news:23891c90.0107260053.70747d65 at posting.google.com... > > > considered to be of little value and can be sacrificed > > > to the "language gods" on a whim. > > > > Is this a one-time gift/sacrifice, of this magnitude, in return for I used 'sacrifice' because you did. I used 'gift' as a less loaded alternative. > It's probably best to leave the whole "gift culture" model out of Fine. I had no intention of dragging Raymond's work in here. > this, just to avoid the usual tedious distractions which have plagued > many of the threads about PEP 238. I won't even air my own opinions on > the accuracy or relevance of that model. Instead you presented your own model of mutual obligation as including mutual respect. I agree. Terry J. Reedy From tjreedy at home.com Mon Jul 30 12:57:18 2001 From: tjreedy at home.com (Terry Reedy) Date: Mon, 30 Jul 2001 16:57:18 GMT Subject: Block mail to news spam? Message-ID: Today, there are two (so far) html site ads delivered to the newsgroup via the mail->news gateway. This strips original path info, making complaints difficult. Suggestion: block html postings at the gateway. Only ignorant newcomers try to post such, and they are more likely to be posting directly, so such are almost always spam. From skip at pobox.com Thu Jul 26 16:03:28 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 26 Jul 2001 15:03:28 -0500 Subject: indetation problem In-Reply-To: References: Message-ID: <15200.30608.898782.730800@beluga.mojam.com> Fuming> I am experiencing indentation problems when mixing tabs and Fuming> spaces in my code. They appear in correct indentation in my Fuming> editor, but cause error when running them. I am using Python Fuming> 2.2a1. I reproduced the problem in following interactive Fuming> sequence: You probably shouldn't mix tabs and spaces in your code. If you do, you will need to define a tab as 8 spaces, I believe. That's what the Python lexer expects. Fuming> Question: is this something new, or it has always been there. It Fuming> is strange that I have been using Python for several years, but Fuming> only notice this behavior recently. I think it's been that way for quite some time now, perhaps ten years or so. ;-) Maybe you only recently changed to == ? -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From aahz at panix.com Tue Jul 3 15:01:40 2001 From: aahz at panix.com (Aahz Maruch) Date: 3 Jul 2001 12:01:40 -0700 Subject: Alternate Syntax for dictionary elements References: <3b421046.1836046@news.t-online.de> Message-ID: <9ht4qk$8rc$1@panix2.panix.com> In article <3b421046.1836046 at news.t-online.de>, Gerson Kurz wrote: >Please consider the following: > >dict = { 'type' : 'button', 'id': 32, 'name' : 'some name' } >... >if o['type'] == 'button': > # do something for objects of type button > >Now, take a look at > >if o.type == 'button': > # do something for objects of type button Why not just do this class fakeDict: pass dict = fakeDict() dict.type = 'button' if dict.type == 'button': .... You can easily muck up an __init__() that uses **kwargs, too. -- --- 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'm not tense, i'm just terribly, terribly alert" --unknown From n_d_gangadhar at yahoo.com Sun Jul 22 08:19:34 2001 From: n_d_gangadhar at yahoo.com (NANDYALA D Gangadhar) Date: 22 Jul 2001 05:19:34 -0700 Subject: Name space quirk? Message-ID: <7b9380ca.0107220419.add15d1@posting.google.com> Hello, [Sorry if this is documented and I missed it; I am pretty new to python.] Running the following as a script goes through (unexpectedly, for me), while trying to run it in the interactive python shell catches the NameError (on "myfile"): #!/usr/bin/env python from os import sys def hello (outfile = sys.stdout): # We are writing to what should be an # unknown file descriptor: myfile.write ("Hello, world!\n") if __name__ == '__main__': f = sys.argv[0] + ".out" myfile = open (f, 'w') hw (myfile) Is this behaviour desirable and correct? I guess it can lead to unanticipated results. As you expect, I saw this when I happened to change my variable name only inside a function, and discovered it after using it a lot of times. Gangadhar From fredrik at pythonware.com Tue Jul 3 02:36:44 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 03 Jul 2001 06:36:44 GMT Subject: Python for air traffic control? References: <9hlfbn$6ok$1@nereid.worldonline.nl> <3b4102f4.887720905@wa.news.verio.net> Message-ID: <0Kd07.7470$e5.974463@newsb.telia.net> Bengt wrote: > > I am wondering if using non-deterministic[1] memory allocation is > permissible in a safety-critical system. note that CPython uses reference counting, which is at least as deterministic as malloc/free or auto_ptr stuff. (if you keep feeding a CPython program the same kind of data, it tends to either leak all the time, or not at all). > What kind of testing could you specify to guarantee that code > would continue to run? I've built mission-critical, real-time Python systems. With careful design, and a few months in a "sandbox" environment, such systems tend to run just fine. And I'm pretty sure people doing safety-critical systems know a lot more about advanced testing than we do. So I agree with Gordon: "Go for it (just be careful)." Cheers /F From matjaz.ostroversnik at zrs-tk.si Thu Jul 26 09:46:19 2001 From: matjaz.ostroversnik at zrs-tk.si (Matjaz Ostroversnik) Date: Thu, 26 Jul 2001 15:46:19 +0200 Subject: Informix IDS2000 and Zope/Python/Perl/PHP on Linux References: <3B600F47.2F59C1FC@gdp-group.com> Message-ID: <9jp6vh$7nv$1@planja.arnes.si> Hi Thomas We are using RH 6.2, IIF 2000, apache and PHP 4.0.4 pl1 for our HCV RNA application. It works fine for one year. We bounce the database twice in this time. There are some problems with apache, php, ifx combination, beacuse from time to time we can observe a rather big list of db sessions, but restarting of apache solved the problem. We are even using php (command line mode) for communication with laboratory engines. We are using the same combination for some number of less important applications and we do not have any complaints. "Thomas Volkmar Worm" wrote in message news:3B600F47.2F59C1FC at gdp-group.com... > Hi all! > > I am consindering to use Informix Dynamic Server (Informix Internet > Foundation 2000/Linux) together with Zope and the other 3 P's. > > I wonder, whether somebody has any experience with Linux and > > - IDS 2000 and Perl > or > - IDS 2000 and PHP > or > - IDS 2000 and Python > or > - IDS 2000 and Zope > > and can tell me about the experience he made with one or more of these > combinations. I am interested to hear about > > - availibility of the needed drivers > - their (practical) compatibility to (eg. perl DBI, python DB-API 2.0, > etc.) > - stability > - and what else someone has experienced > > I already was an php.net, python.org, perl.org, zope.org - I guess I > know whats available. It looks to me as if the support for IDS is not so > strong, so I am really interested in real experience somebody had rather > that what you can read in the READMEs. If you stopped using IDS together > with P..., please tell me why and what db (other than mySQL, thats > allready running here) are you using instead. > > If some Informix/IBM people are around: Are there any contributions > planned or in progress for the 3 P's by Informix/IBM? Where can I find > online information about it? > > If you respond to this posting, please send a CC to my email-address > too. > > Thanks for your efforts in advance > > Regards > Thomas Volkmar Worm > > From aahz at panix.com Mon Jul 16 14:25:49 2001 From: aahz at panix.com (Aahz Maruch) Date: 16 Jul 2001 11:25:49 -0700 Subject: Most efficient solution? References: <9iv450$240$1@panix2.panix.com> Message-ID: <9ivbjd$pah$1@panix2.panix.com> In article , Alexandre Fayolle wrote: >On 16 Jul 2001 09:18:40 -0700, Aahz Maruch wrote: >>Alexandre Fayolle wrote: >>> >>>I was referring to the inner loop. n is the number of elements in B >>>(or of keys in C). 'item in B' is O(n), and 'C.has_key(item)' is O(log(n)). >>>You still have to multiply by len(A) for the whole program. >> >>That's functionally incorrect. Except under severely degraded >>conditions, C.has_key(item) is O(n). > >I'm pretty sure I was wrong, but are you sure you are not too? ;o) >Should it not read: 'C.has_key(item) is constant'? -- --- 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 Fortune cookie: Watch your relations with other people carefully, be reserved. From skip at pobox.com Tue Jul 31 13:57:57 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 31 Jul 2001 12:57:57 -0500 Subject: Typing system vs. Java In-Reply-To: References: <3B66B3A2.F47BA3E2@engcorp.com> <3B66E4FA.158E7DDA@home.net> Message-ID: <15206.61861.849518.329947@beluga.mojam.com> C//> QKS is getting a 10-100X improvement in Python execution speeds C//> without modifying the Python language. I keep seeing this reference, but can find nothing but an "under construction" page about Python on their website. Where's the beef? -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From bill-bell at bill-bell.hamilton.on.ca Wed Jul 11 09:40:05 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Wed, 11 Jul 2001 09:40:05 -0400 Subject: PythonCOM and Office. Arrgh! In-Reply-To: <994829008.697.53815.l8@yahoogroups.com> Message-ID: <3B4C1EF5.7494.3038A61@localhost> Matthew asked: > ... what build of win32all are you running with 1.5.2? ... I don't know how to find out. I can tell you that I'm using ActiveState 2.1, build 211, and that the win32all came with it. From fgeiger at datec.at Mon Jul 9 12:09:36 2001 From: fgeiger at datec.at (Franz GEIGER) Date: Mon, 9 Jul 2001 18:09:36 +0200 Subject: [Tkinter]: Grid as in wxPython? References: <9ic90t$s1l$1@newsreaderm1.core.theplanet.net> Message-ID: <9ie6cq$mvc$1@newsreaderm1.core.theplanet.net> Indeed, it does. Thank you Steve! Regards Franz "Steve S.L. Wong" wrote in message news:tkjjrtr89f687e at news.supernews.com... > #I download this code from internet. Hope that helps you. > > from Tkinter import * > > class MultiListbox(Frame): > def __init__(self, master, lists): > Frame.__init__(self, master) > self.lists = [] > for l,w in lists: > frame = Frame(self); frame.pack(side=LEFT, expand=YES, fill=BOTH) > Label(frame, text=l, borderwidth=1, relief=RAISED).pack(fill=X) > lb = Listbox(frame, width=w, borderwidth=0, selectborderwidth=0, > relief=FLAT, exportselection=FALSE) > lb.pack(expand=YES, fill=BOTH) > self.lists.append(lb) > lb.bind('', lambda e, s=self: s._select(e.y)) > lb.bind('', lambda e, s=self: s._select(e.y)) > lb.bind('', lambda e: 'break') > lb.bind('', lambda e, s=self: s._b2motion(e.x, e.y)) > lb.bind('', lambda e, s=self: s._button2(e.x, e.y)) > frame = Frame(self); frame.pack(side=LEFT, fill=Y) > Label(frame, borderwidth=1, relief=RAISED).pack(fill=X) > sb = Scrollbar(frame, orient=VERTICAL, command=self._scroll) > sb.pack(expand=YES, fill=Y) > self.lists[0]['yscrollcommand']=sb.set > > def _select(self, y): > row = self.lists[0].nearest(y) > self.selection_clear(0, END) > self.selection_set(row) > return 'break' > > def _button2(self, x, y): > for l in self.lists: l.scan_mark(x, y) > return 'break' > > def _b2motion(self, x, y): > for l in self.lists: l.scan_dragto(x, y) > return 'break' > > def _scroll(self, *args): > for l in self.lists: > apply(l.yview, args) > > def curselection(self): > return self.lists[0].curselection() > > def delete(self, first, last=None): > for l in self.lists: > l.delete(first, last) > > def get(self, first, last=None): > result = [] > for l in self.lists: > result.append(l.get(first,last)) > if last: return apply(map, [None] + result) > return result > > def index(self, index): > self.lists[0].index(index) > > def insert(self, index, *elements): > for e in elements: > i = 0 > for l in self.lists: > l.insert(index, e[i]) > i = i + 1 > > def size(self): > return self.lists[0].size() > > def see(self, index): > for l in self.lists: > l.see(index) > > def selection_anchor(self, index): > for l in self.lists: > l.selection_anchor(index) > > def selection_clear(self, first, last=None): > for l in self.lists: > l.selection_clear(first, last) > > def selection_includes(self, index): > return self.lists[0].selection_includes(index) > > def selection_set(self, first, last=None): > for l in self.lists: > l.selection_set(first, last) > > if __name__ == '__main__': > tk = Tk() > Label(tk, text='MultiListbox').pack() > mlb = MultiListbox(tk, (('Subject', 40), ('Sender', 20), ('Date', 10))) > for i in range(1000): > mlb.insert(END, ('Important Message: %d' % i, 'John Doe', '10/10/%04d' % > (1900+i))) > mlb.pack(expand=YES,fill=BOTH) > tk.mainloop() > > > "Franz GEIGER" ???g???l?? > news:9ic90t$s1l$1 at newsreaderm1.core.theplanet.net... > > Is anybody aware of anything like wxPython grids, but for Tkinter? For a > > Tkinter GUI I need a grid as it is available in wxPython. I already use > PMW, > > but there isn't such a beast. > > > > Regards > > Franz > > > > > > > > > > From jwbaxter at spamcop.com Sun Jul 22 22:33:14 2001 From: jwbaxter at spamcop.com (John W. Baxter) Date: Sun, 22 Jul 2001 19:33:14 -0700 Subject: Pedants R us (was RE: Language change and code breaks) References: Message-ID: <220720011933146354%jwbaxter@spamcop.com> In article , Delaney, Timothy wrote: > Nah - all the best solutions are worked out in the shower. That's where my best solutions spring to life, as well. Is that why people here say that I'm all wet? --John From rnd at onego.ru Tue Jul 10 04:52:00 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 10 Jul 2001 12:52:00 +0400 (MSD) Subject: os.nice (or docs) BUG? Message-ID: The following from the Python docs: nice (increment) Add increment to the process's ``niceness''. Return the new niceness. Availability: Unix. Contradicts what I see in python 1.5.2 - 2.1: >>> import os >>> os.nice(1) 0 >>> os.nice(5) 0 (and the process niceness become 6 as reported by top) It's docs inaccuracy or os.nice() bug? Or glibc bug? Which category to report it in the Bug tracker? Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Tuesday, July 10, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "-- is the key to success" _/ From BrianQ at ActiveState.com Thu Jul 5 17:26:58 2001 From: BrianQ at ActiveState.com (Brian Quinlan) Date: Thu, 5 Jul 2001 14:26:58 -0700 Subject: Time for a Python "distribution" ? was:Not enough Python library development In-Reply-To: <3B44B63A.BB507CBF@home.net> Message-ID: <001201c10599$392cff70$b503a8c0@activestate.ca> Chris wrote: > My proposal is to create a Python "Distribution" that includes a large > collection of what are becoming standard modules, but are > maintained by folks other than the core Python team. I'm modeling this > idea on the Linux Distributions: the kernel developers don't make any > effort to package up Linux as a useful system; other organizations do > that. There are now a lot of them, and some are substantial commercial > enterprises, but it all started with SLS and then Slackware, etc. ActiveState has kindof done done this already with ActivePython (http://aspn.activestate.com/ASPN/Downloads/ActivePython/). ActivePython includes, alone with the base Python distribution, a utility that allows you to install 3rd party modules. On Windows, the list of available modules includes: FFTPACK MySQL Numeric MySQL PyXML calldll py2exe pyperl tk (and a bunch of others) To install a module, all you have to do is type: pyppm install [package name] The modules in any given installation may vary though, which is one weakness of not having an inclusive standard distribution. -- Brian Quinlan Python and XSLT Developer BrianQ at ActiveState.com ASPN - ActiveState Programmer Network Essential programming tools and information http://aspn.ActiveState.com/ASPN From tundra at tundraware.com Sat Jul 14 20:10:02 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 15 Jul 2001 00:10:02 GMT Subject: not safe at all References: <3B4F743C.66778F9F@tundraware.com> <9ip1qa012en@enews4.newsguy.com> <3B509C1F.B2E7ABD6@tundraware.com> <9iqea10f19@enews1.newsguy.com> Message-ID: <3B50DE63.4217DC08@tundraware.com> Alex Martelli wrote: > > "Tim Daneliuk" wrote in message > news:3B509C1F.B2E7ABD6 at tundraware.com... > ... > > Sure, there are places where portability is important. And portability > > is not a "Yes" or "No" things - there are degrees. But the most > > important thing that needs to be portable are *the skills of the > > people* so that they can be used in many different roles. > > As in, taking a world-renowned specialist in surface-modeling, and > ensuring he wast^H^H^H^H spends enough time to be able to > program a GUI, or knows enough SQL to write some queries, or...? > > No. I meant that in every commercial software/systems environment I've every seen, the portability of the *programmer's* skills was more important than the portability of their final work product. > > Anyway, our code, *by intent* was *not* portable. It couldn't > > be portable in any practical sense because the underlying > > infrastructure paradigms are really different between, say TPF, > > Underlying infrastructure paradigms do tend to differ deeply > when portability is a problem (otherwise, portability is basically > free and it would be very silly to ignore it:-). But it's a serious > error to claim that a program cannot be portable if the underlying > infrastructure paradigms differ widely! Such underlying differences > just raise (a bit) the COST of portability, because you have to > write most of your code to a higher-level abstraction and also > implement that abstraction on different underlying platforms. > You are dead wrong about this. Not all engineering problems can be fixed with money - some are just plain impossible at ANY cost. Portability can fall into this category. It is (or was, and possibly still is) *impossible* to write portable code, for instance, across IBM TPF (for which no high-level language compiler existed), Tandem Non-Stop (which has a VERY different programming model than most other OSs), and Unix AND still meet the performance critera we were expected to hit. Actually, in the case of TPF at the time, it was *literally* impossible to write portable code - everything was written in IBM/3090 BAL (assembler) cuz that's all there was. Short of writing a VM to run BAL on other machines or a 'C' compiler for TPF (which, at the time, would have been a joke considering the performace requirements we had to hit - *everything* on the mainframe had to be hand tuned) there was no way to do it. Portability is not simply an artifact of willingness to spend money, though that certainly is a factor (as is time). It is a consequence of good requirements, good design, and similar-enough target environments to make it feasible in the first place. It's hard enough to do when you have these "similar enough" systems, like, say, Unix and Win2K. But how are you going to port your nice, clean C program to a machine that speaks EBCDIC, has no stack, has no shell as you understand it, does not implement fork/exec, does not have sockets, each CPU is running at 100% utilization very second of the day? Oh, and those are the fastest CPUs for that sort of computation that money can buy. (These conditions have all probably changed by now, but that was the case then.) > But the costs only grow by _a bit_, because good software IS > 'layered' anyway -- levels of different abstraction built on top > of each other. You just have to ensure your lowest levels are > designed in a way that is decently decoupled from specific > bits of infrastructure -- often not MUCH harder than coupling > them heavily and strongly, and often worthwhile anyway (if > the lower-level quirks aren't ALLOWED to percolate upwards > and pollute the higher-level architecture, that may often be > all to the good of the higher-level cleanness and resulting This is a lovely precept that happens to work enough of the time that people start to assume it is always true. Abstraction layers ARE a convenient and helpful design tool and they DO promote better portability. However, you can forget all that if you've ever had to make performance your first consideration. Again, in original example I gave, performance and uptime was all that mattered because we were already running a 7-way CPU cluster of the biggest, baddest mainframes available. When guaranteed response time and/or human safety and/or huge sums of money are at stake, no one gives a Tinker's Damn about portability or any of the other sacred cows that get flogged in "Software Engineering" community. Get yourself invited to the development center at one of airlines reservations systems or VISA or MasterCard and you will discover an entire world where everything you were taught turns out to be wrong. In other words, software that is not neatly layered is not necessarily badly designed, it may well be purpose-built that way. > > > more interested in creating competitive and distinctive market > > advantage than serving the abstract idea of portability. > > What gave you the idea that anybody around here is interested > in "serving abstract ideas"? I'm interested in serving *our > customers*, all 10,000+ of them at last count -- ensuring None of whom give a damn if your code is portable (unless you're selling programming tools like compilers) or how elegantly architected it might be - they just want your application to run on their system. How it does so, is your problem, not theirs. -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From andy_todd at spam.free.yahoo.com Tue Jul 31 22:07:01 2001 From: andy_todd at spam.free.yahoo.com (Andy Todd) Date: Wed, 01 Aug 2001 02:07:01 GMT Subject: simple question:the count of array References: Message-ID: Simon Brunning wrote in : >> From: sdf [SMTP:wqh-2 at 263.net] >> >>> a=['a','b','c'] >> >>> b=a.count() >> Traceback (most recent call last): >> File "", line 1, in ? >> b=a.count() >> TypeError: count() takes exactly 1 argument (0 given) >> >>> >> >> then how I get the number of a,I mean how much >> values in a,in this case it should be 3 > >>>>b=len(a) >>>>print b >3 > >Cheers, >Simon Brunning >TriSystems Ltd. >sbrunning at trisystems.co.uk > > > > thanks for the simple answer Simon, and for those of use who reached for the interpreter to find out what this does; >>>b=a.count() see section 2.1.5.4 of the documentation (Mutable Sequence Types), which says; """ s.count(x) return number of i's for which s[i]==x """ so, another alternative to what you were trying would be; >>> a=['a','b','c'] >>> b=a.count('b') >>> print b 1 >>> x=a.count('x') >>> print x 0 HTH, Andy -- Content free posts a speciality From dennis at dennis-voss.de Mon Jul 2 14:13:30 2001 From: dennis at dennis-voss.de (Dennis Voss) Date: Mon, 02 Jul 2001 20:13:30 +0200 Subject: trouble making python on HPUX References: Message-ID: <3B40B9CA.2E633113@dennis-voss.de> > Apologizing in advance - trouble is probably platform-dependent. > > When trying to run make after running ./configure, the following error > is received: > > thread_pthread.h:6: p_thread.h: No such file or directory > > I noticed that during ./configure the file pthread.h was not found. > What is going on here and how can I fix it? For HP-UX related public domain/free software pay a visit to the porting center: http://hpux.connect.org.uk/ They offer pre-built software as well as source code (patched ?) http://hpux.connect.org.uk/hppd/hpux/Languages/python-2.1/ Dennis From tdickenson at devmail.geminidataloggers.co.uk Wed Jul 25 03:34:56 2001 From: tdickenson at devmail.geminidataloggers.co.uk (Toby Dickenson) Date: Wed, 25 Jul 2001 08:34:56 +0100 Subject: proposed language change to int/int==float (was: PEP0238 lament) References: Message-ID: Guido van Rossum wrote: >"Bjorn Pettersen" writes: > >> I think perhaps an equally interesting example is something like: >> >> 2L**128/2 >> >> which currently gives an exact result, but under the proposed new >> semantics would give an approximation... > >Have you read the PEP? The PEP only returns a float if the int result >would yield a remainder. That bit of the PEP didnt register on a first reading, and now I am suprised at that rule. As I understand it, this means long/long would sometimes give an exact result and sometimes an approximation, depending on whether the remainder is zero. The problem isnt quite as simple as Bjorn was suggesting, but this is definitely suprising: >>> ((2L**1000)+0)/2 1071508607186267320948425.... >>> ((2L**1000)+1)/2 1.07150860719e+301 >>> ((2L**2000)+0)/2 1148130695274254524232833.... >>> ((2L**2000)+1)/2 inf Toby Dickenson tdickenson at geminidataloggers.com From larryd at musicalheritage.org Fri Jul 13 09:16:55 2001 From: larryd at musicalheritage.org (Lawrence D) Date: 13 Jul 2001 06:16:55 -0700 Subject: dependencies question on 2.1-5 Message-ID: Hello everyone. I have seen the following question asked, but I still do not understand what packages I need. RedHat 7.0 Kernel:2.2.17-8 The error I get when I try and build: error: failed dependencies: libcrypto.so.0.9.6 is needed by python2-2.1-5 libexpat.so.0 is needed by python2-2.1-5 libssl.so.0.9.6 is needed by python2-2.1-5 What packages am I missing? Thank you. Larry D it2000hokie at hotmail.com From s713221 at student.gu.edu.au Fri Jul 27 04:32:57 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Fri, 27 Jul 2001 18:32:57 +1000 Subject: Problem with Python-2.1.1 and Numeric-20.1.0 References: <3B6090BD.F2B81140@quasar.ipa.nw.ru> Message-ID: <3B612739.8E3C6C1C@student.gu.edu.au> "Alexander V. Voinov" wrote: > > Hi, > > It says: > > data = Numeric.transpose(data) > File "/.../site-packages/Numeric/Numeric.py", line 280, in transpose > axes = arange(len(array(a).shape))[::-1] > File "/.../site-packages/Numeric/Numeric.py", line 159, in arrayrange > m = (add.accumulate(ones((n,), Int))-1)*step +(start+(stop-stop)) > NameError: global name 'add' is not defined > > The program worked OK with Python-2.0 and Numeric-17.1. > > Thank you in advance > > Alexander I've gotten something similar when I upgraded to python 2.1.1, even recompiling the numeric modules. >>> import RandomArray Traceback (most recent call last): File "", line 1, in ? File "/usr/lib/python2.1/site-packages/Numeric/RandomArray.py", line 3, in ? import LinearAlgebra File "/usr/lib/python2.1/site-packages/Numeric/LinearAlgebra.py", line 8, in ? import lapack_lite ImportError: /usr/lib/python2.1/site-packages/Numeric/lapack_lite.so: undefined symbol: dgesvd_ I've put in a patch report to both python and numeric (Sorry Guido/others if I seem to be harping. I know you're on the case), but thought I'd add my two cents worth here to encourage/see if others have been having similar problems with Numeric/Py2.1.1. -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From tim.one at home.com Sun Jul 8 22:45:24 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 8 Jul 2001 22:45:24 -0400 Subject: Comment on PEP-0238 In-Reply-To: <9iar91$ds4$1@news.wrc.xerox.com> Message-ID: [Mark Jackson] > ... > But is "//" rather than "div" actually ruled out? I find it hard > to believe that the C++ and Java programmers are actually so > hardwired that > > a = b//c > > looks like "a = b" followed by a comment to them. Na, it's actually so that APL programmers, who think "/" is also a unary prefix operator meaning "reciprocal", don't end up parsing b//c as b / (/c) == b / (1/c) == b * c Paying attention to other languages is indeed a bad idea <0.9 wink>. From reqhye72zux at mailexpire.com Sun Jul 29 18:10:55 2001 From: reqhye72zux at mailexpire.com (Robert Amesz) Date: Sun, 29 Jul 2001 22:10:55 GMT Subject: Let's exclude behind the usable printers, but don't burst the lost opinions. References: <3B63C252.47ED74A3@engcorp.com> Message-ID: Peter Hansen wrote: > A Walter Dupuis bot wrote: > > [...] > >> The flat messy advertisement shoots over Walter's sticky firewall. >> What did James transport to all the librarians? We can't >> learn robots unless Eddie will regularly load afterwards. Go >> persevere a FORTRAN! The insecure modem rarely disconnects >> Pamela, it questions Terrance instead. > > Sounds like you're a newbie. RTFM. This is all clearly documented > in the module index. Try http://www.python.org for a start, and > next time make sure you specify which platform you're using so we > don't have to make wild guesses. Your point is well taken, but I was lead to believe that riverrun, past Eve and Adam's, from swerve of shore to bend of bay, brings us by a commodius vicus of recirculation back to Howth Castle and Environs. Sir Tristram, violer d'amores, fr'over the short sea, had passen-core rearrived from North Armorica on this side the scraggy isthmus of Europe Minor to wielderfight his penisolate war: nor had topsawyer's rocks by the stream Oconee exaggerated themselse to Laurens County's gorgios while they went doublin their mumper all the time: nor avoice from afire bellowsed mishe mishe to tauftauf thuartpeatrick not yet, though venissoon after, had a kidscad buttended a bland old isaac: not yet, though all's fair in vanessy, were sosie sesthers wroth with twone nathandjoe. Rot a peck of pa's malt had Jhem or Shen brewed by arclight and rory end to the regginbrow was to be seen ringsome on the aquaface. Perhaps, with a bit of work, it could be made into a PEP. Robert Amesz From cpsu at larc.ee.nthu.edu.tw Sun Jul 8 03:10:38 2001 From: cpsu at larc.ee.nthu.edu.tw (Chyr-Pyng Su) Date: Sun, 08 Jul 2001 15:10:38 +0800 Subject: Tkinter and printf in C ... References: <3B455B5D.544A2EF5@larc.ee.nthu.edu.tw> <9Jh17.38316$he.2456932@e420r-atl1.usenetserver.com> Message-ID: <3B48076E.B16ACF5B@larc.ee.nthu.edu.tw> Steve Holden wrote: > > Sorry, should have read the subject line. Here's a snippet of code that > write to a PMW scrolled text window, you should be able to do the same in a > Tkinter text window. > > t = Pmw.ScrolledText(self.msgWindow) > grid(t, row=0, column=0, sticky=N+E+W+S) > strmes = > self.index.Message(self.MsgSet[int(self.msgList.curselection()[0])][0]) > message = mimecntl.MIME_document(strmes) > for hdr in ("from", "date", "subject", "to", "cc"): > try: > hdrline = message[hdr] > t.insert(END, "%s: %s\n" % > (string.capitalize(hdr),hdrline)) > except KeyError: > pass > > It's the insert() method you are looking for, I suspect. > > regards > Steve Thanks in advance to help me writing the GUI program.. Actually I intended to contruct a buttom so that when I press it, it will trigger a wrapped function originally written in C. And capture those dumped message, show them in ScrolledText() widget.. Sorry, I can't figure out what the self.index is... besides, where should I place these codes.. in the callback function or in top level... :O From matt at mondoinfo.com Wed Jul 18 15:28:58 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Wed, 18 Jul 2001 19:28:58 GMT Subject: Putting a scrollbar on a frame References: <6f0b3be9.0107171846.20f2623d@posting.google.com> Message-ID: On 17 Jul 2001 19:46:29 -0700, Rob Neely wrote: >I've got a Tkinter app which places a bunch of buttons on a frame, >where each button is a 100x100 image. I'd like to put a scrollbar >along the frame so when my number of buttons exceeds the screen size >(about 30 or so), I can scroll down to see all of them... [. . .] >I also see that Pmw has a ScrolledFrame widget. Is that my answer? Rob, Yes, it is. Pmw is a huge convenience to anyone doing Tkinter programming. It will save you lots of work. Regards, Matt From cjensen at bioeng.ucsd.edu Wed Jul 11 13:15:38 2001 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Wed, 11 Jul 2001 10:15:38 -0700 Subject: apply for keywords Message-ID: <3B4C89BA.DB51C3A7@bioeng.ucsd.edu> Can you use "apply" to pass keywords? If so, what is the syntax? ie: Python 1.5.2 (#4, Sep 5 2000, 10:29:12) [C] on irix646 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> def foo( bar = None ): ... if bar != None: ... print 'ok' ... else: ... print 'not ok' ... >>> apply( foo, [bar = 1] ) File "", line 1 apply( foo, [bar = 1] ) ^ SyntaxError: invalid syntax >>> apply( foo, bar = 1 ) Traceback (innermost last): File "", line 1, in ? TypeError: this function takes no keyword arguments >>> apply(foo, (bar = 1) ) File "", line 1 apply(foo, (bar = 1) ) ^ SyntaxError: invalid syntax >>> -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From mday at apple.com Thu Jul 26 20:31:07 2001 From: mday at apple.com (Mark Day) Date: Thu, 26 Jul 2001 17:31:07 -0700 Subject: PEP 238 (revised) References: Message-ID: <260720011731078325%mday@apple.com> In article , Guido van Rossum wrote: > Semantics of Floor Division > > Floor division will be implemented in all the Python numeric > types, and will have the semantics of > > a // b == floor(a/b) > > except that the type of a//b will be the type a and b will be > coerced into. Specifically, if a and b are of the same type, a//b > will be of that type too. I assume that means type(long//int) == type(int//long) == long. Can we assume that when both arguments are integers (including long integers), that the result is exact (and that no part of the computation involves conversion to floats)? That is, would we get the same result as "classic" division? > - Let / keep its classic semantics; introduce // for true > division. This doesn't solve the problem that the classic / > operator makes it hard to write polymorphic numeric functions > accept int and float arguments, and still requires the use of > x*1.0/y whenever true divisions is required. I don't understand this statement. Wouldn't you use // when you wanted true division? Why wouldn't // (true division) support polymorphic functions? All I can see that's missing (compared to the actual proposal) is floor division that returns the same type as the (coerced) arguments. That seems like it wouldn't be *too* hard: just use classic division (/ in this case) and if the result wasn't an integer, just call floor(). I suppose you could modify floor() [yuck!] or introduce a new function that returns the same type as its operand. Is it that important to provide a type-preserving floor division? (If you're assuming floor division, wouldn't you also use either int(a/b) or floor(a/b)?) > Semantics of True Division > > True division for ints and longs will convert the arguments to > float and then apply a float division. That is, even 2/1 will > return a float (2.0), not an int. Well, then I'd call it Float Division. This has the downside of loosing accuracy when the arguments are longs and the result can be expressed exactly as a long. It would be nice if there was a division that would return exact results of the same type as the coerced arguments (when an exact answer is possible in that type). But that begs the question of what you'd want in the case of division of two longs that can't be represented exactly in either a long or a float. I guess I'd lean towards a long result (i.e. like classic division). -Mark From mlh at idi.ntnu.no Tue Jul 3 19:22:49 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Wed, 4 Jul 2001 01:22:49 +0200 Subject: Is Python Dead? References: <9hp1f002dp6@enews4.newsguy.com> <9hq62g0kiq@enews4.newsguy.com> Message-ID: <9htk49$gad$1@tyfon.itea.ntnu.no> "Chris Gonnerman" wrote in message news:mailman.994136404.11924.python-list at python.org... [...] > I went up the URL until I got to the root http://www.stud.ifi.uio.no/ > and got a page described as: > > Institutt for informatikks studentserver > > I don't read the language, I do ;) > but I'd say that last word is pretty clear > even to an English-speaker like myself. I guess that "larsqa" is out > of school by now. I get redirected to "lmariusg's" homepage before > getting the "Forbidden" error. lmariusg sounds like "Lars Marius Garshol" (don't remember where I have that name from...) -- a quick search turned up this: http://www.garshol.priv.no/download/software/python/index.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 aleaxit at yahoo.com Sun Jul 1 05:32:32 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 1 Jul 2001 11:32:32 +0200 Subject: newbie wants to eval() References: <3b3e3e81$0$88189$2c3e98f8@news.voyager.net> <9hlhkl02cu9@enews1.newsguy.com> <3b3e655b$0$88181$2c3e98f8@news.voyager.net> Message-ID: <9hmqji0rhu@enews1.newsguy.com> "lynx" wrote in message news:3b3e655b$0$88181$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...? In a sense, it's "too powerful" -- it can do so many things that it's bound to have unpleasant fallback in some way or other. Clarity and ease of understanding your program is likely to be the main casualty, but there may be others. For example: usually, the compiler is able to perform a simple but crucial optimization for local variables of your functions -- it knows what variables are local (all that are bound in local scope), and it needs not insert lookup operations for local variable access into the bytecode it generates. But if the function contains an exec, all bets are off -- the compiler DOES need to insert explicit lookups, so all of the function is slowed down. So, use exec when you must, but be aware that you RARELY 'must', and there are usually better alternatives. If and when you do use exec, it's generally best to use explicit dictionaries as namespaces, to avoid accidents and slow-downs. > > 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? Either will work. Having it in your function will make it simpler to use. Having it on the outside makes your function more general, since it can be called with different module-object arguments to set global variables in different modules (or attributes of other objects yet). A person with any knack for overgeneralization would have mymod as an optional argument with a default value of None and do the above only if mymod is None...:-). > 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...? Python is an unusual high-level language in that it DOES expose and document a wide part of how it internally goes about things, and quite explicitly empowers you to "root around" that part. It does mean one must employ good taste and common sense to avoid making one's code a mess of hard-to-understand, hard-to-maintain black magic, yes. But "exec" is still overkill for most things you can do by other means. Specifically, when you think you need exec or eval to bind or access variables whose names you don't know in advance, setattr and getattr are very likely to be a better choice. Whether they must go to a module object is another issue; often you're better served by keeping such variables as attributes of _your own_ object that you fully control, and that will most often be an instance object rather than a module object, because instance objects can check their own attributes via special methods __getattr__ and __setattr__ -- and you may not even need that much. Suppose you keep all of your configuration variables this way: class Config: one = 1 another = 23 andalso = 'feefie' config=Config() Now you can elsewhere in your code check and use config.one, config.another, config.andalso -- as the attributes are not specifically bound in the instance, you'll get the class ones. You can also allow user-configuration code to set ANY attribute of config, no checks needed -- if the user sets an attribute you're not using, that's gonna be a no-op. So you can for example: execfile("userconf.py", vars(config)) and then use config.one, etc, and get either the instance variable if user code has set it, or else the fallback class value. Alex From cfelling at iae.nl Sat Jul 28 11:35:12 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 28 Jul 2001 17:35:12 +0200 Subject: Operator symbol for "nb_intdivide" References: <01Jul26.192106pdt."3453"@watson.parc.xerox.com> Message-ID: <9jum3g$887$1@animus.fel.iae.nl> Guido van Rossum wrote: ... > A better analogy would be = vs. == in C. > But I've never heard of confusion between + and ++ or between - and > --, so I think the psychology of this mistake more complicated than > just the doubling of the symbol. I know I've made the = vs. == > mistake even in Python. Possibly it's more likely because = is by far > the most common symbol. Nay, more likely that confusion comes from "=" and "==" both being "is"-ses in your/my head. I remember from the time I did serious programming in Pascal I trained myself to think of ":=" in terms of "becomes" just to remined me of the leading ":". In the same line of reasoning "+" and "++" aren't likely to get confused as the one reads "plus" and the other "increment". Same for "-" and "--". If this is true than that might be a real motive to use "div" instead of "/". I never once mixed those two up in all of my Pascalling life, so the fact that one is a symbol, the other a keyword sure helped to distinguish them. And now that we have more time before the entangled divide get's introduced, introducing new keywords for div and mod wouldn't influence the rate of new keywords introduced to the language that much either. So I cincerely aske you to reconsider the use of those keywords. Maybe it's because I'm dislectic that I'm more sensitive to mixing things up, but given the abundunce of mixing up others do with "=" and "==" gives me the slight hope I'm on to something here:) On a tangent, someone else mentioned the other day that for him, being dislectic, Python was *the* language. Though, strange as that might sound at first with Python lacking the ability to declare the identifiers to be used and all the uncached typos that might come from that, it *does* work that way for me too, probably because the language is so simple that my mind doesn't run overtime and has ample time to fix those easy typo's (through testing that is:) -- groetjes, carel From kp87 at lycos.com Thu Jul 19 08:16:00 2001 From: kp87 at lycos.com (kevin parks) Date: 19 Jul 2001 05:16:00 -0700 Subject: Bunch lists into sublists via alternation Message-ID: <5e8bd451.0107190415.7cc17f93@posting.google.com> I've asked this on another list and never got a reply. Possibly because i have worn out my welcome with all my dumb questions, or because it is such a dumb question people hurt themselves laughing and are now all in the hospital. I am trying to figure out how to take a sequence and split it up into sub-lists by alternation. For example if i had a sequence like: x = [1,2,3,4,5,6,7,8,9] and i called a function that was: seqSplit(seq, sub-lists) seqSplit(x,2) would yield: ([1,3,5,7,9], [2,4,6,8,None]) # None pads lists that are short elements and seqSplit(x,3) --> ([1,4,7], [2,5,8], [3,6,9]) and seqSplit(x,4) --> ([1,6] [2,7], [3,8], [4,9], [5,None]) I've got something that bunches up consecutive elements into sub-lists: def bunch(mylist, times): """package up list elements in sub-lists n at a time. x=[1,2,3,4,5,6,7,8,9] bunch(x,1) --> [[1], [2], [3], [4], [5], [6], [7], [8], [9]] bunch(x, 2) --> [[1,2], [3,4], [5,6], [7,8], [9, None] bunch(x, 3) --> [[1,2,3], [4,5,6], [7,8,9]] bunch(x, 4) --> [1,2,3,4], [5,6,7,8] [9, None, None, None]]""" out = [mylist[i:i+times] for i in range(0, len(mylist), times)] if out: out[-1].extend([None] * (times - len(out[-1]))) return out # -- --------------------------------------- But i can't figure out how to get the: a = (1,9,1,9,1,9) b = (1,9,7,1,9,7,1,9,7) seqSplit(a,2) --> ([1, 1, 1], [9, 9, 9])""" seqSplit(b,3) --> ([1, 1, 1], [9, 9, 9], [7, 7, 7])""" type arrangement, particularly since i want it to work for any unpredetermined number of sub-lists. I've got a kludge that works only for the case of seqSplit(x,2), but i can't get anything to work for seqSplit(x,n) where n is anything else. cheers, kevin parks From quinn at hork.ugcs.caltech.edu Fri Jul 27 05:56:32 2001 From: quinn at hork.ugcs.caltech.edu (Quinn Dunkan) Date: 27 Jul 2001 09:56:32 GMT Subject: Case insensitivity References: <93d9a839.0107200315.4a0a8c28@posting.google.com> <4n4klt8ud0es25jep3u2v9pj02dctnte0u@4ax.com> <3ui1mt0e07vgp1b18306jd70pdufs91uva@4ax.com> Message-ID: On Fri, 27 Jul 2001 08:19:46 GMT, Courageous wrote: > >>>Because when identifier and someone else writes IdEnTIFIER, I want >>>to kill them Actually, I'd like to kill them for changing the case at all. >> >>But if the language is the same, their editor would warn them about the case >>mismatch, and the code would crash, just like yours would. It would be just >>like your editor, only yours won't warn about those things. > >Oh right. Just _my_ editor. Right. Isolated little ole me, I'm the only small >sole in the whole wide world who wants to use vim. You're just not getting >this, I can tell. I suspect we're talking past each other because I can't make any sense out of that. Is your sarcasm implying that many people use vim (certainly true, given its mainstream status (I've used it since 1.0 on the amiga, BTW))? Or are you saying that most people's editors won't warn about case mismatches (also certainly true)? If so, I'm confused because neither have any relevance. Even if every single person in the world used the hypothetical magic case warning editor, how could you even know they did (if they didn't tell you)? For all you know, everyone else in the world currently uses an editor that disallows identifiers beginning with 'q'. How is this different from everyone (or 3 people) using an editor that warns against 'foo' and 'Foo' in the same module? Could you explain how this could inconvenience you, or how you could even figure out what editor someone else used to write their code? From wware at world.std.com Sun Jul 22 08:41:46 2001 From: wware at world.std.com (Will Ware) Date: Sun, 22 Jul 2001 12:41:46 GMT Subject: Name space quirk? References: <7b9380ca.0107220419.add15d1@posting.google.com> Message-ID: NANDYALA D Gangadhar (n_d_gangadhar at yahoo.com) wrote: > ... the interactive python shell catches the > NameError (on "myfile"): > from os import sys > > def hello (outfile = sys.stdout): > # We are writing to what should be an > # unknown file descriptor: > myfile.write ("Hello, world!\n") > > if __name__ == '__main__': > f = sys.argv[0] + ".out" > myfile = open (f, 'w') > hw (myfile) > Is this behaviour desirable and correct? I guess it can lead to > unanticipated results. Yup, you actually want a NameError here. At the point where you are defining hello(), you start talking about 'outfile' in a way that totally makes sense, but then you call a method of 'myfile'. hello() is not blessed with the gift of prophecy, and is unaware that you will later declare a global variable called 'myfile'. If you really want to write to 'myfile' rather than 'outfile', then you might want something like: def hello (outfile = sys.stdout): global myfile myfile.write ("Hello, world!\n") This tells hello() that it should expect to find a global variable called 'myfile', and should write to that. If you then forget to create a global called 'myfile', you'll get another NameError. It's a general rule of thumb among programmers, and particularly so with object-oriented programming, that you want to avoid too many global variables. Some people (or languages) get very excited about this principle; Java doesn't allow global variables at all. Others view it as a general guideline to be overridden if the programmer has a good reason. -- -----------------------------------+--------------------- 22nd century: Esperanto, geodesic | Will Ware domes, hovercrafts, metric system | wware at world.std.com From skip at pobox.com Tue Jul 24 07:45:56 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 24 Jul 2001 06:45:56 -0500 Subject: real-accurate, numpy...increased precision help In-Reply-To: <9jj0bl$9mq@dispatch.concentric.net> References: <9jj0bl$9mq@dispatch.concentric.net> Message-ID: <15197.24564.153482.413027@beluga.mojam.com> Bryan> I need to be able to work with numbers up to 2^800 in a floating Bryan> point envirnoment. Perhaps you could create a class implements all the required numeric functionality and uses one or more Python longs to represent the number internally. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From paulp at ActiveState.com Tue Jul 3 12:21:26 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Tue, 03 Jul 2001 09:21:26 -0700 Subject: Comment on PEP-0238 References: <3B3BE855.A6223E70@3-cities.com> <7ef50c46.0107020554.31cc948b@posting.google.com> <7ef50c46.0107030657.2e0fc92b@posting.google.com> Message-ID: <3B41F106.8C29D4A@ActiveState.com> "Robert J. Harrison" wrote: > > Paul Prescod wrote in message news:... > > ... Most people do not expect these four > > expressions to yield different results: > > > > 1.0/3.0 > > 1/3 > > 1.0/3 > > 1/3.0 > > I completely disagree, and as someone who has taught math, science and > programming, it is quite clear to me that the distinction between integer > and real arithmetic is an essential concept. If it is such an essential concept, why does Python undermine the distinction by coercing between types. And by the way, why doesn't the division of an integer by a float result always in an integer? Because Python treats integers as a special case of floats? Except in *one particular context*. Hmmmm. > > ... Why is automatic coercion *ever* necessary? > > Mixed type expressions are almost inevitable. It would take a much > larger reworking of the Python numerical model than proposed by > PEP-0238 to do away with that. Exactly. PEP-0238 strives to do away with a single operation that is out of sync with Python's general treatment of integers as a special case of float. The only othre way that behaviour could be made consistent would be to remove all of the other cases where it uses this type hierarchy. > .... The existence of the standard > __coerce__ method illustrates the importance of such expressions. I agree! >... > I might accept an argument that says that anything that coerces > (automatically!) to an integer with no loss of precision can be > used to index a list. But how to distinguish between 1, 1+eps > (eps=machine precision), and 1.1? How many elements are there > between elements [1] and [2]? That's a different discussion altogether but I would say that anything that evaluates equal to an integer could be valid as an array index. But I don't care enough about that to argue it one way or the other. >... > My point was rather poorly made. The new > proposal has simply moved the point at which people need to understand > the distinction between real and integer arithmetic. Currently it must > be understood when the operation is performed. In the new proposal it > must be understood when the result of the operation is used. Nobody argues against understanding. But understanding is eased if you do what people expect. People believe that the integers are a special case of floats. Python encourages them in that belief in most places other than this one. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From bokr at accessone.com Sun Jul 8 21:27:19 2001 From: bokr at accessone.com (Bengt Richter) Date: Mon, 09 Jul 2001 01:27:19 GMT Subject: I'm Sure There's A Better Way References: <3B465858.CB7F38E8@tundraware.com> <9i6e5502d9g@enews4.newsguy.com> <3b478576.1314346961@wa.news.verio.net> <9i92mb02pnp@enews3.newsguy.com> <3b48d5b9.1400429941@wa.news.verio.net> <3B48F5BB.E93EF377@tundraware.com> Message-ID: <3b49078a.1413182168@wa.news.verio.net> On 09 Jul 2001 00:10:01 GMT, Tim Daneliuk wrote: >Bengt Richter wrote: >> > >Thanks to all who answered! A fertitle bunch of minds 'round here.... > >The response that gets it all (despite my fuzzy definition) was mailed >to me privately. I deconstructed it (well really, reinvented it from >scratch myself) to make sure I understood what was going on. > >And the winner is... > >^-?((\d+(\.\d{2})?)|(\.\d{2}))$ > >To be really fussy, the \. should really be a string constant which >is conatenated into the remainder substrings so that other delimiters >could be used when I18Ning the code. > >Just for the record - I knew when I started that a re was a better way to do >this. Although I've programmed a lot in other languages, I am still in >the process of absorbing python, and I had not yet attacked its re >capabilities so I decided to hand code it. Now that I look at the re >implementation, I realize I should have started there because it is so >much more compact and elegant. > >In any case, it was a nice tutorial exercise which made me learn an >essential piece of python. > >I'm writing a complete (small) application which does keyboard I/O, >saves state to disk, does meaningful arithmetic and so on. My intention >is to put it up on the web when done so others can use it to see something >a bit less trivial than the examples which are common in tutorials. > >Once again, many thanks to all who kindly took the time to respond. > >------------------------------------------------------------------------------ For your amusement, here is what the above winning re does with some numbers, followed by the code. You can just type in a list of test numbers on the command line (which wrapped), like so: Is it what you wanted? [18:22] C:\pywk\numck>numcks.py - -0 -.00 -0.00 00.00 012 012.34 12.345 1.2.3 0.00 0 -: Winner says bad, runner-up says bad -0: Winner says ok, runner-up says bad -.00: Winner says ok, runner-up says bad -0.00: Winner says ok, runner-up says bad 00.00: Winner says ok, runner-up says bad 012: Winner says ok, runner-up says bad 012.34: Winner says ok, runner-up says bad 12.345: Winner says bad, runner-up says bad 1.2.3: Winner says bad, runner-up says bad 0.00: Winner says ok, runner-up says ok 0: Winner says ok, runner-up says ok (some lines wrapped below) __________________________________________________ # numcks.py import sys import re def ck(x): if re.match( r'(-(?!(0*\.?0+$|0+\.0*$)))?(0|\d?\.\d\d|[1-9]\d*(\.\d\d)?)$', x): return 'ok' else: return 'bad' # declared winner re: ^-?((\d+(\.\d{2})?)|(\.\d{2}))$ def ckw(x): if re.match( r'^-?((\d+(\.\d{2})?)|(\.\d{2}))$', x): return 'ok' else: return 'bad' def main(): args = sys.argv[1:] if not args: sys.stderr.write("usage: %s number ...\n" % sys.argv[0]) sys.exit(2) for num in args: print "%8s: Winner says %3s, runner-up says %3s" % (num, ckw(str(num)),ck(str(num))) if __name__ == "__main__": main() __________________________________________________________________ From peter at engcorp.com Thu Jul 26 19:44:00 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 26 Jul 2001 19:44:00 -0400 Subject: Ints and performance (was Re: PEP0238 lament) References: <5sdnlt072hm6hp17nluu6f0fqq4bvr6mj8@4ax.com> <916olt0p3kciv0evmotdg6jev9bl29l57i@4ax.com> <3B5C52EA.9430255E@alcyone.com> Message-ID: <3B60AB40.CCE9FA9C@engcorp.com> Guido van Rossum wrote: > > I don't see when a unified number system would ever be less convenient > than the current number system, *except* in the rare case where you > are transliterating an algorithm from C that depends on integer size. > Unsigned ints of n bits are easily emulated by taking all results > modulo 2**n -- I do this now using Python long ints when I need to > emulate unsigned C longs. > > Using the new type/class unification in Python 2.2, you will be able > to subtype the int or long types easily to create your own constrained > types. The interpreter currently has direct support for the most-used integer operations, thus ensuring that this type has performance reasonably close to the maximum feasible given the nature of virtual machines. Would the number system unification imply that this integer optimization would be eliminated? If true, wouldn't this impact Python's performance so negatively that it would definitely get into the realm of "less convenient"? (I'm definitely not in favour of optimization over functionality, but this would go over the line, I think.) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From MarkH at ActiveState.com Fri Jul 20 05:06:40 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Fri, 20 Jul 2001 09:06:40 GMT Subject: get/put Methodes on COM Objects References: <9j8k85$p0t$01$1@news.t-online.com> Message-ID: <3B57F4EB.9070200@ActiveState.com> Achim Domma wrote: > Hi, > > I'm writting COM objects using win32com and want to implement Properties > which are set/read via a get/put function. The documentation mentions the > possibility to do that, but I can not figure out how !? Can somebody help ? You can implement a "getter" simply by providing a method of the same name as the property. Unfortunately, "put" functions do not appear supported. This could be added easily - win32com\server\policy.py has a block: for name in ob._public_attrs_: self._name_to_dispid_[string.lower(name)] = dispid self._dispid_to_get_[dispid] = name if name not in readonly: self._dispid_to_put_[dispid] = name This should probably handle a "set_{name}" function in the last line. The reason this hasn't been done yet is that I need to figure out exactly how to handle the DISPATCH_PROPERTYPUT and DISPATCH_PROPERTYPUTREF cases independently for the 1% of cases that care, and handle them the same for the 99% of cases that don't. Feel free to offer up a patch that supports this, and I will integrate it in. Off the top of my head, "setref_", if it exists, could be used to signify that you _do_ care, while "set_" would be used in the more general case for both. OTOH, I guess I see no real reason to force this support now. We have gone so long without even a setter - so when someone does actually care, we can enhance it then. Whatever :) Mark. From Gareth.McCaughan at pobox.com Sat Jul 28 14:34:46 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Sat, 28 Jul 2001 19:34:46 +0100 Subject: [OT] Number theory [Was: A use for integer quotients] References: <3B5C5665.8D41D1F1@tundraware.com> <3B5C749A.59F97320@tundraware.com> <3b602afa.930850@nntp.sprynet.com> <3b617133.1013412@nntp.sprynet.com> <3b62c8c4.2448381@nntp.sprynet.com> Message-ID: David Ullrich wrote: [I said:] >> You said "Strictly speaking the natural number 2 is ..." >> and gave one possible implementation. It's by no means >> the only one, as I'm sure you know; but you didn't say >> so. > > It's the only one in standard use that I'm aware of. > I know several different "standard" "implementations" > of integers, rationals and reals as sets, but a different > implementation for natural numbers does not spring to > mind. It's much the commonest, mostly because it appears to be the simplest way to do it within ZF and most mathematicians think that set theory == ZF (or perhaps ZFC). :-) > Of course infintiely many others are possible. But > what's another "implementation" of the _natural_ > _number_ 2 as a set that's actually in general use? Depends, I suppose, on what you mean by "in general use". I'd say that *none* of them is in general use, in the sense that no one ever depends on the details when doing real mathematics. The von Neumann construction is certainly far commoner than any other I know of in textbooks on the foundations of mathematics. However: Randall Holmes's book "Naive set theory with a universal set" (which uses NFU as its set theory) defines natural numbers as equivalence classes modulo having-the-same-size, so that 2 is { {x,y} : x != y } and so on. This was Frege's original definition too, though he didn't have a consistent account of set theory to fit it into. > Not that it matters. Indeed. >> I was just concerned that some people might conceivably >> misunderstand you to be saying, as Kronecker didn't :-), >> that God made the von Neumann implementation of the >> natural numbers and all else is the work of man. > > Ah. No, I didn't mean to say that, and yes I suppose > that one might have got that idea. But if we're talking > about implementations _as_ _sets_, and implementations > that are actually _used_, then no I'm not aware of > another. What's an example? The one I gave above is an example. Or you can say that 0 = {} and n+! = {n}. That was Zermelo's definition, 15 years before von Neumann's, and it's the one adopted in Quine's book "Set theory and its logic" (though he is at pains to make it clear that there are other options). I don't know whether you'd consider Conway's approach to be "_as_ _sets_"; Conway himself prefers to regard his theory as being based on an alternative foundation which takes pairs-of-sets as fundamental. But there's no reason why you can't do it his way and still think of what you're doing as working with sets. > (Hint: The two other "implementations" of natural numbers > that spring to mind are not implementations as sets, which > for some reason is what I thought the topic was. Not really. The question was just "Is Z a subset of R?", and I bet the questioner would have been just as happy to have said "Is Z a subclass of R?" but hadn't heard that some mathematicians, for some purposes, like to distinguish sets from classes. And, in any case, all that the question supposes even if you insist on the word "set" is that Z and R are sets, not that their members are sets. (They might be sets of urelements in a theory that allows such things.) > Those > would be regarding natural numbers as defined by Peano > arithmetic and regarding 2 as the class of all sets with > two elements (spelled out without using the word "two", > of course).) The latter of those can perfectly well be an implementation in terms of sets. Not if your set theory is ZF or NBG, of course, but those are by no means the only options. * This has long ceased to have anything to do with Python. I suggest that we take it to e-mail or drop it entirely. (But if you prefer continuing in c.l.py, I don't mind.) -- Gareth McCaughan Gareth.McCaughan at pobox.com .sig under construc From greg at cosc.canterbury.ac.nz Tue Jul 3 00:27:07 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Tue, 03 Jul 2001 16:27:07 +1200 Subject: apply problem References: <9hr0aj$ta0$06$1@news.t-online.com> Message-ID: <3B41499B.BC753752@cosc.canterbury.ac.nz> Heiko Wundram wrote: > > apply(getattr(self,name),(attrs)) Try this instead: apply(getattr(self,name),(attrs,)) Note the presence of the extra comma. Without it, you're not passing a tuple containing your dictionary, but just the dictionary itself. By the way, there's no need to use apply() at all in this case. You could just write getattr(self,name)(attrs) and get exactly the same effect. -- 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 skip at pobox.com Mon Jul 2 11:18:33 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 2 Jul 2001 10:18:33 -0500 Subject: how do I get modules to stop eating memory In-Reply-To: <6f78b8b.0107020626.38939858@posting.google.com> References: <6f78b8b.0107020626.38939858@posting.google.com> Message-ID: <15168.37065.273708.181559@beluga.mojam.com> Charles> - Prior to importing BaseHTTPServer the memory usage was 1432. Charles> Shouldn't Python's memory usage have gone down to that number, Charles> or at least down some? That depends entirely upon two things: 1. How the malloc package you're using behaves in the face of newly freed memory. 2. Whether or not it thinks the memory can be freed. Very basically, when you ask to malloc a chunk of memory and malloc can't locate a sufficiently large free block of memory in the chunks already allocated, it calls the brk system call (or the sbrk library call, which calls sbrk) to get more. (Some now use mmap, at least for very large blocks. That just complicates things.) The brk call just extends the process's heap to some new address. If I then malloc some memory from that block and free *all of it*, the malloc package can *if it so desires* free that block. If any memory is still allocated in that block, it can't be given back to the system. In particular, the heap is treated as a stack in most (all?) systems, so only the topmost block of memory brk'd from the system is eligible to be given back (item #2 above). Then, and only then, will you see your process's memory usage (as displayed by top or ps) get smaller. Many malloc packages never release memory back to the system (item #1 above). For more details, read the GNU malloc source code. Now, there's some fun... ;-) -- Skip Montanaro (skip at pobox.com) (847)971-7098 From grante at visi.com Sat Jul 21 13:08:55 2001 From: grante at visi.com (Grant Edwards) Date: Sat, 21 Jul 2001 17:08:55 GMT Subject: Language change and code breaks References: <9j7gv8$9mg@dispatch.concentric.net> Message-ID: On 19 Jul 2001 20:46:32 GMT, Tim Randolph wrote: >As a member of this group, who is especially fond of Python for how easy it >is to pick up where I left off days or weeks before, I would very much >prefer a case *insensitive* language with tools that enforce *uniform* case >usage. > >Nobody wants to see fOo and FOO and foo with the same meaning, but nobody >wants to see foo and FOO and foo at all in the same program with distinct >meanings. That is simply not true. >I also don't think the cutesy c=C() makes for readable code -- at >least for this sometime programmer. I've been using foo and Foo to mean two different things for many years (and I know of lots of others do also). Perhaps it's not to your taste, but that doesn't make all of us "nobody". -- Grant Edwards grante Yow! It's a lot of fun at being alive... I wonder if visi.com my bed is made?!? From JamesL at Lugoj.Com Sun Jul 29 22:43:29 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Sun, 29 Jul 2001 19:43:29 -0700 Subject: Language Niches (long) References: <8beb91f5.0107280407.5a30341d@posting.google.com> <3B62FAFF.BB987077@Lugoj.Com> <8beb91f5.0107282158.4785ae5e@posting.google.com> Message-ID: <3B64C9D1.C53AEE84@Lugoj.Com> Grant Edwards wrote: > > On Sun, 29 Jul 2001 21:44:37 +0100, Robin Becker wrote: > >In article , Paul > >Prescod writes > >> * For a long time, C was the only way to do system programming for Unix > > > >what language does one use nowadays. > > AFAIK, all Unix system programming is still done in C. (At least > that's true for the Unices I'm familiar with (SCO, Solaris, > BSD, Linux). Do language compilers and interpreters qualify as "system programming"? In what language are the following languages most often written in (or often exclusively): Python sh Perl tcl Scheme Java VB ... Does anyone seriously think that these will all be converted to some other language in the next 10 years? Then ask yourself what one language every programmer should at least be able to read. From FenZhao at mit.edu Wed Jul 18 09:59:08 2001 From: FenZhao at mit.edu (Man Vehicle Laboratory) Date: Wed, 18 Jul 2001 09:59:08 -0400 Subject: sys.argv not found Message-ID: <3B55962C.63F7E2EF@mit.edu> Hi all, I'm writing a python program that uses VRUT (OpenGL application), but I seem to lose the sys.argv list whenever I run VRUT. For example, vrut.go() starts VRUT. I call it after I ask for sys.argv, but somehow it begins to run and in the display window gives an AttributeError for argv. I'm not quite understanding the logic of the order python is doing (why it would call the vrut command before the sys.argv). I tried wrapping the vrut.go in a function, and calling that function instead to no avail- same problem. Sending in the wrong number of arguments however will generate an "IndexError: list index out of range". --Fen Zhao mode=string.atoi(sys.argv[1]) ARGFILE_stim=sys.argv[2] ARGFILE_calib=sys.argv[3] OUTFILE=sys.argv[4] SUMFILE=sys.argv[5] sidOutfile=sys.argv[6] VECTION_DURATION=string.atoi(sys.argv[7]) path=sys.argv[8] ... vrut.go(vrut.NICE) From hcsgss at texlife.com Tue Jul 24 16:31:48 2001 From: hcsgss at texlife.com (Galen Swint) Date: Tue, 24 Jul 2001 15:31:48 -0500 Subject: cost of change In-Reply-To: "Bjorn Pettersen" "RE: cost of change" (Jul 24, 2:10pm) References: <6957F6A694B49A4096F7CFD0D900042F27D57C@admin56.narex.com> Message-ID: <1010724153148.ZM76382@anson.hcs.tl> On Jul 24, 2:10pm, Bjorn Pettersen wrote: > Subject: RE: cost of change > > From: Galen Swint [mailto:hcsgss at texlife.com] > > > $20/hr? I think it's time to renegotiate Well, I'm still just a grad school intern -- one of these days!!!! Galen From achim.domma at syynx.de Fri Jul 20 02:48:18 2001 From: achim.domma at syynx.de (Achim Domma) Date: Fri, 20 Jul 2001 08:48:18 +0200 Subject: get/put Methodes on COM Objects Message-ID: <9j8k85$p0t$01$1@news.t-online.com> Hi, I'm writting COM objects using win32com and want to implement Properties which are set/read via a get/put function. The documentation mentions the possibility to do that, but I can not figure out how !? Can somebody help ? greetings Achim From terekhov at emc.com Thu Jul 5 16:41:15 2001 From: terekhov at emc.com (Mikhail Terekhov) Date: Thu, 05 Jul 2001 16:41:15 -0400 Subject: Is this a true statement: Part III References: <9hsckg$4rt$1@taliesin.netcom.net.uk> <9hsmh1$gtt$1@panix2.panix.com> Message-ID: <3B44D0EB.11CF49D2@emc.com> Grant Edwards wrote: > ... > If you want a compiled, statically typed OO language, then I'd > recommend using a real one like Modula-3. If you want Or Ada (e.g. GNAT). Mikhail Terekhov From kelly.gerber at mindspring.com Wed Jul 18 01:17:12 2001 From: kelly.gerber at mindspring.com (Kelly Gerber) Date: Tue, 17 Jul 2001 22:17:12 -0700 Subject: Readline on RedHat 7.1 with Python 2.1 Message-ID: <3B551BD7.4D666D9E@mindspring.com> I am trying to build Python 2.1 on RedHat 7.1 with readline. I uncommented the readline line in Modules/Setup, but I get an error about readline when running make. Python builds and works fine otherwise. But it is a pain to type in commands again at the interactive prompt when I want to repeat something. Has any one had luck in getting Python to build with readline? Thanks, Kelly -- From nperkins7 at home.com Sat Jul 21 20:31:11 2001 From: nperkins7 at home.com (Nick Perkins) Date: Sun, 22 Jul 2001 00:31:11 GMT Subject: synchronized lists References: <9j8m49$22v$00$1@news.t-online.com> Message-ID: "Andreas Kremer" wrote in message news:9j8m49$22v$00$1 at news.t-online.com... > Hi, > > i have the following design problem: > > in different classes i have lists which consist of elements pointing to > instances of other classes with lists. What i need to acchieve is that if an > instance of one class is pointing towards another instance, the latter needs > a pointer to the former in its list, too, to know who is pointing at it. The > result would be at least two lists in each instance, one with pointers > outwards to other instances, the other with pointer to instances which point > to this instance. > > I was thinking about a superclass of synchronized lists, but that design > did not look "nice". Also a connector doesnt seem to be the best idea. Has > anybody an idea about how to acchieve this goal? > > Thanks in advance, Andreas. > > How about keeping all such 'connections' in sort-of dictionary-like thingy, where all mappings work both ways. That is, if you connect A to B, then B is automatically connected to A... Here is a quick shot at it: class Connections: def __init__(self): self._dict = {} def connect(self, A, B): self._connect(A,B) self._connect(B,A) def _connect(self, A, B): try: self._dict[A].append(B) except KeyError: self._dict[A] = [B] def disconnect(self,A,B): self._disconnect(A,B) self._disconnect(B,A) def _disconnect(self,A,B): try: self._dict[A].remove(B) except: pass # ? def get_connections(self,A): try: return self._dict[A] except KeyError: return [] if __name__=="__main__": con = Connections() class thing: def __init__(self,name): self.name = name def __repr__(self): return "" %(self.name) A = thing('a') B = thing('b') C = thing('c') con.connect(A,B) con.connect(B,C) print "A connects to", con.get_connections(A) print "B connects to", con.get_connections(B) print "C connects to", con.get_connections(C) # OUTPUT: A connects to [] B connects to [, ] C connects to [] con.disconnect(A,B) con.connect(C,A) print "A connects to", con.get_connections(A) print "B connects to", con.get_connections(B) print "C connects to", con.get_connections(C) # OUTPUT: A connects to [] B connects to [] C connects to [, ] At least this approach confines all of the 'two-way mapping' logic to a single class, rather than having to make sure that A and B always sort it out themselves. I'm sure other people have done such two-way mappings before, (come to think of it, it's basically just an undirected graph), and there is surely a better implementation than mine.. Of course, this would require all instances which want to 'participate', to have a reference to the same instance of class 'Connections', but that is another problem.. ( class member, global, mix-in superclass?...hmmm) From kamikaze at kuoi.asui.uidaho.edu Mon Jul 2 23:55:55 2001 From: kamikaze at kuoi.asui.uidaho.edu (Mark 'Kamikaze' Hughes) Date: 3 Jul 2001 03:55:55 GMT Subject: Python for Commercial Games? References: <9haoiv$jnv$1@mtc1.mtcnet.net> <9hr4k5$peq$1@panix6.panix.com> Message-ID: 2 Jul 2001 17:45:57 -0700 in <9hr4k5$peq$1 at panix6.panix.com>, Aahz Maruch spake: > In article , > Mark 'Kamikaze' Hughes wrote: >> I suspect that Infocom-style interactive fiction, with good production >>values and nice packaging, could sell again just fine. You'd have to >>sell it outside of most computer game shops, though, because the games >>publishing and distribution networks just won't carry it, and the games >>magazines won't review it (they're all run by and for hyperactive >>adolescent males (of all ages))... > ...and genders. ;-) Hah! When I was writing, I included exactly that clause, but then removed it because I couldn't think of any female game designers, publishers, or reviewers who trade in the "hyperactive adolescent male" genre, except possibly the "booth babes" at game developer's conferences (and they're almost universally hired models or non-game-design employees) or the female "mascot" at one of the game review mags (that specific word was used to describe her by one of the male reviewers...) There are women in game design (VASTLY fewer than there ought to be, but a few), but they behave like adults, mostly. Which is why they don't sell much... |+( I love games design, but I really really despise the games industry. Does it show much? -- 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 opengeometry at yahoo.ca Mon Jul 30 17:27:53 2001 From: opengeometry at yahoo.ca (William Park) Date: Mon, 30 Jul 2001 17:27:53 -0400 Subject: The best gui library for newbies. In-Reply-To: ; from man_at_moon@hotmail.com on Tue, Jul 24, 2001 at 12:21:48PM +0100 References: Message-ID: <20010730172753.A1113@node0.opengeometry.ca> On Tue, Jul 24, 2001 at 12:21:48PM +0100, David A. wrote: > H~i I program in python for some time now. And I would like to beegin doing > some gui's and other graphical programming. The thing I want to know is wich > one is the best gui toolkit for python when you are a newbie? Wxpython, > tkinter?? Whatis important for me is easy of use and well documented!! this > is what I am looking for. > > Thank you for any help in advance!!! Start with Tkinter, since it's part of standard distribution and been around for a while. There is also a book called "Python and Tkinter Programming" by Grayson from Manning . -- William Park, Open Geometry Consulting, 8 CPUs cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc. From ljz at asfast.com Fri Jul 27 22:13:50 2001 From: ljz at asfast.com (Lloyd Zusman) Date: 27 Jul 2001 22:13:50 -0400 Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <9jnt9p$qhe$1@newsy.ifm.liu.se> Message-ID: Guido van Rossum writes: > [ ... ] > > I think you're right. An early version of ABC worked like this, and > at the time I though "hmm, but why shouldn't 0.98 be an exact > number; it could be intended as a price or something like that", and > I convinced the team to change it. But in practice it was more > often annoying. Now maybe that was because we (the biggest users) > were CS and math folks, and we tended to tackle typical math and CS > problems -- but my gut is to vote against this aspect of the PEP. Lately I've been consulting on Wall Street, and it turns out that in the computations done in that universe, there is a great need for non-float decimal types, such as your example about 0.98 being used as a price. Accountants and their kin want ledgers, positions, etc. to balance to the penny (or centavo, or whatever is the smallest fractional currency in a given country). This can only be accomplished using decimal arithmetic ... like Bignums with implied decimal places. I believe that this kind of exact decimals would be very useful, although I agree that there should be some new way to represent these values (so that 0.98 in a Python program would still be considered a float). Decades ago, IBM had a fairly useful solution to this: since the 1960's, their mainframes have had packed decimal arithmetic implemented within the standard instruction set. This type provided integer-like arithmetic and managed implied decimal places. These had a maximum of something like 18 digits, so we're not dealing with Bignums exactly, but this data type still worked well enough for the vast majority of accounting-related applications done on IBM mainframes. There's no coincidence that IBM (note the middle initial) designed their machines to cater to the computing needs of businesses. I wrote a C library of arbitrary precision math routines around 12 or 13 years ago (and I hear that a version of it is still floating around the net somewhere, in case anyone is interested; it's called APM). It essentially consisted of Bignums with a specified decimal precision for each calculation. Division yielded remainders. This was needed for a currency trading application for which I was one of the designers and developers. On this project, my comp sci colleagues originally argued vociferously against decimal math and maintained that double precision floats would be more than sufficient. However, when the clients (financial firms) saw that their positions at the end of the day were off by a small amount due to the errors inherent in floats, my cohorts suddenly became quite happy (and even a bit insistent) about me writing the decimal arithmetic routines. So anyway, I would argue that some sort of exact decimal type is also necessary for doing financial calculations that have to balance "to the penny". If a rational type is used to implement this, it would have to be a special case, where the denominator of the rationals would always have to be fixed when doing financial calculations (for example, the denominator would usually have to be 100 for the results of calculations involving US dollars and cents). And once again, this numeric type would have to do integer-type division and yield remainders. I just thought that I'd add some more mud to the waters of this thread. :) [ Should this be a PEP? ] > [ ... ] -- Lloyd Zusman ljz at asfast.com From gregj at pdxperts.com Mon Jul 16 03:22:55 2001 From: gregj at pdxperts.com (Greg Jorgensen) Date: Mon, 16 Jul 2001 07:22:55 GMT Subject: re Challenge: More Compact? References: , <3B51E6B1.47E25214@tundraware.com> <92ae279c.0107151429.398e6e9e@posting.google.com> Message-ID: Translating the Perl version to Python leads to un-Pythonic code. How about this: def valid_ip(ip): iprange = range(256) return type(ip) == type('') and \ [x.isdigit() and long(x) in iprange for x in ip.split('.')] == [1,1,1,1] Or this, if you don't like list comprehensions: def valid_ip(ip): iprange = range(256) return type(ip) == type('') and \ map(lambda x, iprange=iprange: x.isdigit() and long(x) in iprange, ip.split('.')) \ == [1,1,1,1] No regular expressions, no other modules, checks the type of input parameter, safe from type conversion errors, and looks for exactly four integers in the range [0,255]. Greg Jorgensen PDXperts LLC Portland, Oregon, USA From tim.one at home.com Mon Jul 23 01:30:09 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 23 Jul 2001 01:30:09 -0400 Subject: A use for integer quotients In-Reply-To: Message-ID: [David Eppstein] > I don't suppose it would be possible to go through some repository of > Python sources and figure out the relative numbers of divisions > of integer arguments that end up an int versus the ones that are > coerced to floats? Guido did this for the Python library, and found three instances of "/" that would break. > In my own code it's 100% int/int->int Mine too -- but only in my integer code . Curiously, I find I *usually* use divmod() even then, because I usually need the remainder too. I've mentioned before that the best way to compute int ceiling in Python is via: def ceiling_of_quotient(i, j): q, r = divmod(i, j) return q + (r != 0) and that code doing (i + (j-1))/j instead is flirting with sign-related errors and spurious OverflowError (there's code like that in the std library, although in context neither sign errors nor OverflowError should be possible). > but that's a small unrepresentative sample. Note I'm less interested > in divisions of quantities that are already floats as those would be > unaffected by this proposal. Understood; see above; and a runtime warning pinpointing instances of "/" where this happens is easy enough to add. From opengeometry at yahoo.ca Sat Jul 14 01:04:21 2001 From: opengeometry at yahoo.ca (William Park) Date: Sat, 14 Jul 2001 01:04:21 -0400 Subject: apply problems In-Reply-To: <3B4F8B57.7684D13A@bioeng.ucsd.edu>; from cjensen@bioeng.ucsd.edu on Fri, Jul 13, 2001 at 04:59:19PM -0700 References: <3B4F3501.E1469159@bioeng.ucsd.edu> <3B4F8B57.7684D13A@bioeng.ucsd.edu> Message-ID: <20010714010421.A393@node0.opengeometry.ca> On Fri, Jul 13, 2001 at 04:59:19PM -0700, Curtis Jensen wrote: > I thought about that. But in the test examples below, you can see that > you'll that you don't have to pass "self" with apply. In fact if you > do, you'll end up with too many parameters. Also, symanticly, I think > "apply( self.ren.Elements, (self, cmd[1]), additional_kwds )" will only > pass two arguments "self" and "cmd[1]" as apposed to sending "self" and > all the items in "cmd[1]" as individual argument. You'd need to put > "self" at the beginning of cmd[1], or make a new tuple to pass in. But > I know what you mean. Sorry, you're right... too many emails. ;-) > > In any case, my problem went away. I'm not exactly sure why. It > probably had to do with unsafe dynamic binding or something like that. > :) -- William Park, Open Geometry Consulting, 8 CPUs cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc. From emile at fenx.com Tue Jul 10 21:05:59 2001 From: emile at fenx.com (Emile van Sebille) Date: Tue, 10 Jul 2001 18:05:59 -0700 Subject: PythonCOM and Office. Arrgh! References: Message-ID: <9ig91u$ii5co$1@ID-11957.news.dfncis.de> "Bill Bell" wrote in message news:mailman.994793537.30396.python-list at python.org... > > "Emile van Sebille" wrote, in part: > > This worked for me. Win2ksp1, excel2k, Python 2.1 > > > > >>> import win32com.client > > >>> xl = win32com.client.Dispatch("Excel.Application") > > >>> xlc = win32com.client.constants > > >>> xl.Workbooks.Open('test',Password='fred') > > > > >>> xl.Visible=1 > > > > What do you get when you try this? > > Using Win95, Excel 97 SR-1, Python build 203 > > This seems to be what the thread's originator experienced. > Tentatively, appears to relate to version or configuration. > I agree. With win98, excel8 and python1.52 it still works for me. -- Emile van Sebille emile at fenx.com From mal at lemburg.com Fri Jul 13 18:21:32 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Sat, 14 Jul 2001 00:21:32 +0200 Subject: PEP: Defining Unicode Literal Encodings (revision 1.1) References: <3B4F6E98.733B90DC@lemburg.com> <004c01c10be8$af2face0$4ffa42d5@hagrid> Message-ID: <3B4F746C.827BD177@lemburg.com> Here's an updated version which clarifies some issues... -- PEP: 0263 (?) Title: Defining Unicode Literal Encodings Version: $Revision: 1.1 $ Author: mal at lemburg.com (Marc-Andr? Lemburg) Status: Draft Type: Standards Track Python-Version: 2.3 Created: 06-Jun-2001 Post-History: Requires: 244 Abstract This PEP proposes to use the PEP 244 statement "directive" to make the encoding used in Unicode string literals u"..." (and their raw counterparts ur"...") definable on a per source file basis. Problem In Python 2.1, Unicode literals can only be written using the Latin-1 based encoding "unicode-escape". This makes the programming environment rather unfriendly to Python users who live and work in non-Latin-1 locales such as many of the Asian countries. Programmers can write their 8-bit strings using the favourite encoding, but are bound to the "unicode-escape" encoding for Unicode literals. Proposed Solution I propose to make the Unicode literal encodings (both standard and raw) a per-source file option which can be set using the "directive" statement proposed in PEP 244 in a slightly extended form (by adding the '=' between the directive name and it's value). Syntax The syntax for the directives is as follows: 'directive' WS+ 'unicodeencoding' WS* '=' WS* PYTHONSTRINGLITERAL 'directive' WS+ 'rawunicodeencoding' WS* '=' WS* PYTHONSTRINGLITERAL with the PYTHONSTRINGLITERAL representing the encoding name to be used as standard Python 8-bit string literal and WS being the whitespace characters [ \t]. Semantics Whenever the Python compiler sees such an encoding directive during the compiling process, it updates an internal flag which holds the encoding name used for the specific literal form. The encoding name flags are initialized to "unicode-escape" for u"..." literals and "raw-unicode-escape" for ur"..." respectively. ISSUE: Maybe we should restrict the directive usage to once per file and additionally to a placement before the first Unicode literal in the source file. (Comments suggest that this approach suits the goal best.) If the Python compiler has to convert a Unicode literal to a Unicode object, it will pass the 8-bit string data given by the literal to the Python codec registry and have it decode the data using the current setting of the encoding name flag for the requested type of Unicode literal. It then checks the result of the decoding operation for being an Unicode object and stores it in the byte code stream. Since Python source code is defined to be ASCII, the Unicode literal encodings (both standard and raw) should be supersets of ASCII and match the encoding used elsewhere in the program text, e.g. in comments and maybe even 8-bit strings (even though their encoding is only implicit and completely under the programmer's control). It is the responsability of the programmer to choose reasonable encodings. Scope This PEP only affects Python source code which makes use of the proposed directives. It does not affect the coercion handling of 8-bit strings and Unicode in the given module. Copyright This document has been placed in the public domain. Local Variables: mode: indented-text indent-tabs-mode: nil End: -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From piercew at hushmail.com Wed Jul 25 17:40:25 2001 From: piercew at hushmail.com (Wayne) Date: 25 Jul 2001 14:40:25 -0700 Subject: BlackAdder Signal/Slots question. Message-ID: <9d848d5d.0107251340.1f92c43f@posting.google.com> I installed the Beta 3 of BA today and have been trying to get the Signal/Slots to work properly (c: at least how I would like it to work, without any prior Qt programming experience). I'm on Win2K and create a slot under "Edit...Slots..." which shows up in the compiled form. But how do I actually add code to the slot? I've tried extending the slot in a sub-class, chaning the main file (c: this doesn't work because it gets changed back on the next save) and can't find any place in the IDE to insert the Python code to run. I started to put manual "connect()"s in the code right before the "exec_loop" but didn't think that was a good idea. When I look at the existing tutorials the signal is assigned in the code that is automatically generated; however, the slot never shows up when I select the "Connect Signal/Slot (F3)" button. I started the form with a basic dialog and have added three lables, two text fields and two buttons. Right now I'm trying to get one of the buttons to exit the form with a simple "sys.exit(0)". Is there anyone out there that would be able to tell me if I am even close to doing this correctly? Also, is there a better NG to post these on? I haven't been able to find a NG specific to BA. Thanks for any help, Wayne From grante at visi.com Thu Jul 5 11:06:25 2001 From: grante at visi.com (Grant Edwards) Date: Thu, 05 Jul 2001 15:06:25 GMT Subject: Python for air traffic control? References: <9hlfbn$6ok$1@nereid.worldonline.nl> <9hrj3q$cj1@news1.gtech.com> <9htgsb$ck3@news1.gtech.com> Message-ID: In article , Russ wrote: >Let's cut right to the chase here. I like strong typing almost >as much as you do, but I don't understand why I can't get it in >Python, perhaps by specialized code-analysis tools. If you want a safe language with strong, static typing and good clean OO features (no, C++ doesn't qualify) you might want to take a look at Modula-3. http://www.m3.org/ M3 isn't very good for tossing together a disposable one-file-wonder the way Python is, and it's not as interactive as Python either. But, it's got a lot of support for building large, complex systems. -- Grant Edwards grante Yow! FIRST, I'm covering at you with OLIVE OIL and visi.com PRUNE WHIP!! From Tom_Good1 at excite.com Fri Jul 20 12:34:46 2001 From: Tom_Good1 at excite.com (Tom Good) Date: 20 Jul 2001 09:34:46 -0700 Subject: BURNING EARTHSHAKING Tuple Question References: <5e8bd451.0107191249.3c0d9f21@posting.google.com> Message-ID: kp87 at lycos.com (kevin parks) wrote in message news:<5e8bd451.0107191249.3c0d9f21 at posting.google.com>... > By the way is tuple pronounced tOOple (god i hope it is), or is it > pronounced > like the word "couple". According to the Merriam-Webster dictionary, it can be pronounced either way, but I most often hear it pronounced to rhyme with "couple". From hnowak at cuci.nl Wed Jul 25 08:27:06 2001 From: hnowak at cuci.nl (Hans Nowak) Date: Wed, 25 Jul 2001 14:27:06 +0200 Subject: Finding Directory Structures ?? Message-ID: <3B701419@twigger.nl> >===== Original Message From pmoscatt at bigpond.net.au ===== >Using python, hows the better way of finding the structure of your >filesystem. I thought it may have been Dir() but this brings back >something completely different. > >Basically I want to create a app that shows a Tree with the various >directories. If you want an application that shows a directory tree like in, say, Internet Explorer, you will probably need a GUI like wxPython or Tkinter to implement this. There might be widgets available that already do what you want. On a lower level, you can get directory and file info from Python modules, too: >>> import os >>> os.listdir(".") ['DLLs', 'Doc', 'hello.py', 'include', 'INSTALL.LOG', 'Lib', 'libs', 'LICENSE.txt', 'NEWS.txt', 'py.ico', 'pyc.ico', 'pycon.ico', 'python.bat', 'python.exe', 'pythonw.exe', 'README.txt', 'tcl', 'Tools', 'UNWISE.EXE', 'w9xpopen.exe'] >>> import glob >>> glob.glob("*.py") ['hello.py'] >>> glob.glob("c:/*.*") ['c:/AUTOEXEC.BAT', 'c:/bicw06tumble.gif', 'c:/boot.ini', 'c:/BOOTSECT.DOS', 'c:/CONFIG.SYS', 'c:/CWBANNER1.gif', 'c:/IO.SYS', 'c:/mpcsetup.log', 'c:/MSDOS.SYS', 'c:/NTDETECT.COM', 'c:/pagefile.sys', 'c:/PDOXUSRS.NET'] For information on subdirectories and such, you might want to look into os.path.walk: http://www.python.org/doc/current/lib/module-os.path.html which traverses a directory tree recursively, and allows you to collect the info you need. HTH, --Hans Nowak From grante at visi.com Tue Jul 3 10:59:03 2001 From: grante at visi.com (Grant Edwards) Date: Tue, 03 Jul 2001 14:59:03 GMT Subject: Python for air traffic control? References: <9hlfbn$6ok$1@nereid.worldonline.nl> <9hrj3q$cj1@news1.gtech.com> <9hrnub$9a2$1@panix3.panix.com> Message-ID: In article <9hrnub$9a2$1 at panix3.panix.com>, Aahz Maruch wrote: >In article <9hrj3q$cj1 at news1.gtech.com>, >Peter Milliken wrote: >> >>Python is a fine language for quick and dirty prototyping. For >>banging out applications that are going to run in an >>environment where it isn't going to matter if the program >>crashes, but it is certainly not something I would put forward >>for something like Air Traffic Control. > >Suppose that the only language choices are between C/C++ and >Python, and that the real-time resolution requirement is on the >order of one second. Which would you choose and why? The one thing about Python that would give me pause is the dynamic memory management. But, I'd have the same concerns if the C/C++ program used malloc/free. -- Grant Edwards grante Yow! FIRST, I'm covering at you with OLIVE OIL and visi.com PRUNE WHIP!! From peter at engcorp.com Fri Jul 20 07:37:46 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 20 Jul 2001 07:37:46 -0400 Subject: Language change and code breaks (fwd) References: <3B5505A0.F89ADB86@engcorp.com> <9j79s6$n27$1@panix2.panix.com> <3B578D96.DCE5B63C@engcorp.com> <3B57937B.B4057461@Lugoj.Com> Message-ID: <3B58180A.2264EDCD@engcorp.com> James Logajan wrote: > > Peter Hansen wrote: > > 1. They are inactive in the Python community and are > > therefore unaware of the upcoming code breakage. > > > > 2. Their code is dependent on the existing integer > > division behaviour, and yet they are not amongst > > the classes of users identified in this newsgroup > > as being the most likely to be impacted. > > > > 3. They are incapable of maintaining their code, > > and simultaneously are entirely at the mercy of > > outside forces who may choose to upgrade them > > against their will or without their knowledge to > > the new and incompatible version of Python. > > > > Or, they are not at the mercy of outside forces, > > yet mysteriously cannot *avoid* upgrading their > > Python installations and thus breaking their > > own code (which they somehow cannot maintain). > > > > 4. Were we to develop and make easily available to > > them a scanner capable at least of identifying > > the probability they will suffer code breakage, > > they would be unable to use it, whether for > > (1) or (3). > > > > Have I missed anything? > > I'm sure you could think of many more insults if you just tried harder. Just > how many years have you been in commercial software development anyway? Did you miss the thread up until this point? I neither intended the above to be insulting nor, as far as I can tell, *is* anything in the above insulting. Therefore, I agree completely with you. I could *definitely* think of more insults (than zero) if I tried. I've been in commercial software development since roughly 1981. (Perhaps you consider something in *this* posting insulting too. If you do, we clearly have a different definition of insulting. You, by the way, were obviously trying to insult me, and I honestly have no idea why.) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From hnowak at cuci.nl Wed Jul 25 08:30:15 2001 From: hnowak at cuci.nl (Hans Nowak) Date: Wed, 25 Jul 2001 14:30:15 +0200 Subject: Making a Sircam virus-remover in Python Message-ID: <3B701D4B@twigger.nl> >===== Original Message From "Morten W. Petersen" ===== >Hia guys, > >I was wondering if it would be hard to remove the Sircam virus using >Python; that is, to change the attribution of some files, edit and delete >some entries in the windows registry and then reboot; could someone point >me in the direction of the proper module to edit the Windows registry? Sure, use the _winreg module that is available since 2.0: http://www.python.org/doc/current/lib/module--winreg.html HTH, --Hans Nowak From Jasper49 at optushome.com.au Wed Jul 25 08:28:38 2001 From: Jasper49 at optushome.com.au (Native_MetaL) Date: Wed, 25 Jul 2001 12:28:38 GMT Subject: maths in programming Message-ID: Hello im new to programming and i have some questions about Maths in programming 1 what type of Maths is used in programming 2 how good do you have to be at maths to program 3 dose all programing have complex maths 4 are all programmers Expert's with maths 5 do you need to be an expert with maths to get Employment in programming 6 in IT firms are there people that do the maths ......... and others that just do the coding <---- the programmers i would really like to learn Programming and one day work as a programmer but i dont have maths skills. Ide like to get input from anyone that can help or maybe from people that have been in my situation and have now got Employment as programmers Thank you From paul at boddie.net Wed Jul 11 05:50:03 2001 From: paul at boddie.net (Paul Boddie) Date: 11 Jul 2001 02:50:03 -0700 Subject: Why database modules are incomplete References: <5174eed0.0107060820.ff90805@posting.google.com> <23891c90.0107090815.3685a9@posting.google.com> <5174eed0.0107100719.e14dfbe@posting.google.com> Message-ID: <23891c90.0107110150.24b7d36@posting.google.com> Dave Cole wrote in message news:... > >>>>> "Edward" == Edward Wilson writes: > > Edward> Dave: The way I see it, nobody is going to use a module "trial > Edward> and error" in the workplace, especially if they suspect it may > Edward> be incomplete. > > If they suspect that it is incomplete - maybe they should spend a few > hours to see if that suspicion is well founded. In most cases there > are only one or two modules to try. What could be interesting would be some kind of common test suite for database modules. It would give module developers something to aim for (for compliance with the DB-API), and module users something to use to verify how good a module is for their purposes. mxODBC has something like this for sanity checking, as well as for investigating certain aspects of type binding. > Edward> They are going to use a proven module, or hack one up in their > Edward> shop's native tounge. > > And the one hacked up locally will automatically be better than the > one which already exists which you could not spare the time to > evaluate... Sadly, in-house code often gets hacked up for database access, but the reasons can be persuasive - if you don't have a high turnover of staff, you can at least have a group of people who are very familiar with the code. It seems slightly ridiculous, though, to duplicate effort because people would rather write code than read someone else's. [...] > Edward> lending our time as testers. My personal feeling is that if > Edward> ten or twenty folks would jump in and help you out, in a year > Edward> (working part-time) Python could have a diamond hardened > Edward> Sybase module. > > You are 100% correct here. If only people were willing to try the > module. For all I know there are more than 20 people who are using > the module for serious work. Noone ever tells me, so how can I claim > that I have a proven module? As I said before - there have been over > 180 unique IP addresses which have downloaded the Sybase-0.2x module. Perhaps it works sufficiently well for the purposes of the users who downloaded it. Nevertheless, sure-fire ways to elicit feedback would be invaluable for module developers. Do any of these Sourceforge surveys ever get used? (Or are people too worn down by having too many meaningless "Who is your favourite actress?"/"What kind of geek are you?" surveys in their face whilst surfing?) > Edward> Python is way cooler than PL/SQL or any other language used > Edward> for writing db apps for that matter. > > Which is exactly why I wrote the module - to avoid using ISQL or Perl. These are certainly reasons that I won't contest. ;-) Paul From FenZhao at mit.edu Wed Jul 18 12:01:06 2001 From: FenZhao at mit.edu (Man Vehicle Laboratory) Date: Wed, 18 Jul 2001 12:01:06 -0400 Subject: sys.argv not found References: <3B55962C.63F7E2EF@mit.edu> Message-ID: <3B55B2C2.74A8FB3D@mit.edu> I've tried putting a print statement right after I import sys. I have the same error as before: ****************************************************************************** * WINVRUT 2.4a Copyright 1995-2001 University of California, Santa Barbara * * Massachusetts Institute of Technology * ****************************************************************************** VRUT 2.4a voicekey Voicekey 0.9 serialthrustmaster Serial thrustmaster 1.0 avstu AvatarStudio 1.1 Traceback (most recent call last): File "", line 1, in ? File "N:\FenZhao\E3_sid_data\e3_sid_data2.py", line 61, in ? print sys.argv AttributeError: argv The error I get from vrut is from my code looking at argv, not vrut (error message w/out print statement: Traceback (most recent call last): File "", line 1, in ? File "N:\FenZhao\E3_sid_data\e3_sid_data2.py", line 62, in ? mode=string.atoi(sys.argv[1]) AttributeError: argv So whatever my first operation is dealing with sys.argv, there's an attribute error with argv) What confuses me is that this error is displayed in the VRUT window; VRUT opens two windows, a display window that shows the 3D VR scene, and a text window that will display print statements and error messages from python. Logically, if argv can't be found, an error message will end the program before vrut ever gets started. I've also tried importing vrut after looking at sys.argv in case vrut does something funky in it's initialization/import. Same problem. Yet commenting out the vrut.go() command, and the sys.argv is fine. --Fen PS. I hope this helps: all of my code up to the call to vrut (minus comments)... there's not much there, can't figure out what's making it work improperly. None of the modules that I wrote and imported do anything with sys import vrut import sid import string import math import time import speeds import e3_dataAn import sys mode=string.atoi(sys.argv[1]) ARGFILE_stim=sys.argv[2] ARGFILE_calib=sys.argv[3] OUTFILE=sys.argv[4] SUMFILE=sys.argv[5] sidOutfile=sys.argv[6] VECTION_DURATION=string.atoi(sys.argv[7]) path=sys.argv[8] vrut.go(vrut.NICE) Steve Holden wrote: > > > > First, can we assume you have included an "import sys" above the code you > quote? > > You should: > > a) Make sure you incude the exact error traceback with postings like this, > so we can see more nearly where the problem might be occurring; and > > b) Scatter "print" statements to give you confidence that your logic is > indeed being executed as you expect, in the sequence you expect. > > I have an idea that vrut.go() might be looking at sys.argv itself, but there > isn't really sufficient data to *know* quite what's going wrong. Your > assumptions appear reasonable, but I think your code *is* being executed in > the order you expect. > > Good luck > Steve > -- > http://www.holdenweb.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From bokr at accessone.com Tue Jul 10 01:47:19 2001 From: bokr at accessone.com (Bengt Richter) Date: Tue, 10 Jul 2001 05:47:19 GMT Subject: Language Shootout References: <3B49F724.1F3DF6B3@yahoo.com> <3B4A0C34.C64202C2@Lugoj.Com> <3B4A185D.7C9EC4A5@yahoo.com> <3b4a468d.1494788532@wa.news.verio.net> <3B4A7139.83AFE9C1@yahoo.com> Message-ID: <3b4a872e.1511334253@wa.news.verio.net> On Tue, 10 Jul 2001 03:12:59 GMT, Paul Winkler wrote: >OK, I'll bite. >fibo.py is mine, ffib.py is yours. >Note that yours computes what is (according to mine and Frederik's scripts) >fibonacci of N-1 rather than fibonacci of N. > I think it's ok for >0, but my fib(0) is plain wrong. A leftover kludge to make it safe for negative numbers at the same time as the starting case. Not very pure. I just googled and found http://math.holycross.edu/~davids/fibonacci/fibonacci.html which seems to agree. Originally I got the sequence definition from a scheme book with the usual recursive demo examples. I also just now googled to http://www.auto.tuwien.ac.at/~blieb/woop/fibnum.html where I found not only the definition F0=0, F1=1, Fn=Fn-1+Fn-2 for n>=2 This defines the sequence 0, 1, 1, 2, 3, 5, 8, 13, 21 and so on. but also what appears to be an iterative version or variant of my recursive algorithm. At least some of the expression terms look suspiciously similar. But it's written in gnat, and seems to use lower case L as a variable, which ought to be outlawed, plus it's got a couple Ada tricks I don't recognize. But at some point I'd like to translate it to Python for comparison. It should be the fastest. Of course it won't be recursive. >Other than that, you've kicked my butt! > >Now is the time for me to strategically retreat and declare that what really >matters is readability. Who cares about speed? Not me! Never did, no sir. > LOL, thanks for the chuckle ;-) From graham at coms.com Wed Jul 4 03:42:35 2001 From: graham at coms.com (Graham Ashton) Date: Wed, 04 Jul 2001 08:42:35 +0100 Subject: Alternate Syntax for dictionary elements References: <3b421046.1836046@news.t-online.de> <3b421cec.5073656@news.t-online.de> Message-ID: In article <3b421cec.5073656 at news.t-online.de>, "Gerson Kurz" wrote: > 2 reasons for using dicts rather than classes: > > - You can easily create the data an object stores *dynamically*, i.e. > from user input. What can you do dynamically with a dictionary that you can't do with setattr() and getattr()? (that's a real question, not a cocky way of pointing out you might have missed something) -- Graham From db3l at fitlinxx.com Wed Jul 25 16:37:26 2001 From: db3l at fitlinxx.com (David Bolen) Date: 25 Jul 2001 16:37:26 -0400 Subject: Version compatibility in division References: <9jm3nq$ulf$1@pea.uk.research.att.com> Message-ID: Duncan Grisby writes: > In article , > Nick Perkins wrote: > > >I suppose the only cross-version solution would be: > > > > # Script MUST run under various Python versions without change > > ... > > print int(container/widget) ,'widgets will fit in the container' > > > >It's a tiny bit verbose, but at least it's very explicit. > > And also wrong in the face of negative divisors (although you probably > wouldn't have a negative number of widgets :-) ). > > >>> 5/-2 > -3 > >>> int(5.0/-2.0) > -2 > > The "simple" solution is divmod(container, widget)[0]. Lovely. Simple if you need to ensure negative number behavior. I'd hazard a guess that of all the existing code that depends on integer division, a majority will never have a negative number. So for that portion, (or for that portion of future code for which its known the integer division is on positive values), int(expr) might well be the simplest approach. Then again, the bigger problem with int() is the potential for rounding that is, at least theoretically, permitted by the implementation, although as someone else pointed out, it's not clear that any C libraries actually do that. -- -- 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 qrczak at knm.org.pl Thu Jul 26 15:03:21 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 26 Jul 2001 19:03:21 GMT Subject: Operator symbol for "nb_intdivide" References: Message-ID: Thu, 26 Jul 2001 18:08:34 GMT, Peter Dobcsanyi pisze: > But, I don't like the "//" operator symbol what we are supposed to > use for implementing "a // b == floor(a/b)". Me too. > I would like to suggest to use a clearly distinguishable > one-character symbol for the "nb_intdivide". Here I disagree. I would preferably use div (and mod) as operators. The only problem with them is that someone could have used them as identifiers. I still think that it's a minor problem, more easily fixed than finding / which need to be changed at all. I still prefer it. Perhaps because I used to use Pascal a lot. It's readable and is already used in Python for other operators. Other proposals: - div (and mod) as functions, i.e. div(a, b). Ugly but the meaning is clear. - A general mechanism of turning functions into binary operators, probably $div like in Miranda. This doesn't steal a keyword but is inconsistent with spelling of existing operators (I don't know about Miranda, but in Haskell there are no operators consisting of letters). - Some language uses \ (I don't remember which, probably a kind of Basic or JavaScript). It is overloaded in Python, but not in the middle of a line. Drawback: can't be used at the end of a line, i.e. x = (2 \ 3) doesn't mean what you might think - this would be legal for + for example because it's in parens. And BTW, I still think that 1/3 is a rational. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From thomas at xs4all.net Sun Jul 15 06:54:01 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Sun, 15 Jul 2001 12:54:01 +0200 Subject: converting from perl: variable sized unpack In-Reply-To: <15184.50121.350177.822472@beluga.mojam.com> References: <15183.48231.771283.235523@anthem.wooz.org> <15184.50121.350177.822472@beluga.mojam.com> Message-ID: <20010715125401.Y5396@xs4all.nl> On Sat, Jul 14, 2001 at 05:12:25PM -0500, Skip Montanaro wrote: > >>>>> "RS" == Roy Smith writes: > RS> What's the best way to translate this perl snippet into python: > RS> ($f1, $f2, $f3, $f4, $f5, $f6) = split ('\s+', $line); > BAW> Python doesn't work this way, but I've been thinking about writing > BAW> a PEP to make sequence unpacking less strict. > What about writing a simple class to do it? Instead of raising an exception > in __getitem__ it would just return "" or None. Much though I would like to see 'loose' tuple unpacking, I have to admit Skip is right: it's easy to do with a wrapper class, or even better, a generator: def loose(l, maxlen, pad=None): for item in (l + maxlen*[pad])[:maxlen]: yield item -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From paul at boddie.net Tue Jul 24 05:09:37 2001 From: paul at boddie.net (Paul Boddie) Date: 24 Jul 2001 02:09:37 -0700 Subject: proposed language change to int/int==float (was: PEP0238 lament) References: Message-ID: <23891c90.0107240109.5b7072d4@posting.google.com> "Tim Peters" wrote in message news:... > > I'm burned out on the repetition here. It's not a question of being hard to > teach. It's largely that it's never sensible for > > x = y / z > > buried in the middle of some routine to do truncating division if y and z > happen to be ints but best-possible division if they happen not to be ints. Indeed. But given that many people know what / is going to do, and have managed to reassure themselves that y and z are going to be integers at the relevant parts of their own code, do you think it's fair to make their code give an "unexpected" result (for them) just because one could get an "unexpected" result in the general case? > It's this damage to polymorphism that hurts people in real life, and we've > had years of testimony about that on c.l.py (even in this incarnation of the > debate, although it's hard to find unless you read every msg). I agree with what you say about the dangers of the / operator, and it is important to at least try to remove the ambiguity (indeed, why not start raising exceptions), but I don't see why this has to be done by breaking untold amounts of code that came before just because a group of people want to reclaim the / operator as their instrument for the "one true kind of division". If someone had suggested using // for the int/int->float operation, I bet that hardly anyone would have complained, apart from some people who might consider it "language bloat". But instead, it seems that for the sake of some aesthetic principle the rug is being pulled out from under everyone whether they want to lie down or not. Paul From bill-bell at bill-bell.hamilton.on.ca Sat Jul 14 16:32:19 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Sat, 14 Jul 2001 16:32:19 -0400 Subject: Calling functions in a loop In-Reply-To: <995137652.463.56460.l9@yahoogroups.com> Message-ID: <3B507413.18231.606E7F@localhost> With >>> def fn1 ( ): ... print "fn1" ... and >>> def fn2 ( ): ... print "fn2" ... Use >>> x = [ fn1, fn2 ] >>> for f in x: ... f() ... fn1 fn2 or >>> y = ['fn1', 'fn2'] >>> for f in y: ... eval ( f ) ( ) ... fn1 fn2 > n_d_gangadhar at yahoo.com (NANDYALA D Gangadhar) > > Hello, > > I am new to Python (I already like it very much) and I have a newbee > question: How do I call a set of functions from inside a loop? I tried > the following, and it understanbly fails with: > > TypeError: object is not callable: 'Fn1' > > -- Code -- > #!/usr/bin/env python > > __all__ = ["Fn1", "Fn2"] > > def Fn1(): > print "I am Fn1" > > def Fn2(): > print "I am Fn2" > > if __name__ == "__main__": > for Fn in __all__: > Fn() > -- /Code -- > > Would someone show the correct way of getting the functionality I > need? From tjenkins at nospiced.ham.devis.com Thu Jul 26 22:34:55 2001 From: tjenkins at nospiced.ham.devis.com (Tom Jenkins) Date: Fri, 27 Jul 2001 02:34:55 GMT Subject: Nasty typo in PEP 238 (revised) References: Message-ID: <3B60D432.5060109@nospiced.ham.devis.com> David Eppstein wrote: > In article , > Guido van Rossum wrote: > > >> Q. How do I write code that works under the classic rules as well >> as under the new rules without using // or a future division >> statement? >> >> A. Use x*1.0/y for true division, divmod(x, y)[0] for int >> division. Especially the latter is best hidden inside a >> function. You may also write floor(x)/y for true division if >> you are sure that you don't expect complex numbers. >> > > > Shouldn't this be float(x)/y ? > > I still don't like the phrase "true division", it implies a value judgement > that quotients are somehow an inferior thing to want to compute. > David, I'm not sure. I thought so to, but decided to try it in the interpreter first (since I never used floor before) >>> xxx = 1.0 >>> yyy = 2 >>> from math import floor >>> floor(xxx)/yyy 0.5 >>> xx = 1 >>> floor(xx)/yyy 0.5 >>> yy = 2 >>> floor(xx)/yy 0.5 >>> floor(xx) 1.0 >>> xx = -1 >>> floor(xx) -1.0 >>> floor(xx)/yy -0.5 >>> so-i-guess-it's-not-a-typo-ly yours Tom From bokr at accessone.com Tue Jul 17 23:57:40 2001 From: bokr at accessone.com (Bengt Richter) Date: Wed, 18 Jul 2001 03:57:40 GMT Subject: [Python-Dev] Re: PEP: Defining Unicode Literal Encodings (revision 1.1) References: <3B50C1FF.7E73739B@ActiveState.com> <200107150126.VAA23781@cj20424-a.reston1.va.home.com> <3B51CFB0.ACE9070D@ActiveState.com> <200107151729.NAA00455@cj20424-a.reston1.va.home.com> Message-ID: <3b54fb14.2196363473@wa.news.verio.net> On Tue, 17 Jul 2001 09:33:43 -0700, Paul Prescod wrote: >David Eppstein wrote: >> >>... >> >> I tend to think putting anything at all in the text of the file is a hack >> and not a clean design -- this is meta-information rather than content, >> right? > >What is the practical problem with mixing "meta-information" and >"content"? > >> ... But maybe as long as you're going to do that you should go all the >> way and have some kind of "meta" directive that allows MIME directives >> beyond just charset=... > >What other ones make sense? You could put the meta-information in another place, e.g., 1. A file with the same name and extension .pym for python meta-info 1.1 File could be a general preprocessing script or just data 2. A string in a directory with the file name (sans extension) as key. 2.1 String could be execable, or flags for special process You could flag files that have associated meta-info or scripts by changing their extensions to .pyx for python with special effex ;-) You could also have spam.pyx be empty, simply to trigger spam.pym, which might see if its work was cached and otherwise torque spam.py (usually, but could be anything) around any which way, including substituting international keyword names or whatever, or maybe doing loading and environment setup. spam.pyx could also control decryption, decompression, uudecoding, or mime-defined stuff, or whatever. Old spam.py etc would be treated as now. The downside of triggering automatic general purpose processing is that it could be a door for an exploit, if not well protected. At least keeping auxiliary information separate would get around the directive-before-docstring problem. -- BTW, I really don't like using file names and extensions as part attribute encodings. I would much rather see a file system with a standard n-sector data prefix that could be invariant irrespective of container file name. There it could have an invariant utf-8 name *for the content* independent of symlinks or renaming of files-as-containers, as the data moved from system to system. File content type would also be encoded in this prefix block, and the unix file command wouldn't have so much guessing to do any more. There would also be room for an assigned GUID to work like a UPC bar code identifying producer software as desired. Enabling easy version compatibility checks, automatic searches for conversion software for import/export, etc. Absolute time of first creation, and original instance vs copy generation might also be encoded. A user-modifiable string in this prefix block could carry the kind of meta-info talked about above, so it could be associated with the file content without relying on platform-specific (container) file conventions such as extensions etc. You could hack access to this prefix block by absolute negative seek as indices to the parts. (This is an idea, not a detailed design ;-) So yet another possible mechanism or two for Defining Unicode Literal Encodings (OT ;-) From sholden at holdenweb.com Fri Jul 20 10:39:50 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 20 Jul 2001 10:39:50 -0400 Subject: Python 2.0.1 bug? References: <20010720095330.19318.00000287@ng-fn1.aol.com> Message-ID: I saw a bug relating to CGIHTTPServer posted about anomalous behavior of IE on Windows 2000, and noted that it also occurred on my Win98 system. POSTs are even weirder: POST, POST, GET is the typical sequence of requests I see. Appears to be a socket programming anomaly, I wonder if you could be hitting the same thing?. http://sourceforge.net/tracker/index.php?func=detail&aid=430160&group_id=547 0&atid=105470 regards Steve -- http://www.holdenweb.com/ "TheDustbustr" wrote in message news:20010720095330.19318.00000287 at ng-fn1.aol.com... > Sutdy the following code: > > # BEGIN CODE BLOCK > # simple webserver > import socket > > HOST = '' # empty string meaning localhost > PORT = 8080 > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > s.bind((HOST, PORT)) > s.listen(1) > > while 1: > conn, addr = s.accept() > print 'Connected by', addr > data = conn.recv(1024) > print data > conn.send(data) # reference point 1 > conn.close() > # END CODE BLOCK > > When you run this program then point your webbrowser to localhost:8080, you > SHOULD see your GET / HTTP/1.1 request echoed to the screen (the "webpage"), as > well as echoed to the console. Well, under Python 1.5.2 running under Linux, > it does. Running 2.0.1 under Windows 95, it doesn't, *nothing* is printed to > the webbrowser. Reference point 1 can be changed to thus to make it work: > conn.send(data+data) Thus under Windows Py2.0.1 it prints the GET request to > the webbrowser ONCE. Under Linux Py1.5.2 it prints it TWICE as expected). > Another test with curious results is to change the reference line to this: > conn.send("first part" + data + "second part") This prints the string "second > part" to the webbrowser, nothing more. > > Hmmm, any known workarounds for this problem? Other python-based servers have > worked on my machine (like the samples included in the docs). > > Thanks, Dustin From mirko.liss at web.de Mon Jul 16 08:46:58 2001 From: mirko.liss at web.de (Mirko Liss) Date: Mon, 16 Jul 2001 14:46:58 +0200 Subject: pipe in read and write mode In-Reply-To: References: Message-ID: <20010716124659.73228ED4.NOFFLE@niccolo.ke4.de> On Mon, 16 Jul 2001, Raphael Bauduin wrote: > I want to pipe the standard input of my script to a command. I use popen, > and it's fine. However, I want to take the standard output of the command > and put it in a variable. I can't open the pipe in read and write mode. I > made it work by redirecting the output of the pipe to a file, and reading > this file. I would prefer not to write it to a temporary file, as the text > piped is somewhat sensitive (I use the script to encrypt it, so it would be > better not to write it to a file ;-) There's a marvellous documentation that came with your Python distribution. Just read the chapter about the ===== 'popen2' ===== module. You might want to look at www.python.org as well. regards, Mirko From tundra at tundraware.com Sun Jul 22 14:20:02 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 22 Jul 2001 18:20:02 GMT Subject: Mainpulating Data Files Message-ID: <3B5B1914.FCC02BF2@tundraware.com> Say, for the sake of argument, I have a bunch of data files in some "alien" format (not Berkeley DB, CSV, or any of the other well-known data formats). Say I know the format and it consists of both ASCII and binary data in fixed record-field, variable-length record-field, and arbitrary variable length data. Some of the data might be in AVL or B-Tree format with embedded linking information in each record. So, as a general matter, is there a 'Pythonic' way to read this kind of thing in or am I stuck with the usual 'C' approach of reading in n-characters and then filling some data stucture? I guess what I am really asking is where there is some Python-enabled templating approach that allows me to describe the schema of a file in some meta-data format, and then use Python to read it in and manipulate it. I vaguely understand that this might be possible using something like XML, but I was thinking more about a language feature like picture fields in perl. TIA, (as always) -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From wheelege at tsn.cc Tue Jul 24 05:09:08 2001 From: wheelege at tsn.cc (Glen Wheeler) Date: Tue, 24 Jul 2001 19:09:08 +1000 Subject: A use for integer quotients References: <3B5BDCB4.A2010560@letterror.com> <3B5C3713.A5201C5A@letterror.com> Message-ID: <00a701c11420$4cc6f1e0$0200a8c0@ACE> > > [Just van Rossum] > > > Do you really want 2047 bytes to be shown as 1 kbyte? > > > Integer division is a lousy tool in this particular example... > > [Terry Reedy] > > Just, this is stupid, wrong, and gratuitously insulting, > > and therefore, in my opinion, ugly and nasty. > > I think you're terribly overreacting. Sorry if I offended anyone, > I admit that first line of mine is a dumb assumption. To put it more > subtly: *I* would never use int arithmetic for this sort of thing in > Python. Right, I think this is a good time for everybody to cool down...Just is clearly not being offensive here. The same arguments are being stated over and over again by the pro 1/2==0 side, and the same refutements are being stated by the other side. My opinion is that if Guido wants it changed even in the light of all these arguments, then so be it. Sure I'll have to change a little bit of code, but that's alright. I distribute alot of my stuff as stand-alone packages anyway - the user never has to worry about upgrading, unless it's >MY< upgrade - which isn't going to break anything. Glen. From steve at lurking.demon.co.uk Sat Jul 21 17:51:13 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Sat, 21 Jul 2001 22:51:13 +0100 Subject: Can I copy a generators state and then backtrack to it if necessary? References: Message-ID: I don't seem to be getting much response. Please help!!! To restate the problem, I want to know how to modify the following code... from __future__ import generators def test () : for a in xrange (4) : yield a a = test () print a.next () print a.next () b = a print a.next () print a.next () print b.next () print b.next () So that the 'b=a' line takes a copy of a - rather than just making a reference. The current code gives the result... 0 1 2 3 Traceback (most recent call last): File "test2.py", line 17, in ? print b.next () StopIteration The output I want is... 0 1 2 3 2 3 Obviously I need a deep copy - the shallow copies achieved by slices on lists etc would not preserve the entire state of the generator. Is there any way to do this? Even a definite no would save me worrying about it. From skip at pobox.com Fri Jul 27 10:56:46 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 27 Jul 2001 09:56:46 -0500 Subject: Threading in Python In-Reply-To: References: Message-ID: <15201.33070.400820.611758@beluga.mojam.com> (Andy, I'm not picking on you.) andy> There seems to be a lot of (arguably) radical changes going on in andy> the Python syntax/grammar/language, perhaps the direction should andy> be towards improving the internals first? andy> One thing Java has which Python lacks is transparent support for andy> multi-cpu threading. Python has threads, but I believe it is andy> internally implemented and has been shown not to take advantage of andy> an SMP machine. Folks, you should all know where the Python source code is. If not, I'll remind you where you can download it: http://sourceforge.net/projects/python/ Python is open source. That means you can make improvements and submit them to SF. People do it all the time. PythonLabs is not a large organization (a half dozen developers at most, with some kibbitzing from the rest of Digital Creations) and they have other higher priority tasks that prevent them from implementing a virtual machine that is 10x, 5x or even 2x faster than the current implementation at the moment. One of the advantages of open source is anyone can hack on it. One of the disadvantages of open source is the development community takes what it can get in the way of skills. Most of us interested in Python are probably application programmers. Compiler experts are a lot harder to find. It may well be that the Python community doesn't have a JIT compiler or SMP multi-threading guru or two laying about with a few months free to devote to such a project. (There's Tim Peters, but I never get the impression he has a lot of time to spare.) Sun, on the other hand, has the money necessary to go out and hire someone (several someones, more than likely) with the necessary skills and make it their job to add JIT compilation or efficient SMP multi-threading to Java. In fact, you could argue that they have to do these sorts of things to keep Java from being crushed by Microsoft. Python is generally not under such competitive pressures. Consequently, it's likely that you'll see more whiz bang compiler stuff in the Java environment for the foreseeable future than in the Python environment. That doesn't mean it won't happen, but it might not happen at the same rate as in other environments. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From akuchlin at mems-exchange.org Fri Jul 20 10:59:40 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 20 Jul 2001 10:59:40 -0400 Subject: Language change and code breaks References: Message-ID: <3d1ynb4per.fsf@ute.cnri.reston.va.us> Guido van Rossum writes: > second that the average identifier length will go up. If you use this > a lot (message = Message() etc.) your code is less readable than it > should be. It also makes it harder to discuss code in person or over It's also less typing if you abbreviate the variable name holding the instance. I often write u = User() or acct = Account or msg = Message(). Case-insensitivity breaking the 'message = Message()' idiom is mildly annoying, but not very significant. --amk From tim.one at home.com Sun Jul 8 18:19:01 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 8 Jul 2001 18:19:01 -0400 Subject: Comment on PEP-0238 In-Reply-To: Message-ID: [Guido, to Emile van Sebille] > Your examples don't show what should happen in this example: > > precision 0 > x = 2/7 > precision 4 > print x > > In other words, is the precision a property of the printing or a > property of the value stored? > > There are lots of other ways to get this effect for printing ("%.4f"%x > comes to mind); if you intended the effect to apply to computation > results, there are questions about the scope of the calculation. If I > write > > precision 3 > x = f() # some function that uses int division > > should every calculation in f() be affected by the precision > statement? > > Etc., etc. IBM's Standard Decimal Arithmetic proposal answers such questions, but abstractly (in terms of the numeric *model*, not in terms of concrete language syntax): http://www2.hursley.ibm.com/decimal/ Fully usable numerics require consulting and updating several kinds of "global" (really thread-local) state. The IBM proposal formalizes this as "the context" component of every numeric computation. This is akin to 754's mandatory set of rounding mode and trap-enable flags (implicit inputs to every fp operation), and sticky "did such-and-such happen?" exception flags (implicit outputs from every fp operation); so you don't get away from this in the end even if "all you want" is supporting platform HW fp correctly. BTW, state-of-the-art rational support also requires context, to determine whether results should be reduced to lowest terms (some programs run 1000s of times faster if you don't, others 1000s of times faster if you do, and only the algorithm author can know which is better). IBM's proposal has similar stuff, and also adds a precision component (an int > 0) to context. The rules for how precision affects operations are spelled out (BTW, Pentium HW also has a hidden "precision control" implicit input to every fp operation, determining whether the result is rounded to 24, 53 or 64 significant bits; the lack of language support for dealing with that in C may well be the #1 cause for numeric discrepancies across C programs run on 754 boxes under different compilers and C libraries). A gloss on this: > If I write > > precision 3 > x = f() # some function that uses int division > > should every calculation in f() be affected by the precision > statement? Believe it or not, probably "yes". REXX has tons of experience with this, and life works best if (a) everyone respects precision, and (b) users rarely fiddle it except once at the start of a program run. That said, f()'s author also needs to make a choice here. Most *library* routines should strive to return a *result* good to strictly less than 1 ULP wrt the precision in effect at the time they were called, even if that requires temporarily boosting precision internally. This kind of construct would be common in well-written libraries: old = context.getprecision() try: context.setprecision(max(8, oldp + 3)) do stuff return roundtoprecision(result, oldp) finally: # Restore starting precision. context.setprecision(oldp) This is reminiscent of: lock.acquire() try: do stuff finally: lock.release() and more generally of C++ code using: { MySideEffectObjectClass x(args); // never referenced do stuff; // No matter how we leave this block, it's guaranteed that // x's destructor gets invoked before we're out. } where the constructor allocates a resource (or fiddles a context), and the destructor releases it (or restores the context). The last time we solved a "it's *hard* to make sure temporary context changes get undone!" problem in Python was via adding ">>" to "print" <0.8 wink>. Python may want a more general approach to this kind of thing. From snowrichard at earthlink.net Sat Jul 14 16:05:36 2001 From: snowrichard at earthlink.net (Richard Snow) Date: 14 Jul 2001 13:05:36 -0700 Subject: New library software development project. References: <3B3601BE.3C84E49A@earthlink.net> Message-ID: <7a32d1c7.0107141205.51f7565b@posting.google.com> "Ed Sharpe" wrote in message news:... > there are already things like this out there.... snip... > Richard Snow wrote in message > news:3B3601BE.3C84E49A at earthlink.net... > > > > 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 snip... > > 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 > > > > > > Ed: I've done a minor update to the web site mentioning koha and openbook. When I get more time and details I'll add some more to my site. Thanks for pointing out these other projects. It would have taken me a long time to get mine to the point that Koha is now. I haven't seen the Open Book beta yet. I have offered to help write some docs for Koha, and I will start on that as soon as I have time to get all my software installed that it needs and actually install Koha on my system. Rough drafts will be on a new page on the above mentioned site before I send them to koha. By the way I'm posting this message from my sister's computer using the new Google Groups system (new to me anyway). Good Job, Google. Richard From quinn at hork.ugcs.caltech.edu Tue Jul 3 15:25:31 2001 From: quinn at hork.ugcs.caltech.edu (Quinn Dunkan) Date: 3 Jul 2001 19:25:31 GMT Subject: Alternate Syntax for dictionary elements References: <3b421046.1836046@news.t-online.de> Message-ID: On Tue, 03 Jul 2001 18:45:05 GMT, Gerson Kurz wrote: >Please consider the following: > >dict = { 'type' : 'button', 'id': 32, 'name' : 'some name' } >... >if o['type'] == 'button': > # do something for objects of type button > >Now, take a look at > >if o.type == 'button': > # do something for objects of type button Won't work because of {}.keys, etc. If you don't mind those name clashes, you could write __getattr__ and __setattr__ to simulate this. It's not advisable, though, because container access is a clearly seperate concept from object access in python. It has a different syntax and a different conceptual purpose, even though there is some implementation overlap (e.g. o.__dict__). If you want object access notation, you should probably be using an object, not a dictionary. For example, your button above is probably not suited for dictionaryhood. In Lua, on the other hand, tables and objects are truly the same, and foo.bar is syntactic sugar for foo['bar']. Lua's object model is rather weaker and more do-it-yourself than python's, though. And here's why using a dict as you did above is probably silly: You don't need to manually encode type information if the language can do it for you. Making a Button class will automatically attach that type to its instances. Furthermore, a fundamental property of all objects (as opposed to true values like an algebraic data type) is that they have unique ids seperate from their values. The language will maintain them for you, and to fetch them you can use the id() function. The 'name' field is the only necessary one. "Yes", you're saying, "but it was only an example." :) From paulp at ActiveState.com Mon Jul 16 20:05:41 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Mon, 16 Jul 2001 17:05:41 -0700 Subject: OO misconceptions References: <9ir1l7$3ja$1@panix2.panix.com> <9irfbc11jaq@enews1.newsguy.com> Message-ID: <3B538155.854D336B@ActiveState.com> Tim Hammerquist wrote: > Re: having a bad day, no problem. > My only regret is that so many people in this NG are so violently > anti-Perl. It's human nature for the people behind the technology in second place to complain about the one in first place. I think Java is not a bad little language but I'll bet that on the Perl mailing lists you'll hear a lot of Java-bashing. And what about Window$ bashing? People hate to see their technology overlooked in favour of something that they think is inferior. Also, the people who like the language in second or third place often have to contend with PHBs that force them to use the first-place language. This tends to cause resentment. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From peter at engcorp.com Wed Jul 18 22:56:19 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 18 Jul 2001 22:56:19 -0400 Subject: Language change and code breaks References: <180720011705003205%jwbaxter@spamcop.com> Message-ID: <3B564C53.F0A6C3B6@engcorp.com> Neil Hodgson wrote: > > John W. Baxter: > > > I also hope that after the change to case-insensitive Python, > > we don't also go through a change to diacriticals-don't-matter > > Python. > > I'm hoping we can move to vowel-insensitive Python to increase ease of > use in Hebrew. And allow for non-deterministic pronunciation of g*d. I'm greatly bothered by language-sensitive Python. I'd much prefer using my native Esperanto, for example, in place of the cryptic (to newbies) English-language keywords. Since some newcomers to the language (like, say, most of the population of the planet) might not understand the keywords as they are or why they don't work in a more "logical" language (i.e. the newbie's own), we should change Python to support any language (including a mixture, for polyglots). Luckily, the proposed move to case-insensitive Python is a clear step in this very reasonable direction, so I fully support it. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com :-) From sill at optonline.net Sun Jul 8 21:35:28 2001 From: sill at optonline.net (Rainy) Date: Mon, 09 Jul 2001 01:35:28 GMT Subject: Keys To The Kingdom References: <3B48F6D7.D9798E7D@tundraware.com> Message-ID: On 09 Jul 2001 00:14:11 GMT, Tim Daneliuk wrote: > I have a two part question about accepting keyboard input in python: > > Is there a standard way to read one keystroke at a time rather than > doing line input via raw_input()? There is an entry in python FAQ about this (not msvcrt). > > For some reason, I cannot seem to catch Ctrl-C when it is typed in response > to a raw_input() call. This code still blows out of the python interpreter > when the user keys in Ctrl-C: > > try: > x=raw_input() > except KeyBoardInterrupt: > # Handle the Ctrl-C and regroup > ... > > ------------------------------------------------------------------------------ > Tim Daneliuk > tundra at tundraware.com -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: http://silmarill.org/cymbaline From bsass at freenet.edmonton.ab.ca Sun Jul 22 17:34:03 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Sun, 22 Jul 2001 15:34:03 -0600 (MDT) Subject: Language change and code breaks In-Reply-To: Message-ID: On Sat, 21 Jul 2001, Courageous wrote: > > >The problem here is that you control the language, but you don't > >control the tools. > > In fact with me, and I'm quite sure a host of others, dictating which tools > we have to use is a complete deal-breaker. I don't think that would be a problem, or necessary. Is there anything about case-insensitivity that could not be handled as a convention. If not, then implement it as a set of tools and options. 0% risk of compatibility issues, all the old tools and editors will still work (but may need some time to code up support for the new mode). - Bruce From jtorborg at fnal.gov Tue Jul 10 17:58:40 2001 From: jtorborg at fnal.gov (jtorborg) Date: Tue, 10 Jul 2001 16:58:40 -0500 Subject: Exiting Toplevel Cleanly Message-ID: <3B4B7A90.21D99807@fnal.gov> I'm writing a GUI using Tkinter that is a base program with buttons that pop up Toplevels. Both the main window and the Toplevel update 1/sec. Of course, when I tried to exit the Toplevel, I get a bunch of garbage about missing objects. I scoured old posts, and figured out (I think) how to use the after_cancel method. As a test, I wrote the little GUI (pure fluff) below, which models, if not emulates, what I'm trying to do. The problem is that about 5% of the time, I still get garbage when I exit the Toplevel. What am I doing wrong or not seeing? Is there another (better) solution to this problem? Or can I expect this to be tempermental? Thanks. from Tkinter import * import time import random import Conversions root=Tk() class TL: def __init__(self): self.tln=1 self.list=['up', 'down', 'strange', 'charm', 'top', 'bottom'] self.instan=Conversions.Convert() def popup(self): self.tl=Toplevel() self.label_list=[] for each in self.list: norm=256*265*256 inte=int(random.betavariate(1,1)*norm) color=self.instan.int_to_color(inte) self.l=Label(self.tl, text=each, bg=color) self.l.pack() self.label_list.append(self.l) self.b=Button(self.tl, text="EXIT", command=self.die) self.b.pack() self.id=self.tl.after(500, self.update_label) def update_label(self): for each in self.label_list: norm=256*265*256 inte=int(random.betavariate(1,1)*norm color=self.instan.int_to_color(inte) each.configure(bg=color) each.update() self.id=self.tl.after(500, self.update_label) def die(self): self.tl.after_cancel(self.id) self.tl.destroy() class main: def __init__(self): self.mln=1 self.tl=TL() self.mb=Button(root, text=self.mln, command=self.tl.popup) self.mb.pack() self.b=Button(root, text="EXIT", command=self.die) self.b.pack() self.id=root.after(1000, self.update_mainloop) def update_mainloop(self): self.mln=self.mln +1 self.mb.configure(text=self.mln) self.mb.update() self.id=self.mb.after(1000, self.update_mainloop) def die(self): root.after_cancel(self.id) root.destroy() root.mainloop() From peter at engcorp.com Sat Jul 14 00:16:42 2001 From: peter at engcorp.com (Peter Hansen) Date: Sat, 14 Jul 2001 00:16:42 -0400 Subject: greenbeen seeks advice References: <9pF37.22474$g96.625691@news.easynews.com> Message-ID: <3B4FC7AA.E6D7F0AC@engcorp.com> wyatt stafford wrote: > I am a computer/network support person who has decided to start programming > for a vocation (no previous experience beyond minor scripting, etc). After > some research I selected Python as a good place to start. [...] > Beyond those mentioned above, may I have any recommendations for self study > resources (books, etc) or techniques that will help me be a good programmer, > in general? Read comp.lang.python religiously. :-) Seriously, you can learn an awful lot by critically reading postings in this kind of forum. It is obvious there are some extremely clear thinkers wandering around here willing and able to educate people on all manner of things. (Then there are people like me, just here because they have no real lives and a pathetic need for acceptance even amongst a group of people as low as computer nerds. Learn to identify the latter type, and ignore us. ;-) > Do I need to know what is taught in CompSci 101/102/etc, to be great? I'm not sure what is taught in those courses, but I became a reasonable programmer before I had formal training. Training can help, but it helps more if you have a foundation and consider the training to be part of polishing your abilities. There are arguments that go the other way (not learning bad habits before going to school) but I tend to disagree with them. School does not typically teach the "right" habits for use in industry anyway, and you said you wanted programming to be your vocation. Learn what industry wants... The perhaps somewhat helpful part of my posting is this: I've found that by far the most effective thing in learning any language is to find a problem of interest to you and to apply the language to solving it. Don't limit yourself (after the first few minutes) to blindly typing what you find in a tutorial. Think of something, no matter how trivial (or complex) it may seem at first, to use the language for. After a while, you'll either solve the problem (warm fuzzy feeling of success), or you'll at least realize you were overshooting the first time and simplify your goals. Your first program needn't be more than a handful of lines. If you preserve each effort as you learn, you'll be able to look back on your code and appreciate the progress you've made, and in many cases learn even more while you improve your earlier attempts. The nice thing (one of them, I mean) about Python is that you always have the interactive prompt available to experiment. Keep one open all the time, even when you're typing code in a text editor, so you can quickly test snippets and one-liners to see if they work the way you expect. By the way, count yourself lucky. Some of us suffered for years with other languages before we finally stumbled across Python! :) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From nde at comp.leeds.ac.uk Tue Jul 24 08:13:29 2001 From: nde at comp.leeds.ac.uk (Nick Efford) Date: Tue, 24 Jul 2001 12:13:29 GMT Subject: UML Packages And Python Modelling References: Message-ID: On Tue, 24 Jul 2001 01:29:11 +0200, Lothar Scholz wrote: > I'm writing an UML Diagram Editor for python and would like to ask the > community what entity is an UML package. My first idea was that a file > is the logical equivalent, not the directory (likejava.and eiffel > programmers would expect). But then what is a directory ? > Should this be represented by a nested package ? A Python module could be drawn as a UML package. The module name would go in the tab at the top-left of the package icon. The implementation of a module (.py, .so, .dll...) could be shown using component diagram syntax. A Python package would map onto the nested package UML syntax. So (borrowing the package example from "Python Essential Reference") if you have a package Graphics, containing subpackage Primitive, containing module fill.py, you could draw that as a regular UML package, but with the name Graphics::Primitive::fill in the tab. Nick From guido at python.org Sat Jul 7 09:33:55 2001 From: guido at python.org (Guido van Rossum) Date: Sat, 07 Jul 2001 13:33:55 GMT Subject: Comment on PEP-0238 References: Message-ID: "Terry Reedy" writes: > GvR: > > I currently favor div(x, y) over x//y and x div y. Maybe also add > > mod(x, y) for symmetry (that would also explain divmod() as a > > messenger from the future :-). > > Since I do not like the change, as explained previously, I would prefer the > least change, which would be // with div second. // would not be new > keyword and breaks nothing sensible that I can think of. An operator form > would run as fast as now since it would be compiled inline as now. A > function call would be slower and make integer division look much more > wierdly asymmetric than it actually is. I suspect that some newbies and > CP4E people would find *that* (div()) strange. > > Terry J. Reedy Indeed, the beauty of binary operators is that they help the human programmer quickly understand an expression. Since we're used to the commutative and distributive laws and various other laws that apply (when they apply!!!), it takes less cognitive effort to understand "x+y+z" and move on to the next expression than "add(add(x,y),y)". Occasionally, the visual arrangement of operators and operands will remind us of a rearrangement that does the same thing more efficiently. (ABC's head designer, Lambert Meertens, developed a whole theory of programming based on this idea; search the web for "algorithmics".) But there are dimisishing returns. Integer division isn't that common, and there are few distributive or commutative laws that apply to it (those are mostly reserved for addition and multiplication). The proposal of "//" got a lot of opposition from folks who are concerned that it would confuse people with a C++ or Java background too much, because it's a comment there. The "div" keyword would be ideal except for the added complexity of adding a new keyword to the language -- do we need a separate warning phase here, too? (Hm. For various reasons I'm very tempted to introduce 'yield' as a new keyword without warnings or future statements in Python 2.2, so maybe I should bite the bullet and add 'div' as well...) --Guido van Rossum (home page: http://www.python.org/~guido/) From aahz at panix.com Sat Jul 21 01:31:47 2001 From: aahz at panix.com (Aahz Maruch) Date: 20 Jul 2001 22:31:47 -0700 Subject: doctest References: <9j7bsv$m3g5h$1@ID-59885.news.dfncis.de> Message-ID: <9jb443$i0e$1@panix2.panix.com> In article <9j7bsv$m3g5h$1 at ID-59885.news.dfncis.de>, Thomas Heller wrote: > >Recently I discovered how incredible useful Tim Peter's doctest is. > >The latest version from Python's CVS tree however does not run any more >under Python 1.5.2. Is there an uptodate version available which is >backward compatible? I don't know how current it is, but PIL contains a 1.5.2-compatible version from the 2.x line. -- --- 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 Fortune cookie: Watch your relations with other people carefully, be reserved. From mal at lemburg.com Mon Jul 16 08:29:11 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Mon, 16 Jul 2001 14:29:11 +0200 Subject: [Python-Dev] Re: PEP: Defining Unicode Literal Encodings (revision 1.1) References: <3B4F6E98.733B90DC@lemburg.com> <004c01c10be8$af2face0$4ffa42d5@hagrid> <3B4F746C.827BD177@lemburg.com> <3B51F378.7DC06482@ActiveState.com> Message-ID: <3B52DE17.E283521@lemburg.com> Paul Prescod wrote: > > "M.-A. Lemburg" wrote: > > > >... > > Since Python source code is defined to be ASCII, the Unicode literal > > encodings (both standard and raw) should be supersets of ASCII and > > match the encoding used elsewhere in the program text, e.g. in > > comments and maybe even 8-bit strings (even though their encoding > > is only implicit and completely under the programmer's control). > > Python programmers do not read PEPs to learn how to use new features. I > think it makes the whole thing much simpler if we define it on the file > level explicitly. To me, the feature is most helpful if it helps the > interpreter and various code inspection tools to understand all of the > non-ASCII information in the file. I don't think I understand your point... please clarify. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From guido at zope.com Fri Jul 27 08:43:01 2001 From: guido at zope.com (Guido van Rossum) Date: Fri, 27 Jul 2001 08:43:01 -0400 Subject: Operator symbol for "nb_intdivide" In-Reply-To: Your message of "Thu, 26 Jul 2001 19:20:59 PDT." <01Jul26.192106pdt."3453"@watson.parc.xerox.com> References: <01Jul26.192106pdt."3453"@watson.parc.xerox.com> Message-ID: <200107271243.IAA23850@cj20424-a.reston1.va.home.com> > > I don't believe this. If you can't distinguish / from //, you need > > new glasses. :-) > > Hmmmm. Not sure I believe this; mistaking "|" for "||" is said to be > a frequent cause of errors in C code. For different reasons: they have different priorities but their meaning is related (both are "or", just one is bitwise and the other is Boolean shortcut). Programmers coming from languages where only "|" existed were tempted to use that, but the priorities are so broken that a==b | c==d is parsed as (a == (b|c)) == d. A better analogy would be = vs. == in C. But I've never heard of confusion between + and ++ or between - and --, so I think the psychology of this mistake more complicated than just the doubling of the symbol. I know I've made the = vs. == mistake even in Python. Possibly it's more likely because = is by far the most common symbol. --Guido van Rossum (home page: http://www.python.org/~guido/) From tim.one at home.com Wed Jul 25 19:58:29 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 25 Jul 2001 19:58:29 -0400 Subject: Eliminating upgrade risk In-Reply-To: Message-ID: [John Roth] > After enduring the PEP 238 threads for far too long, as well as other > threads, I've come to the conclusion that Python is simply too unstable > for real use. Hmm. That suggests to me you haven't really used it. > Now, I've got a slightly different background here. Much of my > professional life was in IBM mainframe shops, Did IBM invite you to their internal bitch sessions? This is Open Source, John: it's *all* out in plain view. Heck, I'm the closest thing Guido has to a PR department , and PEP 238 in particular is talking about something that may change in 2 years. > where installing a new version of the operating system, major utilities > and language processors was essentially **guaranteed** not to break > running applications. I have no idea what "essentially **guaranteed**" means. Was this a clause in a legally binding contract? Or a hyperbolic way of saying you usually didn't have much trouble? If it was legally binding, how much would you pay to get the same kind of clause in a Python contract? The community's aggregate commitment to that cause so far is $0.00 . > I can remember numerous upgrades where I had to do absolutely > nothing on the applications side. > ... Believe it or not, most Python upgrades are like that too -- although we don't currently charge you Big Bux for the opportunity to be locked to IBM iron, I'm sure we could set a price for that too . an-ibm-mainframe-shop-this-ain't-ly y'rs - tim From pinard at iro.umontreal.ca Fri Jul 27 08:48:20 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 27 Jul 2001 08:48:20 -0400 Subject: perl2py - In progress! :-) In-Reply-To: References: Message-ID: [Neil Hodgson] > The Perl lexer built into Scintilla tries to disambiguate "/" by [...] Thanks for this hint, which is clean and simple. I shall take a look in Scintilla then, in case there are other such good ideas! P.S. - While walking to the office, this morning, I came up with a scheme that could ease implementing Semantic processing in `perl2py', and have yet to try it. The main trick goes along better object-orienting the ASTs, even if it means resorting less often to wandering facilities in SPARK. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From jkraska1 at san.rr.com Mon Jul 16 12:09:28 2001 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 16 Jul 2001 16:09:28 GMT Subject: converting from perl: variable sized unpack References: Message-ID: <3946lt0lpo8cvjt7f2p5i32q8if4il95j1@4ax.com> >The Python equivalent to the Ruby trick really isn't that much longer, and >to my mind has the advantage of showing more clearly the programmer's >intent: > (a, b), c = sequence[:2], sequence[2:] If y'll forgive an AOL-style "me too" post, I just have to say that your explicit assignment is far superior to the obfuscating syntactic sugar it replaces. Python: The Right Combination of Power and Elegance. C// From glyph at twistedmatrix.com Thu Jul 26 19:53:51 2001 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: Thu, 26 Jul 2001 18:53:51 -0500 (CDT) Subject: PEP 238 (revised) In-Reply-To: Message-ID: >From the peanut gallery: (so of course, feel free to ignore ^_^) Neither int nor float math is 'real' math. One could make the argument that rational math is the only "true" math, but as points have been made in the past, storage concerns and the lack of closure under certain operations make rationals impractical. I don't see a problem with Python's current implementation, and this PEP does nothing for me but make math on pixels more irritating. (ints are wrong and floats are wrong, but at least ints reasonably approximate screen real estate). The beginners that I teach Python to are mostly interested in display hacks in PyGame at this point; teaching them that they need to do int(x/y) in some cases instead of float(x)/y in others isn't really going to make the job of teaching any easier; users of numerical libraries *must* understand the varieties of precision they have at their disposal. But this PEP does mean that I have to teach it again and in a different way to those who already know it, as well as deal with version incompatibility issues at the level of language semantics (PythonLabs really needs to get involved with linux distributors to make sure that distributions stay more current...) I am unaware of the audience for this PEP, as most of those discussing it seem to understand the issues but be concerned about mythical "new users" of the language. In my experience, real new users are not confused by the current standard and would not be confused by the new one, but the change would be harmful. In short -- this change may help somebody, and I trust that PythonLabs knows at least one real person whose life it will make easier; but it will waste a lot of my time. Whatever it is that PythonLabs decides to do in this instance, please hammer it into stone. While I do not relish the idea of reworking all of my code that uses division now, I'm willing to do it *if it's only this once*, and there's some real perceived good of mucking with Python's math internals. I'll just hope that the million-odd already installed copies of PYthon 1.5.2 are going to get replaced with 2.2 sometime in the near future :). But let's not turn the use of Python itself into a maintenance or integration nightmare; pick a direction and move forward with it. On Thu, 26 Jul 2001, Guido van Rossum wrote: > Here's a completely revised version of PEP 238. It contains a long > motivational section, a clear specification of what will happen, and a > discussion of rejected alternatives, a list of open issues, a Q-and-A > section etc.. I hope it answers most questions that have been raised > about this issue. I'd be happy to revise it if there are still things > unclear. > > --Guido van Rossum (home page: http://www.python.org/~guido/) ______ __ __ _____ _ _ | ____ | \_/ |_____] |_____| |_____| |_____ | | | | @ t w i s t e d m a t r i x . c o m http://twistedmatrix.com/users/glyph From kwoeltje at mail.mcg.edu Tue Jul 24 18:36:13 2001 From: kwoeltje at mail.mcg.edu (Keith F. Woeltje) Date: Tue, 24 Jul 2001 22:36:13 GMT Subject: Learning Python References: <20010724.144042.1258638252.27706@localhost.localdomain> Message-ID: <3B5DF877.6060606@mail.mcg.edu> Paul, If you're new to programming altogether, Python is a good place to start. Check out Alan Guald's excellent tutorial at: http://www.crosswinds.net/~agauld/ If you'd rather learn from a book (I'm personally addicted to the feel of a book) you can get the printed version at: http://www.amazon.com/exec/obidos/ASIN/0201709384/qid%3D973079752/sr%3D1-2/103-8528605-9386238 If you already know how to program, try: http://diveintopython.org/ from where you can download what is reported to be an excellent introduction (I haven't gotten to that one yet). Other good resources are the books /Learning Python/ by Mark Lutz, /The Quick Python Book/ by Daryl Harms and Kenneth McDonald, and /Core Python Programming/ by Wesley Chun (the most up to date of the three). >K Paul wrote: > I would like to know what sources are available for learning how to > program with python. Any help would be appreciated very much. > > Thanks in advance. > From graham at coms.com Wed Jul 4 03:33:44 2001 From: graham at coms.com (Graham Ashton) Date: Wed, 04 Jul 2001 08:33:44 +0100 Subject: accessing class data members References: <3B420804.9882D166@bioeng.ucsd.edu> Message-ID: In article <3B420804.9882D166 at bioeng.ucsd.edu>, "Curtis Jensen" wrote: > In many OO languages, and theory, it is often the case that when you > want to know the value of some data member, that a function is written > to return that value. However, in Python it seems that people just > access the data member directly. I started a similar thread on 25 June. The subject was "Defining accessor methods". I got some interesting answers... -- Graham From cer at tutopia.com Sat Jul 14 15:11:20 2001 From: cer at tutopia.com (Cristian Echeverria) Date: Sat, 14 Jul 2001 15:11:20 -0400 Subject: ANN: Python News in Spanish - Noticias de Python en Español Message-ID: <9iq577$km4p5$1@ID-44371.news.dfncis.de> ANNOUNCING WEBSITE: Python News in Spanish: This site is similar (I hope) to pythonware Daily Python-URL (http://www.pythonware.com/daily/), but in spanish. ANUNCIANDO SITIO: Noticias de Python en Espa?ol A partir de este momento se encuentra en operaciones este sitio, que pretende mantener informado a todos los de habla hispana respecto de las ?ltimas novedades de Python y sus distintas librer?as. La p?gina principal es http://www.chevenet.com. Esta p?gina pretende ser similar al Daily Python-URL disponible a trav?s de pythonware y de hecho utiliza la misma tecnolog?a de publicaci?n. Desde ya hago el llamado a todos los interesados en cooperar con contenidos a esta p?gina para que se comuniquen a: cristian_echeverria at yahoo.com Adem?s de las noticias tengo la intenci?n de incorporar una secci?n con v?nculos y otra con art?culos tutoriales. Cristian Echeverr?a http://www.chevenet.com From python at lee-morgan.net Mon Jul 30 11:44:56 2001 From: python at lee-morgan.net (Lee Morgan) Date: Mon, 30 Jul 2001 15:44:56 GMT Subject: need help converting .py to an exe for windows References: Message-ID: "Derek S, Smigelski" writes: > I have tried both py2exe and installer. I currently have py2exe installed > now. Here's the scoop. I have python 2.1 installed to c:\python21, and ... > C:\Python21\DSSCRI~1> > > The setup.py file looks like this: > > # setup.py > from distutils.core import setup > import py2exe > > setup(name="txlotto", > scripts=["txlotto.py"], > ) > ||||||||||^ this indentation shouldnt be there if it is Otherwise I cant see anything wrong. Although doesn't py21 come with py2exe as part of the dist utils - and if so have you overwritten with an old package? > C:\Python21\DSSCRI~1> > > > Any Ideas? > > Thanks, > Derek Smigelski > DerekS at mip.com > > -- Lee Morgan From aleaxit at yahoo.com Fri Jul 13 06:15:13 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 13 Jul 2001 12:15:13 +0200 Subject: win32gui References: <9ikvsg$jim2i$1@ID-22517.news.dfncis.de> <9im8rm$k0827$1@ID-59885.news.dfncis.de> Message-ID: <9imhni0pup@enews1.newsguy.com> "Thomas Heller" wrote in message news:9im8rm$k0827$1 at ID-59885.news.dfncis.de... > "Harvest T. Moon" wrote in message news:9ikvsg$jim2i$1 at ID-22517.news.dfncis.de... > > hi :) > > > > is there any tutorial/documentation on how to use the ActiveState Win32GUI > > extension? > > > Not that I know of. The htmlhelp online-docs do nothing more than to list > the functions which are available. > On the other hand, these functions are usually very thin wrappers of > the native win32 apis, which are documented on microsofts site somewhere. A good starting point on the MS site is http://msdn.microsoft.com/library/en-us/win32/hh/portals/win32start_1n6t.asp On this page you will find the links to the GDI, User Interface, and Win32 API overviews and references. When you visit this page it will implicitly redirect you to a frameset that includes a TOC and a small interface search engine on the left (a frame that you can hide and show again) as well as the actual page on the right. Alex From guido at python.org Fri Jul 27 22:37:16 2001 From: guido at python.org (Guido van Rossum) Date: Sat, 28 Jul 2001 02:37:16 GMT Subject: Changing the Division Operator -- PEP 238, rev 1.12 References: Message-ID: cliechti at mails.ch (chris liechti) writes: > there is just one unpleasan't thing left over: > in the transition phase its __div__, __truediv__, __floordiv__ and their > respective 'i' version for arg assignment. this solution allows the object > to "see" what the caller wants for a division type. ok, but.. > > classes would need a change when upgrading from 2.x to 3.x ( __truediv__ > will become the same as __div__ in 3.x but its not with "from __future_ > import division" in 2.x)? what would 3.x do? search for __truediv__ and > then for __div__? that would give wrong results with old modules that only > have a __div__ (emulating the missbehaviour) and no __truediv__. (ok i > don't realy belive in classes emulating some missbehaviour, see next > paragraph) > > wouldn't it be better when only __div__ and __floordiv__ were needed? > classes could not provide the two diffrent meanings of '/' but how many > classes do realy need this? when somebody is implementing his own number > object he will anyway provide a true division, wouldn't he? > this would also *not* introduce a new name that's later unused/merged with > __div__. (remember: one obvious way to do it) I have to think some more about this. Maybe nb_true_divide should look for __truediv__ first and then fall back to __div__. Not so for nb_floor_divide though: it is a new operator. --Guido van Rossum (home page: http://www.python.org/~guido/) From skip at pobox.com Sun Jul 22 13:11:09 2001 From: skip at pobox.com (Skip Montanaro) Date: Sun, 22 Jul 2001 12:11:09 -0500 Subject: PEP0238 lament In-Reply-To: References: Message-ID: <15195.2349.947801.54567@beluga.mojam.com> Guido> The reason for wanting / to return a float (or at least a type Guido> that can represent close approximations of numbers like 0.75) has Guido> been discussed many times before. The summary of the argument in Guido> the PEP may not be complete, but I disagree with Arthur's Guido> assessment that integer division is not a problem -- the VPython Guido> folks have ample experience that it is. Guido, I just reread the PEP at http://python.sourceforge.net/peps/pep-0238.html It looks like it hasn't been updated since March. I see no support for the argument that the current integer division semantics are confusing, only a claim that the current semantics are a problem. Perhaps there's a more recent version of the PEP available that hasn't been released to the website. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From JamesL at Lugoj.Com Tue Jul 24 16:52:05 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Tue, 24 Jul 2001 13:52:05 -0700 Subject: cost of change References: Message-ID: <3B5DDFF5.E94DAC95@Lugoj.Com> Galen Swint wrote: > Has anyone tried to figure out how much changes to Python cost? The way I > figure it, it goes something like this: > 500,000 Python programmers Sounds way too high. At least I don't think that is the correct order of magnitude. > $20/hr A little too low. But at least in the correct order of magnitude. > 3 hrs to port *all* needed code Again, sounds low. But order of magnitude looks correct (i.e. probably under 30 hours _on average_). One has to include testing that provide adequate code coverage. For GUI and many apps this probably can't be automated. > Thats $30 *million*, and all those numbers are surely low -- especially the > time to port. Best one could hope to guess is several million dollars. This assumes most everyone tries to track the language changes. From tjreedy at home.com Sat Jul 21 11:35:29 2001 From: tjreedy at home.com (Terry Reedy) Date: Sat, 21 Jul 2001 15:35:29 GMT Subject: Don't understand this "method mapping" References: <3B598059.42027565@compuserve.com> Message-ID: <5jh67.11826$EP6.3144860@news1.rdc2.pa.home.com> "Bas Michielsen" wrote in message news:3B598059.42027565 at compuserve.com... (Cc'ed) to Bas I am rearranging this message. First the class: > def linear( x_in, a=0): # a=0 is a stub to get past an error condition > print "linear called, a =", a > return x_in > > class Curve: > map = linear > > def use_map( self, x): > print "Using self.map = ", self.map > self.y = self.map( x) > > def set_map( self): > self.map = linear > # Test code (I am running Python 1.5.2) > ## # Output produced by the above I am intermixing these to make things clearer > > c = Curve() > print c.map > ## > c.use_map( 1.0) > ## Using self.map = > ## linear called, a = 1.0 > print c.y > ## <__main__.Curve instance at 80c7380> You apparently said print c, not c.y, which should be 1.0 > c.set_map() > c.use_map( 1.0) > ## Using self.map = > ## linear called, a = 0 > print c.y > ## 1.0 Now the questions: > ## I am a beginner with Python and I don't understand why in the code below > ## the attribute `map' first represents Curve.linear Because you made it so, or look like so. Def always generate a function. When you make a function an attribute of a *class*, it gets wrapped as a method. To do so, either define the function in the class body or assign an externally defined function: does not matter. When you 'print' a function (or method), the definition name (stored with the function) is used, whether or not that definition name is currently bound to the function. Try def f(): pass g = f; del f print g and g will print as f even though there is no longer an f in the module namespace. Of course, since only expects one arg, calling c.map(1.0) would generate an exception when c is added as the first argument. > ## which also points to the external function linear The function was defined externally, but except for *also* having a name in the global dictionary (which you could delete after the class definition), it it no more external than your function set_map. Class.map is a method that wraps function . Class.set_map is a method that wraps function . > ## and then, after calling set_map, > ## is simply the external function linear for a Curve object. set_map() assigns as a *function* attribute map of the *instance* c, which, having the map name, will mask the class attribute map. That is why the difference in the second use_mapp output. > ## I had expected that calling Curve.linear would be signalled as an > ## attribute error because there is no method linear in class Curve Correct. It would if you were to do so directly, by that name, but you never did! > ## or otherwise that the two ways to initialise the map attribute would be > ## equivalent??? As explained above, Curve.map and c.map are different things. They only look alike because you called both indirectly. Try print id(linear), id(Curve.map), id(c.map). Terry J. Reedy From aahz at panix.com Sat Jul 28 15:07:20 2001 From: aahz at panix.com (Aahz Maruch) Date: 28 Jul 2001 12:07:20 -0700 Subject: Threading in Python References: Message-ID: <9jv2h8$fo1$1@panix2.panix.com> In article , Andy wrote: > >There seems to be a lot of (arguably) radical changes going on in the >Python syntax/grammar/language, perhaps the direction should be towards >improving the internals first? > >One thing Java has which Python lacks is transparent support for >multi-cpu threading. Python has threads, but I believe it is >internally implemented and has been shown not to take advantage of an >SMP machine. That's about half-true. For more information, see http://starship.python.net/crew/aahz/ (New & Improved slideshow coming Real Soon Now (a couple or three days)) -- --- 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 Fortune cookie: Watch your relations with other people carefully, be reserved. From aahz at panix.com Tue Jul 3 10:25:21 2001 From: aahz at panix.com (Aahz Maruch) Date: 3 Jul 2001 07:25:21 -0700 Subject: Decimal (was Re: Comment on PEP-0238) References: <3B3BE855.A6223E70@3-cities.com> Message-ID: <9hskkh$5ce$1@panix2.panix.com> In article , Terry Reedy wrote: > >I believe something like this is part of the IBM decimal arithmetic >proposal/project. > >1.0/3 = .3, 1.00/3 = .33, etc (in which case, 1/3 = 0 by the same rule) That is incorrect. The decimal arithmetic standard uses something called a "context" to provide the information that an operation needs. Among other things, the context specifies the precision, and unless you explicitly change the context between operations, all three of the examples you list above will provide the same result. -- --- 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'm not tense, i'm just terribly, terribly alert" --unknown From peter at engcorp.com Mon Jul 16 12:25:37 2001 From: peter at engcorp.com (Peter Hansen) Date: Mon, 16 Jul 2001 12:25:37 -0400 Subject: Language change and code breaks References: <6957F6A694B49A4096F7CFD0D900042F27DB98@admin56.narex.com> Message-ID: <3B531581.1E7FFFF@engcorp.com> Bjorn Pettersen wrote: > > > From: Peter Hansen [mailto:peter at engcorp.com] > > Nevertheless, I want to make the clear point (if I haven't already) > > that I'm not suggesting screwing every such programmer... just > > those who are actively using code which would be broken, who will > > not take the time (however small we might make it) to modify the > > source, and yet who "must" have their code work under the new Python. > > > > Are there really any people like that? Enough to make it > > a key factor? I'm not sure I can even think of any realistic > > cases where anyone like that exists (he said, trolling for > > someone to point out an obvious example or two). > > Well, I for one wrote several thousands of lines of Python code in my > last job, and I obviously have no influence on when they're going to > upgrade to a newer version of Python. You can probably safely assume > that they're not going to put a programmer on fixing programs that are > running without any problems. More likely they would upgrade Python, > realize that "a bunch" of Python scripts stopped working, and either > roll back the Python upgrade, rewrite them in Perl/Java, or find someone > with enough Python skills to fix the problems. Neither solution would be > good PR for Python... I agree it wouldn't be good PR for Python, but presumably neither is having division which doesn't behave as newcomers expect. We're trying to choose the lesser of two evils. Anyway, if your previous employer upgrades Python for no good reason and without checking the Change History where they will see all the warnings in BIG PRINT about how existing code might break and that they should run "divscan.py" to see if their code is safe or not, how can we protect them against themselves? I'm trying to point out that this kind of hypothetical example, where some group might upgrade (but not be aware of this issue even after lengthy publicity during the transition period) even though they will not actively maintain their code, is not likely, or not worth worrying about for long. And that's where the contingency plans come into play: we've provided adequate notice, tools, etc., and yet somebody chose to ignore us and got punished. Big deal. -Peter Hansen From bokr at accessone.com Fri Jul 27 17:06:19 2001 From: bokr at accessone.com (Bengt Richter) Date: Fri, 27 Jul 2001 21:06:19 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <9jnt9p$qhe$1@newsy.ifm.liu.se> <024c01c1162f$5e7b56e0$6501a8c0@pacbell.net> Message-ID: <3b61d4ae.580834796@wa.news.verio.net> On Fri, 27 Jul 2001 08:54:13 -0400, Guido van Rossum wrote: [...] >Assuming we'll adopt a variation of Scheme's numerical tower (which >I'm currently in favor of, more or less), this won't happen. Floats >and complex would always be considered inexact (and ints and rationals >exact), and inexact numbers are not allowed as sequence indices, even >if their exact value is an integer. > Why would complex have to be inexact if both its real and imaginary parts were exact? This looks exact, but will it be? >>> (1+2j)**2 (-3+4j) From philh at comuno.freeserve.co.uk Thu Jul 12 19:26:05 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Fri, 13 Jul 2001 00:26:05 +0100 Subject: Version incomptabilities, code changes, __future__, etc References: Message-ID: On Thu, 12 Jul 2001 13:41:31 -0400, Steve Holden wrote: >> > Unfortunately, Python is now released on a more restrictive >> > liscense, which, in a future version, will require all Python >> > programs to contact a Microsoft Certification server and >> > present a Passport certification before executing. In order to >> > ensure that everyone migrates to the new version of the software >> > (to be released as soon as Microsoft finishes building the >> > infrastructure), the migration will be mandatory. >> >> This "bon mot" needs more clarification. This implies that Python will >> only be available to the Windows community. There are environments where >> Microsoft Certification servers will never exist. If there will now be >> a component added to Python to only allow its use when authorized by a >> Microsoft Certification server, then one may need to change or develop a >> new solution set. >> >> I'm not particularly opposed to forking off a "Python for Microsoft >> Windows Environments" or a "Python for Microsoft Certification Server >> Environments" as long as there remains a Python for other communities of >> interest. If the latter is not going to occur, then I need to reconsider >> whether or not Python is part of a viable solution. >> >That's OK. I'm working on a Python-to-Perl translator. That sounds cool. What language is your translator written in -- I hear that bash has some really cool lexical analysis / parsing libraries, so i suggest you use that to write the translater. If you also need a run-time interpreter for the Perl bytecode, I suggest you use JavaScript -- for example the user could just cut-and-paste the bytecodes into a web form and click a button to run the output. This would be cross=platform too, you could use the Netscape Javascript on Unix and the IE Javascript on Windows. Good luck. -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From hnowak at cuci.nl Wed Jul 25 08:40:32 2001 From: hnowak at cuci.nl (Hans Nowak) Date: Wed, 25 Jul 2001 14:40:32 +0200 Subject: Methods of setting class attributes Message-ID: <3B703988@twigger.nl> >===== Original Message From Piotr Legiecki ===== >hnowak wrote: >> Assuming you just want the default behavior to set attributes in a class and >> get going, this is a common idiom: >> >> class Foo: >> def __init__(self, x): >> self.x = x >> self.y = "blah" >> > >Yes. That is assigning in constructor. But what to do if I want to make >an assignment after the object is created? Thats normal during object >life. Simply object.attrib=something, etc? I know it works, but I'm not >sure if it is in python style. Yes, it's the normal way to do it: foo = Foo() foo.x = 37 # etc... >> Python is much more dynamic than C++ and attributes of a class or instance can >> be set or deleted at will. > >Right! I'v noticed that and it is not easy to adopt. What about class >interface? There is simply none in python, because I can change it at >any time. Strange. Other people missed this feature too. I think proposals for an interface mechanism were discussed in the Type-SIG some time ago. Also, there's a PEP you might be interested in: http://python.sourceforge.net/peps/pep-0245.html Regards, --Hans Nowak From thomas at xs4all.net Sat Jul 7 05:38:35 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Sat, 7 Jul 2001 11:38:35 +0200 Subject: lvalues and the lgb rule In-Reply-To: <8Gt17.7112$PF2.1324057@news1.rdc1.md.home.com> References: <8Gt17.7112$PF2.1324057@news1.rdc1.md.home.com> Message-ID: <20010707113835.H8098@xs4all.nl> On Sat, Jul 07, 2001 at 01:33:56AM +0000, Eric Hagemann wrote: > > Not dynamic. Just look at the code in an editor: if a name is bound > > anywhere within a code block, and isn't declared in a "global" stmt, then > > that name is local throughout the entire code block. > Is this true ? Yes. > Given a file with the following > print x > x=1 > print x > The first print will fail with a 'NameError'. It was my (perhaps) wrong > impression > that x "came into being" at the assignment (x=1) Yes and no. If you execute the above snippet at the top level (not inside a function) you'll get a NameError because the name doesn't exist yet. This is because you are evaluating in the 'global' namespace, and it is handled slightly differently from the local namespace inside a function. If you write the above as part of a function, say, def spam(): print x x = 1 print x spam() You'll also get a NameError under 1.5.2, but a more appropriate UnboundLocalError in newer versions of Python. The reason of the error is the same in both cases, but the exact exception raised was changed to make the difference between the first example and the second more obvious. (UnboundLocalError is a subclass of NameError, so catching NameError will still work for both cases.) > I would think the variable is local to the code block once the assignement > has been executed No, it's local once the compiler sees an assignment statement for the variable inside the code block. But because the global (module) namespace is a global one as well as a local one, it behaves slightly differently there. What happens is that the global namespace is a straight dictionary, where assignment is a 'setitem', lookup is a 'getitem', and 'del' is a 'delitem'. The local namespace inside a function is actually stored (in absence of 'exec' or 'import *') as a vector (list) and the names of all local variables are translated into indexes. At runtime the interpreter will try to retrieve the X'th element of the vector and notice it's empty (a NULL value), raising the UnboundLocalError. A 'del' statement also empties the element. Just look at the LOAD_FAST opcode in Python/ceval.c in the source distribution :) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From bh at intevation.de Mon Jul 16 10:39:34 2001 From: bh at intevation.de (Bernhard Herzog) Date: 16 Jul 2001 16:39:34 +0200 Subject: Most efficient solution? References: Message-ID: <6qae252b15.fsf@abnoba.intevation.de> alf at leo.logilab.fr (Alexandre Fayolle) writes: > On Mon, 16 Jul 2001 09:19:09 -0400, Jay Parlar wrote: > >List B consists of my "stopwords", meaning, the words I don't want included in my final version of list A. So what I need to > >do is check every item in list A, and if it occurs in list B, then I want to remove it from the final version of A. My first thought > >would be: > > > >for eachItem in A: > > if eachItem in B: > > A.remove(eachItem) > > > > You may get some speedup by making B a dictionary, and using has_key() to > see if the word is there. This should get you a O(log(n)) instead of O(n) > inside the loop. To gain further performance, use filter to skim A. > > C = {} > for item in B: > C[item]=None > > A = filter(lambda e, dic = C: dic.has_key(e), A) A bit more elegant, perhaps, and a little faster still would be to use 1 as the value in C and directly use C.get in filter: C = {} for item in B: C[item] = 1 A = filter(C.get, A) -- Intevation GmbH http://intevation.de/ Sketch http://sketch.sourceforge.net/ MapIt! http://mapit.de/ From michael at stroeder.com Thu Jul 5 14:21:37 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Thu, 05 Jul 2001 20:21:37 +0200 Subject: There's got to be an easy way to do this References: <9i27i8$gd9bq$1@ID-11957.news.dfncis.de> Message-ID: <3B44B031.819C93E@stroeder.com> Emile van Sebille wrote: > Or (without re): > print "".join([x for x in '(123)/456-7890' if x in '0123456789']) I guess this one will be significantly slower for larger data sets than the re solution because of if x in '0123456789' Ciao, Michael. From robin at jessikat.fsnet.co.uk Thu Jul 26 19:12:55 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 27 Jul 2001 00:12:55 +0100 Subject: Deposing Dictators References: <9jmjne$q54$1@wisteria.csv.warwick.ac.uk> <3b602daf.1623450@nntp.sprynet.com> Message-ID: In article , Gareth McCaughan writes .... >More: to be benevolent is to *try* to act in a way >consistent with the person's best interests[1], even >if in fact you're wrong. So even if Guido is as >horribly wrong as some people here say he is about >what their best interests are, that's no reason to >think he isn't benevolent. ... We all know lightning is God's way of telling us to shut up. Of course God is benevolent no matter how appalling the universe gets. The opposite of benevolent is malevolent. When our quick-sorts go wrong it will be as a result of a benevolent act by a caring designer. -- Robin Becker From thomas.heller at ion-tof.com Sat Jul 14 14:58:17 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Sat, 14 Jul 2001 20:58:17 +0200 Subject: Importing XML modules in py2exe or Installer? References: Message-ID: <9iq4oc$kme5j$1@ID-59885.news.dfncis.de> > Have completed a fairly large project where I, among other modules, use the > Python XML package from the XML SIG. Now I want to make a DOS binary to > distribute it as a standalone application for Windows users. > > Neither py2exe nor Installer is able to find the XML modules by themselves, > and I haven't been able to figure out how to include them. For example, > when running the EXE that Installer creates, I get the following message: > > Traceback (most recent call last): > File "", line 7, in ? > File "E:\pyinst\support\imputil.py", line 117, in _import_hook > return importer._finish_import(top_module, parts[1:], fromlist) > File "E:\pyinst\support\imputil.py", line 206, in _finish_import > bottom = self._load_tail(top, parts) > File "E:\pyinst\support\imputil.py", line 292, in _load_tail > m = self._import_one(m, part, fqname) > File "E:\pyinst\support\imputil.py", line 252, in _import_one > module = self._process_result(result, fqname) > File "E:\pyinst\support\imputil.py", line 281, in _process_result > exec code in module.__dict__ > File "e:\python\lib\xml\dom\minidom.py", line 21, in ? > from xml.dom import HierarchyRequestErr > File "E:\pyinst\support\imputil.py", line 117, in _import_hook > return importer._finish_import(top_module, parts[1:], fromlist) > File "E:\pyinst\support\imputil.py", line 206, in _finish_import > bottom = self._load_tail(top, parts) > File "E:\pyinst\support\imputil.py", line 294, in _load_tail > raise ImportError, "No module named " + fqname > ImportError: No module named _xmlplus.dom > > The XML modules reside at e:\python\_xmlplus in this computer. I have tried > the respective include options, but don't know if I do it right: > > python e:\pyinst\builder.py myscript.cfg --includes e:\python\_xmlplus > The correct py2exe command line would be (assuming your script is named setup.py): 'python setup.py py2exe -p _xmlplus' to include the whole _xmlplus package. Hope this helps, Thomas From duncan at NOSPAMrcp.co.uk Wed Jul 25 10:26:37 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Wed, 25 Jul 2001 14:26:37 +0000 (UTC) Subject: PEP0238 lament References: <5sdnlt072hm6hp17nluu6f0fqq4bvr6mj8@4ax.com> <916olt0p3kciv0evmotdg6jev9bl29l57i@4ax.com> <3B5C52EA.9430255E@alcyone.com> Message-ID: Guido van Rossum wrote in news:cpofqaova7.fsf at cj20424- a.reston1.va.home.com: > If you agree that, if it weren't for breaking old code, PEP-238 would > make Python a better language, what can we do about that old code? > I agree that it would make Python a different language. Neither better nor worse. You arguably gain in meeting some peoples expectations of the division operator, but you lose consistency in that previously (as far I can think), the operators +, -, *, /, % when given two arguments of the same numeric type always return a result of that same type. In future we have to be prepared to explain to beginners that division can give a result of a different type: in fact you cannot even predict the type of the result when you know the types of the arguments, you have to know their values as well. -- 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 oliphant at ee.byu.edu Mon Jul 23 16:37:06 2001 From: oliphant at ee.byu.edu (Travis Oliphant) Date: Mon, 23 Jul 2001 14:37:06 -0600 Subject: Language change and code breaks In-Reply-To: References: <9j7gv8$9mg@dispatch.concentric.net> Message-ID: > > As a member of this group, who is especially fond of Python for how > > easy it is to pick up where I left off days or weeks before, I would > > very much prefer a case *insensitive* language with tools that > > enforce *uniform* case usage. > > And that's of course what I have in mind. > > > Nobody wants to see fOo and FOO and foo with the same meaning, but > > nobody wants to see foo and FOO and foo at all in the same program > > with distinct meanings. I also don't think the cutesy c=C() makes > > for readable code -- at least for this sometime programmer. I'll just chime in to say that as one who uses Python for science/engineering, I would be very unhappy not to be able to define the variables h and H to mean two different things. Engineers often uses case to distinguish between the function and it's Fourier transform for example. But, this has been brought up before... -Travis Oliphant From nospam at nospam Thu Jul 12 11:05:59 2001 From: nospam at nospam (Rufus V. Smith) Date: Thu, 12 Jul 2001 11:05:59 -0400 Subject: Long Live Python! References: <9ijpfk02a67@enews4.newsguy.com> Message-ID: <3b4dd783$0$2149@wodc7nh6.news.uu.net> "Alex Martelli" wrote in message news:9ijpfk02a67 at enews4.newsguy.com... > My proposed solution relied on the fileinput module's "in-place" > behavior (WITH a backup, but that's optional I guess:-). That > module nicely wraps whatever concerns may need to be wrapped, AND > works on as many files as you desire. > > def allbutfirst(files): > for line in fileinput.input(files,inplace=1,backup='.bak'): > if fileinput.filelineno()>1: print line, > I'm a definite Newbie, but to me this looks like it outputs the result to stdout, rather than creating a new file with the first line removed, which is what I thought the goal was. From mac4-devnull at theory.org Fri Jul 6 22:40:45 2001 From: mac4-devnull at theory.org (Neil Macneale) Date: Fri, 06 Jul 2001 19:40:45 -0700 Subject: I'm Sure There's A Better Way References: <3B465858.CB7F38E8@tundraware.com> Message-ID: <3b4676ad$0$324$8eec23a@newsreader.tycho.net> Note: this sollution requires 2 characters after the decimal point.... def isDollarAmount(s): try: if s.count == 1 and s[-3] == '.': dol, cen = s.split('.') int(dol) int(cen) return 1 int(s) return 1 except: return None The idea is that if the int function can't convert to a number, then the string is no good. Hope that helps, Neil Macneale In article <3B465858.CB7F38E8 at tundraware.com>, "Tim Daneliuk" wrote: > I want a function to check a string to make sure it is a legitimate > dollar amount. Which means it follows these rules: > > First character is numeric or "-" > At most, one "." is allowed and, if present, is followed by exactly two > digits All the remaining characters must be in the range "0" - "9" > > > I wrote the attached to check a string for these rules, but I can't help > wondering if my feeble newbie python coding isn't already better done > elswhere and/or using existing logic. Any ideas all? TIA.... Code > follows - > > > > # Check and see if passed string is a legit amount > > def IsNum(num): > if num == "": > return FALSE > digits = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "."] z = > num.split(".") > if len(z) > 2: # At Most, only once decimal permitted. > return FALSE > if len(z) == 2: > if len(z[1]) != 2: # Exactly two digits must follow decimal > return FALSE > if (num[0] == '-') and (len(num) > 1): # 1st char can be sign if > more chars follow > num = num[1:] # Drop sign for purposes of checking > for x in num: # Make sure all chars are legit digits > if not digits.count(x): > return FALSE > return TRUE > -- -- To reply to me via email, remove the '-devnull' from my address. From chris.gonnerman at newcenturycomputers.net Sun Jul 8 09:42:51 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Sun, 8 Jul 2001 08:42:51 -0500 Subject: [Fwd: Comment on PEP-0238] References: <3B474536.DE27A538@3-cities.com> <200107071818.f67II2g18846@odiug.digicool.com> Message-ID: <000f01c107b3$e7115de0$0101010a@local> ----- Original Message ----- From: "Guido van Rossum" > "Chris Gonnerman" writes: > > > Perhaps it's too inconsistent, but I see no reason why longs can't > > continue returning "normal" results forever. When you use a long > > you know what you are doing, or at least think you do; so you should > > expect integer division results just as always. > > Well, but there's another proposal (that taken by itself would have > few detractors) to blur the distinction between int and long. This > would do away with the whole OverflowError problem: int calculations > whose result doesn't fit in an int would simply and silently return a > long instead. I remember that; I'd forgotten about that PEP. > This is PEP 237. I don't expect that this will be added to Python 2.2 > because there are lots of little details that need to be taken care > of, and backwards incompatibilities (e.g. 1<<100 currently yields 0, > but 1L<<100 is the same as 2L**100). > > But given that that is likely to be the way of the future, it seems > best to treat int and long division the same way. > > > What does it buy us to break longs as well as ints? > > > > Overall I am in favor of *eventually* automatically promoting ints to float > > when division is attempted, and likewise converting longs to floats when > > dividing one by the other, but I really think we gain nothing by changing > > the semantics of division of longs. > > This is inconsistent. You are saying that you think we gain nothing > from something (long division) that you want to change anyway. No, I specifically don't want to change division of long by long; that's what I'm saying. "Promotion" of long to float when one of each is in the operation is different. > > I would also say that, when longs and ints are divided together, you should > > probably promote the int to a long rather than performing float division. > > You're thinking of it the wrong way. The operands are first converted > to the same type according to specific rules; then that type is asked > to perform the operation. So what you are requesting here is already > decided, by the existing rule that says that in "int/long", the int is > converted to long before the operation takes place. Ah, so. > > I really don't think a newbie will appreciate > > > > >>> 1 / 2 > > Traceback (most recent call last): > > File "", line 1, in ? > > IntDivisionError: integer division is invalid > > > > any more than they currently understand > > > > >>> 1 / 2 > > 0 > > Good point. So we should switch directly from 1/2 -> 0 to 1/2 -> > 0.5. But it's unavoidable that they will get a warning in some > versions... e.g. > > >>> 1 / 2 > __main__:1: DeprecationWarning: integer division semantics will change; > use x div y to force integer result or float(x)/y to force float result > 0 > >>> So the final operator for int division will be 'div'? Seems fine to me. From juergen.erhard at gmx.net Sat Jul 28 02:12:07 2001 From: juergen.erhard at gmx.net (=?ISO-8859-1?Q?=22J=FCrgen_A=2E_Erhard=22?=) Date: Sat, 28 Jul 2001 08:12:07 +0200 Subject: Deposing Dictators In-Reply-To: References: <9jmjne$q54$1@wisteria.csv.warwick.ac.uk> <3b602daf.1623450@nntp.sprynet.com> Message-ID: <28072001.1@wanderer.local.jae.dyndns.org> >>>>> "Gareth" == Gareth McCaughan writes: >>>>> "David" == David Ullrich writes: >>>>> "X" == anonymous being writes: X>2) The level of dissent required to change the opinion of the X>BDFL perhaps calls into question the 'B'. David> Nonsense. Without saying anything about who's right and David> who's wrong, or about whether the D is B or not: To be David> "benevolent" towards someone is to act in a way consistent David> with that person's best interests. This is not the same David> thing as giving the person what he asks for, not by a long David> shot. Gareth> More: to be benevolent is to *try* to act in a way Gareth> consistent with the person's best interests[1], even Gareth> if in fact you're wrong. So even if Guido is as Gareth> horribly wrong as some people here say he is about Gareth> what their best interests are, that's no reason to Gareth> think he isn't benevolent. dict benevolent was a very interesting read indeed. Thanks for the (kinda, sorta) hint. David> Why in the world should "level of dissent" have any bearing on David> anything? Deciding moral issues by taking a vote is one thing - David> deciding what's best on a technical issue by taking a vote is David> silly. Gareth> Hear hear. Shouldn't that be "Here here"? Gareth> [1] I initially typed "integers". Hmm. Hmm indeed :-) Bye, J -- J?rgen A. Erhard (juergen.erhard at gmx.net, jae at users.sourceforge.net) My WebHome: http://members.tripod.com/Juergen_Erhard Internet Movie Database (http://www.imdb.com) Shah, shah! Ayatollah you so! -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 248 bytes Desc: not available URL: From paulp at ActiveState.com Mon Jul 9 01:07:35 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sun, 08 Jul 2001 22:07:35 -0700 Subject: Help With map() *He says while pulling his hair out* References: Message-ID: <3B493C17.17F61B9C@ActiveState.com> EricIDLE wrote: > > Ok first off I have a wee problem with one of the examples in my book it is > as follows: > > s="12.19.6.7.12" > ls = string.split(s, '.') > md = map(string.atoi, ls) > > Ok. well the problem is basically the whole thing. I know s="12.19.6.7.12" > is just defining the varible 's' with the numbers. It is defining a variable "s" as a *string*. Python doesn't know or care that the string happens to have things that look like numbers to you or me. It is just a bunch of characters. > But my first problem is > after string.split in its argument I know what the S means but I dont know > what the '.' means does that mean to remove all the periods? No. It means to split on the periods and return a *list of strings*. Here's what Python's manual says: split(s[, sep[, maxsplit]]) Return a list of the words of the string s. If the optional second argument sep is absent or None, the words are separated by arbitrary strings of whitespace characters (space, tab, newline, return, formfeed). If the second argument sep is present and not None, it specifies a string to be used as the word separator. The returned list will then have one more item than the number of non-overlapping occurrences of the separator in the string. The optional third argument maxsplit defaults to 0. If it is nonzero, at most maxsplit number of splits occur, and the remainder of the string is returned as the final element of the list (thus, the list will have at most maxsplit+1 elements). > The second problem is that I dont quite grasp the map() function what > exactly does it do, In its argument it says in lamens terms "Turn the string > ls into intergers" my problems is wasent it always intergers? No. It was strings. This is a string "12". This is an integer: 12. Play around a little on the Python command line: >>> 12 12 >>> "12" '12' >>> type(12) >>> type("12") >>> import string >>> string.atoi("12") 12 >>> string.atoi(12) Traceback (most recent call last): File "", line 1, in ? File "string.py", line 214, in atoi return _int(s, base) TypeError: ... -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From skip at pobox.com Thu Jul 26 19:09:13 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 26 Jul 2001 18:09:13 -0500 Subject: interpreter improvements In-Reply-To: References: <5e8bd451.0107190224.7171e61@posting.google.com> Message-ID: <15200.41753.228480.566138@beluga.mojam.com> Quinn> You don't have to know the language to cut and paste and edit Quinn> blocks, you just need a mouse and a terminal which doesn't think Quinn> it's still a teletype. My "other observation" above was taking Quinn> the position that readline is the wrong solution. I don't use Quinn> readline if I can avoid it, and happily cut and paste and edit Quinn> blocks in the top level, and then cut and paste them right into Quinn> the editor, or the other way around. If you're sitting at the interpreter prompt where do you cut-n-paste to with your mouse? If I entered this at the prompt: for i in range(10): ... line 1 ... ... line 2 ... ... line 3 ... ... line 4 ... ... line 5 ... x = math.sin(y) only to have the interpreter tell me I forgot to "import math", it would be nice to execute the import, then with two Ctl-P keystrokes back up into the for loop and have the whole block pop into a mini-editor to be reexecuted upon exit. I believe this is what IDLE is supposed to do. No prompt fiddling required. Quinn> It does require turning off the '>>> ' and '... ' prompts (which Quinn> python won't let you do without hacking pythonrun.c (I think) Quinn> which I think is a bug), but it's my opinion that this is the Quinn> correct behaviour anyway (no prompt). No need to hack pythonrun.c, just set sys.ps1 and sys.ps2 to empty strings. Of course, with smart history retrieval you wouldn't need to do that. Quinn> It's also convenient for return values to be printed like Quinn> 2 + 2 Quinn> #-> 4 Quinn> since that doesn't mess up a cut and paste and is easily filtered Quinn> out. That's an interesting enhancement but doesn't help with the ps1/ps2 thing. They do offer nice feedback to the user about what's expected, so for most situations users won't turn them off before they make a mistake that needs to be repaired. Quinn> I greatly prefer not building special language-awareness into a Quinn> mechanism, because then it can work in a simple and uniform Quinn> manner for every application and language that involves text, as Quinn> opposed to having an ad-hoc intrusive only-works-on-one-editor Quinn> complicated and hard to get right mechanism. Neither solution is ideal, but if you want language awareness you need to either build it into the interpreter or build some configurable layer on top of something like readline that you can customize via a config file, in much the same way that you can train emacs about syntax highlighting. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From ransen_spam_me_not at nemo.it Tue Jul 24 10:49:35 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Tue, 24 Jul 2001 14:49:35 GMT Subject: control-C not responding, short example program Message-ID: <3b5d7220.664033@news.newsguy.com> If you put this in a module and test it: def ForLoopTest (NumLoops) : for Year in range (1,NumLoops) : for Century in range (1,NumLoops) : Months = Year*12 you'll find that ForLoopTest (10000) will apparently halt 500Mhz Windows 98 machine. It simply does not respond to control-C. Is there a way of doing this or do I just have to live with it? -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From guido at python.org Thu Jul 19 08:57:07 2001 From: guido at python.org (Guido van Rossum) Date: Thu, 19 Jul 2001 12:57:07 GMT Subject: RELEASED: Python 2.2a1 References: Message-ID: gerhard.nospam at bigfoot.de (Gerhard H?ring) writes: > Btw. is there a description of what the various CVS branches mean? > Most of the names are pretty obvious, like "release21-maint", but > others aren't. This should only be relevant to a handful of developers. > If such a page doesn't exist, I think it would be a good idea to > write a short dscription for each branch and put it in "Python @ > Sourceforge FAQ". Yes, why don't you write it. I'm tired. :-) --Guido van Rossum (home page: http://www.python.org/~guido/) From jschmitt at vmlabs.com Fri Jul 27 14:27:57 2001 From: jschmitt at vmlabs.com (John Schmitt) Date: Fri, 27 Jul 2001 11:27:57 -0700 Subject: 2.2 features Message-ID: <4197FA5DD22AD5118ADE00805F6FA62F3B67D0@eden.vmlabs.com> Why do we have to wait for 2.2? You can do this already. PythonWin 2.1 (#15, Apr 19 2001, 10:28:27) [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 types >>> types.IntType >>> assert isinstance(0,types.IntType) >>> assert isinstance([],types.IntType) Traceback (most recent call last): File "", line 1, in ? AssertionError >>> > -----Original Message----- > From: Guido van Rossum [mailto:guido at python.org] > Sent: Thursday, July 26, 2001 7:10 AM > To: python-list at python.org > Subject: Re: 2.2 features > > > "Nick Perkins" writes: > > > Here's a nice little use of type/class unification: > > > > instead of using: > > if type(x) is type(0): > > > > we can use: > > if type(x) is int: > > > > or, for type checking.. > > > > assert type(num) is int > > assert type(msg) is str > > > > ( I assume the use of 'is', rather than '==', is acceptable here ) > > Yes, 'is' is right. But you should never use this; instead, you > should use > > assert isinstance(num, int) > assert isinstance(msg, str) > > --Guido van Rossum (home page: http://www.python.org/~guido/) > -- > http://mail.python.org/mailman/listinfo/python-list > From greg at cosc.canterbury.ac.nz Thu Jul 19 23:21:06 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 20 Jul 2001 15:21:06 +1200 Subject: Case insensitivity References: Message-ID: <3B57A3A2.669737DE@cosc.canterbury.ac.nz> Guido van Rossum wrote: > > I apologize for my poor English -- I don't know what you mean by "an > affection" or "an affect". I think he meant "affectation", about which www.wordsmyth.net has this to say: Pronunciation ae fihk te shEn Definition 1. falseness or superficiality of appearance or behavior; pretense. Synonyms pretense (3) , artificiality {artificial (3)} , affectedness {affected (2)} , pretentiousness {pretentious (1)} Crossref. Syn. show , mannerism , air Similar Words sham , show , unnaturalness {unnatural} , posturing {posture (vi)} Definition 2. a specific instance of such pretense. Synonyms mannerism (2) , airs (5) , pose1 (2) , show (4) Crossref. Syn. act Similar Words imposture Related Words camp , pomp , cant , pretense , claptrap -- 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 guido at digicool.com Sat Jul 14 21:26:43 2001 From: guido at digicool.com (Guido van Rossum) Date: Sat, 14 Jul 2001 21:26:43 -0400 Subject: [Python-Dev] Re: PEP: Defining Unicode Literal Encodings (revision 1.1) In-Reply-To: Your message of "Sat, 14 Jul 2001 15:04:47 PDT." <3B50C1FF.7E73739B@ActiveState.com> References: <3B50C1FF.7E73739B@ActiveState.com> Message-ID: <200107150126.VAA23781@cj20424-a.reston1.va.home.com> Explain again why a directive is better than a specially marked comment, when your main goal seems to be to make it easy for non-parsing tools like editors to find it? --Guido van Rossum (home page: http://www.python.org/~guido/) From quinn at yak.ugcs.caltech.edu Thu Jul 19 14:59:46 2001 From: quinn at yak.ugcs.caltech.edu (Quinn Dunkan) Date: 19 Jul 2001 18:59:46 GMT Subject: problem with gzip files References: Message-ID: On Fri, 20 Jul 2001 03:19:42 +1000, Dave Harrison wrote: >Traceback (most recent call last): > File "./zipreader.py", line 3, in ? > import gzip, os > File "/usr/local/lib/python2.1/gzip.py", line 9, in ? > import zlib >ImportError: No module named zlib > >I then tried installed the zlib library, which went fine. Except it hasn't >solved my problem. > >Is there something simple I am missing here ? Any advice ? You probably installed the C zlib library (called libz, confusingly). You still don't have the python zlib module. If you're using 2.0 or newer, you should be able to recompile and setup.py will pick it up automatically and make you a zlib module. Otherwise, edit Modules/Setup. From root at rainerdeyke.com Tue Jul 24 11:24:37 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Tue, 24 Jul 2001 15:24:37 GMT Subject: A use for integer quotients References: <3B5BC73B.2D52E5E2@alcyone.com> <3B5BA29B.E08FEEE9@alcyone.com> Message-ID: "Paul Foley" wrote in message news:m2wv4yhm6v.fsf at mycroft.actrix.gen.nz... > If you want integers, write floor(a,b) [or floor(a/b)], since that's > what you really mean. That would be incorrect though. When I write "a / b", I mean "the largest integer 'c' such that c * b <= a". I don't mean "some approximation loosely resembling a / b", which floating point calculations give me. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From shalehperry at home.com Mon Jul 23 12:40:34 2001 From: shalehperry at home.com (Sean 'Shaleh' Perry) Date: Mon, 23 Jul 2001 09:40:34 -0700 (PDT) Subject: Blender module In-Reply-To: Message-ID: On 23-Jul-2001 Justyna Bia?a wrote: > > Hi, > I need to know how to use the new module for writing scripts in python for > Blender. > > I mean the newest version of Blender (2.14) and actually I have no > documentation to that. > Most scripts I found is written in the old API. > If anybody is familiar with that stuff, please, let me know or maybe you can > send any examples of using that module. > docs can be found on http://www.blender.nl. Tutorials, API, etc. From peter at engcorp.com Fri Jul 27 21:24:19 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 27 Jul 2001 21:24:19 -0400 Subject: a break for comprehensions References: <9jpadd$s5k$1@news.duke.edu> <3B60A053.75938301@engcorp.com> <9jqnlr$flb$1@news.duke.edu> <3B60E96C.2A99AD87@engcorp.com> <3B61B037.3070704@nospiced.ham.devis.com> Message-ID: <3B621443.E657DE94@engcorp.com> Tom Jenkins wrote: > > >>>>>>"PH" == Peter Hansen writes: > > PH> In my post I was attempting to point out that I find list > > PH> comprehensions less readable than the equivalent, longer but > > PH> more explicit while loop version, not that one list comprehension > > PH> is more or less cryptic than another. [...] > I couldn't read list comprehensions until I actually started playing > around with them. After experimenting and writing (oh about 3 or 4) I > discovered I could read them ;) These responses are good to hear. I'm happy to know that after only 5 or 6 experiments (I'm a little slower than you guys :-), I'll find list comprehensions less cryptic and much more readable. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From sholden at holdenweb.com Mon Jul 9 08:20:40 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 9 Jul 2001 08:20:40 -0400 Subject: Bug in rfc822 References: Message-ID: <2ih27.49242$he.3402812@e420r-atl1.usenetserver.com> "Fredrik Lundh" wrote ... > phil hunt wrote: > > I have just found out that rfc822.py doesn't conform to > > RFC2822. > > sounds like it's time to rename that module ;-) > It would be even better to rewrite it. rfc822 builds so many lists of characters which are later returned as strings by joining the lists, a good C optimization would yield huge performance benefits. Pity I'm not better at C. regards Steve -- http://www.holdenweb.com/ From dalke at acm.org Tue Jul 31 07:50:38 2001 From: dalke at acm.org (Andrew Dalke) Date: Tue, 31 Jul 2001 12:50:38 +0100 Subject: FEEDBACK WANTED: Type/class unification References: <3B643C58.1C6C94F9@ActiveState.com> <20010729170054.141$Pa@newsreader.com> Message-ID: <9k6uoa$3sv$1@slb7.atl.mindspring.net> Hernan M. Foffani wrote: > One minor suggestion: > I think it would help if you set a convention for the name > of the first argument in classmethods. Like self for standard > methods. Well, even self can "work" here, too. Guido: >I think 'self' would be confusing. I'd like to propose 'cls'. What's wrong with 'klass'? Other than that it looks either like a typo or like German. Several of the standard libraries use 'klass' when refering to a class and I've seen code outside the std. library using 'klass' as well. Whereas 'cls' is less frequently used in the std. library to hold a class, but I've not seen external uses of that name for that purpose elsewhere. To me, 'cls' means "clear screen" despite the fact I haven't worked in DOS for almost 10 years :) Also, "klass" has an obvious pronounciation, and "cls" can be used as a list of "cl"s. Andrew dalke at dalkescientific.com From carlf at panix.com Tue Jul 3 16:48:34 2001 From: carlf at panix.com (Carl Fink) Date: 3 Jul 2001 20:48:34 GMT Subject: Hiding Console? References: <9ht9to$fei$1@neptunium.btinternet.com> Message-ID: In article <9ht9to$fei$1 at neptunium.btinternet.com>, G. Willoughby wrote: > Is there a way in your script to include a command that when run on a > WinME/32 platform the console does not appear? such as the IDLE ide. I wanna > write apps with neat little gui's using Tkinter but i dont want the console > there when there run, any ideas? Run the program with pythonw.exe instead of python.exe. -- Carl Fink carlf at dm.net From malcolm at commsecure.com.au Tue Jul 31 13:18:57 2001 From: malcolm at commsecure.com.au (Malcolm Tredinnick) Date: Wed, 1 Aug 2001 01:18:57 +0800 Subject: decent syslog replacement? In-Reply-To: <9k6n42$ep6$1@netnews.upenn.edu>; from henken@seas.upenn.edu on Tue, Jul 31, 2001 at 12:43:11PM -0400 References: <9k6n42$ep6$1@netnews.upenn.edu> Message-ID: <20010801011857.A8795@Vetinari.home> On Tue, Jul 31, 2001 at 12:43:11PM -0400, Nicholas Henke wrote: > Hello, I am in the process of writing a Metakit database wrapper. I am > running into performance problems when I try to log a ton of debug > messages. The system with thrash the disk when logging. I have tried using > syslog, replacing stdout with a file, etc. None of these seem to help much. > The only luck I have had is to just use print and have bash redirect to a > file. This causes problems in other servers that are trying to log to the > same file. Well, you have just described a number of _different_ problems here (for example, replacing stdout with a file will not work if you are using system() or os.pipe() calls). As far as your original problem goes, syslog attempts to be reliable even in case of crashes. So, by default, it flushes every message to disk as it is written. It is possible to turn off this flushing to disk after each right, by prepending the filename in /etc/syslog.conf with a '-'. See the syslog.conf(5) man page for details. Note, however, that this is only valid for Linux (it was added in the port from BSD sources originally), but if you aren't running Linux, then there's just not much point to programming, really. :-) Cheers, Malcolm -- The colder the x-ray table, the more of your body is required on it. From martin at strakt.com Fri Jul 6 02:52:20 2001 From: martin at strakt.com (Martin Sjögren) Date: Fri, 6 Jul 2001 08:52:20 +0200 Subject: SSL module In-Reply-To: <3B44AF5E.15B1E7C@alcyone.com> References: <3B44AF5E.15B1E7C@alcyone.com> Message-ID: <20010706085220.A8268@strakt.com> On Thu, Jul 05, 2001 at 11:18:06AM -0700, Erik Max Francis wrote: > "Martin Sj?gren" wrote: > > > The past few days I've been writing on a basic SSL module for Python, > > written completely in C. Yep I'm getting paid to do it. ;) > > It uses OpenSSL (of course?) and it's starting to take shape. Of > > course > > there are a multitude of things not finished, a lot of the OpenSSL API > > that I haven't included. Let's put it this way, it's doing what we > > (the > > company I work for) need it to do. If someone wants to continue > > working on > > it I'll be just as glad. I might continue working on it in my spare > > time > > too. > > I sure hope that you have gotten written, explicit permission to release > the code. If you are getting paid to do it, then the job is work for > hire, and you do not own the copyright, so it is not under your > authority to release it publicly. > > Make sure you've cleared it with your company before you go any further. > (If they have not already okayed it, it is unlikely that they would.) I'm fully aware of that, but it was them, not me, who brought up the idea to try getting the module into the python library. It shouldn't be a problem. -- Martin Sj?gren martin at strakt.com ICQ : 41245059 Phone: +46 (0)31 405242 Cell: +46 (0)739 169191 GPG key: http://www.strakt.com/~martin/gpg.html From skip at pobox.com Mon Jul 9 10:05:31 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 9 Jul 2001 09:05:31 -0500 Subject: Adding a package to the standard distribution In-Reply-To: <9iad21$btd$1@oravannahka.helsinki.fi> References: <9iad21$btd$1@oravannahka.helsinki.fi> Message-ID: <15177.47659.74062.15484@beluga.mojam.com> Panu> Hello all, I've got a package (called Selecting) that I'd like to Panu> subject to consideration for being added to the standard python Panu> distribution. The package implements a better (in my opinion) Panu> scheme of abstraction over select.select() than does asyncore and Panu> asynchat. However, I don't know what mailing list / person I Panu> should write to to get the package included in the standard Panu> distribution. For starters, I'd suggest you make it available via HTTP or FTP and post an announcement to the Python announcements list/group. Also, submit it to the Vaults of Parnassus. As for persuading the powers-that-be, you can send a note to python-dev at python.org. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From tjreedy at home.com Tue Jul 31 20:29:09 2001 From: tjreedy at home.com (Terry Reedy) Date: Wed, 01 Aug 2001 00:29:09 GMT Subject: deja/vu Message-ID: Here's a deja vu article for the 100,000 post celebration [8<) In a 40-article comp.lang.python thread accessable as http://groups.google.com/groups?hl=en&safe=off&th=1d9d3c24ba2f933d&sta rt=10 a pharmacist reported his conversion of life-critical dose-calculation programs from Basic to Python. In messages 3&4, Tim Peters and Fredrik Lundh warned him about 1/2=0. Selected quotes from the discussion that followed: Greg Ewing(15): It's a nuisance in C, but at least there you know whether you're dealing with ints of floats. In a dynamically typed language, where you don't know when you write the code whether you'll get an int or a float, it's lunacy! Tim Peters (10): ... if "/" floated ints and *they* had to type "//" to get integer division. Which may or may not be what Guido would like to do for Python2. Guido van Rossum(12): For the record, this seems a reasonable solution if we can overcome the breakage of all the code that relies on truncating integer division. Perhaps the // notation should be introduced sooner to provide a migration path? [Would that he had - TJR] (It would be easier if it were a function, e.g. div(x, y).) [Tim Peters(16) in response to that line: less attractive because the translation program would have a harder job in several respects. By-hand conversions would also be harder.] GvR continuing: What would 3.0//2.0 (or div(3.0, 2.0)) mean? Aha, there's a precedent: use divmod(3.0, 2.0)[0], which yields 1.0 today. Michael McLay(13): Any guesses on how much code would be broken by making the change? ... How loudly would people scream if Guido made such a drastic change in the 1.6 release? Andrew Kuchling(14): Very, very loudly. ... it's better held off until a x.0 release. ... Terry J. Reedy From SBrunning at trisystems.co.uk Mon Jul 9 04:10:12 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Mon, 9 Jul 2001 09:10:12 +0100 Subject: location of pySol Message-ID: <31575A892FF6D1118F5800600846864D78BE32@intrepid> > From: Scott Hathaway [SMTP:slhath at home.com] > Can anyone tell me where to get the latest version of pySol? Try . 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 dfackrell at DELETETHIS.linuxmail.org Wed Jul 25 13:59:59 2001 From: dfackrell at DELETETHIS.linuxmail.org (Daniel Fackrell) Date: Wed, 25 Jul 2001 11:59:59 -0600 Subject: PEP0238 lament References: <5sdnlt072hm6hp17nluu6f0fqq4bvr6mj8@4ax.com> <916olt0p3kciv0evmotdg6jev9bl29l57i@4ax.com> <3B5C52EA.9430255E@alcyone.com> Message-ID: <3b5f0a37$1@hpb10302.boi.hp.com> "Guido van Rossum" wrote in message news:cpzo9t80l7.fsf at cj20424-a.reston1.va.home.com... > Duncan Booth writes: > > > I agree that it would make Python a different language. Neither better nor > > worse. > > > > You arguably gain in meeting some peoples expectations of the division > > operator, but you lose consistency in that previously (as far I can think), > > the operators +, -, *, /, % when given two arguments of the same numeric > > type always return a result of that same type. In future we have to be > > prepared to explain to beginners that division can give a result of a > > different type: in fact you cannot even predict the type of the result when > > you know the types of the arguments, you have to know their values as well. > > In a farther future, when PEP 228 is fully implemented, Python may > only have *one* (built-in) numeric type, "number". Then all > operations will defined entirely on the mathematical value, and the > different "types" as we know now are merely details of storage > efficiency -- except that numbers will also have an indication of > "exactness" or "approximateness", to acknowledge the fact that the > number system may choose to give approximate results for some > operations. We may end up deciding that rationals have too many > problems, and replace binary floating point with decimal floating > point to address a different set of confusions, and so maybe division > of two exact numbers may not always yield an exact result -- just like > the square root of 2 is conventionally calculated only to a limited > precision. Or we may choose to represent rationals exactly -- in any > case, 1/2==0 will be false, just as PEP 238 proposes. > > Such a (hypothetical!) world is just as consistent, yet it does not > guarantee that the type of the result of an operation is the same as > that of the operands, if by type you mean the storage type (int, long, > float etc.). > > Also look at PEP 237, which proposes to unify ints and longs. Would > you really prefer your "consistency" and see 1000000 * 1000000 raise > OverflowError because the result cannot be represented as a 32-bit > int, or would you prefer to drop the "consistency" in favor of getting > a result at all? > > --Guido van Rossum (home page: http://www.python.org/~guido/) Would this unified number system somehow still be able to provide the functionality that ints provide with regard to bitwise operations? There may be other problems that arise as well, but I'm too much of a newbie to point them out at this time. -- Daniel Fackrell (dfackrell at linuxmail.org) When we attempt the impossible, we can experience true growth. From new_name at mit.edu Wed Jul 18 07:43:41 2001 From: new_name at mit.edu (Alex) Date: 18 Jul 2001 07:43:41 -0400 Subject: Nested List Comprehension References: <9iss5k$2dcd$1@news.idiom.com> Message-ID: > > Yeah, I mucked around a bit with nested list comprehensions when I > > started using them. It causes the same sort of miserable readability > > problems that excessive use of the functional programming facilities > > do. > I think LC's are pretty neat, not that that's likely to sway anyone's > opinion one way or the other. Like many techniques it can be abused by > overuse. Oops, yeah, I meant using them gratuitously can cause problems Alex. From daniel at rawbyte.com Thu Jul 5 17:52:12 2001 From: daniel at rawbyte.com (Daniel) Date: 5 Jul 2001 14:52:12 -0700 Subject: httplib 1.1 Message-ID: <234e16a2.0107051352.352fd6c7@posting.google.com> Is there an httplib 1.1 that works with python 1.5? (I think I saw somewhere a backport of the 2.0 httplib, but cannot find it) httplib for 2.0 is backwards compatible, but only supports HTTP 1.0 in this mode. Thanks Daniel From arne at leithe.spammenot.no Tue Jul 17 14:08:39 2001 From: arne at leithe.spammenot.no (Arne Leithe) Date: Tue, 17 Jul 2001 18:08:39 GMT Subject: Partition Problem References: <3B4FBEA0.D5A6DC8A@engcorp.com> <9ioru22pc9@enews4.newsguy.com> <3B5042C2.F821D916@engcorp.com> <9itb14$2oi$1@newsg1.svr.pol.co.uk> <9iv5e9$bru$1@newsg1.svr.pol.co.uk> <0oR47.12485$p7.4220508@news1.rdc2.pa.home.com> Message-ID: "Terry Reedy" wrote in news:0oR47.12485$p7.4220508 at news1.rdc2.pa.home.com: > So why do you object when I revise an algorith to make it feasible for > much larger n? Because you optimized a brute force-algorithm for speed, without first fixing the algorithm (first and foremost the ability to vary "k"). It seemed that the ability to use large n-s, however, somehow was of paramount importance, and you even suggested that Donovan use a rather obscure technique to vary k. Your latest algorithm is great, though, and I wish you had posted it the first time around. I find it to imortant when explaining algorithms to beginners that extensibility and generality of the algorithm should be taken care of before speed. When I find myself in a position where I need to unroll loops (or even get rid of recursion), I'm already reprogramming the algorithm in C++. Arne Leithe From djc at object-craft.com.au Thu Jul 26 20:35:12 2001 From: djc at object-craft.com.au (Dave Cole) Date: 27 Jul 2001 10:35:12 +1000 Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <9jnt9p$qhe$1@newsy.ifm.liu.se> Message-ID: >>>>> "Guido" == Guido van Rossum writes: Guido> For example, a dict with int keys can be indexed with Guido> corresponding float or complex values. You are a legendissimo!!! I implemented an extension type for the Sybase native NUMERIC column type in my Sybase module but never really gave things like this much thought. Now I know why I do not bother adding my 2c to arguments regarding fundamental language features... ferret:/home/djc% python Python 2.0.1 (#0, Jun 23 2001, 23:50:30) [GCC 2.95.4 20010319 (Debian prerelease)] on linux2 Type "copyright", "credits" or "license" for more information. >>> import Sybase >>> dict = { 42: 'the answer' } >>> n = Sybase.numeric(42) >>> n.precision, n.scale (16, 0) >>> dict[n] 'the answer' >>> n = Sybase.numeric('123456789012345678901234567890.123456789123456789') >>> n.precision, n.scale (49, 18) >>> n 123456789012345678901234567890.123456789123456789 >>> n * 2 246913578024691357802469135780.246913578246913578 >>> - Dave -- http://www.object-craft.com.au From jim at publishingresources.com Wed Jul 25 10:40:59 2001 From: jim at publishingresources.com (Jim Abrams) Date: Wed, 25 Jul 2001 14:40:59 -0000 Subject: Python 2.1.1 ASP/Response object does not HONOR Response.End() References: Message-ID: Response.end() (note lower-case 'e') "Joe Salmeri" wrote in : > When using Python/ASP if you call the Response.End() method the rest of > the script is still processed > > For Example: > > ** Script ** > > <@language="Python"%> > <% > Response.Write("This is line 1") > Response.Write("This is line 2") > Response.End() > Response.Write("This is line 3") > %> > This should NOT appear. > > ** End Script ** > > "This is line 3" and "this should NOT appear." both appear in the page > results. > > Testing the same script with VBScript produces the correct results. > > Is this a known bug? > > From ngps at madcap.dyndns.org Fri Jul 13 13:59:00 2001 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 13 Jul 2001 17:59:00 GMT Subject: Is Python Dead? Long Live Python! References: Message-ID: <9inct4$jes$1@coco.singnet.com.sg> According to Kemp Randy-W18971 : > We run Solaris at my company, and Perl comes bundled with the Sun > machines. It's easier to ask someone to look at Perl because it's an > existing part of every Solaris installation. Since Python is not > pre-bundled with Solaris, I need to ask the Unix administration to > install it. I could sell either language if Python were bundled with > Solaris like Perl is. Which raises an interesting question. Why do > companies like Sun include Perl but not Python with their operating > systems? Python is on the Companion disk. The one I have (late 2000) has Python 1.5.2 only, alas. Is Perl pre-installed? -- Ng Pheng Siong * http://www.post1.com/home/ngps Quidquid latine dictum sit, altum viditur. From gregj at pdxperts.com Thu Jul 19 23:05:03 2001 From: gregj at pdxperts.com (Greg Jorgensen) Date: Fri, 20 Jul 2001 03:05:03 GMT Subject: Python 2 times slower than Perl References: Message-ID: "Roman Suzi" wrote: > Posting tests showing performance weakness in some typical situations > is needed to make Python better. Refining and optimizing Python is a good thing. But these "benchmarks" that show Python slower or faster than language X don't help. Writing real-world Python programs, then profiling and optimizing them, and perhaps finding places to improve the runtime system, the compiler, or the standard libraries: that is useful. Comparing Python's ability to multiply floating-point constants a million times in a loop is not useful, not even when compared to Perl and C. Every Python program I've written since I started with Python (about a year ago) has saved me a lot of time. Whether my program might have executed in 3 seconds instead of 5 if I had used Perl (which I can neither read nor write) is irrelevant. If I was convinced that Perl was 100 times faster I might ditch Python, but for what I do with it Python is more than fast enough, and certainly fun enough. If I really had to multiply floating-point numbers millions of times I'd write the code in C. > These benchmarks also show how good someones Python is compiled. For > exaple, I saw that my AMD K6 225 makes almost same results as somebody > elses Celeron 450 ;-) They probably have screensavers and Napster and a bunch of other background crap running on their machine. The lack of even basic controls in the benchmarking environment changes the results from useless to dangerous. Greg Jorgensen PDXperts LLC Portland, Oregon, USA From peter at engcorp.com Tue Jul 24 22:41:12 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 24 Jul 2001 22:41:12 -0400 Subject: PEP0238 lament References: Message-ID: <3B5E31C8.2EEF4DE@engcorp.com> Stephen Horne wrote: > I cannot believe I am the only person who has gone out on a limb > advocating Python and who is now going to end up looking a right arse. I expect to look somewhat arse-like, but I also believe that a sufficiently long time before this proposed change becomes the default will allow time to spread the arse-likeness out a little and maybe even hide it completely. > The only one shouting so much ATM, maybe ;-) You probably do need to take a day off, if nothing else to rest your mind and fingers a little and come back with a fresh view. (I happen to appreciate your focus on this, though, in case you thought you were entirely alone. I also happen to believe there is room for some further "negotiation" before a final plan is settled on which definitely breaks code. Maybe two operators, and in any case at least much further consideration of backwards compatibility options and so on.) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From aleaxit at yahoo.com Sat Jul 14 17:47:49 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 14 Jul 2001 23:47:49 +0200 Subject: How to run codeobjects in Python? References: <9imphr015u5@enews1.newsguy.com> <3B4FBBD8.45F56742@engcorp.com> <9iorv60pj2@enews4.newsguy.com> <3B50421E.F00DBFD@engcorp.com> <9ipkp501mop@enews4.newsguy.com> Message-ID: <9iqejk0fch@enews1.newsguy.com> "Matthew Dixon Cowles" wrote in message news:slrn9l15i0.qi.matt at happy-hour.mondoinfo.com... > On Sat, 14 Jul 2001 16:25:05 +0200, Alex Martelli > wrote: > > >The latest issue of the Economist magazine has an in-depth survey of > >Italy > > [. . .] > > >it starts out with a Paean titled "What a lovely off place!" > > A rare typo has escaped Alex's keyboard here. It's "odd", rather than > "off". Not so rare, but, yes, my typo (funny, I _thought_ I was copying and pasting from their site...). > I haven't yet read any of the survey (The Economist arrives a little > late here in the colonies) So get on the net, already. www.economist.com is one of the best sites I know, and as a printed-Economist subscriber you get full access to the site too. My only wonder is why they didn't use Python on their site (especially considering they're mostly owned by the same publishing outfit that owns New Riders, who publish the Essential Reference...:-). > but it seems likely that they're making a > small joke about what a British tourist might say. And while I > wouldn't be surprised to hear some things in Italy called odd, I would > be surprised to hears someone say that the country was "off". Why? Anybody from Forza Italia might say Italy is "off and running" now that we've elected Berlusconi, anybody against FI might say we're off our rocker to have elected him, so...:-) Alex From andy_todd at spam.free.yahoo.com Wed Jul 25 02:57:20 2001 From: andy_todd at spam.free.yahoo.com (Andy Todd) Date: Wed, 25 Jul 2001 06:57:20 GMT Subject: newbie projects References: <3B5E4A67.FD4BE81A@engcorp.com> Message-ID: Peter Hansen wrote in <3B5E4A67.FD4BE81A at engcorp.com>: >fett at tradersdata.com wrote: >> >> Uh I know this sounds knda dumb but anyoone have a job that they want >> done cheap or for free that doesnt have to be done by a professional, >> because im not one by any stretch of the immagination. But i need some >> type of project to do to help me hone my skills. > >Why not contribute your efforts to a worthy open-source project, >like maybe one of the ones on SourceForge? Giving your time away >to a commercial enterprise would be silly, unless you are >specifically hoping to turn that into future work for the same >company. And even then working on the open-source project might >end up providing you more lasting value. And fun. (Just a thought.) > Couldn't agree more, just go to http://sourceforge.net/ and enter 'python' in the search box (oh, and then press the 'Search' button ;-) You'll find plenty of projects there, some of which may (or may not) tickle your fancy. Or, you can just get involved with PythonCard (http://pythoncard.sourceforge.net/) Regards, Andy -- Content free posts a speciality From sholden at holdenweb.com Mon Jul 2 12:44:05 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 2 Jul 2001 12:44:05 -0400 Subject: Augmented Assignement (was: Re: PEP scepticism) References: Message-ID: "Courageous" wrote in message news:fr81ktskiqe8guj9b241qd9mtq1324bfkd at 4ax.com... > > >> x += (1,2,3) ... is not the same as... x=x+(1,2,3) > >> That's just plain wrong. > > >No, that's the *whole intent* of the thing. > > Intent involves what people were thinking when they asked for it. > I have a strong feeling that you are quite wrong about this. > I agree. The interpreter's current behavior is, as was explained to me in some detail when I made similar complaints (*before* the PEP was implemented, but after it was approved, and so therefore too late to do anything but waste time :-( ) exactly what was intended. Besides which, for a tuple x then x += (1,2,3) is, *exactly*, the same as x = x+(1,2,3), since both involve a rebinding of the name x to a new tuple containing three additional elements. Previous references to the original tuple will still point to it, unchanged. It's mutable types whose behavior can differ. Unless I'm being incredibly dumb. and-it-wouldn't-be-the-first-time-if-i-were'ly y'rs - steve -- http://www.holdenweb.com/ From grayson-wilson at home.com Mon Jul 9 19:53:35 2001 From: grayson-wilson at home.com (EricIDLE) Date: Mon, 09 Jul 2001 23:53:35 GMT Subject: Help with reduce(). Message-ID: <3ur27.663627$166.13698874@news1.rdc1.bc.home.com> Ok well I have ANOTHER problem with one of the examples in my book (By The Way, "Teach yourself python in 24 hours" is an extremely poorly written book and I do not reccomend it to any newbies who are just starting off) any ways the example is as follows. n = range(1,11) def mult(x,y): return x * y f = reduce(mult,n) print f I get everything up to reduce. I relize mult() takes the first two numbers in range N which would be 1, 2 and multiplys them together to get 2... ok fine im good ... now comes the tricky part!! what does reduce do? Does it take the whole range and make it into a number (12345678910) then subtract 2 (the result of the function mult) or what does it do. And i have another question (not related to first question) x = ['Thu', 'Aug', '5', '06:06:27', 'MDT', '1999'] def strp(x,y): return x + ' ' + y r = reduce(strp,x) print r my problem is this line return "x + ' ' + y" what does it return the value of. I would understand it if it was x + y but the qutation marks are what throw me off what do they mean? Thanks. From cfelling at iae.nl Sat Jul 7 13:25:20 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 7 Jul 2001 19:25:20 +0200 Subject: anonymous variable References: <9i791n$3bh$1@macareux.ens-lyon.fr> Message-ID: <9i7gm0$636$1@animus.fel.iae.nl> Emmanuel Jeandel wrote: ... > In python 1.5, i do : > L.sort ( lambda (_,_, size1) (_,_,size2) : cmp(size1,size2)) a work-a-round might be to use __ and ___ and so on. -- groetjes, carel From gustafl at algonet.se Sat Jul 7 11:52:04 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 7 Jul 2001 15:52:04 GMT Subject: Empty sys.path[0] References: Message-ID: Michal Wallace wrote: >Where do the docs say this? It sounds like a mistake, or something >that needs clarification.. In the library reference, for the 'path' list in the 'os' module: "The first item of this list, path[0], is the directory containing the script that was used to invoke the Python interpreter." I interpreted it as the directory with the script. >you want os.getcwd() It says it returns the working directory. Is that always where the script file is? Suppose I call the script from another directory? Regards, Gustaf Liljegren From eppstein at ics.uci.edu Thu Jul 19 22:29:30 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Thu, 19 Jul 2001 19:29:30 -0700 Subject: Conway's Life References: <3B57AF54.F909FD36@.com> Message-ID: On Fri, 20 Jul 2001 01:10:56 GMT, Doug Newhouse wrote: > > I'm a recreational programmer with some pretty basic experience in > > Python and I'm looking for a good way to implement the grid needed for > > Life (or other cellular automata) in Python. Rather than using grids, Life implementations can really benefit from the sort of more complicated data structure that Python makes easy. A couple non-Python examples worth study are in http://tomas.rokicki.com/hlife/ uses hash tables to avoid recomputing evolution of previously-seen patterns (he's not kidding about running 2^3000 generations of a breeder) http://hensel.lifepatterns.net/ nice (and fast, but not as good as hashlife) Java Life pattern viewer applet, source in http://hensel.lifepatterns.net/lifeapplet.html -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From kwoeltje at mail.mcg.edu Mon Jul 23 13:36:48 2001 From: kwoeltje at mail.mcg.edu (Keith F. Woeltje) Date: Mon, 23 Jul 2001 17:36:48 GMT Subject: Language change and code breaks References: <9j7gv8$9mg@dispatch.concentric.net> <3B587A3F.8060401@mail.mcg.edu> <9jchng$9mr@dispatch.concentric.net> Message-ID: <3B5C60C9.3010705@mail.mcg.edu> I agree that the something = Something() type of notation doesn't appeal to me personally, but others seem to like it. I was unfamiliar with the aSomething = Something() notation, but it kind of makes sense to me. Be that as it may, at least part of the reason being touted for case insensitivity is that it makes the language easier to learn. My only point was that this particular issue is probably trivial. There may be compelling reasons for case insensitivity, but this isn't one of them. >K From ralph at inputplus.demon.co.uk Fri Jul 20 15:06:32 2001 From: ralph at inputplus.demon.co.uk (Ralph Corderoy) Date: 20 Jul 2001 20:06:32 +0100 Subject: Case insensitivity References: Message-ID: <9j9vfo$tpg$1@inputplus.demon.co.uk> Hi, > My own intuition and experience tells me that there seem to be two > kinds of people: some folks think case-sensitively, others think > case-insensitively. Doesn't the fact that most people learn the written form of their natural language ahead of programming mean that they're used to the concept of case (if their language has it) and understand that CAN and can are different, the former being a different case to encode extra information -- that it is an abbreviation. Sorry to add my twopence in an already crowded and `done to death' thread. Ralph. From tim.one at home.com Sun Jul 22 20:39:43 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 22 Jul 2001 20:39:43 -0400 Subject: PEP0238 lament In-Reply-To: <3B5B639C.FF5961E7@Lugoj.Com> Message-ID: [James Logajan] > ... > Speaking of patterns, it unfortunately appears that Guido has a > strong tendency to take the existing user base for granted, since he > continues to keep the door open to code-breaking changes. I'd say it's more the case that people project their particular concerns on to the entire Python user base, and somehow mistake disagreement for being ignored. As I said before, Guido hears *all* the complaints, and, believe it or not, the Python user base is composed of people, and people don't agree. It's Guido's job to make the best sense he can out of conflicting desires (including but not limited to his own). > There is only so much insult ("well, what you were doing was bad style > anyway," or "you shouldn't have written code that depends on integer > division(!)") and injury (the more Python you've written, the more > likely something you wrote wont work with the latest version and will > need to spend hours reviewing,just-in-case-anyway) before one decides > that it just isn't worth the pain. Of course. Do you seriously think Guido is unaware of that? OTOH, do you seriously think 100% backward compatibility is an absolute criterion, immune from competition with other claims? > I do not want to continue to write more Python and expose myself > to further risk of having it either become dependent on an un-maintained > and minority release (e.g. "sorry, you should have upgraded to 3.1 years > ago; who writes stuff on 2.1 these days anyway?") or having a growing > body of code to constantly shepherd along to insure it runs on the next > release. Your choice, but my guess is that Guido has done an excellent job of maintaining backward compatibility so far (he burned me by changing str(long) to stop producing a trailing "L", and I must have spent nearly 20 minutes recovering from that -- BFD). > That is the pragmatics from my point of view. And it doesn't give a > damn what real or perceived "flaw" in the language is being addressed. OK, I'll save this msg for the next time you ask for a change <0.9 wink> From sh at ttsoftware.co.uk Mon Jul 23 14:15:33 2001 From: sh at ttsoftware.co.uk (Steve Horne) Date: Mon, 23 Jul 2001 19:15:33 +0100 Subject: A use for integer quotients References: <9jhi8b$duv$1@pea.uk.research.att.com> Message-ID: On 23 Jul 2001 16:09:47 GMT, Duncan Grisby wrote: >In article , > Guido van Rossum wrote: > >>Of course, I'm well aware of the issues around maintaining old code. >>We will have to carry around "from __future__ import division" for a >>loooooong time. Python 2.2 is the first opportunity to introduce it, >>so let's not be shy. > >What is the suggested course of action for people (like me) who have >to maintain software which must run on more than one version of >Python? Probably to change jobs quick before it hits the fan :-( -- Steve Horne Home : steve at lurking.demon.co.uk Work : sh at ttsoftware.co.uk From emile at fenx.com Sat Jul 7 11:31:10 2001 From: emile at fenx.com (Emile van Sebille) Date: Sat, 7 Jul 2001 08:31:10 -0700 Subject: Comment on PEP-0238 References: Message-ID: <9i7a7k$h9ks6$1@ID-11957.news.dfncis.de> "Guido van Rossum" wrote in message news:cpelrskgrr.fsf at cj20424-a.reston1.va.home.com... > > (Hm. For various reasons I'm very tempted to introduce 'yield' as a > new keyword without warnings or future statements in Python 2.2, so > maybe I should bite the bullet and add 'div' as well...) > If you're going to add keywords, why not add precision and allow those who want non-integer division to set it to the level of precision they require. That breaks no more code (presumably) than adding div or yield does. -- Emile van Sebille emile at fenx.com --------- From tim.one at home.com Fri Jul 27 16:59:01 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 27 Jul 2001 16:59:01 -0400 Subject: PEP 238 (revised) In-Reply-To: Message-ID: [Guido] > IEEE 754, the floating point standard in use in virtually all current > hardware, mandates that -0.0 be distinguishable from 0.0, in order to > be able to represent the sign of degenerated underflow results. That's part of the reason. Another is to distinguish "which side" of a branch cut you're on when slinging functions using complex arithmetic. One more is for careful support of interval arithmetic endcases. These are related in my mind. > (Or so I understand, having been educated in IEEE 754 through numerous > discussions with Tim Peters, but not by reading the standard. If I'm > wrong, Tim will surely correct me. :-) But so gently it's hard to notice you've been dissed . > I don't know of a portable way to generate -0.0 in Python; on my Linux > box, simply writing -0.0 does it, but not on my Windows box. You're almost certainly wrong about that, and this illustrates the difficulty of doing anything with 754 arithmetic in Python that doesn't intersect with Fortran's view of the world circa 1960 (and so adopted wholesale by C89 too, 30 years later). One problem is that there's no cross-platform consistency in whether C's printf will *display* the sign of a 0. Here on my Windows box: >>> x = -0.0 >>> x 0.0 >>> But you can't actually tell anything from that, because the Windows C printf suppresses the sign of a 0. You can't tell by trying to compute the reciprocal either (to look at the sign of the resulting infinity), because *Python* stops you from doing that: >>> 1/x Traceback (most recent call last): File "", line 1, in ? ZeroDivisionError: float division >>> Comparison is also hopeless (but by design: +0 compares equal to -0): >>> x == 0.0 1 >>> Here's one way to tell: >>> import math >>> math.atan2(x, x) -3.1415926535897931 >>> math.atan2(0, 0) 0.0 >>> That is, I really did get minus 0 on Windows! BTW, that also hints at why signed zeroes can be a life-saver when doing complex arithmetic. However, whether atan2() handles signed zeroes correctly also varies across platforms. full-754-is-still-unusable-in-practice-ly y'rs - tim From tim.one at home.com Sat Jul 7 13:48:33 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 7 Jul 2001 13:48:33 -0400 Subject: compile() question: SyntaxError: unexpected EOF while parsing In-Reply-To: <3B471584.3686D0E@engcorp.com> Message-ID: [Peter Hansen] > While examining the core of medusa's monitor.py, we've encountered > a situation that looks on the face of it like an undesirable > limitation or inconsistency of the Python compiler. (I fully expect > to hear an explanation for why this is actually a Good Thing, > but we haven't figured it out ourselves yet.) Na, parser error msgs have a life of their own. You can *try* to change one, but there's no guarantee it won't change back when you stop glaring at it <0.9 wink>. > We expected the following two sequences to produce the same > exception, but they do not. > > >>> good = 'if 1:' > >>> compile(good, '', 'exec') > Traceback (most recent call last): > File "", line 1, in ? > File "", line 1 > if 1: > ^ > SyntaxError: unexpected EOF while parsing > >>> bad = 'if 1:\n print 1\nelse:' > >>> compile(bad, '', 'exec') > Traceback (most recent call last): > File "", line 1, in ? > File "", line 3 > else: > ^ > IndentationError: expected an indented block > > > Medusa's monitor.py uses the "unexpected EOF while parsing" > feature to infer that additional lines of text are going to be > entered by the user (to satisfy the expected indented block for > the "if"). This is how it knows when to deliver another "..." > prompt and when to cancel entry of data and deliver a real > exception. > ... Then it's not smart enough to handle Python code. Code that is smart enough can be found in the std library module codeop.py, and people simulating interpreter loops should use the higher-level facilities in the std code.py. Getting this right in all cases is tricky (read the code); you've only bumped into one subtlety so far. BTW, when reading the code, keep this in mind: >>> issubclass(IndentationError, SyntaxError) 1 >>> From eppstein at ics.uci.edu Sat Jul 28 15:29:30 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Sat, 28 Jul 2001 12:29:30 -0700 Subject: int vs float divide: abbreviating numbers w/SI units Message-ID: Some time buried in the recent division flamewar I posted a message listing the uses I'd recently made of integer division, one of which was some short code for abbreviating numbers like 1008926 to e.g. 988k for more readable text output of file sizes in a web photo gallery generator. Anyway, I decided it would be a good idea to make it more general and robust, and discovered somewhat to my surprise that float division seems to be a better fit for the task. The new code is below if anyone wants to critique or use it. def abbreviateNumber(n, k=1000): """Convert a number into a short string for its approximate value. SI Units are used to convert the number to a human-readable range. For example, abbreviateNumber(3141592) returns '3.1M'. In most cases (except when the number is too big or too small for the units defined in the SI system) the resulting string will be at most four characters long. By default, the program uses decimal k (i.e. 1k = 1000). To use binary k, as is more typical e.g. for numbers of bytes, call with a second argument k=1024. """ # determine number of factors of k and normalize 0.9995 <= n < 999.5 k = float(k) # force floating-point divisions nk = 0 sign = '' if n < 0: n = -n sign = '-' while n >= 999.5: n /= k nk += 1 while 0 < n < 0.9995: n *= k nk -= 1 try: if nk > 0: suffix = ' kMGTPEZY'[nk] elif nk < 0: suffix = ' munpfazy'[-nk] else: suffix = '' except: suffix = 'k^%d' % nk # decide whether to use integer or decimal form and construct result if n < 9.95 and n != round(n): strn = "%1.1f" % n else: strn = "%d" % round(n) return sign + strn + suffix -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From morten at thingamy.net Wed Jul 25 07:04:04 2001 From: morten at thingamy.net (Morten W. Petersen) Date: Wed, 25 Jul 2001 13:04:04 +0200 Subject: Making a Sircam virus-remover in Python Message-ID: Hia guys, I was wondering if it would be hard to remove the Sircam virus using Python; that is, to change the attribution of some files, edit and delete some entries in the windows registry and then reboot; could someone point me in the direction of the proper module to edit the Windows registry? Thanks. -Morten From rcameszREMOVETHIS at dds.removethistoo.nl Tue Jul 24 11:43:35 2001 From: rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz) Date: Tue, 24 Jul 2001 15:43:35 GMT Subject: Language change and code breaks References: <9jhtmk$ap4$1@newshost.accu.uu.nl> Message-ID: Martijn Faassen wrote: > Python currently also enforces consistently case-spelled code. I > believe that this is good as well. For what it's worth, I subscribe to that view too. What impresses me the most about Python is the ease with which I can understand somebody else's code. That is because Python forces its users to have a much more consistent programming style than any other language I know of. Having case sensitivity is a part of that, as you don't have to deal with many individual casing preferences. Even if it wouldn't break a line of code that alone would be enough reason not to change Python in this respect. In my humble opinion, of course. Robert Amesz From skip at pobox.com Tue Jul 31 13:51:41 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 31 Jul 2001 12:51:41 -0500 Subject: 2.2 features In-Reply-To: <200107311705.NAA16444@cj20424-a.reston1.va.home.com> References: <15206.48884.18637.676324@beluga.mojam.com> <200107311705.NAA16444@cj20424-a.reston1.va.home.com> Message-ID: <15206.61485.360973.566871@beluga.mojam.com> Skip> How about 'x in type' as a shorthand for 'issubclass(x, type)' if Skip> x is a type or class instead of an instance? Guido> No, that would be ambiguous. A subclass is not an instance. A Guido> class or type represents a set of instances, so 'in' is justified Guido> in a sense. I guess I'm confused, but if isinstance(x, type) is true isn't issubclass(x.__class__, type) also true? Skip From martin.franklin at westerngeco.com Tue Jul 10 05:15:46 2001 From: martin.franklin at westerngeco.com (Martin Franklin) Date: Tue, 10 Jul 2001 10:15:46 +0100 Subject: backslash woes........ Message-ID: <3B4AC7C2.DD53F6BB@westerngeco.com> Hi all, I am having trouble with windows path names (i'm a UNIX'ite) I want to replace the common prefix of a list of file names with a relative stub (./) I have this... def _removePrefix(self, fullfile): print r'%s' %fullfile filename=re.sub(r'%s' %self.prefix, r'%s' %os.sep, r'%s' %fullfile) print filename return filename Where fullfile is the - full filename... and self.prefix is the os.commonprefix() Currently I get an error:- traceback (most recent call last): File "c:\python21\lib\lib-tk\Tkinter.py", line 1285, in __call__ return apply(self.func, args) File "r:\src\python\squeeze\dev\makesqueeze.py", line 161, in Finish Squeeze(platFileList, open(filename, 'w'), self.prefix_or_path.get(), config) File "r:\src\python\squeeze\dev\Squeeze.py", line 58, in __init__ self._apply(file) File "r:\src\python\squeeze\dev\Squeeze.py", line 137, in _apply file = self._removePrefix(fullfile) File "r:\src\python\squeeze\dev\Squeeze.py", line 151, in _removePrefix filename=re.sub(r'%s' %self.prefix, r'%s' %os.sep, r'%s' %fullfile) File "c:\python21\lib\sre.py", line 63, in sub return _compile(pattern, 0).sub(repl, string, count) File "c:\python21\lib\sre.py", line 136, in _compile raise error, v # invalid expression error: bogus escape: '\\x' I don't understand this as I am (trying) to use raw strings everywhere..... (that's what the DOC's told me to do...) 'Course on UNIX it all works perfectly well with or without the raw strings;-) Hope _you_ can help Martin From qrczak at knm.org.pl Tue Jul 24 02:30:57 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 24 Jul 2001 06:30:57 GMT Subject: PEP0238 lament References: <9jgvbc$dos$1@newshost.accu.uu.nl> <9ji7qc$ciq$1@newshost.accu.uu.nl> Message-ID: 23 Jul 2001 22:17:48 GMT, Martijn Faassen pisze: > Huh? Which contexts are that? ints are converted to floats if you use > them together with a float, yes. int + float results in a float answer, > just like int/float does; why do you claim / is an exception in this? In all arithmetic operators and functions except '/' I can use an int in place of a float and I will get equal answer, possibly with a different type. >> In languages where ints are implicitly converted to strings, addition >> and concatenation are typically different operators. Like in Perl: >> '+' and '.'. > > And in Perl "1" + "foo" is 1. Hardly ideal as an example of separate > operators. :) A good example when the meaning depends on operators rather than types. Types are unified, operators are separated. In fact 1 and "1" (and results obtained by addition vs. concatenation) are treated differently in Perl internally. Perl ints, floats and strings are not kept in the same type. They only convert between one another when requested by the context. This is similar to int and float in Python. Well, they do have different types visible to the programmer, but the distinction is blurred by implicit conversions. >> Python does treat ints and floats as different parts of the same >> concept by letting them compare equal and convert as needed. So real >> division and integer division should be distinguished by the operator. > > Couldn't you make this argument for float multiplication and integer > multiplication as well though? No, because they do give the same answer, so I don't have to care whether I have an int or float if I multiply it. If a is an int, then float(a*b) == float(a)*b (and if it's not ==, it's very close, such that it's hard to tell which imprecise answer is less precise). Division is different. > Ocaml has separate *. for float multiplication, for instance. Because it doesn't have overloading nor implicit conversions at all: it can't use the same operation for types without a common unifier. Now it has an experimental overloading mechanism which will be used for arithmetic. > It does raise the question if polluting so much old code with this > construct (and we can't change code samples) is worth having a > slightly easier to teach language.. old_div is the last resort. The proper fix is to either leave '/' or change it to div, which IMHO makes code more readable, not less. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From JamesL at Lugoj.Com Mon Jul 9 15:55:32 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Mon, 09 Jul 2001 12:55:32 -0700 Subject: Language Shootout References: <3B49F724.1F3DF6B3@yahoo.com> Message-ID: <3B4A0C34.C64202C2@Lugoj.Com> Paul Winkler wrote: > So basically what that benchmark tells me is: "Don't write recursively in Python > if performance is an issue". Well yes, this is what benchmarks are useful for. From cribeiro at mail.inet.com.br Tue Jul 3 21:27:52 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Tue, 03 Jul 2001 22:27:52 -0300 Subject: Pythonic Quote of the Week - sliding away... In-Reply-To: <4E42BD2538CACF79.9FD7275B6CD3244E.A70BBB4C060B585B@lp.airn ews.net> Message-ID: <5.0.2.1.0.20010703215513.02c01d90@mail.inet.com.br> At 17:34 03/07/01 -0500, Emile van Sebille wrote: >Pythonic Quote of the Week... > Quite granted that nobody is forced to use a feature. But when > a language becomes too featureful, people start programming in > the subdialect they like best, later creating difficulties to > other wanting to read their programs, who might like other parts > better. > > One of the reason behind Python legibility success, is that > there is almost only one way to do one thing (to contrast with > Perl, say). We are progressively sliding away of this virtue. > The danger is real. > Fran?ois Pinard > >http://groups.google.com/groups?ic=1&q=msgid:mailman.993966362.10675.python-list at python.org We've got a very good discussion in the past three days about the current status of the library. I feel that at least part of the problem pointed out by Fran?ois Pinard may be attributed at the lack of some highly needed modules on the standard library. As people keep reinventing the wheel, we get two problems: - Less productivity - More fragmentation The solution as proposed by the main python-dev guys - Guido himself and Tim Peters - is that the community should take the responsibility to keep the library, as we can see here: [Guido van Rossum, 2001-06-30 05:53:49 PST] So let's all do what we do best: the core developers (e.g. PythonLabs) improve the language, and the community improves the library. [Tim Peters, Date: 2001-06-30 21:01:05 PST] 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. As it's impossible to clone an army of timbots to solve this problem, we must try to find another solution. I don't believe that we can sort this issue without some involvement of PythonLabs and the core Python-dev guys. The problem is not lack of good modules, but lack of *standard* modules. To make a module standard, some level of Python-dev commitment is a *must*. One of things that plugged me on this "Python thing" was the "batteries included" motto. In fact, the strength of any programming environment can be measured by the extension and usability of its standard library. That's where Java is shining today. The investment on the standard library is one of the surest ways of making Python popular while keeping with the "there's one way to do it" motto. Carlos Ribeiro From tim at digicool.com Thu Jul 19 16:24:03 2001 From: tim at digicool.com (Tim Peters) Date: Thu, 19 Jul 2001 16:24:03 -0400 Subject: doctest In-Reply-To: <9j7bsv$m3g5h$1@ID-59885.news.dfncis.de> Message-ID: [Thomas Heller, on doctest] > The latest version from Python's CVS tree however does > not run any more under Python 1.5.2. > Is there an uptodate version available which is backward > compatible? I expect the incompatibility is shallow, introduced when someone charged thru the std libraries changing all uses of the string module into string methods. If you'd like to change that back again and check it in, fine by me -- there was no intent here to be incompatible (or compatible either, for that matter ). From phillip at transwitch.co.za Thu Jul 12 10:09:19 2001 From: phillip at transwitch.co.za (phillip) Date: 12 Jul 2001 07:09:19 -0700 Subject: The size of a list Message-ID: <74cc9702.0107120609.6c8dc5f6@posting.google.com> Hi, Is there a way to determine the size of a list (disregarding any possible null entries)? tks Phill From steve at lurking.demon.co.uk Fri Jul 20 17:11:10 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Fri, 20 Jul 2001 22:11:10 +0100 Subject: The unPEP: List-Tuple Unification References: <3B586A1E.B037349D@javanet.com> <3B587279.A225AC51@javanet.com> <%3%57.7717$m11.427739@e420r-atl1.usenetserver.com> <3B588720.83400FB5@javanet.com> Message-ID: On Fri, 20 Jul 2001 15:31:44 -0400, Raymond Hettinger wrote: >Steve Holden wrote: > >> "I don't >> see why immutability has to be a one-way attribute when converiosn between >> list and tuple is so easy. >Dictionary's rely on immutability of keys. If the list is used as a key, then >it cannot be subsequently assigned to without breaking the key reference. > >Also, immutability can be an important internal optimization. Once made >immutable, the list can be fixed length, stored as an array, and hashed >once and for all. > >tuples-who-needs-them-ly, yours Raymond I'd have... .lock () Lock any object in place locked () Return immutable copy of object unlocked () Return mutable copy of object .is_locked Return bool - is object immutable locked and unlocked would only change the mutability - all other properties would remain the same. unlocked (locked (x)) == x - 'locked' mustl necessarily lock all nested objects, but they should be marked differently so that 'unlocked' can unlock only the nested objects that were previously unlocked. I don't like the idea of having an immutable attribute as such - I'd rather the actual implementation was separate. But I don't have a good reason. Just a thought ;-) From tim.one at home.com Mon Jul 30 02:22:21 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 30 Jul 2001 02:22:21 -0400 Subject: proposed language change to int/int==float (was: PEP0238 lament) In-Reply-To: Message-ID: [Terry Reedy] > If I write def(seq, n, k): return seq[3*n//k] and a call receives > n=20.0 instead of 20, it would accord with the polymorphic rationale > for new / and // to go ahead and return the item intended. Or perhaps > floored numbers should be marked as exact (if the marking is > independent of type). [Guido] > Good point. What does Scheme do? [Tim Hochberg] > Floor, ceiling, truncate and round all return integers. Careful: that (integer? x) returns true in Scheme does not imply that x "is an integer" in Python's current sense (which has mostly to do with storage format). The std actually says (about floor & friends): the procedures listed below will always return an exact integer result provided all their arguments are exact integers and the mathematically expected result is representable as an exact integer within the implementation and even that last part doesn't mean "stored in an integer format", while there's an escape clause if floor (& friends) can't represent the *value* "as an exact integer" (but what that means under the covers is undiscoverable: Scheme says and reveals nothing about internal representations.). > It seems that it wouldn't really be possible to have // do that > consistently without PEP 237 though. IMO, so long as we've got internal numeric representations on the brain, Scheme's model makes little sense -- the point of Scheme's model was to get away from representations and move toward abstract mathematical values. That said, you may get to the same result in the end in this case anyway, thanks to the contagiousness of inexactness (but not of *type*!): > (integer? (floor (/ 20. 2))) #t > (exact? (floor (/ 20. 2))) #f > So 20.//2 is not usable as a sequence index in Scheme, despite that "it's an integer" (as Scheme means "an integer"). Python can get to the same place in the end, but the terminological battle on the way there is going to be excruciating. From cookedm+news at physics.mcmaster.ca Tue Jul 24 15:06:19 2001 From: cookedm+news at physics.mcmaster.ca (David M. Cooke) Date: 24 Jul 2001 15:06:19 -0400 Subject: real-accurate, numpy...increased precision help References: <9jj0bl$9mq@dispatch.concentric.net> Message-ID: At some point, Skip Montanaro wrote: > Bryan> I need to be able to work with numbers up to 2^800 in a floating > Bryan> point envirnoment. > > Perhaps you could create a class implements all the required numeric > functionality and uses one or more Python longs to represent the number > internally. Or use Alex Martelli's wrapper of GMP: http://gmpy.sourceforge.net This gives you your multiprecision integers, rationals, and floats. -- |>|\/|< /--------------------------------------------------------------------------\ |David M. Cooke |cookedm(at)physics(dot)mcmaster(dot)ca From qrczak at knm.org.pl Sat Jul 28 03:55:47 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 28 Jul 2001 07:55:47 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <3b60d65e.219212588@news.eircom.net> Message-ID: Fri, 27 Jul 2001 13:37:51 GMT, Guido van Rossum pisze: > If we have rationals in our numeric tower, I definitely want (5/2 - 3/2) > to be usable as a sequence index, This doesn't work in my model. The simplest way to let it work is to treat ints (with longs) and rationals as representation details of the same concept (no matter if it's the same Python's type or not). This is not nice IMHO and it leads to more cases when the type of the result depends on the value of the argument (x**y returns at least a float when y is a rational, but may return an integer when y is a nonnegative integer) and turns some TypeErrors into ValueErrors (e.g. s[1/2]). I would not make 5/2-3/2 usable as a sequence index. My style is more "typeful". But you decide. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From tanzer at swing.co.at Wed Jul 25 04:37:04 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Wed, 25 Jul 2001 10:37:04 +0200 Subject: Future division patch available (PEP 238) In-Reply-To: Your message of "Sun, 22 Jul 2001 00:36:38 EDT." <200107220436.AAA05323@cj20424-a.reston1.va.home.com> Message-ID: Guido, I deeply respect your language design skills and I appreciate your ongoing improvements. I'm impatiently looking forward to using many of the features new in 2.2. The future division patch is a different issue, though. While I agree that the proposed changes are a definite improvement over the current semantics, the issue of backwards compatibility is a huge problem difficult to solve. I see the following problems: - What's going to happen to code released into the wild (i.e., I can change all my code but what about code I gave to others)? - How can one write readable code working correctly in both old and new Python versions? - It takes a potentially huge effort to change all the existing code. - In some cases, warnings might not be seen (e.g., they might land in /dev/null or in some log files nobody looks at). - If an application jumps versions (e.g., from 2.1 to 2.6), no warnings might be generated at all. - Upgrading to a new version of an application might break user scripts or databases. I have no idea how to tackle all these issues but I'll offer some ideas nevertheless. - If `int` always truncated (instead of truncating or rounding, depending on how the C compiler does it), one could write reasonably readable version independent code for truncating integer division. Compare `int (a/b)` to `divmod (a, b) [0]` or `int (math.floor (a/b))`. - Just a wild idea: the problem you want to solve is that the existing division operator mixes two totally different meanings and thus leads to nasty surprises. What if `/` applied to two integer values returned neither an integer nor a float but an object carrying the float result but behaving like an integer if used in an integer context? For instance: >>> x = 1/2 >>> type(x) >>> print "%d %f %s" % (x, x, x) 0 0.5 0.5 >>> 2 * x 0 >>> 2. * x 1.0 The difficult issue here is how `integer context` is defined. Should multiplication by an integer be considered an integer context? Pro: would preserve correctness of existing code like `(size / 8) * 8`. Con: is incompatible with Rationals which might be added in the future. - Command line options are not a good way of handling this -- in many cases, different modules might need different settings. Even worse, looking at the code of a module won't tell you what option to use. - If there is a possibility of specifying division semantics on a per module case (via a directive or the file extension), it should also be possible to specify the semantics for thingies like `compile`, `execfile`, `exec`, and `eval`. This only works if absence of a semantics indicator means old-style division. I think this would go the farthest to alleviate compatibility problems. I understand your desire to avoid dragging the past around with you wherever you go and I like Python for its cleanliness. But in this case, it might be worthwhile to carry the ballast. Let me outline the problems faced by my current customer TTTech (I'm working as consultant for them). [This is going to be long -- sorry.] TTTech provides design and on-line tools for embedded distributed real-time systems in safety critical application domains (e.g., aerospace, automotive, ...). TTTech sells software tools (programmed in Python) to customers worldwide. Currently, there is a major release once a year. Due to various reasons, the shipped tools normally don't use the most recent version of Python. The current release is still based on 1.5.2. We hope to use Python 2.1 for the release planned for the end of the year. Internally, we try to use the most recent Python version. Therefore, our Python code must be compatible to several Python versions. The division change effects: - Python programs - Python scripts - user scripts - design databases Python programs --------------- I just used Skip's div-finder (thanks, Skip) to check the code of three of our applications. It finds 391 uses of division. I know that many of those are meant to be truncating divisions, while many others are meant to be floating divisions. Somebody will have to look at each and every one and fix it -- automatic conversion won't be possible. Unfortunately, the applications also contain lots of code inside of strings feed to eval or exec during run-time. I don't know how many divisions are in those, but somebody will have to look at them as well. This is one area frequently overlooked when the effect of changes is discussed and conversion tools proposed on c.l.py. As these tools are frozen, they don't depend on what Python version the user has installed. Python scripts -------------- Internally, TTTech uses quite a number of Python scripts. Unfortunately, different users have different Python versions installed. Currently, 1.5.2, 2.0, and 2.1 are installed (there might still be the odd 1.5.1 around somewhere, too). As the scripts are taken from a central file server whereas Python is installed locally, the scripts and the library modules used must be compatible to all the Python versions deployed. That makes migration difficult if the same symbol means crossly different things in different versions. User scripts ------------ Our tools are user scriptable. These scripts are written in Python and executed in the application's context via execfile (they don't work as standalone scripts). Such scripts are written and maintained by unknown customers who may or may not be programmers and who may or may not have Python experience. (One of the nice features of Python is that even a computer naive user can start writing scripts with little knowledge about Python by modifying examples). Quite often, important scripts have been implemented by people who since changed jobs. Various customers use such scripts for interfacing to other tools, creating designs, checking designs for conformance, writing test cases, implementing test frameworks, generating design reports, ... The delivery of a new tool version ***must not break*** such scripts. TTTech simply cannot tell their customers that they have to review all their scripts and change some but not all occurrences of the division operator. We don't want to get stuck with an outdated Python version, either. OTOH, we cannot assume old style semantics in the scripts either as new users might never have heard about how division used to work in warty versions of Python. Design databases ----------------- Design databases store the design of an embedded distributed real-time system as specified by the user. Such databases must stay alive for a looooong time (think of 10+ years for some application domains). Our tools allow the specification of symbolic expressions by the user. Such expressions are feed through eval at the right time (i.e., late) to get a numeric value. The symbolic expressions are stored in the database as entered by the user. Reading an old database with a new tool version ***must not change*** the semantics. To be honest, for TTTech design databases the change in division probably doesn't pose any problems. Due to user demand, the tools coerced divisions to floating point for a long time. Other companies might be bitten in this way, though. -- 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 barry at zope.com Tue Jul 24 23:17:27 2001 From: barry at zope.com (Barry A. Warsaw) Date: Tue, 24 Jul 2001 23:17:27 -0400 Subject: PEP0238 lament References: <5sdnlt072hm6hp17nluu6f0fqq4bvr6mj8@4ax.com> <916olt0p3kciv0evmotdg6jev9bl29l57i@4ax.com> <3B5C52EA.9430255E@alcyone.com> Message-ID: <15198.14919.30039.645293@anthem.wooz.org> >>>>> "DB" == David Bolen writes: DB> Thus, the very fact that the behavior is moving towards DB> breakage may hold up people from moving for fear of the DB> resource involved to ensure they don't have a problem, which DB> in turn may prolong the period of time when such breakage is a DB> risk. If this is a real fear then you can never upgrade your Python, even if a new version introduces no language changes. A new version will always have /some/ changes, even if it's only patches to the library, or improved performance. Otherwise there'd be almost no reason to release a new version of Python, and we can all just go home. The "Python-is-perfect-now" crowd would be happy, but they'd be just as happy to unsubscribe from this newsgroup, ignore any future Python development, and stick with 1.5.2 forever. Now, you may have a mission critical application that still might break on an upgrade to such a hypothetical new version. Maybe it's because one of your modules has a subtle race condition that behaves different suddenly because you just upgraded to the newer faster Python. Or maybe it's relying on an undocumented feature that got removed because it was buggy (and undocumented). Or maybe one of your extension modules isn't quite thread-safe and breaks when Python eliminates its global interpreter lock. Whatever. But if this is really a fear then upgrading Python might not even be your biggest worry. What if you upgrade some underlying library, or apply an OS patch, or add more memory, or a faster disk, or change to a new C compiler? Any or all of those things may break your code or it may not. I've certainly been victim to such "innocent" upgrade breakages. So you still have to think hard about it, test aggressively, plan defensively, and cross your fingers. Why would you upgrade Python any differently? DB> I'm still at 1.5.2 and unlikely to move beyond that until at DB> least this year's end. At that point I would have been using DB> Python 1.5.2 for about 21 months with it fully deployed in all DB> production sites around 18. I would anticipate about a 6 DB> month preparation cycle before moving to any new release (code DB> test, ensure third party support, etc...) and would then DB> expect to get at least 12-18 months run time again. Right now DB> I was planning on moving to 2.1.1 unless 2.2 looked to arrive DB> soon enough (unlikely) to meet the testing/third party DB> criteria. Sounds like a reasonable plan. I think the only thing you can do is try to get assurances that your mission critical applications are compatible with newer versions of Python. If you can't get such assurances from the vendors, or you've got a lot of third party code, then you can test and fix stuff yourself. Or run multiple versions of Python and migrate your applications one by one. Or never upgrade. There's no law saying you should. But there's also no reason why Python should stagnate, or not fix its warts, or not evolve, so that /new/ applications or newer versions of existing applications cannot be written more elegantly, more succintly, or more maintainably. No, new versions should not gratuitously break old code without some systematic migration plan, but that's what __future__ and the PEPs are all about. -Barry From mjackson at wrc.xerox.com Sun Jul 8 19:44:33 2001 From: mjackson at wrc.xerox.com (Mark Jackson) Date: 8 Jul 2001 23:44:33 GMT Subject: Comment on PEP-0238 References: Message-ID: <9iar91$ds4$1@news.wrc.xerox.com> Guido van Rossum writes: > "Terry Reedy" writes: > > > Another *STRONG* argument for replacing int / with another infix operator > > is the feasibility of revising the thousands of broken lines of code to run > > under 2.whatever. Any decent programming editor can do a 'find / and > > replace with xxx if I say yes' (which will require the reviser to examine > > the code to determine if / meant int div) but hardly any can do 'find / and > > examine the code on both sides to determine the strings that the > > interpreter will see as e1 and e2 and replace e1 / e2 with div(e1,e2) if I > > say yes'. Writing a special purpose update program would also be much > > easier. > > This is a very good argument for a 'div' operator that I hadn't > thought of before! Good. There may be applications in which the functional form has a slightly more natural feel than the infix operator - but in dealing with mathematical expressions the preference is strongly the other way. I speak from bitter experience, having once translated a lot of complex arithmetic from Fortran (A = B*C + D) to Intel Pascal86 (Call Cmult(B, C, E); Call Cadd(E, D, A)). But is "//" rather than "div" actually ruled out? I find it hard to believe that the C++ and Java programmers are actually so hardwired that a = b//c looks like "a = b" followed by a comment to them. If so, how do they cope when (after working in Python for a while) they encounter a stray octothorpe in some other language? If "//" is dismissed on this trivial basis it's obvious that, in fairness to Fortran programmers, starting an unindented line of code with "C" or "c" must be disallowed in Python as well! Perhaps I shall write a PEP. . . -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson The chief executives of large American corporations are, as a class, the most overpaid people on the planet. - James Surowiecki From cbarber at curl.com Fri Jul 27 14:30:42 2001 From: cbarber at curl.com (Christopher Barber) Date: 27 Jul 2001 14:30:42 -0400 Subject: Typing system vs. Java References: <871yn2zdch.fsf@complete.org> Message-ID: John Goerzen writes: > However, it's valuable to me > that as many things as possible be caught before runtime. Do you > think that Python would be a worthwhile language to investigate given > these criteria? AFAIK there is no way to do compile-time type checking in Python. If this is important to you, you might be interested in the Curl language. It lets you omit type declarations when rapid prototyping or writing throwaway code and add them later to get compile-time type checking and code optimizations. - Christopher From edsinger at ai.mit.edu Tue Jul 3 00:37:54 2001 From: edsinger at ai.mit.edu (Aaron Edsinger) Date: Tue, 03 Jul 2001 04:37:54 GMT Subject: newbie apply() question Message-ID: hi. i'm stumped on something that seems easy. why doesn't this work: x=4 apply(sys.stdout.write,x) #fails apply(sys.stdout.write,(x,)) #fails is there a way to make this work? thanks, aaron From sholden at holdenweb.com Tue Jul 17 20:28:00 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 17 Jul 2001 20:28:00 -0400 Subject: OO misconceptions References: Message-ID: "Fran?ois Pinard" wrote in ... > [James_Althoff at i2.com] > > > Plus the fact that Perl sucks. (Just kidding. (Well, not really. > > (Well, kinda, sorta))). ;-) > > Perl was immensely useful to me. Than Python came, which allows me to > write bigger projects, allowing them to be much more maintainable. I'm very > grateful to Perl, believe me. But I would resent being forced into using > Perl, now that I have something which I enjoy even more that I enjoyed Perl. > I did my share of Perl in a commercial web environment, and some of it was great. Far less great was the bunch of grot masquerading as CGI scripts produced by programmers with only six months experience whose first language was self-taught Perl. Can't blame the language for that, though, I suppose. I then gave Perl up when I changed jobs, and becuase I was programming for pleasure for a while I went back to Icon. Having been involved with Snobol in a previous incarnation I really liked Icon. A very well structured language design, with most features orthogonal, and generators built in to expression evaluation. Not the fastest language, like Python it ended up interpreting bytecodes. Very similar assignment semantics to Python too, which helped enormously when I finally decided I'd like something more object-oriented. Interestingly, Griswold's team *did* produce a compiler for Icon - it generated C, which you then compiled in the stamdard way. The C source it produced was long and tortuous, and from experience your programs would be larger by a factor of three or more when compiled, and the speedup was often less than 20% for the text-processing programs I wrote for production. > I'm still dreaming about an automatic Perl to Python converter. Despite many > consider this is not possible, I stick with my naive impression we could > do something about it. It could revolve around three parts: analysing Perl > into a tree, applying some tree-transformational engine using a specialised > language (I wrote a few such in my life), and producing final Python text. > Suppose a Perl-to-Python conversion were possible (and I'm not suggesting it isn't): would it be the kind of Python you'd want to use to teach the language? I suspect not, any more than I would have used the compiled Icon to teach C. Given that Perl is ubiquitous, would there really be any point? I like to poke fun at Perl as well as the next person, but I'd rather do something new in Python and keep the trusty old Perl scripts around, performing day in and day out, than translate them into Python just to avoid using Perl. When I was using it every day it was a concise language, but the further behind I left it the harder it got to read. > Would you believe, this is the first step which looks most difficult to me. > Parsing Perl might not be that difficult after all, but its tokenizer is > extremely hairy, and rather discouraging. If I could swallow that snake, > the rest would not necessarily be easy, but at least, it would be fun! :-) > Ah, well, if you'd do it for fun I have no objection at all. If computing ever stops being fun I'll stop doing it. regards Steve -- http://www.holdenweb.com/ From Alexandre.Fayolle at logilab.fr Fri Jul 6 10:20:38 2001 From: Alexandre.Fayolle at logilab.fr (Alexandre Fayolle) Date: Fri, 6 Jul 2001 16:20:38 +0200 (CEST) Subject: pb with xmlrpclib In-Reply-To: <15173.49956.612553.189434@beluga.mojam.com> References: <15173.49956.612553.189434@beluga.mojam.com> Message-ID: On Fri, 6 Jul 2001, Skip Montanaro wrote: > > Alexandre> If I use the default server, the following call causes an > Alexandre> error on the server: > > ... print server.echo('\231') > > Alexandre> Is this a bug in xmlrpc or in the underlying xmllib ? > > Neither, I think. The default encoding for XML is utf-8, not latin-1. In > addition, XMLRPC only supports ASCII. Well, maybe, but xmlrpclib says that is supports unicode strings in arguments. > Try > > server.echo('a') This obviously works, but it's not what I'm asking about. However I get this \231 character from elsewhere (some webpage, actually), and I need to get a way to pass it around. Using server.echo(unicode('\231','latin-1').encode('utf-8')) dies not help either. If I test with a loop such as for a in range(256): print a,'%c'%a try: print repr(server.echo(unicode('%c'%a,'latin-1').encode('utf-8'))) except Error, v: print "ERROR", v I get errors for chars in range (decimal) 0-8,11-12,14-31,127-159,192-223. For range 0-8,11-12,14-31 I can understand that there might be a problem somewhere, because these are controle characters. For range 127-159, I can understand, because the chars are left undefined in latin-1, but 192-223 are valid latin-1 characters as far as I know (capital accentuated letters mainly). Alexandre Fayolle -- LOGILAB, Paris (France). http://www.logilab.com http://www.logilab.fr http://www.logilab.org Narval, the first software agent available as free software (GPL). From guido at python.org Sat Jul 14 11:28:23 2001 From: guido at python.org (Guido van Rossum) Date: Sat, 14 Jul 2001 15:28:23 GMT Subject: Language change and code breaks References: <3B4E586D.35460F68@engcorp.com> <3B4FAC17.48377423@engcorp.com> Message-ID: Tim Churches writes: > version 2.1 /* emulate Stata 2.1 */ > ...assorted old Stata code.... > version 6.5 /* emulate Stata 6.5 */ > ...newer code... > version 7.0 /* revert to current version behaviour */ > ...code to take advantage of latest changes to syntax... I have no doubt that we *could* implement this. It would be fine to only accept one version statement per module, as long as modules using different versions could be used together. The __future__ statement does this. But it's butt-ugly, and encourages keeping unmaintained code around. It also becomes a burden on the programmer, who has to maintain all this cruft and has to keep old manuals around etc. I find it a last resort. The nice thing about __future__ statements is that eventually you will be able to take them out, unlike version statements. --Guido van Rossum (home page: http://www.python.org/~guido/) From sh at ttsoftware.co.uk Tue Jul 24 09:33:47 2001 From: sh at ttsoftware.co.uk (Steve Horne) Date: Tue, 24 Jul 2001 14:33:47 +0100 Subject: PEP0238 lament References: <9jgvbc$dos$1@newshost.accu.uu.nl> Message-ID: On 23 Jul 2001 19:41:48 GMT, Marcin 'Qrczak' Kowalczyk wrote: >Mon, 23 Jul 2001 18:45:12 GMT, Grant Edwards pisze: > >>>But ints *are* implicitly converted to floats when needed >> >> Language design mistake. > >It allows to write code which increments a number of unknown type >by one. How would you write it in your universe? Well, in the Ada universe - where clarity, simplicity and reliability (but not conciseness) were explicit language design goals - no typecasts are ever done implicitly. In Ada, 'velocity := distance / time' may well be an error - unless you've make sure you have operators that deal in the right mixture of types. The benefit happens when you have a temporary fit and type 'velocity := distance / velocity' or some such - if your types are set up right, that's an error because the division operator for distance_type divided by velocity_type should return time_type - same as keeping track of the units in physics - and you can't assign a time_type into a distance_type. The fact that all three types are probably implemented with exactly the same numeric representation is irrelevant. Literals can be used for any type where the representation matches, so incrementing is not a problem. There's some compile-time-only type for 'untyped' numbers as well, so you can name a value and more or less treat it as a literal if necessary (an often misused feature - you wouldn't believe the number of programs with the identifiers 'zero' and 'one' defined). -- Steve Horne Home : steve at lurking.demon.co.uk Work : sh at ttsoftware.co.uk From enrico.spinielli at marconi.com Mon Jul 23 11:18:56 2001 From: enrico.spinielli at marconi.com (Enrico Spinielli) Date: 23 Jul 2001 17:18:56 +0200 Subject: PyUnit and Jython Message-ID: Hi all, is anybody using PyUnit or any other unit test framework for jython 2.0? If so, can you please point me to some useful link or tell me about your experience with unit testing jython scripts? Thanks in advance Enrico From werme at mediaone.net Wed Jul 18 09:43:52 2001 From: werme at mediaone.net (Ric Werme) Date: Wed, 18 Jul 2001 13:43:52 GMT Subject: All computers in the world MUST sync with ATOMIC clock before 12:00 AM 21 July 2001!!! References: <3B54F839.AC6C11C3@yahoo.com> Message-ID: alavoor writes: >All computers in the world MUST sync with ATOMIC clock before 12:00 AM >21 July 2001!!! >hello: >You must sync your PC's date and time with Cesium Atomic clock. Garbage! >Use this very small and tiny program written in PHP. "This won't hurt a bit!" At least you aren't hawking a .EXE virus. What wrong with NTP? (Assuming one needs his computers' time to be accurate.) -- Ric Werme | werme at nospam.mediaone.net http://people.ne.mediaone.net/werme | ^^^^^^^ delete From hgiese at ratiosoft.com Wed Jul 11 14:37:33 2001 From: hgiese at ratiosoft.com (Helmut Giese) Date: Wed, 11 Jul 2001 18:37:33 GMT Subject: shortest match regexp operator anyone? References: Message-ID: <3b4c9b7f.8143238@news.hrz.uni-kassel.de> Hello Harald, >2) TASK: Find the first '' and match, if it is followed by a 'B' > SOLUTION: ??? I would - naivly - do it in two steps: 1) Find the first ''. 2) Return a match only if it is followed immediately by 'B'. But I concede voluntarily that this solution has two drawbacks: 1) It doesn't solve the intellectual challenge. 2) It's not a one-liner and as such not really acceptable. :) Best regards Helmut From ljohnson at resgen.com Tue Jul 10 09:37:27 2001 From: ljohnson at resgen.com (Lyle Johnson) Date: Tue, 10 Jul 2001 08:37:27 -0500 Subject: An unspeakable act References: Message-ID: > it is just used for small to medium scripting. I know better but I don't have any proof. Can anyone > point me at a list of companies and the applications they have written (I already know about Zope > and I can't find the list of companies on the Python website since they moved the page to PSA). Daniel, Even though the main PSA page has moved this link still works (as of this morning): http://www.python.org/psa/Users.html Hope this helps, Lyle From nhodgson at bigpond.net.au Tue Jul 3 09:36:46 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Tue, 03 Jul 2001 13:36:46 GMT Subject: Is Python Dead? References: <9hp1f002dp6@enews4.newsguy.com> <9hq62g0kiq@enews4.newsguy.com> <008701c1037d$f6280de0$0101010a@local> Message-ID: Paul Prescod: > Is anybody else suspicious about the sudden uptick of troll-like > behavior on comp.lang.python? Keep an eye out and don't bother > responding to anything inflammatory. Its that damned PSU - Martijn must have let something a little sensitive out and they're flooding the group hoping to From cliechti at mails.ch Sat Jul 28 23:27:36 2001 From: cliechti at mails.ch (chris liechti) Date: 29 Jul 2001 05:27:36 +0200 Subject: Best practices with import? References: <9jvnoe$om2$1@slb5.atl.mindspring.net> <3B6369D4.671C1870@alcyone.com> Message-ID: Erik Max Francis wrote in news:3B6369D4.671C1870 at alcyone.com: > def main(): > import sys # here's the only place that sys gets used > lines = sys.readlines() > # do something with lines ... > > if __name__ == '__main__': > main() > > I'm really not sure what the value would be in deleting the module after > you're through with it, except perhaps to clean up namespaces, which I > wouldn't think would be useful if, say, it were defined in the scope of > a function. > i think the module gets deleted anyway because its imported into the local namespace of the function and that gets deleted after the function returns. there is a performance argument against "import"ing in functions: if this fu is called in a loop the module gets imported and deleted every time. importing it at top level doesn't need that and hence the loop runs faster. on the other hand for debugging functionality that is later removed i find it appropriate to import only there where its needed. and for modules that are only used in "__name__ == '__main__'" section, it's also very suitable. and yes there is a "cache" see here: --cut--------file: mymod.py print "mymod" --cut--------test code: import mymod mymod.a = 1 def fu(): import mymod print "fu" print dir(mymod) fu() --cut-------this is the output: mymod fu ['__builtins__', '__doc__', '__file__', '__name__', 'a'] --cut------- as you can see the main module alters "mymod" and this change can be seen in the function where it is imported another time. -- chris From robin at brainexeculink.com Mon Jul 23 08:20:22 2001 From: robin at brainexeculink.com (robin at brainexeculink.com) Date: Mon, 23 Jul 2001 08:20:22 -0400 Subject: web sessions support References: Message-ID: Jeff Davis wrote: >I have been looking around and I have not been able to find a session >module for python (for the web). Basically I just need a normal session >manager that can work somewhat like the one in PHP. I have recently been >moving away from PHP to python for web stuff and I need a session manager. >If no such module exists, I would write my own. Well, that's what I did! I built session support on top of Wasp, my platform-independent open-source HTML preprocessor. Written in Python, this framework provides an organised way of designing and programming a web application. Template files containing powerful Wasp tags may be easily customized through plug-in Python modules. It's like PHP or ASP, except with the powerful Python language at your fingertips. It's here: http://www.execulink.com/~robin/wasp/readme.html Wasp is up to version is 1.25. Contributions are welcome! ----- robin robin at brainexeculink.com (remove "brain" to reply) From sh at ttsoftware.co.uk Mon Jul 23 14:15:34 2001 From: sh at ttsoftware.co.uk (Steve Horne) Date: Mon, 23 Jul 2001 19:15:34 +0100 Subject: PEP0238 lament References: Message-ID: <11moltg2i6s1ftkpku5dkr0cmifn9f5q1o@4ax.com> On Mon, 23 Jul 2001 16:07:45 GMT, "Tim Hochberg" wrote: >Let me stray from the topic for a paragraph here: I'm astounded to discover >the number of people pining for integer division that truncates towards >zero. That sort of integer division is horriible. When programming in C, I >always had to simulate Python's behaviour in order to get code that might >take both positive and negative integral values to work correctly. Python >gets this exactly right. Probably a good point. I have tended to expect division to round towards zero - I tend to expect (-a / b) == -(a/b) - but I do appreciate the extra conditionals and general hacks you can end up needing as a result. I suppose it depends on what you are doing with integers - and given that most my integers - being subscripts and indices - are rarely negative anyway, it's not a big deal anyway. On this one, my current feeling - a rather vague and dubious preference I admit - is towards rounding towards zero. Python rounds towards -inf. Yet I am *not* in favour of changing Pythons behaviour at all. Division resulting in negatives will be much rarely than general division - much fewer than half of all cases - because of the subscripts/indices bias - yet this would still cause much too many problems to consider it whatever my personal opinion. >thing. I couldn't disagree more. C-style division in a dynamically typed >language is an accident waiting to happen. And does this mean that code There are many ways to deal with that, without pretending that floating point division is somehow fundamentally different to integer division when in fact it is simply a logical extension of the same operation. >Anyway, not being an educator, I'm not particularly concerned with whether >integer division is easy or hard to learn. I like the proposal because there >just isn't a good way currently to spell >divide-these-two -numbers-using-normal-division. The fact that oponents of So add a new operator for the new functionality - but don't change the semantics of the existing one people have been using for years. >It has been suggested as recently as this morning, I believe, that this be >rewritten: > >def simple_func(x, y): > return y / float(x)**2 > >This is simple, clear and ... wrong, as Konrad Hinsen pointed out several >days ago. At least it's wrong if complex numbers are ever a possibility. One Obviously - if complex numbers are considered valid inputs then that function is wrong. What you are saying, though, is that integer inputs are invalid and should be coerced to floats. That *CAN* be tested for and done now without ANY changes to the language. If it's too awkward, then what is needed is a simpler way to do achieve that. I have suggested several ways to achieve this kind of result, and one that achieves EXACTLY that. NONE of those suggestions would break old code. NOBODY has replied in any way to any of them though. how about... def simple_func(x, y): $coerce x, y : $integer -> $float return y / x**2 Notice I even used my simple prefix-to-indicate-keywords idea to avoid breaking any 'coerce' identifiers anyone might be using. I admit the syntax hasn't been thought through - I'll bet there's a dozen holes picked in it before tomorrow morning - but the principle is simple, clear, effective and non-destructive. I think thats number five for my plausible alternatives. -- Steve Horne Home : steve at lurking.demon.co.uk Work : sh at ttsoftware.co.uk From kirschh at lionbioscience.com Tue Jul 10 05:07:29 2001 From: kirschh at lionbioscience.com (Harald Kirsch) Date: 10 Jul 2001 11:07:29 +0200 Subject: import namespace issues Message-ID: THE PROBLEM: I have to separate a module's function into two .py-files. Now I would like to import both in a way that they behave like they are one file. FIRST TRY: Suppose the files are called first.py and second.py. I put a from second.py import * into first.py. This does not work as necessary since functions in second.py don't find functions defined in first.py. Same story when using __import__(). FINDINGS: What I gathered from experiments is that even with `from ... import' as well as when using __import__('second', my_globals, my_locals) there will *always* be a *new* dictionary used for the globals() of the imported functions. Example: Given that second.py contains def doStuff(): print hex(id(globals())) it will not report the same id as print my_globals even if imported with __import__ as shown above. QUESTION 1: How can I achieve to merge two .py into one globals() as if the were in one imported file while maintaining the file-search semantics of `import'? QUESTION 2: Is there a detailed description somewhere in the docs about the namespaces (or dictionaries) used/created/shuffled during an import? Thanks, Harald Kirsch -- ----------------+------------------------------------------------------ Harald Kirsch | kirschh at lionbioscience.com | "How old is the epsilon?" LION bioscience | +49 6221 4038 172 | -- Paul Erd?s *** Please do not send me copies of your posts. *** From guido at python.org Mon Jul 23 07:46:45 2001 From: guido at python.org (Guido van Rossum) Date: Mon, 23 Jul 2001 11:46:45 GMT Subject: A use for integer quotients References: Message-ID: > [David Eppstein] > > I don't suppose it would be possible to go through some repository of > > Python sources and figure out the relative numbers of divisions > > of integer arguments that end up an int versus the ones that are > > coerced to floats? [Tim Peters] > Guido did this for the Python library, and found three instances of "/" that > would break. Alas, all this suggests is that the test suite *still* doesn't have enough coverage. Looking for '/' tokens I found 30 modules using '/' amongst Lib/*.py, and a quick inspection suggests that the majority of these use integer division -- an expected result, given the over-emphasis of the standard library on classic data types and algorithms, which were mostly developed in a culture that despises floating point numbers as too expensive. :-) But I also found a likely bug! In colorsys.py, there are two routines (rgb_to_hls() and rgb_to_hsv()) that seem to be doing floating point math using (r, g, b) inputs and don't take any consistent precaution to cast these inputs to floats before dividing them. The outputs are definitely intended to be floats. The inputs are likely RGB triples taken from images, which are usually ints. This is why making / fractional division and // truncated division will reduce the number of bugs in new code: for all occurrences of truncated division, the author *knows* she wants truncated division, and it's easy to remember to use // because using / gives an immediately wrong result. When the users wants fractional division though, it's common to test only with float inputs, or to miss a path through the code where ints aren't casts to floats before they are being divided. Then, much later, when an int gets passed and a slightly wrong result is calculated, it takes hours of debugging to discover the error. Note that this kind of bug is unique to Python (or dynamically typed languages in general): in C, the arguments would have been declared as floats and the problem would have been prevented. Reiterating why the current definition of '/' is evil: int and float together aren't really two distinct types: they are at most a type-and-a-half, and the integers are embedded in the space of floats for most practical purposes. Division is the one exception, and it hurts. Nobody wants to write polymorphic code where '/' means truncated division for int arguments but fractional division for float arguments. You know which kind of division you want when you write the code, but there's no way to spell it. (I've seen this countered with the argument that classes can overload / any way they want, and thus you can't rely on the "meaning" of / anyway. But there you get what you ask for, and it's up to the author of the class to decide how her class needs to behave in the context of other numeric types. How integers behave in the context of floats is already decided: you should be able to pass an int whenever something requires a float.) Of course, I'm well aware of the issues around maintaining old code. We will have to carry around "from __future__ import division" for a loooooong time. Python 2.2 is the first opportunity to introduce it, so let's not be shy. --Guido van Rossum (home page: http://www.python.org/~guido/) From mikeb at mitre.org Wed Jul 18 17:34:28 2001 From: mikeb at mitre.org (Mike Brenner) Date: Wed, 18 Jul 2001 17:34:28 -0400 Subject: greenbeen seeks advice (24 recommended exercises) Message-ID: <3B5600E4.4B03A51F@mitre.org> Wyatt > Do I need to know what is taught in CompSci 101/102/etc, to be great? The part that you need from Comp Sci 101/102 (in making a program that fully meets its specifications) is in the book DISCIPLINE OF PROGRAMMING by Edsger Dijkstra. That book shows how to compute preconditions that are required to meet a spec. It also gives quite a few good examples of simple and complex programs to write. However, most programmers don't write programs that meet specs. Most programmer define greatness to be simply having fun while making money. To be great in that sense, instead of meeting specs, write the following Python programs (and for extra credit, do each program twice -- once using wxPython graphics, and once using Jython.) 1. Algebra. Accept inputs from the user which are two lines in the form Y = m1 X + b1 Y = m2 X + b2 That is, the user inputs the numbers m1, b1, m2, b2. The two m's are the slopes of the two lines. The two b's are the y-intercepts. The python program will draw the first line in blue and the second line in green on a pair of axes in black. Then a Red Cross will be placed at the intersection of the two lines. Write a test program that tests this for lines in various positions, slopes, and intercepts. Recover from the problem that parallel lines don't intersect at all. 2. TABLES. Neatly display a two dimensional table of numbers, as well as displaying the sum of each row at the end of that row, the end of each column at the bottom of that column, and a grand total row sum and a grand total column sum (which should be the same). When you recompile the program with different values in the table, the row and column and grand total sums will change appropriately. 3. ROTATION. Display a red square, a blue square, and a green square rotating across the page. 4. TEXT. Write a 3-line message to the screen inside a rectangle, such that each time you compile it with a different message, the rectangle adjusts its height and width, so it is a skootch larger than the text. 5. SIMPLE BOXES. Let box be defined as . Store an array of boxes. Display the boxes with their text at the proper (x,y) location on the screen. 6. SIMPLE ARROWS. Let arrow be defined as . In an applet, store and array of boxes and an array of arrows. Let the applet display the boxes with their text at the proper (x,y) location on the screen, and the arrows connecting the boxes neatly. 7. FINITE STATE MACHINE. Implement a Python program that reads in a list of states, character classes, transitions, and transductions (output translations), and produce a Python program that implements them as a Finite State Transducer. (See Epstein's WORD PROCESSING IN GROUPS chapters 1 and 2.) 8. PYTHON SERVER PAGE. Install Apache and write a simple Python Server Page with CGI communication. 9. ODBC. Same as (2) above, but get the data from a SQL database via ODBC instead of from an internal array. 10. THREADS. Same as (3) above, but let each of the squares be in a different thread. 11. HTTP ARROWS. Same as (6) above, only get the files of arrows and boxes from a URI via HTTP. 12. HTTP FSM. Same as (7) above, only get the states, etc. via HTTP. Also implement an action table with code to be executed upon each transition. 13. SHOPPING BASKET. Create a set of Python Server Pages that implement a simple Shopping Basket, permitting searching a database of products, put selected products into the shopping basket, update the quantities in the shopping basket, charge credit cards or budget allocations from a simulated bank, ship via a simulated shipping company from a simulated warehouse, and notify a simulated marketing department of how many widgets were sold. 14. TREE. Retrieve a tree structure from an http file and walk the tree graphically in an applet that demonstrates recursive tree walks, multiple class constructors, inheritance, preconditions, mixing text and graphics, and generating XML from the tree structure. 15. SOCKETS. Send information back and forth between computers via sockets and via ftp. 16. MOUSE CLICKS. Same as (10) above, except control the motion of each square via mouse clicks and drags. 17. THREE DIMENSIONS. Same as (16) above, except in three dimensions. 18. MOUSE ARROWS. Same as (6) above, except the mouse can add or delete or move boxes, add or delete or move arrows, change the color of boxes or arrows, examine the contents of boxes, etc. 19. MERGE. Given a Master file consisting of data fields and a unique key field, and a Detail file consisting of data fields and a non-unique key field, produce three output files. First, the intersection consisting of the keys and data from all records whose keys match in the Master and the Detail files. Second, the records in the Master file that have no matching keys in Detail. Third, the records in the Detail file that have no matching keys in Master. 20. DOM. Read an XML file into a DOM tree and process the tree, looking for all system nodes. For each system nodes, call the required external program to process the system node, passing the parameters correctly. Test it with external program that include encryption, decryption, database queries, database updates, etc. 21. LL(1). Given an LL(1) grammar at a URI and a document at another URI, create a recursive descent transducer from the grammer and execute that transducer against that document, generating code for a virtual machine. 22. THREE TIER. Convert the shopping basket from (13) above into a full three-tier system. 23. GAME. Create a multi-player multi-computer game. 24. SEMANTICS. Create a Python program that clusters ideas together in multi-dimensional semantical space and creates a four-dimensional visualization of how close they are, how much they are coupled, and how much cohesion they have. Test it on Shakespeare's Sonnets, on the Python Source Code, and on the TeX version of Michael Spivak's CALCULUS. Substitutions in the assignments can be arranged with the instructor. From hfoffani at yahoo.com Sun Jul 29 17:00:54 2001 From: hfoffani at yahoo.com (Hernan M. Foffani) Date: 29 Jul 2001 21:00:54 GMT Subject: FEEDBACK WANTED: Type/class unification References: <3B643C58.1C6C94F9@ActiveState.com> Message-ID: <20010729170054.141$Pa@newsreader.com> I hope this msg is not too far away from what you expected by "FEEDBACK WANTED". If I understood the unification correctly, in http://www.python.org/2.2/descrintro.html where it reads: >>> print a.keys() [1, 2, 3, '__builtins__', 'x'] the 3 is a typo, right? And where it says, But notice this: class E(C): def foo(x, y): # override C.foo print "E.foo() called" C.foo(y) Isn't a call to "foo = classmethod(foo)" missing after that? If so, in the PEP the call is missing too. One minor suggestion: I think it would help if you set a convention for the name of the first argument in classmethods. Like self for standard methods. Well, even self can "work" here, too. Regards, -Hernan -- -------------------- http://NewsReader.Com/ -------------------- Usenet Newsgroup Service From tim at vegeta.ath.cx Sun Jul 15 21:24:40 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Mon, 16 Jul 2001 01:24:40 GMT Subject: OO misconceptions References: <9ir1l7$3ja$1@panix2.panix.com> <9irfbc11jaq@enews1.newsguy.com> <3B52314B.F7F73ED5@engcorp.com> Message-ID: Me parece que Peter Hansen dijo: > Tim Hammerquist wrote: > > But what does 'larger' mean in this case? Larger than the MySQL engine? > > Larger than a linux kernel? Larger than the Red Hat install scripts? > > Yes. Yes. And yes. Ok. Not hard. And not hard. > (Oh, sorry... how big are those programs? No, wait, it doesn't matter.) No, it doesn't. The use of 'larger' was just vague IMO. > > I wouldn't implement a RDBMS in Python. Nor would I implement a word > > processor in assembler. > > Neither would I. An RDBMS would most likely need performance beyond > what Python could provide, but if that were not the case, Python would > most certainly be an option. (I don't know what assembler has to do > with this discussion, but I would prefer Python over it for writing > a word processor, performance issues aside. Performance issues > included, I might use a little bit of assembler for the hot spots > of the word processor, but a more reasonable choice would be C, of > course. A good way of writing very large applications in Python > would be to have the performance-critical parts coded not in Python, > then spend the development effort where it counts on the higher level > complex functionality, and testing.) You've made my points for me. =) (Tho I'd probably do the DBMS in C, with a Python front-end and API hooks.) > > *nix OSes (like BSD) have attained an incredible scalability. > [...] > > And what language is the > > majority of the core of BSD written in? It's written in C, which does > > not even claim to be an OO language. > > Typical Python applications, even really large ones, would not likely > have the sheer number of programmers working on it that the BSD core > has had, nor the length of time they've worked on it. True. Python's age and amount of support were not the point. The point was that even C can implement large, scalable, OO-type ideas like abstraction. > > An application's scalability has much more to do with the programmer's > > use of algorithms and abstraction than with the language in which it's > > implemented...no matter how much money ActiveState has invested in it. > > Did you write all this just for this jab at ActiveState? I know of the > opinion some people have of them, but I didn't sense that *someone*'s > posting contained anything more commercial or biased than what many of > the rest of us, who don't work for ActiveState, have written. Maybe I was wrong in my inferrence, and this probably isn't the location for personal opinions on corporate business practices. But no; the jab just came to me while writing. > You're right about algorithms having more to do with this issue than the > language, but some languages support better algorithms (by making > their implementation easier and less buggy) and faster development than > others. Those are merely two of the ways in which Python supports > "larger" applications. All very good points. I have certain reservations, tho. I dread waiting for Microsoft Word to startup as it is, written in compiled C++. I fear for the speed of anything of that scale and complexity implemented in Python. My $0.03US -- Me? Lady, I'm your worst nightmare -- a pumpkin with a gun. -- Mervyn Pumpkinhead, The Sandman From bsass at freenet.edmonton.ab.ca Thu Jul 19 18:08:46 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Thu, 19 Jul 2001 16:08:46 -0600 (MDT) Subject: Language change and code breaks In-Reply-To: <200107191933.f6JJXZF17263@odiug.digicool.com> Message-ID: On Thu, 19 Jul 2001, Guido van Rossum wrote: > > I'm still wondering what advantage there is to crippling the > > expressivity of a language for the sake of a small group of > > non-programmers. > > IMO there are two non-truths in this statement. > > (1) The expressivity of the language is not crippled. I defined what I mean by "exressivity" in a previous post, no one complained, so I continue to use it... With a case-insensitive language "a" == "A", so you would need to do "a_first" and "a_second" (whatever); the ideas represented by "a" and "A" can be referred to more succinctly in a case-sensitive language, so I went so far as to say case-sensitive is more expressive than case-insensitive. ...feel free to s/expressive// The short of it is... ya got less symbols to work with, therefore it is less ... why is that good for programmers? > (2) Potentially, the group of non-programmers is much larger than the > group of programmers (and it's easier to teach programmers an > arbitrary rule than non-programmers). Ok... it is not the group that is small, but the amount of programming done by the individuals in the group... why should a general purpose programming language cater to a group who rarely program? Surely that is best left to a specialized language that addresses the concerns of that group, and not foisted upon those who use the language everyday. - Bruce From nospam at newsranger.com Thu Jul 5 18:28:07 2001 From: nospam at newsranger.com (Levente Sandor) Date: Thu, 05 Jul 2001 22:28:07 GMT Subject: Building an embedded Python application with Borland C++ References: Message-ID: You will find useful information at: http://www.cyberus.ca/~g_will/pyExtenDL.shtml The page refers to extendig Python with the Borland 5.5 C++ compiler but I hope it works for embedding too. If you don't need C++, you can use the free LCC-Win32 compiler: http://www.cs.virginia.edu/~lcc-win32/ -- it works for both embedding and extending. Levi In article , Lothar Scholz says... > >I have the problem that i can build an import library from the >python20.dll but not link my program against it. > >Python is compiled without the preceding underline character, so >i must compile my application with the -u- option. But when i do >so the runtime library can't find a "_main" function because it is >now compiled as "main". > >Has anybody solved this problem or has a makefile to build the >complete python DLL with the Borland 5.5 version. From morten at thingamy.net Thu Jul 26 12:08:03 2001 From: morten at thingamy.net (Morten W. Petersen) Date: Thu, 26 Jul 2001 18:08:03 +0200 Subject: Building a minimal Python 2.2 for Windows Message-ID: Hia, I've just tried to build a small Python distribution that will fit on a floppy disc (to do some cleanups on the filesystem without starting windows itself); however, the message python22.dll is needed.. ..now, I've just copied a couple of files from the install directory, files like python22.exe and certain .py and .lib files, can't find the python22.dll file though.. Any ideas? Does there exist a minimalistic Python 2.2 distro for Windows? Thanks, Morten From dgrisby at uk.research.att.com Fri Jul 27 06:32:10 2001 From: dgrisby at uk.research.att.com (Duncan Grisby) Date: 27 Jul 2001 10:32:10 GMT Subject: Going from webscripting to server-client software. References: <6572890e.0107251014.47e07810@posting.google.com> <9jop6k$l2d$2@pea.uk.research.att.com> <97ae44ee.0107262210.795d3e0e@posting.google.com> Message-ID: <9jrfva$dhj$1@pea.uk.research.att.com> In article <97ae44ee.0107262210.795d3e0e at posting.google.com>, Stephen wrote: [...] >Thank you very much, Duncan. After looking around for a couple of days (hence >my late followup. sorry), it does seem like my options are >(a) CORBA >(b) SOAP >(c) XMLRPC >(d) Pyro You might want to add DOPY, which is along the same lines as Pyro: http://www.users.cloud9.net/~proteus/dopy/welcome.html I don't know anything about it, though. >CORBA has always been intimidating. So much work just to do "hello world", >let along build a full app. People often say this, but it just isn't true, especially if you use Python. "Hello world" doesn't make a lot of sense in a distributed application, but here's the full code for a "fortune cookie" service. First, declare the interface in IDL: // fortune.idl module Fortune { interface CookieServer { string get_cookie(); }; }; Now convert it to Python declarations with your chosen ORB's IDL compiler, for example with omniORBpy: $ omniidl -bpython fortune.idl [ orbit-python doesn't have the IDL compiler step -- it always compiles it on the fly. ] First the client, on the Python command line: >>> import CORBA, Fortune >>> orb = CORBA.ORB_init() >>> o = orb.string_to_object("corbaloc::spud.uk.research.att.com/fortune") >>> o = o._narrow(Fortune.CookieServer) >>> >>> print o.get_cookie() Objects are lost only because people look where they are not rather than where they are. >>> print o.get_cookie() "I'd love to go out with you, but I'm staying home to work on my cottage cheese sculpture." There really is a fortune cookie server running on spud.uk.research.att.com, so you can run this example. Now the server: #!/usr/bin/env python import sys, os import CORBA, Fortune, Fortune__POA FORTUNE_PATH = "/usr/games/fortune" class CookieServer_i (Fortune__POA.CookieServer): def get_cookie(self): pipe = os.popen(FORTUNE_PATH) cookie = pipe.read() if pipe.close(): # An error occurred with the pipe cookie = "Oh dear, couldn't get a fortune\n" return cookie orb = CORBA.ORB_init(sys.argv) poa = orb.resolve_initial_references("RootPOA") servant = CookieServer_i() poa.activate_object(servant) print orb.object_to_string(servant._this()) poa._get_the_POAManager().activate() orb.run() That's it. Note that about half the lines of code are nothing to do with CORBA -- they're just getting the fortune cookie. When you run the server it prints a long hex string like: IOR:010000001d00000049444c3a466f7274756e652f436f6f6b69655365727665723 a312e300000000001000000000000005c000000010102000d0000003135382e313234 2e36342e330000f90a07000000666f7274756e6500020000000000000008000000010 0000000545441010000001c0000000100000001000100010000000100010509010100 0100000009010100 which can be given to orb.string_to_object (without the line breaks). That IOR string is also the server running on spud.uk.research.att.com. A version of the server that can be used with the corbaloc URI is just as simple, but omniORB specific, so I haven't shown that. Cheers, Duncan. -- -- Duncan Grisby \ Research Engineer -- -- AT&T Laboratories Cambridge -- -- http://www.uk.research.att.com/~dpg1 -- From loewis at informatik.hu-berlin.de Tue Jul 31 11:15:18 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 31 Jul 2001 17:15:18 +0200 Subject: Error on mimetools? References: <9k368v$a8q$1@news.uit.no> <9k3l62$d31$1@news.uit.no> Message-ID: "Arnulf Heimsbakk" writes: > I'm using only the raw base64 text. It is the same text I used in my winzip > experiment and in python test program I've made. It works in winzip but not > with python code. As I mentioned python gives me a file slightly bigger than > winzip. It's about 300 bytes bigger. > > I'm without clues to this one. It does not seem to be any logic in the > error. If you want others to help investigate the problem, please put the file you are trying to process and a code snippet that you use to process it somewhere on the Web, and post an URL. If you think there is a Python bug, you might also report one at python.sf.net. Regards, Martin From paulp at ActiveState.com Thu Jul 5 08:48:59 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Thu, 05 Jul 2001 05:48:59 -0700 Subject: Comment on PEP-0238 References: <3B3BE855.A6223E70@3-cities.com> <7ef50c46.0107020554.31cc948b@posting.google.com> <7ef50c46.0107030657.2e0fc92b@posting.google.com> <3B42B152.5EC4F056@3-cities.com> <3B43AE03.F58B72C7@3-cities.com> Message-ID: <3B44623B.1E30897B@ActiveState.com> "Robert J. Harrison" wrote: > > Paul Prescod wrote: > > "Robert J. Harrison" wrote: > > > Python does not undermine the distinction between integers and floats. > > >>> 5 + 10 > > 15 > > >>> 5 + "10" > > Traceback (most recent call last): > > File "", line 1, in ? > > TypeError: number coercion failed > > You seem to want to have the string "10" automatically > converted to be an integer. PEP-0238 will have no > impact on this. > > Python extensively distinguishes between numeric > types and other types. That's my *exact* point. Python strongly enforces the view that there are "numbers", "strings".... not "integers", "floats", "strings" Integers and floats are strongly related. Much more so than other types. No, I do not want to change the behaviour of either of these lines. I'm making the point that a threshold has been crossed. The distinction between integers and floats has been blurred. The logical conclusion is to treat integers as a special case of floats everywhere. >... > One of the great virtues of Python is indeed dynamic typing, > and I am not struggling to preserve type consistency. I do think > that the current behaviour is more consistent with the properties > of mathematical integers, and for this reason I have had no trouble > in communicating to students the expected behaviour. I don't see how we are talking about the fundamental properties of integers. From my point of view, we're talking about the choice of meaning for a symbol. Outside of a cultural context, the choice is meaningless. As far as the mathematical construct "integers" are concerned, we could as well use "/" to mean "to the power of". > My comments have been directed at > > - the assumption that the change will help beginners. I believe > this to be incorrect - the PEP merely moves the point at which > they must appreciate the difference between integer and > floating point arithmetic. Once we've moved the point of confusion back, we can recognize the next roadblock and move it back further. There are many other PEPs that address other issues in the numeric model. This is one of them. > - the amount of code that is broken No argument there. > Hinsen and others have noted that functions written to expect a > floating point argument will behave more consistently if they > are mistakenly given an integer argument. The PEP will indeed > accomplish this. But so would other far less drastic mechanisms. > > You cite an example above. cos(5) does the "right" thing. It > is a property of the function itself, not the argument > passed to it. cos(5) does the "right" thing because Python's C API is statically type checked and it coerces integers to floats for the implementor automatically. In other words, C programmers do the easiest thing and get code that automatically coerces properly. Python programmers get no such free ride. It takes extra care to write a function that treats integers as a special case of float....but ONLY if it involves division. If it involves multiplication or anything else, it isn't a problem. > But cos("5") also (correctly in my view) gives a > type error. I agree that that's the right thing. Strings and integers are very different in Python. Integers and floats are blurred together by the implementation and the language semantics. > ... > This issue is only mentioned in passing in this article and no > reference is given to an actual survey. Can U please post a better > link to the reference? All I can find on Prof. Pausch's > home page or with a Google search are either third party notes from a > Python conference or papers on Alice that again only touch on this > issue in passing. I'm a big fan of Alice, so I know he knows about > usability, but I'd like to see his description of how the survey > was conducted and his conclusions. I agree that I'd like to see more detail but I only know what he said at the talk. Nevertheless, I don't really see it as useful to over-emphasize that one data point. Let me offer the following concrete observation. Python is the *only* dynamic language that I know of that makes this choice. JavaScript, Tcl, Perl and (I think) Ruby, int/int -> float. In fact, most of the newer languages always treat integers as integral floats (or in Ruby Integer is a subclass of Numeric). Python is also the only language where people complain about the division behaviour and have arguments about it every six months. Consider that a massively distributed usability test. You make integers a subset of floats and users are happy. You give them different operations and you get perpetual Usenet filler. There is only one humane choice. :) >... > Integers have properties that most floats do not - so forcing the > coercion > of integers to floats in *some* pure integer expressions is a matter > of choice. It is only this choice that PEP-0238 is addressing. I agree 100%. All I argue is that the choice for division should be consistent with the choice made elsewhere to treat integers as a special case of floats. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From jblazi at hotmail.com Tue Jul 24 16:00:37 2001 From: jblazi at hotmail.com (Janos Blazi) Date: Tue, 24 Jul 2001 22:00:37 +0200 Subject: size of a file Message-ID: <3b5dd418_8@news.newsgroups.com> How can I find out the length of a file. I have a descriptor fd of the file (I am using the os module). Janos Blazi -----= 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 objectway at divalsim.it Fri Jul 6 10:00:45 2001 From: objectway at divalsim.it (Nicola Musatti) Date: Fri, 06 Jul 2001 16:00:45 +0200 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> <9i201402voe@enews1.newsguy.com> <9i2jva23cm@enews2.newsguy.com> Message-ID: <3B45C48D.413A5E@divalsim.it> Ciao, Alex. Alex Martelli wrote: [...] > Haven't done *identical* projects in C++ and Python yet, except > for Python extensions prototyped in Python then coded with Boost > Python, and for those (small extensions) it seems I'm about 4 > times more productive in Python than in C++. I have no personal > experience doing the same task in Python and Java, yet. How do you measure your productivity? Cheers, Nicola From mal at lemburg.com Tue Jul 17 08:11:21 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Tue, 17 Jul 2001 14:11:21 +0200 Subject: PEP: Defining Python Source Code Encodings References: Message-ID: <3B542B69.8C092964@lemburg.com> Roman Suzi wrote: > > On Tue, 17 Jul 2001, M.-A. Lemburg wrote: > > > After having been through two rounds of comments with the "Unicode > > Literal Encoding" pre-PEP, it has turned out that people actually > > prefer to go for the full Monty meaning that the PEP should handle > > the complete Python source code encoding and not just the encoding > > of the Unicode literals (which are currently the only parts in a > > Python source code file for which Python assumes a fixed encoding). > > > > Here's a summary of what I've learned from the comments: > > > > 1. The complete Python source file should use a single encoding. > > Yes, certainly > > > 2. Handling of escape sequences should continue to work as it does > > now, but with all possible source code encodings, that is > > standard string literals (both 8-bit and Unicode) are subject to > > escape sequence expansion while raw string literals only expand > > a very small subset of escape sequences. > > > > 3. Python's tokenizer/compiler combo will need to be updated to > > work as follows: > > > > 1. read the file > > 2. decode it into Unicode assuming a fixed per-file encoding > > 3. tokenize the Unicode content > > 4. compile it, creating Unicode objects from the given Unicode data > > and creating string objects from the Unicode literal data > > by first reencoding the Unicode data into 8-bit string data > > using the given file encoding > > I think, that if encoding is not given, it must sillently assume "UNKNOWN" > encoding and do nothing, that is be 8-bit clean (as it is now). To be 8-bit clean it will have to use Latin-1 as fallback encoding since this encoding assures the roundtrip safety (decode to Unicode, then reencode). > Otherwise, it will slow down parser considerably. Yes, that could be an issue (I don't think it matters much though, since parsing usually only done during byte-code compilation and the results are buffered in .pyc files). > I also think that if encoding is choosen, there is no need to reencode it > back to literal strings: let them be in Unicode. That would be nice, but is not feasable at the moment (just try to run Python with -U option and see what happens...). > Or the encoding must _always_ be ASCII+something, as utf-8 for example. > Eliminating the need to bother with tokenizer (Because only docstrings, > comments and string-literals are entities which require encoding / > decoding). > > If I understood correctly, Python will soon switch to "unicode-only" > strings, as Java and Tcl did. (This is of course disaster for some Python > usage areas such as fast text-processing, but...) > > Or am I missing something? It won't switch any time soon... there's still too much work ahead and I'm also pretty sure that the 8-bit string type won't go away for backward compatibility reasons. > > To make this backwards compatible, the implementation would have to > > assume Latin-1 as the original file encoding if not given (otherwise, > > binary data currently stored in 8-bit strings wouldn't make the > > roundtrip). > > ...as I said, there must be no assumed charset. Things must > be left as is now when no explicit encoding given. This is what the Latin-1 encoding assures. > > 4. The encoding used in a Python source file should be easily > > parseable for en editor; a magic comment at the top of the > > file seems to be what people want to see, so I'll drop the > > directive (PEP 244) requirement in the PEP. > > > > Issues that still need to be resolved: > > > > - how to enable embedding of differently encoded data in Python > > source code (e.g. UTF-8 encoded XML data in a Latin-1 > > source file) > > Probably, adding explicit conversions. Yes, but there are cases where the source file having the embedded data will not decode into Unicode (I got the example backwards: think of a UTF-8 encoded source file with a Latin-1 string literal). Perhaps we should simply rule out this case and have the programmer stick to the source file encoding + some escaping or a run-time recoding of the literal data into the preferred encoding. > > - what to do with non-literal data in the source file, e.g. > > variable names and comments: > > > > * reencode them just as would be done for literals > > * only allow ASCII for certain elements like variable names > > etc. > > I think non-literal data must be in ASCII. > But it could be too cheesy to have variable names in national > alphabet ;-) That's for Guido to decide... > > - which format to use for the magic comment, e.g. > > > > * Emacs style: > > > > #!/usr/bin/python > > # -*- encoding = 'utf-8' -*- > > > > * Via meta-option to the interpreter: > > > > #!/usr/bin/python --encoding=utf-8 > > > > * Using a special comment format: > > > > #!/usr/bin/python > > #!encoding = 'utf-8' > > No variant is ideal. The 2nd is worse/best than all > (it depends on how to look at it!) > > Python has no macro directives. In this situation > they could help greatly! We've been discussing these on python-dev, but Guido is not too keen on having them. > That "#!encoding" is special case of macro directive. > > May be just put something like ''# at the beginning... > > Or, even greater idea occured to me: allow some XML > with meta-information (not only encoding) somehow escaped. > > I think, GvR could come with some advice here... > > > Comments are welcome ! Thanks for your comments, -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From peter at engcorp.com Sun Jul 29 00:23:04 2001 From: peter at engcorp.com (Peter Hansen) Date: Sun, 29 Jul 2001 00:23:04 -0400 Subject: PEP0238 lament References: <18289ee4.0107261001.664eb547@posting.google.com> <18289ee4.0107271117.7df350d4@posting.google.com> <18289ee4.0107281021.468246a7@posting.google.com> Message-ID: <3B638FA8.8D24A152@engcorp.com> David Boddie wrote: > > Guido van Rossum wrote in message news:... > > Suppose that python 3.x would *always* have to be invoked as > > "python3". Would that still break legacy code? This approach was > > used successfully by Perl. > > That's a good compromise which will prevent a lot of breakage. As long > as you're happy with it, then I'm happy. How so? Wouldn't that just be something which forces people moving to Python3 to take a small explicit step, thereby allowing us to say, "Of course your code broke, you changed your executable, what did you expect?". This could be a "solution" if the change wasn't clearly communicated over the next two (or whatever) years before the change becomes the default, but assuming the change is widely publicized, what real benefit does it bring to force the name of the executable to be python3? And would the same benefit arise by having the default name of the executable be "python3", but not forcing it to be so? -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From cfelling at iae.nl Sun Jul 8 17:34:36 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 8 Jul 2001 23:34:36 +0200 Subject: Comment on PEP-0238 References: Message-ID: <9iajlc$4dj$1@animus.fel.iae.nl> Tim Peters wrote: ... > I'm sorry, Alex, but `` is here to stay. Guido is insanely fond of it! > Meaning no more than that he doesn't hate it <0.9 wink>. I see something > like > print ``1`+`2`` yuck, yuck, yucky-dy-yuck, it's not only yucky, it's nesting yuckyness, quite unlike other quote forms. -- groetjes, carel From m.faassen at vet.uu.nl Wed Jul 4 17:44:02 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 4 Jul 2001 21:44:02 GMT Subject: Pythonic Quote of the Week - sliding away... References: Message-ID: <9i02n2$c2e$2@newshost.accu.uu.nl> Carlos Ribeiro wrote: [snip] > The solution as proposed by the main python-dev guys - Guido himself and > Tim Peters - is that the community should take the responsibility to keep > the library, as we can see here: > [Guido van Rossum, 2001-06-30 05:53:49 PST] > So let's all do what we do best: the core developers (e.g. PythonLabs) > improve the language, and the community improves the library. > [Tim Peters, Date: 2001-06-30 21:01:05 PST] > 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. > As it's impossible to clone an army of timbots to solve this problem, we > must try to find another solution. I don't believe that we can sort this > issue without some involvement of PythonLabs and the core Python-dev guys. > The problem is not lack of good modules, but lack of *standard* modules. To > make a module standard, some level of Python-dev commitment is a *must*. I agree completely; I've been pointing this out myself. And I wrote a PEP that tries to account for both; I posted it just a bit ago. In it, I define two roles, integrators and maintainers. The integrators are PythonLabs (although some other group could be formed), and the maintainers can be anyone; hopefully people from the community. Anyway, see the text of the PEP for more information. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From jkraska1 at san.rr.com Sun Jul 1 12:43:20 2001 From: jkraska1 at san.rr.com (Courageous) Date: Sun, 01 Jul 2001 16:43:20 GMT Subject: Augmented Assignment (was: Re: PEP scepticism) References: Message-ID: On Sat, 30 Jun 2001 22:05:46 -0700, Paul Prescod wrote: >Courageous wrote: >> >It's funny how this discussion just goes around and around in circles. BTW, the problem you are talking about was in Python before augmented assignment came around: >>> tpl1 = (1,2,) >>> tpl1 = tpl1+(3,4,) >>> tpl1 (1, 2, 3, 4) >>> The tpl *appears* to be mutable, but it's not. C// From guido at python.org Tue Jul 24 20:41:11 2001 From: guido at python.org (Guido van Rossum) Date: Wed, 25 Jul 2001 00:41:11 GMT Subject: A use for integer quotients References: <3b5c4dc9$1@hpb10302.boi.hp.com> Message-ID: "Daniel Fackrell" writes: > Why not add a "from __past__ import division" for those who need old > code to work. Then there might be a little less resistance to this > (arguably good) change. That's not a totally bogus idea, yet I don't like it very much. It would mean that the old semantics will live on *forever*. The idea of the __future__ statement is that eventually (say, when Python 3000 is released :-) you *are* in the future, and then the __future__ statement becomes redundant, so it is a temporary wart in your code. For sites that absolutely cannot afford to upgrade their code, it should be possible to simply keep the old interpreter version around, just like there are still scripts requiring perl4. --Guido van Rossum (home page: http://www.python.org/~guido/) From sholden at holdenweb.com Fri Jul 6 08:00:36 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 6 Jul 2001 08:00:36 -0400 Subject: Tkinter and printf in C ... References: <3B455B5D.544A2EF5@larc.ee.nthu.edu.tw> Message-ID: <9Jh17.38316$he.2456932@e420r-atl1.usenetserver.com> "Chyr-Pyng Su" wrote in message news:3B455B5D.544A2EF5 at larc.ee.nthu.edu.tw... > > Recently I have wrote a program in C, and start to write the GUI for it. > > I want to capture the message dump by the C program and show them on a > text window. > Does anyone have some idea to do that??? redirect the stdout??? > Sorry, should have read the subject line. Here's a snippet of code that write to a PMW scrolled text window, you should be able to do the same in a Tkinter text window. t = Pmw.ScrolledText(self.msgWindow) grid(t, row=0, column=0, sticky=N+E+W+S) strmes = self.index.Message(self.MsgSet[int(self.msgList.curselection()[0])][0]) message = mimecntl.MIME_document(strmes) for hdr in ("from", "date", "subject", "to", "cc"): try: hdrline = message[hdr] t.insert(END, "%s: %s\n" % (string.capitalize(hdr),hdrline)) except KeyError: pass It's the insert() method you are looking for, I suspect. regards Steve -- http://www.holdenweb.com/ -- http://www.holdenweb.com/ From tjenkins at nospiced.ham.devis.com Thu Jul 26 13:07:08 2001 From: tjenkins at nospiced.ham.devis.com (Tom Jenkins) Date: Thu, 26 Jul 2001 17:07:08 GMT Subject: a break for comprehensions References: <9jpadd$s5k$1@news.duke.edu> <3B6031C3.6010707@nospiced.ham.devis.com> Message-ID: <3B604F1F.3030402@nospiced.ham.devis.com> Nick Perkins wrote: > > This misses the point of the original post. > Notice the 'break' in the original for-loop version. > The idea is to return consecutive elements, > up to, but not including, the first element which > does not meet the condition. > > ie. > lst = [0,2,4,5,6] > evens = [0,2,4] > *sigh* yep missed that break now-if-my-newsgroup-reader-only-had-python-syntax-highlighting-ly yours Tom From nospam at mega-nerd.net Fri Jul 13 17:04:49 2001 From: nospam at mega-nerd.net (Erik de Castro Lopo) Date: Fri, 13 Jul 2001 21:04:49 GMT Subject: PyDNS? References: <3B4ECBE0.96898063@stroeder.com> <3B4EFD40.C0C075B6@stroeder.com> Message-ID: <3B4F626E.5DDEAD49@mega-nerd.net> Michael Str?der wrote: > > Wolfgang Strobl wrote: > > > > Michael Str?der schrieb am Fri, 13 Jul 2001 > > 12:22:24 +0200: > > > > >I wonder if there's interest to maintain the DNS module formerly > > >written as demo by Guido van Rossum. Anthony Baxter has a modified > > >version of it under http://www.interlink.com.au/anthony/dns.tar.gz. > > >I've added support for SRV RRs and I'm thinking about adding caching > > >support. > > > > Great. > > > > File "DNS\Lib.py", line 105, in addname > > index.append(keys[j], offset + len(buf)) > > TypeError: append() takes exactly 1 argument (2 given) > > > > This definitely needs an overhaul. :-) > > Already fixed this too. Not sure if I covered all cases though. > > For the impatient: My version of the module is shipped with > http://web2ldap.de. Simply pull it out of pylib/ dir. This version has exactly the same filename as Anthony Baxter's original. Maybe its time to add version info to the name of the tarball :-). Erik -- ----------------------------------------------------------------- Erik de Castro Lopo nospam at mega-nerd.com (Yes its valid) ----------------------------------------------------------------- Q: How do you stop a Windows NT machine from crashing? A: Shut it down and switch it off. From peter at engcorp.com Mon Jul 9 22:02:46 2001 From: peter at engcorp.com (Peter Hansen) Date: Mon, 09 Jul 2001 22:02:46 -0400 Subject: Bug in rfc822 References: <2ih27.49242$he.3402812@e420r-atl1.usenetserver.com> Message-ID: <3B4A6246.1008F36@engcorp.com> phil hunt wrote: > > I am currently writing a program that reads emails, modifies > them in various ways (adding headers, encryption, etc) and > outputs the result. At last! I spend way too much time every day doing that manually. When will your program be available? I can't wait! wistfully-but-I'd-have-to-say-not-exactly-serious-ly y'rs, -Peter From peter at engcorp.com Thu Jul 26 19:17:52 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 26 Jul 2001 19:17:52 -0400 Subject: how on earth do i get a drive list? References: <9jpqlh$phf$1@uranium.btinternet.com> Message-ID: <3B60A520.4F30C0BC@engcorp.com> "G. Willoughby" wrote: > > how on earth do i get a drive list? i've been searching for a command to > display a tuple or list containing all available drives, but i can't find > it! is it just me or are the standard python docs quite confusing. oh well > any ideas out there? On Windows, with the win32all stuff installed: >>> import win32api >>> drives = win32api.GetLogicalDriveStrings() >>> drives 'a:\\\x00c:\\\x00d:\\\x00e:\\\x00v:\\\x00' >>> drives.split('\x00')[:-1] ['a:\\', 'c:\\', 'd:\\', 'e:\\', 'v:\\'] This is definitely not cross-platform, and I know nothing about the Windows API so there are very likely much better ways to do this, but this one's kind of cute... :) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From BPettersen at NAREX.com Thu Jul 12 11:06:16 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Thu, 12 Jul 2001 09:06:16 -0600 Subject: Language change and code breaks Message-ID: <6957F6A694B49A4096F7CFD0D900042F27DB94@admin56.narex.com> > From: "J?rgen A. Erhard" [mailto:juergen.erhard at gmx.net] [snip] > I had a script recently where I wanted to pass in a command line param > that could be a numeric ratio, s.th. like > > thescript --ratio=1/3 > > Now, what do I do with that? I can't use 1/3, because that eval'd is > 0. So... either people need to specify a float (--ratio=.3333... not > very good looking) or I have to do some magic inside the script (look > whether the ratio contains a /, split, float() on part, and merge) If you're eval'ing random strings the user types in you really deserve whatever you get <1/3 wink>. >>> r = '1/3' >>> import re >>> tmp = r.split('/') >>> assert len(tmp) == 2 >>> a, b = tmp >>> assert re.match(r'[0-9]+', a) != None >>> assert re.match(r'[0-9]+', b) != None >>> x, y = map(int, [a,b]) >>> ratio = (x + 0.0) / y >>> ratio 0.33333333333333331 >>> Nothing magic about it... -- bjorn From mgerrans at ix.netcom.com Tue Jul 17 16:29:28 2001 From: mgerrans at ix.netcom.com (Matt Gerrans) Date: Tue, 17 Jul 2001 13:29:28 -0700 Subject: Handling errors in PyXML/SAX References: <3B545EB5.6BB5DF57@wyeth.gsfc.nasa.gov> Message-ID: <9j27dl$c1r$1@slb4.atl.mindspring.net> I don't know the exact answer, but based on a quick look: Look at the " validate_attributes() member of ValidatingApp, on line 201 of xmlval.py ("self.parser.report_error(2006,attr)"), in the xml directory under the python directory. That is where it is printing the message, using the string 2006 from the localization dictionary in errors.py. You'll have to dig a little deeper to find out what the (poorly named) attrs variable is, but seems it is a list of filenames, from which "Unknown" is coming. Maybe it is a bug that it shows Unknown instead of the filename. - Matt Gerrans Tom Bridgman wrote in message news:3B545EB5.6BB5DF57 at wyeth.gsfc.nasa.gov... > I'm finally starting to work with the SAX parser and DTDs. With the SAX > defalult error handler, when parsing a file, I get error messages like: > > ERROR in Unknown:94:22: Element 'animationtype' not declared > ERROR in Unknown:98:18: Element 'thumbnail' not declared > ERROR in Unknown:99:14: Element 'medialist' not declared > > which I find ideal but for the fact that I would like to print the file > name rather than 'Unknown'. > > I've tried setting the systemID (which seems to be where the 'Unknown' > comes from) in a locator object like so: > > location=xmlreader.Locator() > location.setSystemId=inputfilename > self.handler.setDocumentLocator(location) > > but still get 'Unknown'. > > The documentation at http://pyxml.sourceforge.net/topics/docs.html is > really pretty vague on how to use this feature. > > Suggestions? > > Thanks, > Tom > -- > Dr. William T."Tom" Bridgman Scientific Visualization Studio > Global Science & Technology, Inc. NASA/Goddard Space Flight Center > Email: bridgman at wyeth.gsfc.nasa.gov Code 935 > Phone: 301-286-1346 Greenbelt, MD 20771 > FAX: TBD http://svs.gsfc.nasa.gov/ From guido at zope.com Sun Jul 29 18:53:31 2001 From: guido at zope.com (Guido van Rossum) Date: Sun, 29 Jul 2001 18:53:31 -0400 Subject: FEEDBACK WANTED: Type/class unification In-Reply-To: Your message of "Sun, 29 Jul 2001 12:37:04 PDT." <3B6465E0.368A104@ActiveState.com> References: <3B643C58.1C6C94F9@ActiveState.com> <200107291708.NAA07525@cj20424-a.reston1.va.home.com> <3B6465E0.368A104@ActiveState.com> Message-ID: <200107292253.SAA08093@cj20424-a.reston1.va.home.com> > > Yes, it's a lot less useful than you seem to think. If you are > > interested in documentation, it's better to use something like pydoc > > which gives much more details. > > Major: Pydoc seems only useful for a small subset of types and classes. I was going to fix that. It currently seems to believe only classic classes and instances can be introspected using __class__ etc. > Major: I use dir() in object browsers and other graphical constructs. I > can't use pydoc for that. I don't see an obvious dir-like function in > inspect.py. An object browser is a big app. Surely it can implement the simple rules for finding all the attributes. As a potential user of a GUI object browser, I would like it to tell me not just which attributes the class defines but also which ones are inherited and from where; and information about which ones overload which other ones, etc. > Minor: It returns so much prose information that I might prefer to use > dir() to just get the spelling or name of a function. That's at the >>> prompt right? > Consider this traceback and you'll see why I still depend on dir() > > >>> a=urllib.urlopen("file:///c|/autoexec.bat") > >>> type(a) > > >>> dir(a) > ['fileno', 'fp', 'headers', 'read', 'readline', 'readlines', 'url'] You're very lucky that this gives the information you want. These all happen to be instance variables. > >>> help(a) > Help on instance of addinfourl: > > 'rb' at 00 > F7EB28>> I think help() should be improved here. > >>> m = re.match("abc","abcdef") > >>> type(m) > > >>> dir(m) > ['end', 'expand', 'group', 'groupdict', 'groups', 'span', 'start'] > >>> help(m) > Help on SRE_Match: > > Clearly help() can stand improvement. > > Right now, pydoc doesn't understand the new types yet, but eventually, > > before 2.2 final, pydoc (or more likely inspect.py) will be able to > > introspect according to PEP 252. > > Maybe that will be enough to help me for my object-browsing > applications. And perhaps pydoc will be reliable enough for me to give > up on dir(x). I repeat: your object-browsing apps should implement the PEP 252 protocol. > > .... > > Hm, I'd like you to tell me more about how you use dir(). I find > > getting the entire list of attributes overwhelming. > > I use dir(x) as a compressed and somewhat more reliable pydoc that works > great for modules and built-in types and works poorly for instances. At the >>> prompt, right? I don't believe in adding built-ins to make this mode truly self-sufficient. That ought to be a function of the IDE. (In that sense help() is already against my philosophy -- I don't find it very useful at the >>> prompt. I much prefer pydoc's server / webbrowser mode.) > What do *you* use dir(x) for? When do you want to introspect an instance > and you care about instance data but not class data and functions that > are instance attributes but not true methods. I like to know which attrs are ivars and which ones are methods, so I prefer to do dir() on the instance to see what ivars it has, and dir() on the class to see methods. If dir() gave me the entire list of ivars and methods it would be overwhelming and less useful. --Guido van Rossum (home page: http://www.python.org/~guido/) From machin_john_888 at hotmail.com Tue Jul 10 00:59:32 2001 From: machin_john_888 at hotmail.com (John Machin) Date: 9 Jul 2001 21:59:32 -0700 Subject: Unicode -> String problem References: Message-ID: <92ae279c.0107092059.8b56186@posting.google.com> Jay Parlar wrote in message news:... > I'm having a problem converting unicode text to string type with str(). [snip] > > I haven't found anything that will explicitly do what I want, namely, > completely remove any uncovertable unicode characters. I > have to be able to parse this text afterwards, > using a lot of Python's string functions, [snip] Are you completely sure that the offending characters are totally meaningless in your application? u'\u00A0' is a no-break space; seems stripping that out but leaving normal spaces (u'\u0020') might not be a good idea. What other non-ASCII characters do you have? Are you sure it's Unicode? Is \xA0 exactly what you are seeing, or are you seeing \u00A0 and telling us it's \xA0 ?? Which "lot of Python's string functions" do you plan to use? Note that 8-bit strings and Unicode strings support a large number of same-name as-close-to-same-functionality-as-possible methods -- see section 2.1.5.1 of the Python Library Reference manual. Also the re module supports the same functions and methods on both types. From dgrisby at uk.research.att.com Mon Jul 23 10:14:11 2001 From: dgrisby at uk.research.att.com (Duncan Grisby) Date: 23 Jul 2001 14:14:11 GMT Subject: PEP0238 lament References: Message-ID: <9jhbfj$79s$1@pea.uk.research.att.com> In article , Guido van Rossum wrote: >The reason for wanting / to return a float (or at least a type that >can represent close approximations of numbers like 0.75) has been >discussed many times before. The summary of the argument in the PEP >may not be complete, but I disagree with Arthur's assessment that >integer division is not a problem -- the VPython folks have ample >experience that it is. Many people have mentioned the backwards compatibility issue. For me, the main issue is related to that, but much more devastating. I maintain libraries which have to work on a range of Python versions. At the moment, I can have a single set of source files which work on all versions. The various recent language changes don't affect that. With this division change, I will either have to maintain two parallel versions of the source, or make use of ugly and inefficient code which works with both old and new versions of Python. The reality is that the whole world will not switch Python versions overnight, so everyone who maintains a library will have to face this issue. Cheers, Duncan. -- -- Duncan Grisby \ Research Engineer -- -- AT&T Laboratories Cambridge -- -- http://www.uk.research.att.com/~dpg1 -- From steve at lurking.demon.co.uk Wed Jul 25 04:21:10 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Wed, 25 Jul 2001 09:21:10 +0100 Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <4dqslt4pj7algruf69gg3497m663gggjnf@4ax.com> Message-ID: On Tue, 24 Jul 2001 23:40:21 -0700, Tim Roberts wrote: >Steve Horne wrote: >> >>Intellectual decline is not what it used to be ;-) - apparently the >>avarage childs IQ these days (I forget the exact age range) is around >>120. Must it's all the TV and video games ;-) > >The average child's IQ these days is 100. That is the very definition of >IQ. Not in the case where you compare current childrens performace against past childrens performance on the same test and using the same assessment criteria - which was the point. Of course I was misusing a specialist statistic and I doubt I can even find the source now, but it was just a joke. From gustafl at algonet.se Tue Jul 3 17:15:55 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 3 Jul 2001 21:15:55 GMT Subject: AttributeError: 'getopt' module has no attribute 'GetoptError' Message-ID: I use Python 2.1 on Win98. Try to use the getopt module, but get the error in the subject line. What's wrong? My code: try: opts, args = getopt.getopt(sys.argv[1:], 'f:hcr') except getopt.GetoptError: usage() sys.exit(2) Another question about getopt: Are options optional by nature? You can't have a mandatory option? Regards, Gustaf Liljegren From rnd at onego.ru Thu Jul 12 10:00:35 2001 From: rnd at onego.ru (Roman Suzi) Date: Thu, 12 Jul 2001 18:00:35 +0400 (MSD) Subject: list and implicit continuation may cause bugs in Python programs Message-ID: FYI: Do not forget commas: list =[ "update", "y", "m", "d", "y1", "m1", "d1", "event", "url", "preview" ] list =[ "update", "y", "m", "d", "y1", "m1", "d1", "event", "url" "preview" ] Or Python will silently make: ['update', 'y', 'm', 'd', 'y1', 'm1', 'd1', 'event', 'urlpreview'] Does PyChecker check for these kind of things? Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From stevewilliams at wwc.com Thu Jul 5 11:46:30 2001 From: stevewilliams at wwc.com (Steve Williams) Date: Thu, 05 Jul 2001 15:46:30 GMT Subject: Is Python Dead? References: <458b194a.0107050711.72007607@posting.google.com> Message-ID: <3B448C81.4DAC7DD@wwc.com> Resty Cena wrote: > "Edward B. Wilson II" wrote in message news:... > > I have been following Python for five years now, and I am still just as > > frustrated with it as I was in 1996. > > > > Python still doesn't have good database support, > > I, too, have been following Python since 1996, waiting all the while > to make it easy for me to do database programming. [snip] How about this little jewel returned by a Google search on "Python DB2 AIX"? From http://webevents.broadcast.com/ibm/developer/050901/display_qa.asp Question 10: DB/2 can be used whit PHP or Pyton ? Answered by Nanda Pilaka: DB2's supports C/C++/Java/COBOL/REXX/Basic/Perl/Fortran currently. Python is not supported. We now return you to the whitespace discussion currently in progress. . . From donn at u.washington.edu Mon Jul 23 12:21:56 2001 From: donn at u.washington.edu (Donn Cave) Date: 23 Jul 2001 16:21:56 GMT Subject: What confuses the newbies: An unscientific study References: Message-ID: <9jhiv4$cv8$1@nntp6.u.washington.edu> Quoth 9nick9m at alum.mit.edu (Nick Mathewson): | I thought it might be cool for me to use suck(1) to pull down all the | articles I could from comp.lang.python, find all the ones that | represented questions about the language, and tabulate which aspects | of the language people were misunderstanding. Congratulations on a good job! That was very interesting. Donn Cave, donn at u.washington.edu From ngps at madcap.dyndns.org Fri Jul 13 13:50:39 2001 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 13 Jul 2001 17:50:39 GMT Subject: Long Live Python! References: <3B4CC986.A5C8E605@engcorp.com> <270c68fe.0107121546.249b9efa@posting.google.com> Message-ID: <9incdf$k98$1@coco.singnet.com.sg> According to Alan Green : > Until it reaches the mythical "mindshare critical mass", Python is > going to have to take over the world just one project at a time. For > those of us who want to work in Python in the typical IT shop, this > means doing some advocacy. > > To be an effective advocate of Python, you need to: > [...] Just browsed this book "Techno-Ready Marketing" at a local bookstore. (Forgot the authors' names.) Amazon has two 5-star reviews, fwiw. Anyone else read this book? Does it offer good advice applicable to, say, advocating Python in the work-place? -- Ng Pheng Siong * http://www.post1.com/home/ngps Quidquid latine dictum sit, altum viditur. From zeitlin at seth.lpthe.jussieu.fr Sat Jul 7 13:22:39 2001 From: zeitlin at seth.lpthe.jussieu.fr (Vadim Zeitlin) Date: 7 Jul 2001 17:22:39 GMT Subject: [Problem] wxPython -- wxSplitterWindow References: <3hGKC2$kHq@openbazaar.net> Message-ID: On 07 Jul 2001 07:12:02 GMT, ?Q?@?U wrote: >Hi, guys.. > >How to split frame like above. > > +-----+-----------------+ > | | | > | +-----------------+ > | | | > | | | > | | | > +-----+-----------------+ You need 2 splitters: create the first one as the child of the main window and split it vertically, then create the second one as the child of the first and split it horizontally. 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 tim.one at home.com Wed Jul 25 19:25:12 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 25 Jul 2001 19:25:12 -0400 Subject: doctest x idle problem? In-Reply-To: Message-ID: [Jon Schull] > If I run "python doctest.py" from the command line (win2K) doctest > does what I'd expect (which in this case is nothing). > > If I load doctest.py into idle and go "Edit| Run Script" I get > something similar(a blank line). > > But if I go "Edit| Run Script" again, I get a Whole Bunch of Stuff > (and doctest seems not be testing docstrings). Is there a right way > to have doctest and idle coexist? > > Here follows a Whole Bunch of Stuff .... > *** Tester.merge: 'doctest.testmod' in both testers; summing outcomes. > [and lots more of the same] You should read the "ADVANCED USAGE" section of doctest.py's module docstring. What you're seeing is that doctest maintains a (module-global) instance of class doctest.Tester, in module variable doctest.master, into which any number of doctest runs can merge their results. If you run doctest on itself multiple times, then it will try to merge the results of all those runs into one master report, and Tester.merge warns you when it sees multiple tests with the same name. That said, I have no idea why you're doing "Run Script" on doctest to begin with. That's not a sensible thing to do -- doctest is a library module in 2.1, and you shouldn't need to load it into IDLE at all, let alone ever run it on itself. If for some reason you simply can't resist , set "master" to None between useless runs so that doctest stops trying to merge their redundant results. From rumjuggler at cryptarchy.org Mon Jul 16 13:53:06 2001 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Mon, 16 Jul 2001 17:53:06 GMT Subject: re Challenge: More Compact? References: Message-ID: On Mon, 16 Jul 2001 02:39:50 GMT, tim at vegeta.ath.cx (Tim Hammerquist) wrote: >Ok, so here's my version (I hate wasted line space and unnecessary temp >vars): > >def valid_ip(ip): > m = re.match( r'(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$', ip) > if m: return max(map(int, m.groups())) < 256 > return 0 In that case you can eliminate a whole line this way: def valid_ip(ip): m = re.match( r'(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$', ip) return (m and max(map(int, m.groups())) < 256)) or 0 -- Barnabas T. Rumjuggler No man can run so fast that he can escape his own past's projectile vomit. From alf at leo.logilab.fr Wed Jul 18 03:42:52 2001 From: alf at leo.logilab.fr (Alexandre Fayolle) Date: Wed, 18 Jul 2001 07:42:52 +0000 (UTC) Subject: distutils and python2.1 Message-ID: Hello, I have both python 1.5.2 and python 2.1 installed on my machine (python 2.1 is accessed through 'python2' on the command line), and I'd like to generate rpm packages for python 2.1. However, when I launch python2 setup.py bdist_rpm the rpm I get will install in /usr/lib/python1.5/site-packages. Is there something I can tweak in the setup.cfg, maybe ? TIA Alexandre Fayolle -- LOGILAB, Paris (France). http://www.logilab.com http://www.logilab.fr http://www.logilab.org Narval, the first software agent available as free software (GPL). From alankarmisra at hotmail.com Tue Jul 3 15:36:49 2001 From: alankarmisra at hotmail.com (gods1child) Date: 3 Jul 2001 12:36:49 -0700 Subject: explain this Message-ID: <25b2e0d9.0107031136.5dc0dad2@posting.google.com> In the code below, why can i add elements to locals but not delete them? >>> def function(argument): ... print locals() ... modify(locals()) ... print locals() ... >>> def modify(locals): ... del locals['argument'] ... locals['new_argument'] = 'new_value' ... >>> function(10) {'argument': 10} {'argument': 10, 'new_argument': 'new_value'} From bokr at accessone.com Sat Jul 14 13:55:25 2001 From: bokr at accessone.com (Bengt Richter) Date: Sat, 14 Jul 2001 17:55:25 GMT Subject: LAMBDA IS IT USELESS? References: <9in61201nuf@enews1.newsguy.com> <3b4f6eb5.1832748462@wa.news.verio.net> <9ip0u401117@enews4.newsguy.com> Message-ID: <3b507741.1900473085@wa.news.verio.net> On Sat, 14 Jul 2001 10:48:43 +0200, "Alex Martelli" wrote: >"Bengt Richter" wrote in message >news:3b4f6eb5.1832748462 at wa.news.verio.net... >> On Fri, 13 Jul 2001 18:01:37 +0200, "Alex Martelli" >wrote: >> [...] >> >or to the def. The ONLY difference is that lambda generates an >> >anonymous function (and is an expression), while def generates a >> >named function (and is a statement). >> >> In that case why not allow an anonymous version of def, e.g.., >> >> map( >> def(x): #>> x**2 return x**2 # thanks to Fredrik >> ,xrange(5)) >> >> which would work like >> >> map( >> lambda x:x**2 >> ,xrange(5)) > >Judging from this sole example, the only difference here would >be the inconsequential syntax sugar of WRITING def(x) vs >lambda x -- who cares for such trifles? > Sure. Sorry about the ambiguity (and unhelpful error in the example) >Very different would be if the def was still a statement (and >particularly a compound statement, including other statements): Yes, that is what I was intending >in that case, its anonimity would be no use UNLESS one fundamental >principle of Python syntax was abrogated -- no expression can >include statements. If that were done, then there would be very >wide-spread repercussions, needing a careful redesign of many >apparently-unrelated things. > I didn't mean to abrogate the no-statements-in-expressions principle in general, just within a fullfledged lambda definition. Actually, it would have been clearer to leave def out of it, and say I would like lambda to work just like def except returning the function instead of binding a symbol to it. In practice, since it's so easy to use def with a throwaway name, the real question is when could the name mess things up. I don't have an immediate answer ;-) >From the grammar, we have funcdef: 'def' NAME parameters ':' suite where parameters: '(' [varargslist] ')' and lambdef: 'lambda' [varargslist] ':' test So what would happen if that last "test" were changed to "suite" ? If the end of "suite" is well defined, why would there be a problem? > >> (OTOH you could make lambda multi-line ;-) > >lambda can be multi-line today. I.e., you're free to break the >line after the ':' in the above example. Lines are not an issue. >STATEMENTS vs EXPRESSIONS is the issue. > Sorry, I should have said "OTOH you could make lambda multi-statement" ;-) From JamesL at Lugoj.Com Tue Jul 10 11:31:27 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Tue, 10 Jul 2001 08:31:27 -0700 Subject: Newbie asks: How to translate this line of C to Py References: Message-ID: <3B4B1FCF.54BAE9F0@Lugoj.Com> Fredrik Lundh wrote: > > Steve S.L. Wong wrote: > > > while (command = strtok(line_ptr,";"),line_ptr=0,command) { > > } > > ouch. that's ugly. ever heard of for-loops? and did you miss > the "Never use this function" sentence in your C library manual? ;-) > > anyway, this is a pretty good emulation: > > for command in line.split(";"): > ... I'm pretty sure that is NOT equivalent. The strtok is treating ";" as whitespace whereas split is treating ";" as a delimiter. The difference shows up when more than one whitespace/delimiter are adjacent. So "this;;code;" parses to: [ "this", "", "code", ""] But a proper strtok equivalent should give: [ "this", "code" ] That is why I added a filter to my example. On the other hand, I'm guessing the actual application from whence that C code comes really needs to treat the semicolon as a delimiter. From paulp at ActiveState.com Sun Jul 1 15:46:39 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sun, 01 Jul 2001 12:46:39 -0700 Subject: PEP: Support for "wide" Unicode characters References: Message-ID: <3B3F7E1F.E0146380@ActiveState.com> Marcin 'Qrczak' Kowalczyk wrote: > > Thu, 28 Jun 2001 15:33:00 -0700, Paul Prescod pisze: > > > 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. > > I don't like it. Scripts will work under some builds of Python and > not work in others. Just as they do today. i.e. if you use import win32api or if you use a 64-bit integer. > > Rejected Suggestions > > > 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. > > But will work, as opposed to working only sometimes. > > If memory consumption is really a problem, I would definitely hide > varying character sizes as an implementation detail. Here are two relevant paragraphs from the version of the PEP I will check in today: Another 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. Guido is not willing to undertake the implementation right now. .... This PEP represents the least-effort solution. Over the next several years, 32-bit Unicode characters will become more common and that may either convince us that we need a more sophisticated solution or (on the other hand) convince us that simply mandating wide Unicode characters is an appropriate solution. Right now the two options on the table are do nothing or do this. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From rumjuggler at cryptarchy.org Wed Jul 25 03:07:18 2001 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Wed, 25 Jul 2001 07:07:18 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <4dqslt4pj7algruf69gg3497m663gggjnf@4ax.com> Message-ID: On Tue, 24 Jul 2001 23:40:21 -0700, Tim Roberts wrote: >Steve Horne wrote: >> >>Intellectual decline is not what it used to be ;-) - apparently the >>avarage childs IQ these days (I forget the exact age range) is around >>120. Must it's all the TV and video games ;-) > >The average child's IQ these days is 100. That is the very definition of >IQ. Except in Lake Woebegone, natch. -- Barnabas T. Rumjuggler No man can run so fast that he can escape his own past's projectile vomit. From paulp at ActiveState.com Fri Jul 20 13:38:19 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Fri, 20 Jul 2001 10:38:19 -0700 Subject: Language change and code breaks References: <3B5863EE.F9047098@Lugoj.Com> Message-ID: <3B586C8B.305B8679@ActiveState.com> James Logajan wrote: > > Guido van Rossum wrote: > > If you use this > > a lot (message = Message() etc.) your code is less readable than it > > should be. > > Um, you've got that precisely reversed! If I see "message" anywhere in my > code, I know immediately that it is an instance of the class Message. Think > of it as an advanced form of Hungarian notation that tells you what type of > thing the variable is holding. (Although I'm no fan of Hungarian per se.) The Ruby convention is aMessage which is really more clear. i.e. "message" could be of type string or of type Unicode or anything. I'm sure I've got code on my computer where message was of any of these types. After all, lower case names are not ALWAYS used for instances of a type. Sometimes they are merely descriptive of the variable's role. If you are trying to say that an instance is an instance of a class then the aFoo convention is very clear. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From aleaxit at yahoo.com Tue Jul 3 08:33:49 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 3 Jul 2001 14:33:49 +0200 Subject: Augmented Assignment (was: Re: PEP scepticism) -- what variable names are you using? References: <3b41b15a.22907188@news.tpi.pl> Message-ID: <9hse3f01vvt@enews1.newsguy.com> "Maciej Pilichowski" wrote in message news:3b41b15a.22907188 at news.tpi.pl... > Hello there, > > As far as I can see everybody uses examples likes this: > > x += 2 > > Max. was 2 chars name long. Gosh, in my programs I use as long name > as it is possible and as short as it is still understandable. > So if it is 11 p.m. I would love to see possibility of writing > > BiezaceWolneSrodkiKlienta += LimitKredytu > > instead of > > BiezaceWolneSrodkiKlienta = BiezaceWolneSrodkiKlienta+LimitKredytu > > /sorry for non-english names/. It is much clearer. Less to typing, > less thinking "is that the same variable?". > For me -- I see only advantages of such operator. > > One rule more to learn? Well, the idea is simple -- "adding in > place" /for example above/ -- that defines very well all cases /I > think/. And if you don't want to learn? Well -- don't. > > I vote for go :-) > > have a nice day > bye > > -- > Maciej "MACiAS" Pilichowski > http://www.torun.pdi.net/~macias/ > > z a k u p i e : pisma Komputer: 3/86,4/87 From bww00 at amdahl.com Thu Jul 19 11:22:18 2001 From: bww00 at amdahl.com (Bryan Webb) Date: 19 Jul 2001 15:22:18 GMT Subject: float to str help Message-ID: <9j6tva$9mb@dispatch.concentric.net> Hi, In converting a float (5.661706091586558e+240) to a string using str() I come up with 5.6617060916+240 . I checked the string variable in the debugger. I need the full precicsion. I know its probably simple but this red hair is causing me problems. Thanks Bryan Webb From rnd at onego.ru Mon Jul 2 06:21:45 2001 From: rnd at onego.ru (Roman Suzi) Date: Mon, 2 Jul 2001 14:21:45 +0400 (MSD) Subject: problem with sending email In-Reply-To: Message-ID: On 2 Jul 2001 piet at cs.uu.nl wrote: > >>>>> Haris Lekatsas (HL) writes: > > HL> I have a problem running the script below on FreeBSD. When I run it from the > HL> UNIX prompt it runs fine and it sends a file (bigtextfile) of any size to > HL> the recipient address. Whenever a run the exact same script from a web > HL> browser as a CGI script it will send only about 17K of the bigfile and not > HL> the whole thing. I tried many different files and all of them get cut off > HL> at around 17K. It seems on other OS this problem does not appear. Any ideas > HL> why this is happening would be appreciated. What if you try to send mail by piping to "sendmail -t"? Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From hgg9140 at seanet.com Sat Jul 28 06:50:59 2001 From: hgg9140 at seanet.com (Harry George) Date: 28 Jul 2001 03:50:59 -0700 Subject: Distributing multiple related scripts References: Message-ID: Don Dwiggins writes: > I have a distribution need that might be somewhat unusual: instead of > distributing a single program, I need to distribute a collection of scripts, > some to be run manually, others scheduled. Since there's considerable > common code among them, I want to have one or more common modules that the > scripts can load as needed. > > Both the source and target of distribution are Windows machines. Also, it's > possible to have Python installed on the target machine(s). > > 1) What would be the best distribution tool and setup for this? > 2) How would the scripts access the common modules? > Use the standard "setup.py". In your development or working dir, do: myproject/ mypackage/ __init__.py mod01.py mod02.py scripts/ script01.py script02.py setup.py setup.py has: ... packages=['mypackage'], scripts=['scripts/script01.py','script02.py'], ... The scripts of course import the package and use its modules: import mypackage ... mypackage.mod01.do_something() To distribute: python setup.py build python setup.py sdist Copy the resulting tarball to the installation location and untar. Then follow the std process: python setup.py build python setup.py install <-- maybe as root If you need some help writing a setup.py, you ca see my "mkpythonproj" at: http://www.seanet.com/~hgg9140/comp/index.html > Thanks for any good words, > > -- > Don Dwiggins "Solvitur Ambulando" > Advanced MP Technology > dwig at advancedmp.net > > -- Harry George hgg9140 at seanet.com From sholden at holdenweb.com Wed Jul 11 12:14:41 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 11 Jul 2001 12:14:41 -0400 Subject: evalstr References: <3B4C2A0E.60AA094@nokia.com> <8oZ27.41795$F%5.2523550@e420r-atl2.usenetserver.com> <3B4C78FE.C2B6CECB@nokia.com> Message-ID: http://aspn.activestate.com/ASPN/Cookbook/Python -- http://www.holdenweb.com/ "Joonas Paalasmaa" wrote in message news:3B4C78FE.C2B6CECB at nokia.com... > Steve Holden wrote: > > > > "Joonas Paalasmaa" wrote in message > > news:3B4C2A0E.60AA094 at nokia.com... > > > Shannon --jj Behrens wrote: > > > > > > > > Hello All, > > > > > > > > I wrote a useful C module for doing string > > > > interpolation. I find it indespensible when working > > > > with large blocks of triple-quoted text. When working > > > > with large blocks of triple-quoted text, nothing else > > > > is quite as convenient. Here's the Python doc: > > > > > > [lots of text snipped] > > > > > > > Please forgive my arrogance, but I think that it might > > > > even be useful enough to be included as a standard > > > > module. If, not perhaps you guys might have some > > > > suggestions as to what I can do with it. You may > > > > download the entire packages from: > > > > > > > > > > > > > > I prefer the following method for evaluations inside strings. > > > > > > >>> class Eval: > > > def __getitem__(self, key): > > > return eval(key) > > > > > > > > > >>> foo = 3.0 > > > >>> spam = 5.0 > > > >>> print "%(foo/spam)s" % Eval() > > > 0.6 > > > >>> print "%(foo/spam).55f" % Eval() > > > 0.5999999999999999800000000000000000000000000000000000000 > > > > That's a very neat trick. Had you though of writing it up as a Python > > recipe? > > > To where? From jdavis at empires.org Mon Jul 23 05:42:48 2001 From: jdavis at empires.org (Jeff Davis) Date: Mon, 23 Jul 2001 02:42:48 -0700 Subject: web sessions support References: <3B5BE6CC.9B71B87E@stroeder.com> Message-ID: Michael Str?der wrote: > Jeff Davis wrote: >> >> I have been looking around and I have not been able to find a session >> module for python (for the web). Basically I just need a normal session >> manager that can work somewhat like the one in PHP. I have recently been >> moving away from PHP to python for web stuff and I need a session >> manager. If no such module exists, I would write my own. > > You might wanna borrow some ideas from > http://www.stroeder.com/pylib/PyWebLib/ > > I'm the author => take it with a grain of salt. ;-) > > There are other modules too: > http://thor.prohosting.com/~pboddie/Python/web_modules.html > > Ciao, Michael. > Great! I will take a look, and if I can improve it, I will. Thanks! Jeff Davis From frdelarue2000 at yahoo.fr Thu Jul 26 10:29:31 2001 From: frdelarue2000 at yahoo.fr (=?iso-8859-1?q?franck=20delarue?=) Date: Thu, 26 Jul 2001 16:29:31 +0200 (CEST) Subject: garbage collector Message-ID: <20010726142931.53348.qmail@web14805.mail.yahoo.com> hi, I use python1 with a lot of object (dictionnairies + lists) and my program takes 3 or 4 hours to execute on a 4 processors (700 mghz) and 2 Go Ram machine (linux red hat). The problem is that when the program is finished, python still continues to delete the objects (I've put some "print" to see when the "del" function is executed) during about 30 minutes. Is that normal ? Is there a solution to stop the program correctly ? ("ctrl+alt+del" or "kill -9 XXX" works but i don't feel satisfied) ===== __________________________________ ___ \ \ | _ | \ \ F R A N C K D E L A R U E \ | |_ | | | / + - + - + - + - + - + - + / | _ | | | /_________________________________/ |_| |__/ ___________________________________________________________ Do You Yahoo!? -- Vos albums photos en ligne, Yahoo! Photos : http://fr.photos.yahoo.com From Arthur_Siegel at rsmi.com Sun Jul 22 12:01:08 2001 From: Arthur_Siegel at rsmi.com (Arthur_Siegel at rsmi.com) Date: Sun, 22 Jul 2001 11:01:08 -0500 Subject: PEP0238 lament Message-ID: <00867F2E.N22121@rsmi.com> Before going further in attempting to contribute to the discussions of Pep238 (or case sensitivty) allow be to present my credentials. None, to speak of. Except that I've been through the program. Guido's program. His language. His environment. His tutorials. I think with some success. Participate little on python-list, because much of what goes on is over my head. But on the question of learning programming with Python - as I mention, been through the program. Here the issues are under my nose, not over my head. I particpate actively on the edu-sig list, because I understand my success could be other's success. Am a big supporter of Guido's CP4E ideals. Yet despite the gratitude I try to keep in mind, I clash consistently with Guido on CP4E - sometimes in unpleasant ways. Can only hope he appreciates at some level that I bring some passion to the table on some common goals. Because that clash now spills over to the Python list. Since I have convinced myself that not only do I object to the rationale and evidence gathering behind the integer division change - I am going to step up and be arrogant enough to say that I am against it as a design feature, in light of the only aspect of Python design about which I would dare to speak - CP4E goals. 3 / 4 = 0 3.0 / 4 = .75 Something important is going on here. I have a decent understanding of what that is. Enough to get me by in the real world. I came to It - having already understood that I would only get so far if I expected it all to come to me. That reckoning has been put off an hour ot two for the Python 2.2 learner, with a measurable cost. Pity for the Python2.2 learner. Quite well realize that I am not saying anything that hasn't been said before on the issue. But disappointed to never have heard the counter argument from Guido - what put the issue over the top for him? If I was told that experinced programmers might appreciate this change for any possible reason - I'd be quiet as a mouse. Since I remain convinced that the single most important factor for Python's acceptance as an educational language is the growth of its acceptance as a professional language. It will be interesting to see where Guido chooses to draw the line on the thought process that lead him to his integer division conclusion. Which is the real issue - the integer division thing, stand-alone, not likely to be a deal breaker for anyone. Like to believe that there is more real world thinking than Guido chooses to share publicly. Alternatively, I'm baffled as hell. ART From daniel.dittmar at sap.com Fri Jul 13 12:53:46 2001 From: daniel.dittmar at sap.com (Daniel Dittmar) Date: Fri, 13 Jul 2001 18:53:46 +0200 Subject: Newbie list question References: <13c69f60.0107130843.5cd7dc38@posting.google.com> Message-ID: <9in92s$9qf$1@news1.wdf.sap-ag.de> > >>> foo = foo + ['c'] # Add 'c' back to foo. > >>> foo > ['a', 'b', 'c'] # 'c' is back. Good. > >>> bar > ['a', 'b'] # ??? What the... ??? Where is 'c'? If you want to find out this one yourself, use >>> id (foo), id (bar), id (baz) at various places Daniel -- Daniel Dittmar daniel.dittmar at sap.com SAP DB, SAP Labs Berlin http://www.sapdb.org/ From m.faassen at vet.uu.nl Mon Jul 23 18:17:48 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 23 Jul 2001 22:17:48 GMT Subject: PEP0238 lament References: <9jgvbc$dos$1@newshost.accu.uu.nl> Message-ID: <9ji7qc$ciq$1@newshost.accu.uu.nl> Marcin 'Qrczak' Kowalczyk wrote: > 23 Jul 2001 10:47:08 GMT, Martijn Faassen pisze: >> "+" does two different things depending on what you pass in (strings or >> numbers). "*" does so too. They both can be said to lose information. > The difference between '+' and '/' is that ints aren't implicitly > converted to strings, so one wouldn't use an int instead of a string > expecting '+' to do the conversion and concatenation. But ints *are* > implicitly converted to floats when needed in about all contexts except > '/', so it would be reasonable to expect them to be converted in the > '/' case too. Huh? Which contexts are that? ints are converted to floats if you use them together with a float, yes. int + float results in a float answer, just like int/float does; why do you claim / is an exception in this? Anyway, string * int involves in a string result as well, which could be claimed to be analogous, though I know that's a shaky argument. :) > In languages where ints are implicitly converted to strings, addition > and concatenation are typically different operators. Like in Perl: > '+' and '.'. And in Perl "1" + "foo" is 1. Hardly ideal as an example of separate operators. :) > Python does treat ints and floats as different parts of the same > concept by letting them compare equal and convert as needed. So real > division and integer division should be distinguished by the operator. Couldn't you make this argument for float multiplication and integer multiplication as well though? After all integer * float will lead to an inexact float result.. Ocaml has separate *. for float multiplication, for instance. > To help with migration there can be old_div(x,y) function. That way > old / can be unconditionally replaced with old_div for a quick fix, > and it can be made nicer by saying explicitly which division is meant > when somebody has time to do it properly. It wouldn't help too much with efficiency, but I imagine that's what people will end up doing, yes. At least you could make a tool that did that for each and every / (excluding situations with eval), so that's a relief. It does raise the question if polluting so much old code with this construct (and we can't change code samples) is worth having a slightly easier to teach language.. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From nhodgson at bigpond.net.au Fri Jul 27 07:30:43 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Fri, 27 Jul 2001 11:30:43 GMT Subject: PEP: Defining Python Source Code Encodings References: <9jmp05$47j$1@animus.fel.iae.nl> Message-ID: Marcin 'Qrczak' Kowalczyk > I suspect that if foreign characters are allowed in > identifiers, the recommended practice would be > to make each feature available under an ASCII > name too. Java and C# allow the use of Unicode escape sequences in variables so you could have something like: double \u03C0 = 3.0; This would be a pain to work with but editors can be set up to show this as the greek letter pi. Another common technique is to allow aliasing statements such as VB's Declare Function CreateWindowEx Lib "USER32" _ Alias "AnotherNameThatCouldIncludeWeirdCharacters" Neil From coldstrongvision at gmx.net Mon Jul 9 15:52:11 2001 From: coldstrongvision at gmx.net (Marcus Lauster) Date: Mon, 9 Jul 2001 21:52:11 +0200 Subject: www.pygame.org Message-ID: <9id1t4$j9q$02$2@news.t-online.com> hi What r u thinking about this site. I like it. All the little games r in python :). cya all Marcus :) From grante at visi.com Wed Jul 25 11:07:57 2001 From: grante at visi.com (Grant Edwards) Date: Wed, 25 Jul 2001 15:07:57 GMT Subject: Language change and code breaks References: <9j7gv8$9mg@dispatch.concentric.net> Message-ID: In article , Guido van Rossum wrote: >How did engineers cope with Fortran? By swearing through gritted teath. :) >Fortran has long been the preferred language for engineers, after C.S. folks >moved on to C and C++... "Cope" is exactly the correct verb. You cope with arthritis because you've got no choice. Much the same is true of Fortran. You use it because there's nothing else you can do. First because the alternative was assembly. Later, because you need complex math and the other languages available don't support it. Finally you've got a huge existing library of routines and no time to re-write them all in something else. -- Grant Edwards grante Yow! Yes, but will I at see the EASTER BUNNY in visi.com skintight leather at an IRON MAIDEN concert? From ngps at madcap.dyndns.org Fri Jul 13 13:39:14 2001 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 13 Jul 2001 17:39:14 GMT Subject: Encryption and python? References: <3B4EB456.5A315CF9@stroeder.com> Message-ID: <9inbo2$rov$1@dahlia.singnet.com.sg> According to Greg Copeland : > Fair enough. I'm looking for low-level algorithms for public > key exchange, some encryption, digital signatures and hashes. M2Crypto: $ python rsatest.py testing public-key encryption: pkcs1_padding testing public-key encryption: pkcs1_oaep_padding testing private-key signing: pkcs1_padding $ python dsatest.py testing signing... ok testing asn1 signing... ok $ python dhtest.py generating dh params: ...+...+.+.+...++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++*++* p = '\000\000\000\021\000\201\366\316W\372\036\272\352\004&\214\010\317\2072\313' g = '\000\000\000\001\002' a.pub = '\000\000\000\020V4\277\363c\325!;1\211\261\262u\350\223\371' a.priv = '\000\000\000\020K\246\035e\235\254\2010G\372\200u\357D1\214' b.pub = '\000\000\000\021\000\201\205\031=W\252g\262\336\242Iz\202\020\360\336' b.priv = '\000\000\000\020d\226\034\3723\357\354W~\366co\014\345\275\032' a.key = '2\001:\015\013tE\215D\365\276\302;\324u\367' b.key = '2\001:\015\013tE\215D\365\276\302;\324u\367' $ python evp_ciph_test.py testing bf_ecb ... ok testing bf_cbc ... ok testing bf_cfb ... ok testing bf_ofb ... ok testing idea_ecb ... ok testing idea_cbc ... ok testing idea_cfb ... ok testing idea_ofb ... ok testing cast5_ecb ... ok testing cast5_cbc ... ok testing cast5_cfb ... ok testing cast5_ofb ... ok testing rc5_ecb ... ok testing rc5_cbc ... ok testing rc5_cfb ... ok testing rc5_ofb ... ok testing des_ecb ... ok testing des_cbc ... ok testing des_cfb ... ok testing des_ofb ... ok testing des_ede_ecb ... ok testing des_ede_cbc ... ok testing des_ede_cfb ... ok testing des_ede_ofb ... ok testing des_ede3_ecb ... ok testing des_ede3_cbc ... ok testing des_ede3_cfb ... ok testing des_ede3_ofb ... ok testing rc4 ... ok testing rc2_40_cbc ... ok -- Ng Pheng Siong * http://www.post1.com/home/ngps Quidquid latine dictum sit, altum viditur. From eppstein at ics.uci.edu Sun Jul 1 14:52:21 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Sun, 01 Jul 2001 11:52:21 -0700 Subject: No os._exit() in MacOS? Message-ID: I am having difficulty getting a Mac W applet to exit cleanly -- sys.exit(0) causes W.application.mainloop() to put up a traceback window (and not quit), W.application._quit() causes W to stop responding (but still not quit, unless called from a Quit event handler), and os._exit(0) isn't available on the Mac. Are there any other alternatives? As a sign that this isn't only my problem, the BuildApplication applet that comes with the 2.1 build has similar problems -- if you let it run to completion, it gets into a state where you can't exit without Cmd-Ctrl-Option-Esc. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From teo at crepido.com Wed Jul 25 10:04:29 2001 From: teo at crepido.com (teo) Date: 25 Jul 2001 07:04:29 -0700 Subject: xml - parsing with 4Suite, how does it work? Message-ID: Hi all! I'm looking for some documentation about howto parsing an xml-file into a DOM with the 4Suite-tools. Does anyone have an idea where to search, or how to do? if so, that wold be great! /teo From michael at stroeder.com Thu Jul 5 05:57:09 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Thu, 05 Jul 2001 11:57:09 +0200 Subject: Python for air traffic control? References: <9hlfbn$6ok$1@nereid.worldonline.nl> <9hrj3q$cj1@news1.gtech.com> <9htgsb$ck3@news1.gtech.com> Message-ID: <3B4439F5.71A96046@stroeder.com> Russ wrote: > > Do you think PyChecker could ever be sophisticated enough to do static > type checking? Inspired by this thread I played with PyChecker yesterday on my rather small project. I enjoyed finding some obsolete module imports and variable declarations. But some reported errors pointed to perfectly valid and intended code. I could switch on and off some of the checks. But that's not really helpful. I would be very careful with these kind of tools which check for errors *after* the program passed syntax checking. They are useful to do checks you should have done on your own but forgot to do. For really safe systems I'd prefer a programming language where the program is not runnable at all if the rules are violated which are usually checked by lint-like tools. I even would claim that it takes much less to time to let the compiler impose strict rules than check for them later. Ciao, Michael. From abulka at netspace.net.au Tue Jul 31 02:48:06 2001 From: abulka at netspace.net.au (abulka at netspace.net.au) Date: Tue, 31 Jul 2001 16:48:06 +1000 (EST) Subject: xmlrpc via proxy In-Reply-To: References: Message-ID: <996562086.3b6654a653596@www.netspace.net.au> Thanks Jeff, for the url to your proxy code - this code happens to be the code I was adapting ! Your code works OK for betty = Server("http://betty.userland.com", transport=UrllibTransport()) but fails for meerkatsvr = Server("http://www.oreillynet.com/meerkat/xml-rpc/server.php", transport=UrllibTransport()) giving the following exception Traceback (innermost last) File "c:\\xmlrpc work\python xmlrpc server\andyrpc1.py", line 40, in ? print meerkatsvr.system.listMethods() Fault: I am also getting a similar error message attempting to communicate with 'http://xmlrpc-c.sourceforge.net/api/sample.php' as per the python example at XML-RPC HOWTO at http://xmlrpc-c.sourceforge.net/xmlrpc-howto/xmlrpc-howto- python-client.html Thus it seems your code works ok for http://betty.userland.com but not for the other two ? Here is the code for your xmlrpc_urllib_transport.py with a couple of extra lines which is me attempting to talk to meerkatsvr. Any further thoughts by you or anyone else would be appreciated! import xmlrpclib class UrllibTransport(xmlrpclib.Transport): '''Handles an HTTP transaction to an XML-RPC server via urllib (urllib includes proxy-server support) jjk 07/02/99''' def request(self, host, handler, request_body): '''issue XML-RPC request jjk 07/02/99''' import urllib # ANDY added his proxy as parameter to urllib.FancyURLopener() urlopener = urllib.FancyURLopener( {'http' : 'www- proxy.BLAH.au:8080' } ) urlopener.addheaders = [('User-agent', self.user_agent)] # probably should use appropriate 'join' methods instead of 'http://'+host+handler f = urlopener.open('http://'+host+handler, request_body) return(self.parse_response(f)) from xmlrpc_urllib_transport import UrllibTransport from xmlrpclib import Server betty = Server("http://betty.userland.com", transport=UrllibTransport()) print betty.examples.getStateName(41) # WORKS OK # ANDY added extra code to talk to meerkatsvr from pprint import pprint meerkatsvr = Server("http://www.oreillynet.com/meerkat/xml-rpc/server.php", transport=UrllibTransport()) print "Now attempting to communicate with meerkat server" print meerkatsvr.system.listMethods() # EXCEPTION RASIED - why? - Andy > > I'm trying to get xmlrpc to work through a firewall/proxy. > > I wrote a urllib transport for XML-RPC a couple years ago. It > worked then, but I can't test it now because I no longer have > to deal with a proxy firewall :-) > > Look for: > xmlrpc_urllib_transport.py > at: > http://starship.python.net/crew/jjkunce/ > > --Jeff ------------------------------------------------- This mail sent through IMP: www.netspace.net.au From web2ed at yahoo.com Fri Jul 6 12:20:03 2001 From: web2ed at yahoo.com (Edward Wilson) Date: 6 Jul 2001 09:20:03 -0700 Subject: Python: Database to Web Part II Message-ID: <5174eed0.0107060820.ff90805@posting.google.com> To the Snake's Den: This is a continuation to an earlier post "Is Python Dead". Perhaps my previous title was a bit loud and over the top. In response to being accused a Troll, I want to say that this has been a serious plea for help. I would rather eat Spam than be a Troll. I have been hoping that someone else would write Oracle, DB2, and SQL Server drivers/modules for Python, so I wouldn't have to. Mostly because I haven't had time, and also because such an undertaking is better suited for a group with a formal review board rather than an individual code Maverick. I have come to the harsh reality that 90% of the developers who use Python are advanced developers doing mostly scientific research. I guess I am jealous that most of you get to work with Python, on a daily basis, while the rest of us are relegated to using slave's tools. Unless I go back to school, and take up academic research, I will not be using Python, unless I take two years off, working alone, to add the necessary database support which Python lacks. I understand that most of you geniuses can hit databases for storing your scientific data, however, I write applications which save peoples life's-public safety systems. I can't possibly use "EXPERIMENTAL" code in my day to day work. If something goes wrong with my code, I lose my job, and if it can be shown that I used experimental code downloaded from the Internet, I could be charged with criminal negligence. Python is too good of a language to hoard in the laboratory. Python could make both programmers and end-users life's so much better if it only had a "FEW" additional features. I think it is a shame that Python is only used for advanced-scientific-computing tasks. I know that as a representative of the business community, I have a small voice among scientists. However, surely the scientists among you, long to proliferate Python to the masses; to share your talents and achievements with the non-scientific world. I dare say, that Python would smash Java, Perl, Visual Basic, and any other new age tool (C/C++ dodgers) if it only had certifiable database support on par with that of JDBC. This is not to say that JPython, or whatever it is now called, is an alternative. I need C based Python--I need SPEED. I need to be able to hook into other C/C++ code. Until Java drops the VM fantasy, and starts compiling to native, it will never out pace what C-Python has to offer. I pray to the Python Gods "please bless us with a Python JDBC counterpart" and all in the world will be in balance. Thank you for all of your comments, I will surely give Zope a whirl, this may be the opportunity I have been waiting for --zERO. From philh at comuno.freeserve.co.uk Thu Jul 19 20:03:32 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Fri, 20 Jul 2001 01:03:32 +0100 Subject: Language change and code breaks References: <6957F6A694B49A4096F7CFD0D900042F27D55F@admin56.narex.com> Message-ID: On Thu, 19 Jul 2001 16:44:06 -0400, Guido van Rossum wrote: >> TRuE, tHe ExPRESsiVity oF ThE lANGuaGE is ProBAbLY nOt cRipPled, >> hOWEvEr, tHere ARe SigNIficantLy FeweR ideNtIFIeRs AVaILABlE whICh mEAns >> iT is LESs eXPRessIvE. IN pArTicULar, cOMmON Idioms liKE naMiNg CLASseS >> stArTiNg WiTh UppER cASE lETtERS, AND instaNCeS OF THose cLAsSes >> begINNiNG with A lOwER caSE LettER CaN NO LongeR Be usED. > >Very funny (not). You misunderstood the intention. The programming >environment should be case-preserving, and automatically correct >identifiers to use the same case as used when they were defined. Which would be good, as pressing [shift] slows down my typing. For those that remember, Sinclair QL BASIC did this. Though the case it saves it as should be alterable. -- #===== Philip Hunt == philh at comuno.freeserve.co.uk ======# Herbivore: effort-free public key encryption. See: ** First software release coming soon! ** From rnd at onego.ru Fri Jul 6 16:35:52 2001 From: rnd at onego.ru (Roman Suzi) Date: Sat, 7 Jul 2001 00:35:52 +0400 (MSD) Subject: Comment on PEP-0238 In-Reply-To: Message-ID: On Fri, 6 Jul 2001, Guido van Rossum wrote: >Roman Suzi writes: > >> This is reasonable. However, IMHO, solution need to be different >> than redefining established "/" behaviour? >> >> Could "right" division be given some other symbol than "/" and old "/" be >> left intact as a "low-level" C-conformant division every Python programmer >> is accustomed to? > >Unfortunately, the number of potential Python programmers who will be >frustrated by the current integer division is much larger than the >number of established Python programmers. The sooner we fix this the >better! Oh, yes... >Another thing. Division of integers is a pretty uncommon operation May be... (I recall all my sins using /) * >The warning framework and the future statement are there to make the >transition easier. Here's my plan, "new division in four phases": > >1. First we introduce a new function div() and a future statement that >2. In a following revision, we add a warning when / is used on two int >3. A revision later, we change all plain integer divisions to be an >4. Finally we can implement the "future" behavior by default. I wish, there were also from __past__ import old_lovely_integer_division from __past__ import old_xrange from __past__ improt old_non_nested_scopes and whatever was dropped. ;-) >I haven't picked dates yet; if folks agree, I would like to add div() >and a future statement to 2.2 and space the other steps a single >revision apart, so phase 4 would be at Python 2.5 (April 2003, if we >keep the current release schedule up). Is that too aggressive? It is not agressive at all... When we will have ANSI Python or ISO Python?;-) >I currently favor div(x, y) over x//y and x div y. Maybe also add >mod(x, y) for symmetry (that would also explain divmod() as a >messenger from the future :-). > >I'm not sure how to spell the future statement. Here are some >choices: > > from __future__ import float_division > from __future__ import real_division > from __future__ import new_division > from __future__ import division true_division probably Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Friday, July 06, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ ""Stupid" is a boundless concept." _/ From JamesL at Lugoj.Com Thu Jul 19 16:30:34 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Thu, 19 Jul 2001 13:30:34 -0700 Subject: Language change and code breaks References: Message-ID: <3B57436A.993F349F@Lugoj.Com> Bjorn Pettersen wrote: > > > From: Guido van Rossum [mailto:guido at digicool.com] > > > > > I'm still wondering what advantage there is to crippling the > > > expressivity of a language for the sake of a small group of > > > non-programmers. > > > > IMO there are two non-truths in this statement. > > > > (1) The expressivity of the language is not crippled. > > > > (2) Potentially, the group of non-programmers is much larger than the > > group of programmers (and it's easier to teach programmers an > > arbitrary rule than non-programmers). > > TRuE, tHe ExPRESsiVity oF ThE lANGuaGE is ProBAbLY nOt cRipPled, > hOWEvEr, tHere ARe SigNIficantLy FeweR ideNtIFIeRs AVaILABlE whICh mEAns > iT is LESs eXPRessIvE. IN pArTicULar, cOMmON Idioms liKE naMiNg CLASseS > stArTiNg WiTh UppER cASE lETtERS, AND instaNCeS OF THose cLAsSes > begINNiNG with A lOwER caSE LettER CaN NO LongeR Be usED. > > AS fAR aS thE Size Of thE VARious camPs, I haVE YeT tO sEe a coMPeLLinG > aRGuMeNt thAT THE grOup of noN-pRoGRaMmeRS THat WILl taKe up > pRoGRAmmInG, ANd wiLL DO sO in PYTHon InsTEad oF VisUal BasiC, Is any > LARGeR Than The groUp of ProgRAmmERs. I'M TELLING THERE IS NO SEMANTIC DIFFERENCE BETWEEN UPPER AND LOWER CASE! anything you see that may suggest otherwise is merely a figment of your imagination. it has been proven with case studies and geometric logic that there were strawberries, er, i mean indications that understanding mutable versus immutable, class versus instance variables, slice assignment, threading, slicing, and dicing were child's play for new programmers compared to the agonizing difficulty of remembering that on line 3 they used mySum and on line 6 they used mysum (but on line 9 they used my_sum...nevermind!) it has also been shown that the words "their", "there", and "they're" (among many homonyms) are easily confused even in written form and theirfore the english language should be changed to accommodate people knew to the english language. yeah, write. Note to the humor impaired: :-) From kens at sightreader.com Tue Jul 10 05:07:39 2001 From: kens at sightreader.com (Ken Seehof) Date: Tue, 10 Jul 2001 02:07:39 -0700 Subject: File processing References: <9id5p9$8r62@interserv.etn.com> Message-ID: <01b001c1091f$c9c74340$0e4ab43f@kens> import os path = '/junk' # put your directory here for fname in os.listdir(path): # list of files in your directory f = open(fname, 'r') lines = f.readlines() # reads a list of lines f.close() f = open(fname, 'w') f.writelines(lines[1:]) # writes all but the first line f.close() Now, be careful! This will remove the first line of every file in the directory, including files you don't want to ruin. Back up everything first! ----- Original Message ----- From: "Chris McMillan" Newsgroups: comp.lang.python To: Sent: Monday, July 09, 2001 2:01 PM Subject: File processing > Hello all! > > I'm trying to write a script that will open a file, delete the first line, > and then save the file with the same name. Can someone please point me in > the right direction? Thanks! > > Why am I doing this you may ask: I have tens of data files that I need to > strip the first line before I can process it in Matlab. So, I dream of a > script that opens every file in a directory, deletes the first line, ..... > > Thanks, > > Chris > > > -- > http://mail.python.org/mailman/listinfo/python-list From llothar at mailandnews.de Mon Jul 23 19:29:11 2001 From: llothar at mailandnews.de (Lothar Scholz) Date: Tue, 24 Jul 2001 01:29:11 +0200 Subject: UML Packages And Python Modelling Message-ID: I'm writing an UML Diagram Editor for python and would like to ask the community what entity is an UML package. My first idea was that a file is the logical equivalent, not the directory (likejava.and eiffel programmers would expect). But then what is a directory ? Should this be represented by a nested package ? From tjreedy at home.com Sat Jul 7 16:31:18 2001 From: tjreedy at home.com (Terry Reedy) Date: Sat, 07 Jul 2001 20:31:18 GMT Subject: Comment on PEP-0238 References: Message-ID: > Indeed, the beauty of binary operators is that they help the human > programmer quickly understand an expression Yes, indeed. ... > The proposal of "//" got a lot of opposition from folks who are > concerned that it would confuse people with a C++ or Java background > too much, because it's a comment there. I can see that now (I don't program in either) > The "div" keyword would be ideal except for the added complexity of > adding a new keyword to the language While adding one (yield), another won't hurt much, since a program to search for conflicts with names and make replacements in a collection of files could easily do both in the same two passes. (Two passes are needed so that the replacement for variable 'yield' or 'div' does not conflict with another existing variable such as 'yields' or 'divx'.) Another *STRONG* argument for replacing int / with another infix operator is the feasibility of revising the thousands of broken lines of code to run under 2.whatever. Any decent programming editor can do a 'find / and replace with xxx if I say yes' (which will require the reviser to examine the code to determine if / meant int div) but hardly any can do 'find / and examine the code on both sides to determine the strings that the interpreter will see as e1 and e2 and replace e1 / e2 with div(e1,e2) if I say yes'. Writing a special purpose update program would also be much easier. >-- do we need a separate warning phase here, too? Maybe yes, in parallel with / warnings. Maybe no, depending on what do with yield. I think it more important to make it as easy as possible to fix broken lines, whenever that does become necessary. Terry J. Reedy From deepak9999 at mail.com Fri Jul 6 09:18:22 2001 From: deepak9999 at mail.com (Deepak) Date: 6 Jul 2001 06:18:22 -0700 Subject: Tkinter doesn't work for MFC applications with Embedded Python? Message-ID: <48365474.0107060518.3f07cf24@posting.google.com> Hi, I am trying to run scripts that use Tkinter for GUI inside of an MFC application that has embedded python interpreter. I read through the other postings on this newsgroup regarding the difficulties of doing so. However, I am not able to figure out what I am doing wrong... Here is the C code in the MFC application: - void myFunc (int argc, char **argv) { Py_Initialize (); PySys_SetArgv (argc, argv); PyRun_SimpleString ("execfile ('myTkinterApp.py')"); } The contents of myTkinterApp.py are: - try: import Tkinter print 'Successfully imported Tkinter' try: rt = Tkinter.Tk () print 'Successfully executed Tkinter.Tk ()' except: print 'Error in Tkinter.Tk ()' except: print 'Error importing Tkinter' The result is printed as: - Successfully imported Tkinter Error in Tkinter.Tk () The exception thrown is something like "Tkinter.tk could not be initialized.." All other scripts and commands run fine in the MFC app. It is only the Tkinter based commands that have the problem. Please help... Deepak From robin at jessikat.fsnet.co.uk Fri Jul 27 12:49:03 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 27 Jul 2001 17:49:03 +0100 Subject: Deposing Dictators References: <9jmjne$q54$1@wisteria.csv.warwick.ac.uk> <3b602daf.1623450@nntp.sprynet.com> Message-ID: <$dK+wKA$tZY7Ewin@jessikat.demon.co.uk> In article , Guido van Rossum writes >Robin Becker writes: > >> We all know lightning is God's way of telling us to shut up. Of course >> God is benevolent no matter how appalling the universe gets. The >> opposite of benevolent is malevolent. When our quick-sorts go wrong it >> will be as a result of a benevolent act by a caring designer. > >I sincerely wish you would be struck by lightning. Your attitude >disgusts me. > >--Guido van Rossum (home page: http://www.python.org/~guido/) Oh dear I sense a humour deficit :( -- Robin Becker From chrishbarker at home.net Wed Jul 25 12:59:23 2001 From: chrishbarker at home.net (Chris Barker) Date: Wed, 25 Jul 2001 09:59:23 -0700 Subject: Proposal for .py2, py3, etc. extensions. Was: A way to accommodate laguage changes References: <3B5CB83B.F3B7D51@home.net> <5E877.23798$EP6.5677355@news1.rdc2.pa.home.com> <23891c90.0107240128.4715d705@posting.google.com> <3B5DC56F.3B84E77D@alcyone.com> <3B5DE39C.543DA6@home.net> <3B5DE7F3.EB5EC5F1@Lugoj.Com> <3B5E1075.94167ECD@home.net> <3B5E45B7.2C4AE40@Lugoj.Com> Message-ID: <3B5EFAEB.1EB156B3@home.net> James Logajan wrote: > But, but, Python ALREADY relies on file name suffixes! The "import" > statement: > > import > > snip snip > That is it; I can think of some minor objections or esthetic complaints, but > can't see any show stoppers unless I basically misunderstand some Python > internals. I thought I made this clear already, and it has been repeated in various other threads: A lot of python code is not in *.py files, and not run with the import statement. It is in dhtml, or a database, or an embedded script, or..... and run with exec or eval or execfile, or... For this reason, there needs to be a version identifier in the code for this scheme to 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 bas.vangils at home.nl Wed Jul 25 12:32:51 2001 From: bas.vangils at home.nl (Bas van Gils) Date: Wed, 25 Jul 2001 18:32:51 +0200 Subject: A few things :) In-Reply-To: <3B5EC9EE.108@australia.edu> References: <3B5EC9EE.108@australia.edu> Message-ID: <20010725183251.A26481@cp68200-b.tilbu1.nb.nl.home.com> On Wed, Jul 25, 2001 at 11:30:22PM +1000, Lee Nutter wrote: > Im a beginner, and although (i think) I know the base language all > right, I haven't really made anything. Can anyone recommend anything for > a first project? someone very wise (actually, a collegue of mine) once told me to only learn new things if you need them :-) Either way, there's lots of fun stuff you can do as a first project... > Also, I was just wondering, Why do you use python? To me its a hobby. > Why do some of you use it over other languages? I love the language, > don't get me wrong, I was just curious :) I'm also a bit new to Python. I had a basic course in JAVA once, tought myself the (basics) of Perl, Php and finallyh moved to Python. I'm getting used to it more and more, and am learning new things each time I use it (many thanks to Thomas Wouters for his patience, and Mark Pilgrim for writing the `dive into python' book). I use Python mostly because it makes it very very easy to write readable code, because it's a very intuitive language, because it's a good way of learning new things about programming, and mostly because it's fun :-) it's-not-much-but-I-hope-it-helps'ly yours Bas -- Bas van Gils Python - programming the way Guido indented it From b.jones at acecad.demon.co.uk Tue Jul 17 12:05:37 2001 From: b.jones at acecad.demon.co.uk (Brian Jones) Date: Tue, 17 Jul 2001 17:05:37 +0100 Subject: Python, C++, Java, Smalltalk, Eiffel,... References: <9is8rm$46d$1@panix3.panix.com> <4as5lt82h2oc47fl72mkb8i21ppf6lboop@4ax.com> Message-ID: <995385506.24044.0.nnrp-10.9e98af18@news.demon.co.uk> "phil hunt" wrote in message news:slrn9l8aj8.8in.philh at comuno.freeserve.co.uk... > On Mon, 16 Jul 2001 15:56:30 +0200, Lothar Scholz wrote: > >> > >>The problem is that there isn't one "better", just "better in the eyes of > >>the author", > > > >I believe that this not really true, for example you must accept that > >Common Lisp is much more powerful than any other language. > > Define powerful > > >The problem is that most people are not very open minded - mostly > >because there intellectual skills are to low to capture more. > >Sorry this seems to be arogant - but its the truth. > > Are you trolling? It's possible, isn't it? Able to grasp the complexities of too-hard-for-the-rest-of-us Lisp, but having more trouble with there/their, to/too and its/it's... Brian. From skip at pobox.com Fri Jul 13 13:53:34 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 13 Jul 2001 12:53:34 -0500 Subject: FW: Newbie list question In-Reply-To: <3D7C088D6CCFD31190A5009027D30E9103391050@torex004.attcanada.ca> References: <3D7C088D6CCFD31190A5009027D30E9103391050@torex004.attcanada.ca> Message-ID: <15183.13726.951719.329037@beluga.mojam.com> Mark> Does: Mark> foo += 'c' Mark> act like an append then? I always assumed it was the same as: Mark> foo = foo + 'c' Mark> which obviously should raise a TypeError. Here however it works, Mark> in that it appends 'c' to the object to which foo refers and thus Mark> to the object to which bar refers... You can tell whether a variable name has been bound to a new object or not by calling the id builtin function: >>> foo = [1,2,3] >>> id(foo) 136434132 >>> foo += '4' >>> id(foo) 136434132 >>> foo += '567' >>> id(foo) 136434132 >>> foo [1, 2, 3, '4', '5', '6', '7'] >>> foo += u"987" >>> foo [1, 2, 3, '4', '5', '6', '7', u'9', u'8', u'7'] >>> id(foo) 136434132 That you can augment a list with a string may seem weird until you realize that Python considers lists, tuples, plain strings, and Unicode strings to all be sequences, hence the acceptability of augmenting a list with strings. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From mcc at TO.GD-ES.COM Fri Jul 6 23:01:06 2001 From: mcc at TO.GD-ES.COM (Merton Campbell Crockett) Date: Fri, 6 Jul 2001 20:01:06 -0700 (PDT) Subject: Tuple Assignment Statement In-Reply-To: Message-ID: On Fri, 6 Jul 2001, Merton Campbell Crockett wrote: > I am new to Python. The last time that I used a high-order language was at > university in the early Seventies when I wrote a compiler for a language > with characteristics fairly similar to Python. Since then, I've spent a > significant portion of my time writing in machine and assembler languages. > > Am I correct in assuming that the following assignment statement is valid. > > Scheme, Host, Path = urlparse("http://JANUS.TO.GD-ES.COM/netops/") I, probably, should have played around before asking the question. The above appears to be correct except that Python requires that the number of variables must match the number of elements in the tuple. > If valid, would the three elements contain the following? > > Scheme: http: > Host: //JANUS.TO.GD-ES.COM > Path: /netops/ Unfortunately, there is an error in the urlparse function. I can understand why one might strip the string that terminates the scheme and introduces the network location. I do not understand why the path component was changed from "/netops/" to "/netops". These gives raise to another question. Why are there multiple libraries dealing with URLs? I had, initially, assumed that urllib would be the appropriate library. Merton Campbell Crockett From skip at pobox.com Wed Jul 25 17:03:54 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 25 Jul 2001 16:03:54 -0500 Subject: Distributed computing using SOAP. What about speed ? In-Reply-To: <3HF77.292$Fp.2574@news1.oke.nextra.no> References: <3HF77.292$Fp.2574@news1.oke.nextra.no> Message-ID: <15199.13370.758875.477614@beluga.mojam.com> Thomas> If you ever implement something like this, please post it here, Thomas> at Parnassus etc. A version on my compression patch (against xmlrpclib 0.9.8) is available from my website: http://musi-cal.mojam.com/~skip/python/ Ninth item on the "More or Less Current Stuff" list. If a patch against 0.9.9 or the version shipping with Python 2.2 is desired/required, let me know. Skip From paul at boddie.net Mon Jul 30 05:32:47 2001 From: paul at boddie.net (Paul Boddie) Date: 30 Jul 2001 02:32:47 -0700 Subject: PEP 238 (revised) References: <3B60B3D5.664A3D7F@engcorp.com> <23891c90.0107270138.6bb70413@posting.google.com> <3B61E456.78DFE802@sneakemail.com> Message-ID: <23891c90.0107300132.7caada93@posting.google.com> Joshua Macy wrote in message news:<3B61E456.78DFE802 at sneakemail.com>... > > It seems to me that if upon reading the PEP someone thinks "How on > Earth am I going to know what needs changing?", he is almost guaranteed > to have bugs in his code that relate to the very issue that the PEP > addresses. How could he not, since he's obviously never thought about > it before? He hasn't needed to think about changes to his division-utilising code before because no-one proposed a fundamental change to the division operator before. It's obvious that "places where division is used" may be affected, but it's possible that not all of them will be, just as it's possible that areas of the code "around" the division may need changing too. > Someone who thinks this way should be thanking his lucky stars that if the > PEP is implemented the language is going to grow the machinery in the near > term to help him identify the bugs (warnings and possibly tools), write code > that's not subject to the bugs (using / and // appropriately) and the > incentive (Python 3.0) to attack the problem in the next few years. It's certainly an interesting perspective you have. One writes code according to the published, well-defined and longstanding semantics of a particular operator in a programming language (namely those which dictate that the / operator yields a particular style of integer result when presented with two integer operands but a different style of floating point result when presented with at least one floating point operand), but then these semantics are then changed so that a floating point value (of the latter style) results in such cases. In your opinion, it is not sufficient to read the documentation carefully and comply with it, but also to second-guess the language designer's future intentions. I can't wait for people to start posting to comp.lang.python about how the examples in the Python books they have just bought all give the wrong answers. Perhaps Python book authors should start producing the errata for their books now, given that those books must all contain plenty of "bugs" too. Yes, I would hope that the language does "grow the machinery" to help people deal with this, and expect that people don't have to deal with it until such machinery is in place. Paul From hinsen at cnrs-orleans.fr Thu Jul 12 12:35:56 2001 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 12 Jul 2001 18:35:56 +0200 Subject: Numerical Python tutorial available Message-ID: The slides of my Numerical Python tutorial at last week's European Python Meeting in Bordeaux are now available on my Web site: http://dirac.cnrs-orleans.fr/~hinsen/courses.html 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 steve at lurking.demon.co.uk Mon Jul 23 03:20:07 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Mon, 23 Jul 2001 08:20:07 +0100 Subject: A use for integer quotients References: Message-ID: On Mon, 23 Jul 2001 01:30:09 -0400, "Tim Peters" wrote: >> but that's a small unrepresentative sample. Note I'm less interested >> in divisions of quantities that are already floats as those would be >> unaffected by this proposal. > >Understood; see above; and a runtime warning pinpointing instances of "/" >where this happens is easy enough to add. > Maybe that is what should be done for those doing numeric work who are worried about the silent loss of precision... from __warnings__ import paranoid_division Could lead to a warning every time '/' is done with integers, so that they could change it to the *new* '//' operator that always returns floats ;-) Why make the majority change their code when it only benefits the minority? From nde at comp.leeds.ac.uk Wed Jul 18 06:53:29 2001 From: nde at comp.leeds.ac.uk (Nick Efford) Date: Wed, 18 Jul 2001 10:53:29 GMT Subject: Regex for strings utility References: <1103_995396879@pan> Message-ID: On Tue, 17 Jul 2001 19:07:59 GMT, rhys tucker wrote: > I'm trying to write a script which operates like the Unix 'strings' > utility but I'm having difficulties with the regex. > > #!/usr/bin/env python > > # strings program > > import sys, re > > f = open(sys.argv[1]) > line = f.readline() This isn't answering your regex question but... You're opening a text file and reading it line-by-line here, which probably isn't what you want if you are trying to duplicate the behaviour of 'strings' exactly. f = open(sys.argv[1], 'rb') data = f.read() might be better. Nick From heikowu at ceosg.de Mon Jul 2 19:34:45 2001 From: heikowu at ceosg.de (Heiko Wundram) Date: Tue, 3 Jul 2001 01:34:45 +0200 Subject: apply problem Message-ID: <9hr0aj$ta0$06$1@news.t-online.com> Hey to all fellow Python users! I have a (strange) problem using apply under Python 2.1. I have a function in a class, that wishes to call another function in the same class whose name it receives as a name. I use the following code: apply(getattr(self,name),(attrs)) where name is the name of the function to call, and attrs is a variable (a dictionary) that is passed in to the function as well. Python comes with a very funny error message when I try to run this code: It throws a KeyError exception with the key being zero! What is wrong here? I have absolutely no clue, as the documentation of apply is, well, quite short. ;) Any help is appreciated! Yours, Heiko W. From colin at meeks.ca Tue Jul 24 13:02:09 2001 From: colin at meeks.ca (Colin Meeks) Date: Tue, 24 Jul 2001 17:02:09 GMT Subject: Sorting Lists Message-ID: I have a list that comprises of First Name, Surname, Age The list looks something like [["Mickey","Mouse","50"],["Stan","Mantz","3"],["Junior","Wilst","40"],["Kim" ,"Bean","15"]] How can I sort the list to rearrange it by either First Name, Surname, Age I believe I'd have to use a cmpfunc in the sort, but not too sure how to achieve the above. Thanks Colin --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.265 / Virus Database: 137 - Release Date: 18/07/2001 From dirck at pacbell.net Wed Jul 11 14:47:17 2001 From: dirck at pacbell.net (Dirck Blaskey) Date: Wed, 11 Jul 2001 11:47:17 -0700 Subject: Language change and code breaks References: Message-ID: "Guido van Rossum" wrote in message news:cplmlvh6dx.fsf at cj20424-a.reston1.va.home.com... > Very good sumary, Terry. I'm beginning to get second thoughts about > integer division -- maybe it's better to leave well enough alone, and > try to fix areas of the language that could really stand some fixing > (such as subclassing built-in types). > > --Guido van Rossum (home page: http://www.python.org/~guido/) Glad you're having second thoughts, I'm on my third or fourth. At one point you even had me convinced, but then... to someone maintaining a large code base, dealing with a change this subtle could be somewhere between 'intimidating' and 'terrifying', especially since there are no type declarations. I don't think I agree with the spirit of PEP 228, either. Hardware is a fact of life. Anyway, Just another point to consider: In all the examples cited that show why this is a problem, it's not integer division that causes the confusion, it's division of integer *literals*. Anyone using literal '1/2' in a program has probably made a mistake. I don't know how smart the compiler is in pre-processing constant expressions, but if it is, it could be smart enough to issue warnings for constant integer division yielding quotient == 0 or remainder != 0. Just a thought. d From aahz at panix.com Mon Jul 16 12:18:40 2001 From: aahz at panix.com (Aahz Maruch) Date: 16 Jul 2001 09:18:40 -0700 Subject: Most efficient solution? References: Message-ID: <9iv450$240$1@panix2.panix.com> In article , Alexandre Fayolle wrote: > >I was referring to the inner loop. n is the number of elements in B >(or of keys in C). 'item in B' is O(n), and 'C.has_key(item)' is O(log(n)). >You still have to multiply by len(A) for the whole program. That's functionally incorrect. Except under severely degraded conditions, C.has_key(item) is O(n). -- --- 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 Fortune cookie: Watch your relations with other people carefully, be reserved. From sdm7g at Virginia.EDU Mon Jul 23 17:35:28 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Mon, 23 Jul 2001 17:35:28 -0400 (EDT) Subject: the "Right Thing" [was: PEP0238 lament] In-Reply-To: Message-ID: 1/2 = 0 1/2 = 0.5 It's been asserted that one of those expressions above is "illogical" . ( Actually, it's been asserted that both of them are illogical, but each has been asserted by a different group of people. ) Which one seems to depend on your initial point of view: 1: The "close to the hardware" POV knows that computer CPU's have separate integer and floating point units, integer and floating point are disjoint sets, and hiding that fact is only going to confuse folks and delay the time the confront that truth. 2: The "abstract" POV, which is best implemented in Lisp & Scheme where number classes are nested sets: { fixnums (native ints) } { integers } == { fixnums } + { bignums } { rational } == { integers } + { ratios } so from that POV, it's not to be viewed as the "illogical" int op int => float but as: rational op rational => rational. However, Lisp also has another orthogonal classification which is disjoint: exact and inexact, which does map into hardware representation, as well as representing irrationals and algorithms that yield numeric approximations. So again, it's not viewed as: SQRT(int) => float but: SQRT(number) => number (may be inexact) [ I'm not sure I know how to weigh the question of backward compatability, effeciency, and all of the other issues involved here for Python and come up with a better answer on what's the "Right thing" , but I don't think you can win this argument with what seems to be "logical" ! ] -- Steve Majewski From tim at vegeta.ath.cx Tue Jul 3 21:14:35 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Wed, 04 Jul 2001 01:14:35 GMT Subject: Access all classes in a directory, put into an array, and print them out References: <9hsql302ghk@enews1.newsguy.com> Message-ID: Alex Martelli wrote: > "Kemp Randy-W18971" wrote in message > news:mailman.994168205.8845.python-list at python.org... > > Can anyone share a short code example of how to access all the programs in > a > > Unix directory, put them into an array, and print them out in Python? > Here > > is the code I have to do it in Perl (please forgive the harsh language). > > > > #!/usr/bin/perl -w > > #use Net::FTP; > > opendir (TEMP, '/usr2/ecadtesting/javaprograms') > > or die "Can't open current directory."; > > @files=join(',',grep(!/^\.\.?$/, readdir TEMP)); > > closedir TEMP; > > print "\n"; > > print @files; > > print "\n"; > > #!/usr/bin/python > import os > print os.listdir('/usr2/ecadtesting/javaprograms') > > Makes you wonder where Perl got its reputation for > conciseness, doesn't it?-) [Note the . and .. entries > are automatically removed by the listdir function]. A more concise Perl example would be: #!/usr/bin/perl -w sub listdir { opendir DIR, $_[0] or die $!; @files = grep { !/^\.\.?$/ } readdir DIR; close DIR; @files; } print join ',', listdir('/usr2/ecadtesting/javaprograms'); Someone had to package the code to open/read/close a directory in the os.listdir function, right? =) There is, undoubtedly, a Perl module that's already simplified this. People are just as capable of writing bad Perl code as they are of writing bad Python code. You've heard of people writing this? for i in range(len(array)): process(array[i]) Of course, once you know a little more it becomes: for item in array: process(item) or map(process, array) etc. =) -- -Tim Hammerquist Any emotion, if it is sincere, is involuntary. -- Mark Twain From cliechti at mails.ch Fri Jul 27 14:26:22 2001 From: cliechti at mails.ch (chris liechti) Date: 27 Jul 2001 20:26:22 +0200 Subject: File Reading , Reverse Direction References: <3B60F7EC.5275E026@lsu.edu> <3B6103B4.AF7AE15B@engcorp.com> <3B610A3C.5AF439E4@lsu.edu> Message-ID: Ratnakar Malla wrote in news:3B610A3C.5AF439E4 at lsu.edu: > Hi, > Thanx for the lightning reply. > Well , sorry for not speciying my platform. It is a pentium , running > Windows 2000. > what I really wanted was some sort of "tail " kind of functionality. > Unfortunately, there is no "tail" command in Windows. I was just > wondering, if there is any better way than reading the entire file into > memory. Anyways thanx for your reply. I am sticking with readlines() > Cheers, > Ratnakar ok thats somewhat offtopic - but the CygWIN distribution (http://sourceware.cygnus.com/cygwin/) includes all the nice unix commands on win32. in the newest version python is also included and the c-compiler (GCC) is nice for writing extesions. chris From vvainio at karhu.tp.spt.fi Mon Jul 9 03:30:58 2001 From: vvainio at karhu.tp.spt.fi (Ville Vainio) Date: 09 Jul 2001 10:30:58 +0300 Subject: Python: Database to Web Part II (and "teaching language") References: <5174eed0.0107060820.ff90805@posting.google.com> Message-ID: web2ed at yahoo.com (Edward Wilson) writes: > I have been hoping that someone else would write Oracle, DB2, and SQL > Server drivers/modules for Python, so I wouldn't have to. Mostly > because I haven't had time, and also because such an undertaking is > better suited for a group with a formal review board rather than an > individual code Maverick. I have to agree with this. There should be one, obvious choice for a database package. This would do wonders to popularity of Python and would beef up all attempts to convince management (and fellow programmers) that Python is a superior solution. It should also be non-restricted open source (not GPL, not "free for non-commercial use"). > I dare say, that Python would smash Java, Perl, Visual Basic, and any > other new age tool (C/C++ dodgers) if it only had certifiable database > support on par with that of JDBC. This is not to say that JPython, or We will see what Micro$soft's .NET will bring along as far as DB support goes... if it would make all languages "equal" in DB access (and Python gets a good .NET support), the stage is ours on the Win32 arena :-). > I pray to the Python Gods "please bless us with a Python JDBC > counterpart" and all in the world will be in balance. Amen. BTW, another thing to do for the "image" of python - stop emphasizing the newbie-friendlines, it traditionally repels the more advanced programmers who often think there is a trade-off between that and power. "Teaching language" is a somewhat uninteresting concept, learning to program isn't hard enough to warrant having languages specific to that. Besides, only l4m3rs need to be taught programming anyway ;-). -- 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 tim.hochberg at ieee.org Thu Jul 19 16:00:59 2001 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Thu, 19 Jul 2001 20:00:59 GMT Subject: Case Insensitivity (was Language change and code breaks) References: Message-ID: <%%G57.15495$Cy.1928702@news1.rdc1.az.home.com> I expect there will always be people who come to python expecting it to be case sensitive as well as those new programers who supposedly expect it to be case insensitive. Making the language purely case insensitive, particularly given its dynamic nature, seems like a recipe for disaster. On the other hand, if this does turn out to be a real impediment to new programers, a variation on case sensitivity -- prefereably activated by a flag to the interpreter -- might be useful. I'm not sure what to call this variation, except that it would flag as an error using a name that differed from another only by case. Hmmm. Since all variables with the same name would have the same case, I guess we could call it 'case consistency' instead of 'case insensitivity. Let's look at an example for why case sensitivity could be a problem. It's common practice to use all caps to designate constants, so consider the following code: class Contrived: HAS_SPAM = 1 HAS_EGGS = 2 #.... def has_spam(self): if self.flags & self.HAS_SPAM: return 1 else: return 0 For pure case sensitivity this would fail rather mysteriously (with an attribute error for HAS_SPAM, I believe). For the second type of case insensitivity described above, this would instead fail during compilation with an error something like: CaseMismatchError: Case of 'has_spam' doesn't match previous usage (did you mean 'HAS_SPAM'). With a carefully designed error message, I think it could be made obvious to both beginner and expert alike where the error was and how to fix it. In addition, since case consistent programs would be a subset of case sensitive programs, this could be implemented as a flag to the interpreter that would cause the interpreter to behave this way so that beginners and others who prefer case consistency could have it, while us sensitive folks could continue using Python with its current case sensitivity. There would, admittedly, be some trickiness in calling out to case sensitive modules from from case consistent ones, but I don't think these would be insurmountable. sensitive-to-change-ly yours, -tim From dedalus at yifan.net Thu Jul 26 03:04:51 2001 From: dedalus at yifan.net (Duilio Foschi) Date: Thu, 26 Jul 2001 07:04:51 GMT Subject: importing modules References: <3b5eff6a.97328527@news.libero.it> Message-ID: <3b5fbfef.146620710@news.libero.it> I got my answers. Thanks to everybody Duilio From dfackrell at DELETETHIS.linuxmail.org Mon Jul 23 12:11:25 2001 From: dfackrell at DELETETHIS.linuxmail.org (Daniel Fackrell) Date: Mon, 23 Jul 2001 10:11:25 -0600 Subject: A use for integer quotients References: Message-ID: <3b5c4dc9$1@hpb10302.boi.hp.com> Newbie comment: Why not add a "from __past__ import division" for those who need old code to work. Then there might be a little less resistance to this (arguably good) change. "Guido van Rossum" wrote in message news:cpzo9veuml.fsf at cj20424-a.reston1.va.home.com... > > [David Eppstein] > > > I don't suppose it would be possible to go through some repository of > > > Python sources and figure out the relative numbers of divisions > > > of integer arguments that end up an int versus the ones that are > > > coerced to floats? > > [Tim Peters] > > Guido did this for the Python library, and found three instances of "/" that > > would break. > > Alas, all this suggests is that the test suite *still* doesn't have > enough coverage. Looking for '/' tokens I found 30 modules using '/' > amongst Lib/*.py, and a quick inspection suggests that the majority of > these use integer division -- an expected result, given the > over-emphasis of the standard library on classic data types and > algorithms, which were mostly developed in a culture that despises > floating point numbers as too expensive. :-) > > But I also found a likely bug! In colorsys.py, there are two routines > (rgb_to_hls() and rgb_to_hsv()) that seem to be doing floating point > math using (r, g, b) inputs and don't take any consistent precaution > to cast these inputs to floats before dividing them. The outputs are > definitely intended to be floats. The inputs are likely RGB triples > taken from images, which are usually ints. > > This is why making / fractional division and // truncated division > will reduce the number of bugs in new code: for all occurrences of > truncated division, the author *knows* she wants truncated division, > and it's easy to remember to use // because using / gives an > immediately wrong result. When the users wants fractional division > though, it's common to test only with float inputs, or to miss a path > through the code where ints aren't casts to floats before they are > being divided. Then, much later, when an int gets passed and a > slightly wrong result is calculated, it takes hours of debugging to > discover the error. > > Note that this kind of bug is unique to Python (or dynamically typed > languages in general): in C, the arguments would have been declared as > floats and the problem would have been prevented. > > Reiterating why the current definition of '/' is evil: int and float > together aren't really two distinct types: they are at most a > type-and-a-half, and the integers are embedded in the space of floats > for most practical purposes. Division is the one exception, and it > hurts. Nobody wants to write polymorphic code where '/' means > truncated division for int arguments but fractional division for float > arguments. You know which kind of division you want when you write > the code, but there's no way to spell it. > > (I've seen this countered with the argument that classes can overload > / any way they want, and thus you can't rely on the "meaning" of / > anyway. But there you get what you ask for, and it's up to the author > of the class to decide how her class needs to behave in the context of > other numeric types. How integers behave in the context of floats is > already decided: you should be able to pass an int whenever something > requires a float.) > > Of course, I'm well aware of the issues around maintaining old code. > We will have to carry around "from __future__ import division" for a > loooooong time. Python 2.2 is the first opportunity to introduce it, > so let's not be shy. > > --Guido van Rossum (home page: http://www.python.org/~guido/) From jblazi at hotmail.com Sat Jul 28 23:35:48 2001 From: jblazi at hotmail.com (Janos Blazi) Date: Sun, 29 Jul 2001 05:35:48 +0200 Subject: Opening a file, second attempt Message-ID: <3b6384c7_6@news.newsgroups.com> I'd like to open a file for writing using the os.open function call. But if the file is already in use, the OS denies access to the file. How do I find out about this in my Python program? I do tno know the name of the exception that is raised. I have tried if os.access(filename_trunk,os.W_OK)==0: print "file not open" return but this does not work, access returns 1, though the file ist not accessible. Janos Blazi -----= 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 tjenkins at devis.com Tue Jul 10 12:29:33 2001 From: tjenkins at devis.com (Tom Jenkins) Date: Tue, 10 Jul 2001 12:29:33 -0400 Subject: An unspeakable act References: <3B4B28FD.B15CE75B@yahoo.com> Message-ID: <3B4B2D6D.7000703@devis.com> We also have python & zope apps in a number of client sites: United States Agency for International Development (USAID) US Department of State US Department of Labor Paul Winkler wrote: > Lyle Johnson wrote: > >>>it is just used for mall to medium scripting. I know better but I don't >>> >>have any proof. Can anyone >> >>>point me at a list of companies and the applications they have written (I >>> >>already know about Zope >> > > End of discussion right there, I'd say. > > "Zope users include Bell Atlantic Mobile, Red Hat, NASA, the US Navy, > ishopehere.com, i-Gift, IDG (Brazil), GE, Digital Garage, Verio, > www.HireTechs.com, and Storm Linux." > -- from http://www.zope.org/WhatIsZope > > -- Tom Jenkins devIS - Development Infostructure http://www.devis.com From bernhard at intevation.de Fri Jul 13 08:38:21 2001 From: bernhard at intevation.de (Bernhard Reiter) Date: 13 Jul 2001 12:38:21 GMT Subject: Cross-platform GUI app -- Tkinter? References: <3b4e211f$1@news.blarg.net> Message-ID: <9imq3s$jv3c9$1@ID-89274.news.dfncis.de> In article <3b4e211f$1 at news.blarg.net>, steveha at animal.blarg.net (Steve R. Hastings) writes: > If I want to make a GUI application with menus and such, and I want it to > be easily portable to multiple platforms, what is the best way to do it? www.wxpython.org (IMO) > Actually, do I need the expensive book? Is there a web site you like that > explains Tkinter well? I guess a good book will be worth the price. > In a perfect world, I'd like my Python program to be compiled to Java > bytecodes and thus theoretically portable anywhere. Does the use of > Tkinter make this impossible? Java is not as portable as you might think. When you start depending on libraries it gets system dependend pretty fast. Even C might be more portable. > I know I could use GLADE to design my app, and it would run great in Gtk+ > on Linux... if Gtk+ has been made portable to other systems (Win32, Mac) > then Gtk+ might be better for me than Tkinter. Gtk+ runs on W32 platforms. I generally recommend wyPython because of two major reasons: - uses native widgets - is not just a widget set, but an application framework 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 Mon Jul 16 11:17:13 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 16 Jul 2001 17:17:13 +0200 Subject: converting from perl: variable sized unpack References: <9iulp401r93@enews3.newsguy.com> <9iuq95$3e0$1@panix6.panix.com> Message-ID: <9iv0hr0lla@enews2.newsguy.com> "Roy Smith" wrote in message news:9iuq95$3e0$1 at panix6.panix.com... > Alex Martelli wrote: > > I find I can rarely throw away the match-objects in this cavalier > > way, because they carry much, often-needed information -- so, I ... > No it's not, but the problem is not that match returns None, the > problem is that Python doesn't allow assignment as a side effect. If I wanted "assignment as a side effect" it would of course be trivial for me to code it. I far prefer to have failure be signaled by exceptions -- a much more general & solid idiom. > Imagine if you could write it this way: > > if mo = re1.match(thestring) > dostuff(mo) > elif mo = re2.match(thestring) > dootherstuff(mo) > elif mo = re3.match(thestring) > etcetcetc(mo) > else: > nomatchatall() > > Wouldn't that be elegant and clean and obvious? > > After 4 years of using Python, I still find the lack of any way to do > an atomic "assign and test" unbelievably constraining. Surely you ARE jesting, right? After (I believe it was) four DAYS of Python, I had already placed in my sitecustomize.py the few lines (just typing them from memory now, as I've since removed them): class DataHolder: def __init__(self, value=None): self.value = value def set(self, value): self.value = value; return value def get(self): return self.value setattr(__builtins__,'DataHolder',DataHolder) setattr(__builtins__,'data',DataHolder()) to help me transliterate some existing C and Perl code which used what you call "atomic assign and test" -- a q&d hack until I could find the time to do it more Pythonically (and, actually, LEARN the Pythonic ways of doing things -- after four days, it was clear to me that I had not yet mastered them:-). So, IF I considered it elegant to set something and test it too, I could easily code, e.g: if data.set(re1.match(thestring)) dostuff(data.get()) elif data.set(re2.match(thestring)) dootherstuff(data.get()) elif data.set(re3.match(thestring)) etcetcetc(data.get()) else: nomatchatall() So far, so obvious, I hope -- whence my near-certainty that your bemoaning a 'lack' so trivially fixed as 'unbelievably constraining' must be some kind of deadpan humor whose point I'm missing -- if half a dozen lines in sitecustomize.py are all it takes to eliminate something "unbelievably constraining", how believable is it that one's really feeling constrained?-) Hmmm, maybe I should write this up as a Cookbook entry (not that there's much to write about...), just so I can give a pointer to it in the future rather than typing it in again and again on each such discussion...:-). Done -- see http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66061 Alex From ngps at madcap.dyndns.org Fri Jul 13 13:33:46 2001 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 13 Jul 2001 17:33:46 GMT Subject: Integrating SimpleHTTPServer into asyncore References: <9ifsp7$k1a$1@oravannahka.helsinki.fi> <9ihsuo$255$1@coco.singnet.com.sg> <9iibsu$kj$2@oravannahka.helsinki.fi> Message-ID: <9inbdq$rnd$1@dahlia.singnet.com.sg> According to Panu A Kalliokoski : > It depends. I haven't checked Medusa's code, but if it's done in a > sensible way (i.e. protocol handlers are separate objects from > socket/channel handlers), it should be at most a 15-minute job. Where > could I get the Medusa source to try it out? http://www.nightmare.com/medusa/ -- Ng Pheng Siong * http://www.post1.com/home/ngps Quidquid latine dictum sit, altum viditur. From andreas at digicool.com Thu Jul 12 12:06:06 2001 From: andreas at digicool.com (Andreas Jung) Date: Thu, 12 Jul 2001 11:06:06 -0500 Subject: list and implicit continuation may cause bugs in Python programs References: <07cb01c10ae4$64a3c440$9865fea9@SUXLAP> Message-ID: <086c01c10aec$8ebe4b80$9865fea9@SUXLAP> >It should check because this is poor writing style to have concatenation >of strings written with such a vertical alignment. "url" and "previews" >have no kind of logical vertical alignment, and a good checker should >consider this as suspicious. Is there a common opinion what "poor writing style" is ? :-) Andreas From bsass at freenet.edmonton.ab.ca Thu Jul 19 14:23:47 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Thu, 19 Jul 2001 12:23:47 -0600 (MDT) Subject: Language change and code breaks In-Reply-To: <200107191200.IAA06994@cj20424-a.reston1.va.home.com> Message-ID: On Thu, 19 Jul 2001, Guido van Rossum wrote: > > Now that we're in a new century, I think it's time to update to a > > new excuse! > > I didn't mean it as an excuse! > > > How about: > > > > Now that everyone's making the transition to multiple language support, > > unicode and multiple encodings, how to you portably define/implement > > case-insensitive comparison? > > Sorry, no problem. The Unicode standard defines for each character > whether it is upper or lower case, and what the corresponding > character is in the other case (if any). Hehe, so, if both case-insensitivity and multiple encodings were adopted... the easy to distinguish between "a" and "A" would not be allowed, but the hard to read versions of "a" with diacritical marks would be... ...ya, that makes sense. :-/ - Bruce From sholden at holdenweb.com Mon Jul 30 09:58:25 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 30 Jul 2001 09:58:25 -0400 Subject: Proxy Server References: <3B6513A6.C4B84218@beth.uniforum.org.za> Message-ID: "mixo" wrote in message news:3B6513A6.C4B84218 at beth.uniforum.org.za... > > How does one connect to an external mail server when you actually > connect to the outside through a proxy server (which may or may not > require a user id and or a password)? What I want to be able to do > is , given an email address, get the mail host ,and using that host, > verify > that the email receipient exists before sending mail using "smtplib". > > Seems to me the point of the proxy is precisely to stop systems from connecting to port 25 on anything but the mail proxy host. You will almost certainly find (if your net admins have done their job properly and the situation is correctly described) that you cannot use smtplib to connect to anything other than your mail proxy host. Certainly nothing outside your firewall, anyway. In the case where no firewall is installed the correct procedure is to separate out the domain from the email address (that will be everything following the "@") and use the DNS to look up the domain's mail hosts by retrieving the MX records, then trying each mail host, in order of increasing numerical priority, until you get a response or the list is exhausted. In the latter case you could try using the domain itself as a last-resort mail exchanger, but this will usually fail. I have written code to do precisely this, to allow a client to send email billing statements on behalf of their agents. I'm not sure I want to publish the code, however, given its ability to skip around the normal "no forwarding" rules imposed by most sensible mail hosts. This, by the way, is one reason you are being forced to work through a mail proxy: in combination with the firewall it stops you from spamming external domains with traffic purporting to come from some other domain which is not a part of your own. don't-shoot-the-messenger-ly y'rs - steve -- http://www.holdenweb.com/ From meowbot at meowing.net Tue Jul 10 06:47:27 2001 From: meowbot at meowing.net (Inconsistent Meowbot) Date: 10 Jul 2001 06:47:27 -0400 Subject: os.nice (or docs) BUG? References: Message-ID: <87g0c5oybk.fsf@litterbox.meowing.net> Roman Suzi wrote: > The following from the Python docs: > > nice (increment) > Add increment to the process's ``niceness''. Return the new > niceness. Availability: Unix. > > Contradicts what I see in python 1.5.2 - 2.1: > > >>> import os > >>> os.nice(1) > 0 > >>> os.nice(5) > 0 > > (and the process niceness become 6 as reported by top) > > It's docs inaccuracy or os.nice() bug? Or glibc bug? Both the documentation and posix_nice() itself could use help. The return value of the nice syscall is platform dependent. Unix returns (new nice value - 20), -1 on failure (but see below); while Linux returns 0 on success, -1 on failure. On at least some Unix systems, -1 may or may not really be an error, depending on whether the process priority had been changed beforehand. So, it looks like the One and Only Real True Way to call nice() is to set errno to 0, raise an exception only if errno is set after the call completes, and not to trust the return value to actually mean anything unless you know what platform you're on and what its nice returns. Ewwwwwwwww. From nperkins7 at home.com Sun Jul 1 04:58:11 2001 From: nperkins7 at home.com (Nick Perkins) Date: Sun, 01 Jul 2001 08:58:11 GMT Subject: Discussions and developing References: Message-ID: The newsgroup is a bit like an evolving ecosystem. A certain balance is achieved by the fact that really dumb questions generate fewer and shorter responses, while really interesting ones generate more and longer responses. In turn, the level of response may influence whether (and how often) similar questions are asked in the future. It's a bit like 'survival of the fittest', and a bit like 'supply and demand'. Newbie questions get asked because newbie questions get answered. This may be boring for experienced c.l.p readers, but I think it is a good thing. When I was a newbie I learned a lot from reading this ng, often such 'newbie questions', even if the answer was just a link to the faq or docs. We have to keep in mind that the 999th person to ask the 'compiler question' does not know about the previous 998 people, and should not be treated as if they had asked the question themselves 998 times. Fortunately, the generous clp readers do seem to understand this, and I am proud to be a part of a ng that embraces newbies, and tolerates such frequently asked questions. These days, I usually skip the newbie questions, but then I also skip lots of other stuff that doesn't really interest me. In fact it is easier to skip over dumb questions than it is to skip over dumb answers to good questions (which are much more numerous). Skipping over the newbie questions is no more effort than skipping over any other question that doesn't interest me. Besides, taking a quick scan of the current postings, I see very few 'dumb questions', and a lot of very specific and intelligent questions. You would have to purposely seek out the dumb questions amongst the good ones just to get upset about it. If the "compiler" question comes up once per day out of hundreds of messages, it's no skin off my back. And if someone wants to answer the "compiler" question (or 5 people), then let them do it. Less work for the rest of us. What is not productive is getting all upset about such questions and going out of one's way to reply with "you should have read the faq", when the question has already been answered. If you don't like dumb newbie questions, don't answer them. There is no point getting upset about such a small percentage of all postings. Final point-- Python is supposed to be 'programming for everyone', and to that end, it is important to know what the most common newbie questions and mis-understadings are. The frequency of the "compiler question" should be taken as a hint that the topic requires more prominence in the documentation. You may say, 'but it's right there in the faq!', however numbers don't lie. If the question is asked so often it's not becuase the newbies are dumb, it's becuase the question is one that naturally occurs to newbies. It's better to know what the newbies are wondering about, it helps to improve the docs and the faqs etc. From jwbaxter at spamcop.com Fri Jul 27 19:56:45 2001 From: jwbaxter at spamcop.com (John W. Baxter) Date: Fri, 27 Jul 2001 16:56:45 -0700 Subject: PEP 238 (revised) References: Message-ID: <270720011656458534%jwbaxter@spamcop.com> In article , Guido van Rossum wrote: > I expect that only mathematicians use longs outside the range of > IEEE double, and they will be wise enough to use //. I suspect "mathematicians" is the wrong word there...this example would be more like (sorry...long day and wrong word) "computationalists"...or do I mean numerical analysts. --John From tim.one at home.com Sat Jul 21 17:41:54 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 21 Jul 2001 17:41:54 -0400 Subject: Can I copy a generators state and then backtrack to it if necessary? In-Reply-To: Message-ID: [Steve Horne] > Can I copy a generators state and then backtrack to it if necessary? No, generators implement the iterator interface, and that's all; the iterator interface doesn't have a copy method. > To explain what I mean, imagine the following... > > from __future__ import generators > > def test_gen (p) : > for i in range (p) : > yield i > > def use_gen (p) : > i = p.copy () # or some equivalent > > # Do something that may accept values from p > > p = i # Backtrack > > # Do something that may accept values from p > > > use_gen (test_gen (50)) > > > I know that I could rewrite the use_gen function to accept a function > rather than a generator, so that it would be called as... > > use_gen (test_gen, 50) > > ... and the function parameter could then be evaluated to rederive the > initial generator state at any time, There are as many ways to fake it as you can afford hours to dream them up <0.7 wink>; and don't forget that class methods can be generators too, and so access instance variables (a very general way to influence the state; nested scopes add another; see the Knight's Tour solver in test_generators.py for natural applications of both). > but this isn't really as flexible> (you can't easily recreate any > state other than the initial state), and it also seems less intuitive > to me. It's not at all clear what p.copy() "should" do, though-- even for simple iterators --and that's why we're leaving it out, at least at the start. For example, the bindings of local variables are part of a generator's state. What should p.copy() do about *them*? If a local vrbl is also a generator, should it (recursively) apply the .copy() method to it too? Just make another reference to the current bindings of the locals? Systematically do shallow copies of values? Systematically do deep copies? > A major use I could think of for this is in applications that need to > balance searching by depth and by breadth according to some heuristic. > In addition to the search tree so far, it would be easy to record > generator states that have only identified some of the branches from a > particular state - so you could explore this area of the tree > depth-wise for a bit then nip-back to expand the breadth later. An > obvious application would be for board games such as chess. Needs a PEP, and won't go in for 2.2 because I can pretty much guarantee "one size fits all" won't. Python generators aren't quite like any other language's, and so we need more real-life experience with them before deciding what (if anything) more is truly needed. in-the-meantime-python-chess-apps-aren't-really-a-major-use-ly y'rs - tim From skip at pobox.com Tue Jul 24 07:55:08 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 24 Jul 2001 06:55:08 -0500 Subject: Pinecones multiply like rabbits around here... Message-ID: <15197.25116.543399.481142@beluga.mojam.com> I was on a walk with my wife and dog yesterday. Out of the blue I asked her "what's the result of five divided by two?" After a little back-and-forth where she tried to figure out how I was trying to trick her and make her look foolish she answered, "two-and-a-half". I then posed, "Suppose you have five pinecones and you want to clump them into groups of two. What would you do?". Her answer was, "Put two in the first group, two in the second group, and break the last pinecone in two so the third group would have two as well." Can we represent that in Python's arithmetic operations somehow? :-) -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From sholden at holdenweb.com Thu Jul 5 11:29:46 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 5 Jul 2001 11:29:46 -0400 Subject: Is Python Dead? References: <458b194a.0107050711.72007607@posting.google.com> Message-ID: "Resty Cena" wrote in message news:458b194a.0107050711.72007607 at posting.google.com... > "Edward B. Wilson II" wrote in message news:... > > I have been following Python for five years now, and I am still just as > > frustrated with it as I was in 1996. > > > > Python still doesn't have good database support, > > I, too, have been following Python since 1996, waiting all the while > to make it easy for me to do database programming. What I'd call good > database support is where I download a file or set of files into a > directory under my Python directory, perhaps run an install program, > then start Python, import a package, issue a command to connect to > Oracle, and start playing around with the scott/tiger database. I > don't want, nor do I have the time, to compile anything, nor muck > around with the Windows registry, nor manually set paths -- I just > want to try the product, not install it for production use. Ideally, > I'd like the IDE to do this for me. I'm a database programmer, and I > want to write applications right away. I'm also lazy and I expect much > from my tools. Of course, one of the reasons why support isn't better is the huge ratio of consumers to producers. That's not necessarily a bad thing, but most of the best parts of Python have been the results of individuals providing what they needed for their own purposes and then opening up the resulting code. Continue to sit on your hands by all means. What you need should be along in another five years or so. But simply posting to complain that things aren't as you want is unlikely to change in the next six months what nothing else has changed in the last five years. There are lots of people doing much good database work with Python. The mxODBC package (free for non-commerical use) and the cx_Oracle package (free) do indeed let you do what you describe (i.e. download, unpack, run an install script and connect to a database). So I suggest you look a little harder and complain a little less. Normally I try to include URLs in postings such as this, but you know, somehow I get the impression that clicking on a link in a news posting might just be too much trouble ;-) Come on in, the water's lovely. regards Steve -- http://www.holdenweb.com/ From kzaragoza at mediaone.net Mon Jul 2 10:45:49 2001 From: kzaragoza at mediaone.net (Kris J. Zaragoza) Date: Mon, 02 Jul 2001 14:45:49 GMT Subject: Is Python Dead? References: Message-ID: This strikes me as flamebait, but I'll put on my asbestos suit and dive in anyway. :-) On Sun, 1 Jul 2001 21:42:37 -0700, Edward B. Wilson II wrote: >I have been following Python for five years now, and I am still just as >frustrated with it as I was in 1996. > >Python still doesn't have good database support, nor has it grown to be >useful in the web space as mod_perl. PyApache has been around longer than >mod_php, yet php has far surpassed it as a productivity tool in the web >space. It seems that you are completely ignoring both mod_snake and mod_python, both of which offer all the power of mod_perl. You are also ignoring the wealth of database drivers available for Python, as others in this thread have already attested to. >It would seem Python can do everything, yet nothing. Everyone wants to >write the next killer application with Python, XML parsers, image >manipulators, super computer steering modules, yet no one wants to work on >making Python perform where it matters most. Python is the best language at >eclectic stuff, however, poor at bread and butter tasks. Here is your fundamental error: You are assuming that everyone else sees Python from your point of view. For many people, XML parsers, image analysis and manipulation, and heavy numerical work ARE bread and butter tasks. There are many people working within corporations and research institutions that couldn't care less about spitting out web pages. What you consider to be extremely important is simply trivial or completely unimportant to others. > >Python needs better leadership in areas of its growth. Python is truly the >best language in use today, except it still isn't very useful for the >largest solution sector, database access, and information presentation (web, >or otherwise). > >It seems that Python should strive to be great at the ABC's before it >attempts poetry. I think that Python's leadership (specifically Guido) has been doing a fantastic job. The powers that be have avoided trying to pigeon-hole Python into one particular application area, instead making it useful to a broader audience of software developers. It is this flexibility that makes Python so incredibly useful, in my opinion. I myself use Python for a variety of tasks. It scales down nicely to simple scripting tasks, and scales up to heavy data analysis and manipulation using relational databases. I use Python for "bread and butter" work that has nothing to do with generating web pages. I'm even using the Jython implementation in a production order processing environment and haven't seen a single hiccup. Python gives me all the power and flexibility I need to get my job done. -Kris -- Kris J. Zaragoza | "Unfortunately, most people can't out-think a kzaragoza at mediaone.net | grapefruit." --Jon Bodner From chrishbarker at home.net Fri Jul 27 15:41:56 2001 From: chrishbarker at home.net (Chris Barker) Date: Fri, 27 Jul 2001 12:41:56 -0700 Subject: PEP 238 (revised) References: Message-ID: <3B61C404.919C3030@home.net> > > - Use a directive (or some other way) to specify the Python > > version for which a specific piece of code was developed. This > > requires future Python interpreters to be able to emulate > > *exactly* every previous version of Python, and moreover to do > > so for multiple versions in the same interpreter. This is way > > too much work. A much simpler solution is to keep multiple > > interpreters installed. Since I last commented on this section, there have been a few other comments, and I have had a few more thoughts. "Terry Reedy" writes: > The only way I can think of to 'globally' turn on new division on my > own Windows computer is to rebind .py and .pyc to python.bat > containing '...python.exe -Dnew'. Yes, but what do you do if you don't want the behaviour global? Then you are stuck. Guido van Rossum wrote: > Well, I hope that making the change Python 3.0 does the right thing > for you. It shouldn't be hard to alert your customers that Python 2 > is required for your company's applications. Like Perl 4 and Perl 5, > Python 2 and Python 3 will probably live alongside for many years. I realise that my fantasy of an interpreter that fully emulates all previous versions is just that, a fantasy, but if, as you say, Python 2 and Python 3 are going to be living alongside each other, than we need to have a way of marking a given module as one of the other. File extension is one possibility, but certainly a limited one, something in the code itself would be better. Even if there is no integrated interpreter, "python" could be a small script that dispatches the file to the appropriate interpreter, similarly to Terry Reedy's batch file above. The sysadmin could decide how many old versions to keep around. > Requiring a version specifier in all new code is very annoying. The > future statement is annyoing too, but at least it's a transitional > measure. I think it is "a little annoying" rather than "very", and I just think explicit is better than implicit. I suppose it could be optional. If you have confidence that your code will be run the right interpreter, you could omit it (A command line option like -IgnoreVersion (or -RequireVersion) could be added to support this). > I agree that if we really need to have a way to explicitly request > past behavior, "from __past__ import ..." is a decent syntax. I just > noticed that PEP 236 (the __future__ PEP) mentions this as an > possibility (although the author claims it is unlikely). The problem with the from __past__ statement is that we will end up with many different dialects of the language, all of which need to be supported (if it's too much work to have old versions supported, why is this OK?) and will need to be supported forever! At least updating your versions is a one-way street. Yes, if you want some of the new features you have to take them all, but I thikn that's better that to have each new feature optional! -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 grumble at usa.net Wed Jul 11 09:14:38 2001 From: grumble at usa.net (jcm) Date: 11 Jul 2001 13:14:38 GMT Subject: Python speed References: <9ifjjh$1e3$1@news.mathworks.com> <3B4B562F.77C1B79@yahoo.com> <9ifo90$4hh$1@news.mathworks.com> Message-ID: <9ihjfu$3ls$1@news.mathworks.com> Greg Jorgensen wrote: > "jcm" wrote in message > news:9ifo90$4hh$1 at news.mathworks.com... >> Well, I say this because I've written a mud engine in Python and it's >> slow. > I drove my motorcycle around Laguna Seca, and it was slow. Maybe if I bought > a different brand of motorcycle I could go around the track faster. Well that's just silly. That's a bad analogy, for reasons that should be obvious. Also, recall that I said my ONLY point was that cpu-bound performance CAN become an issue. That is, depending on what you want your mud to do, you may find Python to be slow. I've spent time trying to squeeze more performance out of Python, but was unable to speed things up to a point where I was happy. I didn't bother posting my source code, because I'm personally not interested in looking for further optimizations. Feel free to email me if you want it, but I doubt it's worth your time. From stepken at little-idiot.de Mon Jul 16 02:17:30 2001 From: stepken at little-idiot.de (Guido Stepken) Date: Mon, 16 Jul 2001 08:17:30 +0200 Subject: [Q]Remove Directory in Win2k References: <3hMlEP$l9c@openbazaar.net> <9isj52$k5sis$1@ID-7529.news.dfncis.de> Message-ID: <3b52a287$0$19082$9b622d9e@news.freenet.de> Karl M. Syring wrote: > "?Q?@?U" schrieb im Newsbeitrag > news:3hMlEP$l9c at openbazaar.net... >> Hi~~guys ^^ >> My patition is NTFS >> when I execute below codes, it return error "Permission Denied". >> And, the directiory "test" remainly exist. >> >> import os >> os.mkdir('test') >> os.remove('test') > > That should be > os.rmdir('test') > > Karl M. Syring > > > > From Randy.L.Kemp at motorola.com Tue Jul 3 20:57:54 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Tue, 3 Jul 2001 19:57:54 -0500 Subject: What's wrong with this program Message-ID: Thanks. I will try that when I get back to work on Thursday. -----Original Message----- From: Bill Bell To: python-list at cwi.nl Cc: Kemp Randy-W18971 Sent: 7/3/01 6:04 PM Subject: RE: What's wrong with this program Kemp Randy-W18971 wrote, in part: > Does anyone have an example of how to set filename to access files in > a directory list, so I can implement this? My Python is limited, as I > don't use it every day, and in limited ways. Thanks. import glob for filename in glob.glob('.\*'): print filename Replace the argument to 'glob' with a string that gives the directory you want to list, and the 'print filename' with one or more statements making use of 'filename' that do whatever it is that you want to do. Bill > -----Original Message----- > From: Oleg Broytmann [mailto:phd at phd.fep.ru] > Sent: Tuesday, July 03, 2001 3:05 PM > To: Kemp Randy-W18971 > Cc: 'python-list at python.org' > Subject: RE: What's wrong with this program > > > On Tue, 3 Jul 2001, Kemp Randy-W18971 wrote: > > Thanks for the correction. > > Actually I think you don't need ftp.connect() at all - it is called > in ftp.__init__... > > > Anyone know the correct format to transfer files > > from one server directory to another server directory? > > I don't know - I've never used ftplib, but the idea is obvious: put > it one by one. Something like this: > > for filename in somelist: > ftp.storbinary("STOR " + filename, open(filename, 'rb')) > > Oleg. > ---- > Oleg Broytmann http://phd.pp.ru/ From atl023 at srl.css.mot.com Fri Jul 20 12:37:14 2001 From: atl023 at srl.css.mot.com (Tien Lee) Date: Fri, 20 Jul 2001 11:37:14 -0500 Subject: Question about the Python Priority Queue Module - PQueue 0.1a Message-ID: <3B585E3A.F6BC689A@srl.css.mot.com> Hi there, Has anyone downloaded and used the priority queue module - PQueue 0.1a - from the web site: http://mail.python.org/pipermail/python-announce-list/1999-July/000121.html? This module is very useful in most cases, but I found one problem when I used it, and I wonder if there is some bug in the original code of that module. The problem is described as the follows: If I use the PQueue object in my simulation program (i.e., set an attribute of one of my class as a PQueue object), even the simulation result is correct, the system will just hang there after the program finishes running, and I have to hit Ctrl-C to get the prompt back. If I use "del" statement to delete the existing PQueue object in the end of the program, the system will freeze on the del command line. However, if I just pop one element from the existing PQueue in the end of the program, then everything will be fine and I get the prompt back after the program finishes running. Has any of you encountered this problem before? Could you guess the possible reason to cause that problem? Do you know any newer version of Python priority queue module available from the web? Thanks a lot for your time and kind help. Sincerely, Tien -- Tien-Hsiung Lee Motorola PCS Research and Advanced Technology Labs 2015-5 North Division Street Harvard, IL 60033 IL21 / AN284 Work: 815-884-0964 Fax: 815-884-2519 Pager: 847-576-0295 PIN# 17975 -------------- next part -------------- An HTML attachment was scrubbed... URL: From urner at alumni.princeton.edu Thu Jul 26 14:34:54 2001 From: urner at alumni.princeton.edu (Kirby Urner) Date: Thu, 26 Jul 2001 11:34:54 -0700 Subject: Norton AV 2001 + popen + WinMe = crash References: Message-ID: Thanks for the enlightening chatter guys. I forwarded Tim's "appalled" post (above) to Symantec NAV tech support and within 24 hours got a message back that the problem was fixed for NAV 2001 Ver 7.07 -- all I'd need to do is run LiveUpdate to get the latest version (must have come out recently, as I run LiveUpdate a lot -- was it since my post?...) Anyway, I did as advised, and it works! popen and its flavors now work with NAV enabled. Hooray. Kirby "Tim Peters" wrote: >[Kirby Urner] >> So how does IDLE invoke the browser if not with popen and if >> it uses popen, then why can't I from the IDLE shell? The kind >> of question that keeps me up at night. > >[David Bolen] >> At least this can be answered by looking at the source, and let you >> get some sleep :-) <> >> So there's no popen() involved. > >Almost all correct. Thanks, David! The 2.0 truth is hairier than it looks, >because win32api doesn't ship with the base Python distribution: 2.0 also >uses webbrowser and os.startfile(), and indeed the latter function was >introduced at the last second for 2.0 precisely so that IDLE wouldn't have >to use MS popen(). From paul at svensson.org Wed Jul 25 21:55:05 2001 From: paul at svensson.org (Paul Svensson) Date: 26 Jul 2001 01:55:05 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: Message-ID: <9jnt9p$qhe$1@newsy.ifm.liu.se> "Terry Reedy" writes: >> The interesting thing is that the one thing that has to change in >> order to get a unified numeric model, whether we introduce rationals >> in the numeric tower or not, is integer division > >(IMO -- and attempting to be helpful again) This (and similar >statements) is rhetorically wrong and counter-productive. In PEP238, >you are NOT proposing to delete integer division (and I hope/presume >you never will), you are NOT proposing to switch it to C's version >(ditto), nor are you proposing any other substantive change (ditto). >From a technical viewpoint, you are merely, in Tim's words, proposing >to change it's spelling, so that future i//j == current i/j, down to >the very last bit. This is not what's proposed. i//j will be for all numeric types like current i/j for ints. i/j will be for all numeric types like current i/j for floats. >The *really* interesting thing is that the one thing that has to >change for you to pursue your further numeric goals is the current >overloading of integer and fractional division onto one symbol, which >is exactly what 238 undoes by adding a second symbol. The main >practical technical issue, to repeat from my essay of two weeks ago, >is code breakage, forwards and back, and the costs and benefits >thereof. The important thing is that i//j will return the same value regardless if i and j ar ints or floats; ditto for the new i/j. Numeric unification means that (i == x and j == y) == (i op j == x op y) for all op, i, j, x, y, regardless of numeric type (ignoring exceptions and round-off errors). This is not true for the current semantics of '/'. That's why it must go. /Paul From juergen.erhard at gmx.net Mon Jul 16 14:49:02 2001 From: juergen.erhard at gmx.net (=?ISO-8859-1?Q?=22J=FCrgen_A=2E_Erhard=22?=) Date: Mon, 16 Jul 2001 20:49:02 +0200 Subject: Is Python Dead? Long Live Python! In-Reply-To: <31575A892FF6D1118F5800600846864D78BE89@intrepid> (message from Simon Brunning on Mon, 16 Jul 2001 13:06:40 +0100) References: <31575A892FF6D1118F5800600846864D78BE89@intrepid> Message-ID: <16072001.4@wanderer.local.jae.ddns.org> >>>>> "Simon" == Simon Brunning writes: [The martellibot said you have to sleep close to books in order to learn from them...] Simon> Putting them under your pillow does no good; you have Simon> to *eat* them if you want to gain their power. Simon> The 'Essential Reference' isn't a problem here, but you'll Simon> need to be a *big* eater to cope with 'Programming Python'. Too many games of nethack? Bye, J -- J?rgen A. Erhard (juergen.erhard at gmx.net, jae at users.sourceforge.net) MARS: http://members.tripod.com/Juergen_Erhard/mars_index.html "vi has two modes the one in which it beeps and the one in which it doesn't" -- Alan Cox -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 248 bytes Desc: not available URL: From guido at python.org Wed Jul 25 16:24:46 2001 From: guido at python.org (Guido van Rossum) Date: Wed, 25 Jul 2001 20:24:46 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: Message-ID: David Bolen writes: > Guido van Rossum writes: > > > "Bjorn Pettersen" writes: > > > > > I think perhaps an equally interesting example is something like: > > > > > > 2L**128/2 > > > > > > which currently gives an exact result, but under the proposed new > > > semantics would give an approximation... > > > > Have you read the PEP? The PEP only returns a float if the int result > > would yield a remainder. > > Does it? While returning an integral value in the above case, > wouldn't it would in fact be a float data type (barring the addition > of rationals), as per: > > (from PEP238) > > "The type of a/b will be either a float or a rational, depending on > other PEPs[2, 3]. However, the result will be integral in all case > the division has no remainder." > > And given that, what happens if float can't represent the resulting > precision necessary? > > Of course, this is only true later when this is the default, right? > Until then, the "future" implementation is an addition of 0.0 to the > divisor, so the result would definitely be float, and not necessarily > integral. > > Unless you meant something other than the data type involved by > "returns a float". The PEP is currently contradictory and incomplete. The "future division" operator (generated by x/y when in the scope of a future division statement) will return either a rational or a float -- obviously it can't return a rational until they have been made part of the language (which may or may not ever happen). Since 2.2 won't have rationals, it will return a float even for 2L**128/2 -- but only when you use a future division statement, and in that case you get what you ask for. The current patch on SF adds 0.0 but that's not what it will do once 2.2 is released. --Guido van Rossum (home page: http://www.python.org/~guido/) From gerhard.nospam at bigfoot.de Fri Jul 6 06:33:46 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Fri, 6 Jul 2001 12:33:46 +0200 Subject: ICFP 2001 contest - Python team, anyone? References: Message-ID: On Fri, 06 Jul 2001 07:15:35 GMT, Nick Perkins wrote: >... reading contest rules... so, we would have to write for Python 1.52?? >... and this is for a functional programming contest? 2.1 would be better, >with nested scopes and list comprehensions, etc. I certainly won't be going back to 1.5.2. This just means we'll have to freeze to entire thing (they recommend submitting statically linked executables anyway). 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 bsb at winnegan.de Thu Jul 5 08:09:46 2001 From: bsb at winnegan.de (Siggy Brentrup) Date: 05 Jul 2001 14:09:46 +0200 Subject: python-mode and py-python-command In-Reply-To: References: Message-ID: <87vgl77f1x.fsf@winnegan.de> Roman Suzi writes: > On 5 Jul 2001, Siggy Brentrup wrote: > > >Roman Suzi writes: > > > >> Hello! > >> > >> How do I tell Emacs to call specific Python interpreter > >> within a certain file with Python code? > >> > >> I know that for this I need to set up py-python-command > >> variable, but how to do it? > > > >Which version of py-mode.el are you using (C-h v py-version)? > >On my system it shows > > > > Value: "3.105" > > Exactly this! > > >That version is slightly broken, it runs the Python interpreter > >in the py-which-shell buffer-local variable. This variable is set from > >py-python-command on M-1 C-c C-t (py-toggle-shells). Just checked out python-mode.el from the CVS tree. As cvs annotate shows, the problem has been fixed since long in $Revision: 3.103$ . To whomever it concerns: Where does the broken 3.105 come from? > So, toggling between, say, 1.5.2. and 2.1 is impossible? Toggling is meant for switching between CPython and JPython interpreters, but I guess you can abuse py-jpython-command. Regards Siggy -- Siggy Brentrup - bsb at winnegan.de - http://www.winnegan.de/ ****** ceterum censeo javascriptum esse restrictam ******* From missive at frontiernet.net Mon Jul 23 19:00:25 2001 From: missive at frontiernet.net (Lee Harr) Date: Mon, 23 Jul 2001 23:00:25 +0000 (UTC) Subject: incrementing characters References: <9jhojp$t7h$1@solaria.cc.gatech.edu> Message-ID: <9jiaa9$3s96$2@node21.cwnet.roc.gblx.net> On Mon, 23 Jul 2001 18:22:02 GMT, Nick Perkins wrote: > > "Holland King" wrote in message > news:9jhojp$t7h$1 at solaria.cc.gatech.edu... >> how do you interate a letter or string? for instance: >> a + 1 = b >> or >> aa + 1 = ab >> etc. in c it is similar to above and i am guessing there is an equally >> simple way to do it in python, i just can't figure it out. thank you >> for your time and help. perl makes this simple: $s = "aabc"; $s++; print "$s\n"; $s = "zzzz"; $s++; print "$s\n"; would print: aabd aaaaa I think in python I would create some kind of IncrementableString class which does exactly what I want it to do on only the right kind of data. From chrishbarker at home.net Wed Jul 25 19:45:08 2001 From: chrishbarker at home.net (Chris Barker) Date: Wed, 25 Jul 2001 16:45:08 -0700 Subject: PEP238 and zope References: Message-ID: <3B5F5A04.C1CB0707@home.net> Guido van Rossum wrote: > Perhaps we should change the interpreter to guarantee truncation, so > we can tighten the docs? I'm adding a bug report for this to SF. > > --Guido van Rossum (home page: http://www.python.org/~guido/) Yes, yes yes.!!! The fewer things that depend on "the underlying C library[compiler]" the better! -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 Sun Jul 8 21:18:23 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Mon, 9 Jul 2001 02:18:23 +0100 Subject: license suggestions? References: Message-ID: On Sun, 8 Jul 2001 17:39:45 -0500 (CDT), Chris Watson wrote: > > >On Sat, 7 Jul 2001, Neil Macneale wrote: > >> I am wondering if there is a straight forward license which I can use for >> python code I plan to distribute. Is there a standard header, or >> possibly a link that can be placed in a header which basically says that >> people use the code at there own risk, and that they are free to change >> it? I ask here because I know there has been conflict between python and >> GPL. Is there some vanilla header that people in this group use? > >This is what I use. What software do you publish under this license? ># 1. Redistributions of source code must retain the above copyright ># notice, this list of conditions and the following disclaimer. ># 2. Redistributions in binary form must reproduce the above copyright ># notice, this list of conditions and the following disclaimer. ># 3. No changes are made to this license and/or additional terms of use ># are placed without prior written permission from Chris Watson. Say you write a program, B, under this license. I then make some modifications to B, creating MB. I license my modifications under the GPL. B is still your license. But anyone wanting to link code to MB must GPL it. How does this differ from if B was licensed under the regular BSDL? -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From joonas.paalasmaa at nokia.com Wed Jul 11 09:50:39 2001 From: joonas.paalasmaa at nokia.com (Joonas Paalasmaa) Date: Wed, 11 Jul 2001 13:50:39 GMT Subject: MySQL-python-0.9.0 setup problems under windows98 References: Message-ID: <3B4C5A47.50D8E366@nokia.com> Joe Potter wrote: > > Hello all, > > I have MySQL running on a win98 box. All systems are go with the package. > > Now, I would like to use the system from within python. So far I have downloaded the > module that does this job. The one listed above is supposed to be the windows > version. > > However, I can not seem to understand how to install the module and get it imported > so as to start using MySQL. Download MySQL-Python Windows installer from http://highqualdev.com/ It is very easy to use. From qrczak at knm.org.pl Sat Jul 28 03:44:27 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 28 Jul 2001 07:44:27 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <9jnt9p$qhe$1@newsy.ifm.liu.se> Message-ID: 27 Jul 2001 22:13:50 -0400, Lloyd Zusman pisze: > Accountants and their kin want ledgers, positions, etc. to balance to > the penny (or centavo, or whatever is the smallest fractional currency > in a given country). This can only be accomplished using decimal > arithmetic ... like Bignums with implied decimal places. Not only; rationals work too. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From ullrich at math.okstate.edu Fri Jul 27 10:09:07 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Fri, 27 Jul 2001 14:09:07 GMT Subject: Toppling the numeric tower References: Message-ID: <3b6174fa.1981112@nntp.sprynet.com> On Thu, 26 Jul 2001 08:43:45 -0700, David Eppstein wrote: >In article , > "Tim Hochberg" wrote: > >> > 1. isnatural() >> > 2. isintegral() >> > 3. isrational() >> > 4. isreal() >> > 5. iscomplex() >> > >> > a. isexact() >> >> This is too many. I would strip this down to >> >> A. iscomplex() >> B. isexact() >> C. isintegral() > >I have to say that this would be more convenient for situations such as >defining your own extension of number types for, say, exact arithmetic in >Q[sqrt(3)]. Or even better Q[sqrt(-3)]. I was wishing I was able to do >this recently for a different project unrelated to Python, unfortunately >the program I was using didn't make it easy to plug in your own number >types... > >But a couple points of clarification: >(1) is it safe to assume that isintegral() implies isexact()? >(2) should isintegral() return true for algebraic integers that are not >rational integers? Of course not - this would introduce awesome confusion in many for the sake of the needs of a small number. (Perhaps classes could have a way to declare themselves as integral or exact or whatever... then you could make _your_ algebraic integers integral.) About whether isintegral should imply isexact: I dunno much algebra. For the flavors of "algebraic integer" that seem dimly familiar it seems like one could give an exact representation. Is this true? >-- >David Eppstein UC Irvine Dept. of Information & Computer Science >eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ David C. Ullrich From nhodgson at bigpond.net.au Wed Jul 18 21:01:15 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Thu, 19 Jul 2001 01:01:15 GMT Subject: Language change and code breaks References: <180720011705003205%jwbaxter@spamcop.com> Message-ID: John W. Baxter: > I also hope that after the change to case-insensitive Python, > we don't also go through a change to diacriticals-don't-matter > Python. I'm hoping we can move to vowel-insensitive Python to increase ease of use in Hebrew. And allow for non-deterministic pronunciation of g*d. Neil From db3l at fitlinxx.com Mon Jul 2 16:22:04 2001 From: db3l at fitlinxx.com (David Bolen) Date: 02 Jul 2001 16:22:04 -0400 Subject: Implementation of popen() with timeout References: Message-ID: Tom Harris writes: > I want to use one of the popen() functions to call an external program and > capture the output, but I would like to have the facility to kill the > external program if it does not complete within a specific time. > Unfortunately I am using NT. Options appear to be to use the Win32 API to > write my own, as the popen source looks fierce code. Any ideas? What I did for something like this (some legacy Perl scripts that would get hung up in database accesses sometimes) was to multi-thread. The popen() was done in one thread, and a separate thread acted as the monitor. As long as output was being processed (indicated via a shared flag) all was well, but if nothing was seen for a timeout, the monitor thread killed off the process at the Win32 level. I actually used a separate utility (the sysinternals 'pskill' utility) although if win32all wraps the kill process call that could also be used. To add insult to injury, the legacy scripts could decide to exit successfully (exit code wise) even if there was a problem, so in my case I added some code to monitor the output and look for a final message - if I didn't see it I'd declare a failure even if the underlying scripts didn't. Here's a slightly edited version of the function (sans monitoring for that message), and the top level "execute" function that used it (note that the FindPerl function located Perl processes that had been running at least as long as the timeout, since the machine might be running other Perl processes - replace that with whatever you need to determine the appropriate child PIDs): # # -------------------------------------------------- # class PerlThread (Thread): """This class executes a separate thread to run a perl command, monitoring its output and timing how long a delay there is since the last output. A separate method (intended to be called from a separate thread) will check this time and if necessary try to kill off any perl processes to free up a hung system.""" def __init__(self, command): Thread.__init__(self) self.command = command self.lasttime = 0 self.finished = 0 self.result = 0 def monitor(self, timeout): """monitor(self, timeout) This function should be called from a separate thread, and will monitor the delay since last sub-process output, trying to kill off any perl processes if it exceeds the threshold. When this function returns, the process has either completed or timed out. This should only be called after the start() method has already returned for the separate thread of execution""" while 1: if self.finished or not self.isAlive(): break if (self.lasttime and (time.time() - self.lasttime) > timeout): sys.stdout.write('ERROR: Monitor Timeout waiting for command ' 'to complete (%ds)\n' % timeout) pids = FindPerl(timeout) sys.stdout.write('Trying to kill Perl processes %s\n' % pids) for curpid in pids: os.system('pskill %s' % curpid) self.result = 255 break time.sleep(5) return def run(self): """run(self) This is the independent thread that executes the command.""" sys.stdout.write('Executing: %s\n' % self.command) pipe = os.popen(self.command + " 2>&1") while 1: self.lasttime = time.time() line = pipe.readline() if not line: break print " ", line, self.result = pipe.close() def rc(self): return self.result # # -------------------------------------------------- # def ExecuteCmd(command, timeout): """ExecuteCmd(command) Executes the command using the PerlThread class with an execution and monitoring thread. Returns the result code from the execution.""" # Create thread for execution and execute perl = PerlThread(command) perl.start() perl.monitor(timeout) perl.join() return perl.rc() -- -- 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 cb921 at voice.co.za Tue Jul 31 13:24:49 2001 From: cb921 at voice.co.za (Campbell) Date: Tue, 31 Jul 2001 19:24:49 +0200 Subject: Control of flow In-Reply-To: <9k6b2u027hv@enews4.newsguy.com> References: <9k6b2u027hv@enews4.newsguy.com> Message-ID: On Tue, 31 Jul 2001, Alex Martelli wrote: >"Campbell" wrote in message >news:Pine.LNX.4.31.0107311355450.2321-100000 at cb921.local... >> I use python to write telephony apps, and I find that a 'goto' is often >> a nice tool (stop going 'aargh', its properly "useful" sometimes =). > >Naah, you can always get the same effect with better structure:-). > So I have been told. :) >What are the conditions under which you want to repeat >this inner loop (letting the user enter a day for the >fixed month) rather than redo the outer loop (letting >the user enter the month again)? In this case I'd like to keep the caller in the inner (day) loop, entering '#' cound be checked to go to the outer loop, but I use constructs like this for many things. Sometimes a caller will enter the begin and end of a range, and which loop to jump into could depend on what specific error condition was noticed. I've made something exactly this ugly (except which worked) twice today already, and this is what it all gets to look like? Every time I do it, I think to myself, that it is rare unless I'm handling this kind of input, where values are available one at a time, and I must respond with prompts correctly. Following which is the thought: "that sort of input is kind of common around this place..." Here is where Perl's name-able loops are remembered with fondness. (but Perl by nature just isn't maintainable of course ;-) >that's not too bad for a couple of entries, but it >gets slightly tiresome when you have a zillion. That >is (part of:-) what exceptions are for... thank you... I could make an interesting while 1: with a try: inside of it handling custom exceptions, and in each except: could have the retry/continue stuff. Still, for the common situation where context differs and 'error' conditions that are checked for vary, it seems like a bit of overkill. It's not that I mind doing it, it's at least 'elegant' while my cont variables are not, I just mind having to explain that to the workers :) I'm trying to replace a commercial telephony platform with something I hacked together with swig and Py, on which many different applications share the server, each with it's own number. So far it's going very well, the only Gripe I have ever heard from others (or had myself) has been this. So I shouldn't whine too loud, Python really has changed my world for the better. :) Alex Thanks, I sincerely appreciate your thought and time. The world is our spoon tick, tock. From thomas at xs4all.net Tue Jul 3 03:25:06 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 3 Jul 2001 09:25:06 +0200 Subject: Augmented Assignement (was: Re: PEP scepticism) In-Reply-To: <5.0.0.25.0.20010702215108.02a92958@pop-server> Message-ID: <20010703092506.S32419@xs4all.nl> On Mon, Jul 02, 2001 at 09:54:17PM -0700, Courageous wrote: > Be what may about the current implementation and future of Python, it is > simply wrong that a = a + 1 is evaluated differently than a += 1. And I simply disagree :) Like I said before, I see no reason for it to be wrong that they are different. To me, it would be very wrong if they did the *same* thing. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From glenfant.nospam at bigfoot.com Mon Jul 2 06:22:29 2001 From: glenfant.nospam at bigfoot.com (Gilles Lenfant) Date: Mon, 2 Jul 2001 12:22:29 +0200 Subject: Is Python Dead? References: Message-ID: <9hphnj$aee$1@norfair.nerim.net> Of course, there's no "good" database support in the standard package list. But there is a full featured DBI 2.0 API spec and lot of addon DB packages compliant with this spec. This API is very simple and the Python power makes it easy to put an object layer above the database (persistant objects). Can you do it in Perl. For Web development, AFAIK Zope is the best open source solution for content management with a built-in object database. Zope is not done in Perl or PHP but in Python (95%). If you find a better solution than the pythonic one, please let us know. --Gilles From paulp at ActiveState.com Tue Jul 31 19:18:44 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Tue, 31 Jul 2001 16:18:44 -0700 Subject: 2.2 features References: <3B6727F6.6D43D989@ActiveState.com> <20010731200832.L19610@tux.distro.conectiva> Message-ID: <3B673CD4.72ED0E59@ActiveState.com> Gustavo Niemeyer wrote: > > > It sounds weird from an English perspective to me. "If Guido in > > programmer and Guido in author then". "isa" or even just "a" makes more > > sense. or how about "in class" "If Guido in class programmer and Guido > > in class author then". > > What about "If programmer in Guido" ("type in x" instead of "x in type")? I think that the little future programmer is in Guido's *wife*. Medical science has not yet advanced to the point where they can share that burden. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From alankarmisra at hotmail.com Wed Jul 4 18:07:37 2001 From: alankarmisra at hotmail.com (gods1child) Date: 4 Jul 2001 15:07:37 -0700 Subject: ignore -> pickling and methods Message-ID: <25b2e0d9.0107041407.6318284f@posting.google.com> The Python documentation on pickle clearly states that the function code isnt saved while pickling. Dont ask me why i didnt look there before posting to this group coz I feel extremely stupid already ;-) sincere apologies. From jeff at ccvcorp.com Wed Jul 25 13:56:55 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Wed, 25 Jul 2001 10:56:55 -0700 Subject: 2.2 features References: Message-ID: <3B5F0867.7447E5FB@ccvcorp.com> Tom Good wrote: > "Nick Perkins" wrote in message > > > How about generators, who's tried them out? > > [snip] > > I like generators a lot. Here's a fun one: > > #------ begin code > [snip] > if __name__ == "__main__": > g = fib() > for i in range(9): > print g.next(), > > #------ end code Haven't looked into this in detail, or even downloaded 2.2 yet, but... couldn't that be written as: if __name__ == '__main__': for i in fib(): print i, ??? (being under the impression that the main point of iterators is convenient for-loop usage...) Jeff Shannon Technician/Programmer Credit International From peter at engcorp.com Fri Jul 13 23:16:03 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 13 Jul 2001 23:16:03 -0400 Subject: not safe at all References: <3B4F743C.66778F9F@tundraware.com> Message-ID: <3B4FB973.115B83B1@engcorp.com> Tim Daneliuk wrote: > > Dennis Roark wrote: > > misuse 500 lines later in the program. My original note was > > not intended to be an indictment of Python, but only to > > bring up some reasons that for me make more strongly typed > > languages like C++ or Object Pascal better at coding very > > large projects. As others have noted, your lack of experience attempting to implement a large application in Python reduce the value of this statement. Nevertheless, your sentiment is echoed repeatedly by many (which doesn't make it any truer) and so we seem to be compelled to respond. :) In the following, wherever "you" appears, please consider it the impersonal "you" applied to anyone who might make statements like the above. > I have programmed extensively in C, assembler, BASIC, PL/M and a some > in C++, Forth, Pascal, AWK, Perl, Java... For my money, I have *never* > seen a language more suited for rapid applications development - even > pretty good sized applications - that strongly encourages the programmer > to write clean, easy to read code, than *Python* - this after only a > month or two of fiddling with it. [...] > Furthermore, bear in mind that code "portability" is no where near as > important in the commercial sector as it is in academics. [...] > What *is* important is code *reliability*, *cost of > ownership*, *readability*, and portability of *programmer's skills*. All very true. I can attest from personal experience with Python over the last year and a half (to strengthen Tim's claim from only a month or two of use) that Tim's statements above are *absolutely* on the mark for commercial developments. I've programmed seriously for about 23 years. I too have used a gazillion languages. I've personally written, architected, or managed development of large applications in C, C++, Java, Object Pascal, LabVIEW (>shudder<) and now Python. I'm an engineer, not a computer scientist, which might mean I'm more interested in pragmatism than theory (not trying to be denigrating there). (Don't flame me for saying this... some people like a little background material to help evaluate someone's claims...) My experience convinces me Tim is exactly right: The most important thing about the product is *reliability*. The most important thing about the source is *maintainability*. Python ranks higher than any of the other languages I mentioned, based on direct observation and lengthy consideration, in both those areas. It is also more productive in general ("cost of ownership") by a factor of at least two (I'm being conservative). My programmers (team of 16) uniformly like Python, find it more "fun" than any previous language they've used, and produce better results with it (as measured by any of the above measures, and by the fact that I can understand their code easily). Only one of them had even heard of it prior to the first interview. None of them took more than about a week to begin contributing to our development, and I believe each was, after less than a month of active use, more effective with Python than with his or her previous "best" language. I'll note also that I make these claims even before we've fully implemented extensive automated testing along the lines of what people in this group generally claim is "essential". (I don't disagree with that claim, but even as we implement such processes -- prior to our code releases -- I am seeing very significant improvements over what I have seen in the past with other languages.) In other words, *even without testing Python leads to fewer bugs*. You can say that's not possible. You can disbelieve it. You can insist you need stronger typing. You can claim that, because of your own special, unique situation or for personal reasons it just somehow isn't true. I say you are probably wrong. Or at least, until you give Python a fair try on a large application, you won't convince me otherwise based on theoretical arguments. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From tjreedy at home.com Sun Jul 29 19:26:24 2001 From: tjreedy at home.com (Terry Reedy) Date: Sun, 29 Jul 2001 23:26:24 GMT Subject: PEP0238 lament References: <18289ee4.0107261001.664eb547@posting.google.com> <18289ee4.0107271117.7df350d4@posting.google.com> <18289ee4.0107281021.468246a7@posting.google.com> <3B638FA8.8D24A152@engcorp.com> <18289ee4.0107291329.6d082ccf@posting.google.com> Message-ID: "David Boddie" wrote in message news:18289ee4.0107291329.6d082ccf at posting.google.com... > > And would the same benefit arise by having the default name > > of the executable be "python3", but not forcing it to be so? > > I would imagine that renaming your new "python3" interpreter to > "python" would wipe out any advantage that the above plan gives you. The only way to force a name for the executable is to check argv[0] and die if it does not end 'python3' (after being lowercased). I personally would find that kind of obnoxious. Besides which, DOS/windows has not always correctly filled in argv correctly, I've read. Terry J. Reedy From aahz at panix.com Thu Jul 12 10:25:26 2001 From: aahz at panix.com (Aahz Maruch) Date: 12 Jul 2001 07:25:26 -0700 Subject: Python speed References: <9ihjfu$3ls$1@news.mathworks.com> <9ik9kd$nch$1@news.mathworks.com> Message-ID: <9ikc0m$bmg$1@panix2.panix.com> In article <9ik9kd$nch$1 at news.mathworks.com>, jcm wrote: > >If you'd like, reread my point as "muds are likely to be CPU-bound >programs". Fine, but in that case, what *is* your point? -- --- 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 "How come we choose from just two people for President but more than 50 for Miss America?" --AEN From slinkp23 at yahoo.com Mon Jul 9 14:43:45 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Mon, 09 Jul 2001 18:43:45 GMT Subject: PEP: Procedure for Adding New Modules (please comment) References: <9hvqhr$gj2$1@newshost.accu.uu.nl> Message-ID: <3B49F9EC.CA10886A@yahoo.com> Martijn Faassen wrote: > Open issues > > Should there be a list of what criteria integrators use for > evaluating contributions? (source code but also things like > documentation and a test suite, as well as such vague things like > 'dependability of the maintainers'). I think test suites would be a very, very good idea. At a minimum, some doctest examples. Even better would be a well-defined suite of unit tests using the unittest module. I propose that this be made a requirement for adding new modules to the standard library. It would be A Good Thing if unit tests were added to the existing standard library modules, but my mind boggles at the size of the job. -- ................... paul winkler .................... custom calendars & printing: http://www.calendargalaxy.com A member of ARMS: http://www.reacharms.com home page: http://www.slinkp.com From sheila at spamcop.net Tue Jul 3 10:05:28 2001 From: sheila at spamcop.net (Sheila King) Date: Tue, 03 Jul 2001 14:05:28 GMT Subject: Calculus References: Message-ID: <46k3ktcr165se0871chsnlfdmpdout3epv@4ax.com> On Tue, 03 Jul 2001 08:55:32 -0400 (EDT), Andrew Todd wrote in comp.lang.python in article : :I wrote: :>Is there a calculus module? I couldn't find one. : :Sheila King wrote: :>What are you talking about? Do you mean a newsgroup for :>discussing calculus? : :No. I probably was too brief. I meant a module for Python :that has functions commonly used in Calculus. For example, :the Simpsons Rule, and the formula that allows you to find :the error. Sorry for the confusion. Oh, shoot, I canceled that message, about two minutes after I posted it. I see it made it to the mailing list half of this group, though. :( I forgot what newsgroup I was reading when I posted that. (I thought I was in a completely different hierarchy, not even comp.* ) Sorry for my stupid message! -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From sill at optonline.net Wed Jul 18 18:24:45 2001 From: sill at optonline.net (Rainy) Date: Wed, 18 Jul 2001 22:24:45 GMT Subject: basic python-unix question References: Message-ID: On Wed, 18 Jul 2001 21:51:25 GMT, Ed T wrote: > Hi Folks, > New to Python and have been unable to us the "ps ef |grep" command > correctly. From what I can tell I need to use the os.system() command. But > have had no luck. Here an example of a basic script: > > import os, sys > process = ("test1", "test2") > > for eachProcess in process: > os.system('ps ef | grep eachProcess') change last line to os.system('ps ef | grep ' + eachProcess) > > > The idea is to place processes that should be running into a for loop and > see if it is running. When I do the above it appears only to check for the > word "eachProcess" not for the process (i.e., test1 or test2). Is this a > case of how to enter this command where substitution takes place in Python? > What am I doing wrong? > > Thanks in advance! > > Ed > > -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: http://silmarill.org/cymbaline From scarblac at pino.selwerd.nl Wed Jul 4 19:04:09 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 4 Jul 2001 23:04:09 GMT Subject: Maybe I can help.. References: Message-ID: Lindstrom Greg - glinds wrote in comp.lang.python: > however I did not notice SIGs for > either numerical python or scientific python. If any of you are into this > type of thing, or if any of you would be willing to give me some pointers on > numerical research, particularly concerning the above topics (I received a > MS in numerical methods, but that was in 1990 and I have since "officially" > left the field) please feel free to contact me at yuba at cyberback.com. I > plan to create python modules to help with various mathematical tasks (I > might start with Simpson's rule :-) Uhm, http://www.numpy.org (and the links from there, like to Scientific Python). There's a wealth that's already there, but I think any extra experts are always welcome :-) Maybe I missed the point of your post (they are indeed not official SIGs). -- Remco Gerlich From Greg.Lindstrom at acxiom.com Mon Jul 9 17:18:37 2001 From: Greg.Lindstrom at acxiom.com (Lindstrom Greg - glinds) Date: Mon, 9 Jul 2001 16:18:37 -0500 Subject: Is Python Dead? Long Live Python! Message-ID: >Beauty is only beauty if one can experience it. >I can't experience Python on a day to day basis >(in the workplace), so therefore I can't >appreciate it. This is quite true in my experience, too. I work in an IT shop that simply refuses to recognize Python (and Perl) because most of the people in leadership will not accept it. The major strikes? 1. It's Free. How serious can a language be if it's given away? We seem to feel more secure in spending over $2500.00 per box for MS Developers Studio and various other software license (CORBA goes for $1,200 a box, I'm told)? 2. If my boss had to code in C/C++, it's should be good enough for me (dammit!). C++ has the added benefit of producing code that is nearly unreadable, and complex enough to take days to explain. Now this may be because we do not know how to properly code C++ (surely there is good C++ code out there somewhere). In a recent (very large) project here, the "architecture team" would not even consider STL for the string class; they designed and wrote their own! The ironic twist in this is that 10 years ago these same people insisting on C/C++ were the ones leading the way away from assembler language. 3. No Support! At least no 900 number to call for a per minute fee. Doesn't seem to matter that in the past couple of years I have never had to wait over a day to get a answer to a question. Perhaps we would feel better if there were someone we could sue. 4. To easy to understand. A sin among most coders. It's embarrassing to go into a review meeting and show product managers and others code that they can understand. It's much more impressive to hand out code that baffles 10 year veterans. I showed the code to a recent prototype to a customer relationship manager, and she understood the flow (to be fair, she could not have produced the code, but she felt good about making minor changes). 5. A fear of maintainability. My boss worries that nobody will be able to maintain the code I write. While I believe that is a fair criticism on Perl (and is why I stopped coding Perl), it is my experience that Python is quite easy to understand. Of course, a poor programmer can produce poor code in any language (they just have to work a little harder at it in Python). Perl and Python (and I love 'em both) are gaining ground among those who have to get things done because they improve productivity. I write almost all of my test routines in Python if for no other reason as to remove a common language between application and test. Most of my prototypes are Python (love the wxPython). In time, I hope others will be won over; and -- with no disrespect to Python -- it does not keep up with my needs as a programmer, I will leave it for anything better that comes along. Until then I will fight for both Perl and Python. Greg Lindstrom "When the solution is simple, God has spoken" Albert Einstein From quinn at hork.ugcs.caltech.edu Fri Jul 27 03:23:58 2001 From: quinn at hork.ugcs.caltech.edu (Quinn Dunkan) Date: 27 Jul 2001 07:23:58 GMT Subject: Case insensitivity References: <93d9a839.0107200315.4a0a8c28@posting.google.com> <4n4klt8ud0es25jep3u2v9pj02dctnte0u@4ax.com> <3ui1mt0e07vgp1b18306jd70pdufs91uva@4ax.com> Message-ID: On Fri, 27 Jul 2001 02:05:06 GMT, Courageous wrote: > >>I don't understand this assertion, however. What keeps you from continuing to >>use vim, ed, windows notepad, whatever, in this case? The language is exactly >>the same. > >Because when identifier and someone else writes IdEnTIFIER, I want >to kill them Actually, I'd like to kill them for changing the case at all. But if the language is the same, their editor would warn them about the case mismatch, and the code would crash, just like yours would. It would be just like your editor, only yours won't warn about those things. From bsass at freenet.edmonton.ab.ca Sat Jul 28 16:29:39 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Sat, 28 Jul 2001 14:29:39 -0600 (MDT) Subject: PEP 238 (revised) In-Reply-To: <3b62459e.609746999@wa.news.verio.net> Message-ID: On Sat, 28 Jul 2001, Bengt Richter wrote: > On Fri, 27 Jul 2001 12:27:44 -0700, Chris Barker wrote: <...> > >What I don't get, is why // couldn't return an integer always? It will > >always have an integral value. I suppose one problem is that the range > >of integers that a float (C double) can handle is larger than a 32 bit > >integer can hold. This could be solved in the future with int/long > >inification, what will be the behaviour then? > > > I think it has to do with being consistent with the idea of using the > representation type as an indicator of exactness. ...and using the precision of the representation to decide if the result is exact (one of the few cases where Python can have enough information to determine the exactness of a result based solely on its inputs?), is just too much work for too little gain? > Using that idea, float is a visible name and means inexact, > and int and long are visible and mean exact. > > Floor can't turn inexact to exact, so it must return inexact (i.e., float) > if it gets an inexact (i.e., float) input. > > int(x) will effectively be an exactness coercion because of the > representation-type linkage. > > If Dr Who takes us forward a bit, and we have no floats or ints, but just > exact and approximate numbers, with exact being integers or rationals, and > approximate being approximate[1], then you would have to translate your statement > to "What I don't get, is why // couldn't return an exact number always?" > > [1] Approximate numbers will undoubtedly be implemented as floats, but hiding > that will let people think about aspects of approximation instead of the hardware > below. And if someone came up with a new approximate number representation for > special situations, e.g., an alternate rational with bounded numerator/denominator > values, it could be implemented without changing the language. The point is you > need to know the effectiveness of the approximation for your purposes, not what > representation tricks they have come up with for the latest version of Python. > Take us back, Dr Who. ok > If the current numeric literal formats persist, as I think they must, then I > think the old formats for float should not automatically become formats for > approximate. > > All the numbers you can reasonably enter as literals can be represented > exactly, so why not break the 1.0 -> float-hence-inexact chain, and let 1.0 and 1 > signify the same thing? Driving the internal representation with a decimal point > is arms-length C programming, not Python, IMHO. Would this break evaluations of representations of unreasonable to enter literals, reasonably generated by a program? a special case? > Evaluating some expressions will result in approximations, but not all the time. > Inputs can be exact all the time. Including 0.1 and 1/3, after number unification. > (0.1 just becomes 1/10). Sounds reasonable, but once you have adopted a representation that can not be exact, there is no way to know if the representation is exact or just accurate to whatever the representation allows. So, interpretation of the intent (exact or not) will be context sensitive, and to some degree involve telepathy or a time machine... then my mailbox exploded, because PEP238 fiddles with the telepathy part of the problem in a spectacularly visible way. (am I getting it?) Hmmm, I think I'd rather forget the whole telepathy thing and assume that an `inexact' representation is inaccurate... unless told otherwise by some property other than `format' (an idea which has been mentioned but not really discussed). - Bruce From eppstein at ics.uci.edu Fri Jul 27 14:42:54 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Fri, 27 Jul 2001 11:42:54 -0700 Subject: Nasty typo in PEP 238 (revised) References: Message-ID: In article , Andrew Koenig wrote: > >> A. Use x*1.0/y for true division, divmod(x, y)[0] for int > >> division. Especially the latter is best hidden inside a > >> function. You may also write floor(x)/y for true division if > >> you are sure that you don't expect complex numbers. > > David> Shouldn't this be float(x)/y ? > > What if x is complex? Did you read the last line? -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From jwbaxter at spamcop.com Sun Jul 22 23:39:32 2001 From: jwbaxter at spamcop.com (John W. Baxter) Date: Sun, 22 Jul 2001 20:39:32 -0700 Subject: PEP0238 lament References: Message-ID: <220720012039325082%jwbaxter@spamcop.com> In article , Tim Peters wrote: > Not all experienced programmers agree. At the last Python Conference, I > moderated a 40-some person group discussion on conceivable changes to > Python's numeric model, not advocating but keeping the participants from > killing each other . The meaning of integer division wasn't the > focus, but naturally came up. By show of hands, about 3/4ths of the > participants agreed that 3/4 should not return 0, but rather *something* x > such that x*4 had a better chance of being confused with 3 than with 0. > There was no consensus on exactly what 3/4 should return -- rational or HW > float or decimal float were the most popular alternatives. I see a fairly strong argument there for starting out with a language in which int / int --> float (or rational) and int // int --> int (or int div int --> int). I don't see it as a strong enough argument to overcome the fact that the careful programmer will have to inspect every / in all the code, before installing 2.3 or whatever version this happens in, to see whether (a) it IS division, as opposed to the / in '' (that's contrived...but possible) and if so whether it has to be respelt as // (or div). Some of them will; some won't: some of both outcomes indicate latent errors in the code, so the inspection isn't completely wasted after all. And it may not be her code...she could be 3 or 4 people removed from the creator, who is gone. [Another good thing about finding the latent errors.] It's true--as stated elsewhere--that Guido hears all the complaints. It's also true that until recently there was no reason for Guido to hear "Guido, thank you for defining int / int to be integer division, because integer division is natural for my problem space." So he's been getting a biased sample. Probably a fairly representative one even so. --John From robin at jessikat.fsnet.co.uk Fri Jul 27 03:52:17 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 27 Jul 2001 08:52:17 +0100 Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <9jnt9p$qhe$1@newsy.ifm.liu.se> Message-ID: In article , Tim Hochberg writes .... > * Unification of ints and longs (PEP 237)? This seems almost impossible >to dislike. .... well I have at least one extension that requires 32 bit unsigned as inputs. Under existing python I can manipulate myself around bit 31 problems with ease (using negative numbers or hex). It seems it will/might be a bit more complicated if this pep goes through. I'm sure there are others who have explicit int size requirements. Effectively removing ints takes away ease of external communication in at least some cases. >Anyway I'm sure we'd all be much happier if everyone went to >python.sourceforge.net/peps, read all the number PEPs and then, if >necessary, panicked about what was actually in them. > >-tim > > > > -- Robin Becker From boegli at iinet.net.au Sun Jul 8 07:35:10 2001 From: boegli at iinet.net.au (Richard) Date: Sun, 08 Jul 2001 19:35:10 +0800 Subject: python 2.1 rpm and tgz don't install under rh7 with xfree86 4.1.0 Message-ID: <3B48456D.27A7CFC4@iinet.net.au> I can't get python 2.1 to install rh7 with xfree86 4.1.0??? What is wrong, I have gotten python2-2.1-5.src.rpm like the web page said and expat-1.1-4tummy.src.rpm but when i run python2-2.1-5.src.rpm it says i need => expat-1.1-3tummy.src.rpm and it stops what is wrong? with the .tgz copy of python it says that the compiler might be the problem when i type make. What is wrong? From richard at bizarsoftware.com.au Wed Jul 25 00:39:28 2001 From: richard at bizarsoftware.com.au (Richard Jones) Date: Wed, 25 Jul 2001 14:39:28 +1000 Subject: python2.2: type('name') -> ?? In-Reply-To: References: Message-ID: <200107250437.OAA22898@goanna.adroit.net> On Wed, 25 Jul 2001 14:14, Tim Peters wrote: > Note this cute consequence: > >>> x = 1L > >>> type(x)(3) > > 3L > > > That is, type() in 2.2a1 truly returns a constructor, and type(1L)(y) is > the same as long(y). Likewise for > > >>> type("abc")(42) > > '42' > > >>> type("abc") is str > > 1 > > >>> type(1L) is long > > 1 Not having access to 2.2 for the moment, what's the story if type() returns the instance type? just-curious'ly ... Richard -- Richard Jones richard at bizarsoftware.com.au Senior Software Developer, Bizar Software (www.bizarsoftware.com.au) From aahz at panix.com Mon Jul 9 12:52:34 2001 From: aahz at panix.com (Aahz Maruch) Date: 9 Jul 2001 09:52:34 -0700 Subject: "has" Operator References: <9ibe9n$ffu$1@news.mathworks.com> Message-ID: <9icngi$21d$1@panix6.panix.com> In article , Skip Montanaro wrote: > > Joshua> On the other side of things, it seems this could be introduced > Joshua> into the language without making 'has' a keyword--no syntactic > Joshua> rules currently use concatenation. > >This is a good point. I sometimes use this sort of construct: > > has = {"foo":1, "bar":1, ...}.has_key > ... > if has(a): > ... Woah! That's s[l]ick! -- --- 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 "How come we choose from just two people for President but more than 50 for Miss America?" --AEN From mnenadov at stclairc.on.ca Tue Jul 24 08:31:41 2001 From: mnenadov at stclairc.on.ca (Mark Nenadov) Date: Tue, 24 Jul 2001 12:31:41 GMT Subject: constructor chaining? References: <20010724.081619.1139901474.1751@d150-169-166.home.cgocable.net> <6Sd77.62285$2V.13130988@news3.rdc1.on.home.com> Message-ID: <20010724.084415.1856669179.1751@d150-169-166.home.cgocable.net> In article <6Sd77.62285$2V.13130988 at news3.rdc1.on.home.com>, "Daniel Ellison" wrote: > This is my first post here; I've just started looking into Python and so > far like what I see. To answer your question, you simply call Media's > __init__ constructor from within Book's __init__ constructor: class > Book(Media): > def __init__(self): > Media.__init__(self) > ... Awesome. Thank you very much, that was exactly what I was looking for. -- ~Mark Nenadov (author/editor for http://www.coffeecode.com) From johnroth at ameritech.net Fri Jul 27 11:37:40 2001 From: johnroth at ameritech.net (John Roth) Date: Fri, 27 Jul 2001 08:37:40 -0700 Subject: Eliminating upgrade risk References: <3B601811.4B68578B@interet.com> <3B60AA24.B26F6B76@engcorp.com> Message-ID: "Peter Hansen" wrote in message news:3B60AA24.B26F6B76 at engcorp.com... > > I agree the rate of change is enough to make many of us nervous > (perhaps especially in industry). And I agree some of the new > features appear (from my particular point of view) unnecessary > and more like CS playthings than anything else. > > That said, I have to say that at least one change is likely to > improve my ability to produce bullet-proof programs. > > The surgery on the way division works will almost certainly > reduce the risk of my accidentally (and quietly) truncating a > result when I really meant to say float(x)/y and forgot, since > this is an idiom I rarely need to use. (This is leaving aside > the issue of code breakage, but I'm talking only about new > code here, and in my case I don't need to maintain backwards > compatibility.) I have to agree with you on the division mess - don't think that what I wrote to start this thread means that I don't think it needs to be fixed! What everyone seems to have overlooked is that I presented a plan for allowing the continued evolution of the language, while providing stability for the existing code base. What I'd actually like to see, from a bullet-proofing point of view, is the complete elimination of the "/" operator, in favor of "idiv", "rdiv" and "fdiv" (with the obvious meanings of integer, rational and floating.) Of course, this would reduce the obviousness of the language, but it would also eliminate mistakes. John Roth > > -- > ---------------------- > Peter Hansen, P.Eng. > peter at engcorp.com From fleet at teachout.org Thu Jul 19 12:28:51 2001 From: fleet at teachout.org (fleet at teachout.org) Date: Thu, 19 Jul 2001 12:28:51 -0400 (EDT) Subject: Variable Substitution in commands or funtion names? In-Reply-To: <33105F8B185CD51182E300306E06473E2701B0@hermes.isr.thomson-csf.com> Message-ID: On Thu, 19 Jul 2001 hao-nghi.au at fr.thalesgroup.com wrote: In my response I blew the dictionary syntax: when I try: >>>CurCust["street"] Traceback (innermost last): File "", line 1, in ? TypeError: sequence index must be integer >>>CurCust[2] of course returned the third letter in "smith" correctly. - fleet - PS: Why do we always discover these stupid errors immediately after hitting the "send" button?! :) > Hi fleet, > > Just learn that when you write : from cust import CurCust > ==> CurCust becomes local and you have to reference to it by : > print CurCust["street"] > > regards, > Hao-Nghi Au > -----Original Message----- > From: fleet at teachout.org [mailto:fleet at teachout.org] > Sent: Thursday, July 19, 2001 2:26 PM > To: python list > Subject: Variable Substitution in commands or funtion names? > > > > I think I may have gotten myself into a box. > > I have a module "cust.py" that contains several dictionaries - each > references a different customer with address info, etc. such as: > > smith={"busname":"Smitties", "street":"123 West Ave"} > > Parsing the csv output of a spreadsheet allows me to assign "smith" to a > variable - CurCust. > > Now I want to do something like: > > from cust import CurCust > > print cust.CurCust["street"] > > Spent the evening trying to solve this (Learning Python, and Sam's Teach > Yourself Python) then tried the archives. The little I found on "variable > substitution" almost seems to say "no way!" ??? > > (I know someone is going to suggest a database. That's a little further > up the learning curve. I can see it from here; but I'm not there yet.) > > Thanks for any assistance, > - fleet - > > > > From Tom_Good1 at excite.com Tue Jul 24 13:24:13 2001 From: Tom_Good1 at excite.com (Tom Good) Date: 24 Jul 2001 10:24:13 -0700 Subject: Partition Problem References: <0oR47.12485$p7.4220508@news1.rdc2.pa.home.com> Message-ID: Duncan Booth wrote in message news: > > As I originally wrote it the return stopped it executing the main body and > attempting to permute a 0 length sequence. Since I had written it so that > permuting a 0 length sequence gave no permutations, this meant the return > simply cut out a lot of code that had no net result. However, once it is > fixed to correctly return one permutation of an empty sequence the return > becomes essential. Ah, OK. With the new test, the return matters for sequences of length 1. Tom From tim.one at home.com Tue Jul 10 01:41:37 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 10 Jul 2001 01:41:37 -0400 Subject: Comment on PEP-0238 In-Reply-To: Message-ID: [Tim] > BTW, state-of-the-art rational support also requires context, to determine > whether results should be reduced to lowest terms (some programs run 1000s > of times faster if you don't, others 1000s of times faster if you do, and only the > algorithm author can know which is better). [Marcin 'Qrczak' Kowalczyk] > If such context affects only performance, then maybe it's acceptable, > but if it affects essential semantics, For most people, whether they get results back in their lifetimes is important despite being "only performance". > I'm worried that it's a bad idea to introduce global state where it doesn't exist in > the problem domain. In finite arithmetic, precision is part of the problem domain, like it or not. Ditto rounding and exception policies, and that "one default size fits all" policies don't work. > The more global settings affect the meaning of a piece of code, the > harder is to use independent modules together and to understand code > in isolation. So it goes. You can write wrappers that require explicitly passing all context info to every arithmetic operation, and explicitly collects the outputs too; but most people will prefer implicit state so they can continue writing x = y + z instead of x, non_fatal_conditions = add(y, z, precision, rounding_mode, exception_masks) Even if you reduce that to x, context = add(y, z, context) it's still a PITA. Note that your HW 754 fp is already swimming in global (really thread-local, if the OS and libraries aren't insane) state; you usually don't notice it (unless you're a serious numeric programmer) simply because no name-brand language has yet bothered to expose it in a portable way (C99 is the first big stab at this). finite-numerics-can't-be-understood-"in-isolation"-ly y'rs - tim From skip at pobox.com Thu Jul 5 15:02:09 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 5 Jul 2001 14:02:09 -0500 Subject: There's got to be an easy way to do this In-Reply-To: <9i2c77$gmc74$1@ID-11957.news.dfncis.de> References: <9i27i8$gd9bq$1@ID-11957.news.dfncis.de> <3B44B031.819C93E@stroeder.com> <9i2c77$gmc74$1@ID-11957.news.dfncis.de> Message-ID: <15172.47537.816562.599573@beluga.mojam.com> Ooh! A performance thread! This function is about one-third better than str_join. def str_join2(iters): has = {0:1,1:1,2:1,3:1,4:1,5:1,6:1,7:1,8:1,9:1}.has_key for i in iters: "".join([x for x in '(123)/456-7890' if has(x)]) :-) -- Skip Montanaro (skip at pobox.com) (847)971-7098 From rnd at onego.ru Sun Jul 15 03:38:04 2001 From: rnd at onego.ru (Roman Suzi) Date: Sun, 15 Jul 2001 11:38:04 +0400 (MSD) Subject: This is spoiling Python image! Message-ID: The problem: it is impossible to use IDLE with non-latin1 encodings under Windows. IDLE is standard IDE for Python and it is what beginner users of Python see in their Start->Programs. Unfortunately, IDLE can't work with non-latin1 characters any more. This could lead beginners to reconsider their choice of language because of unfriendly i18n issues. The problem is explained in detail below. Lets consider all errors one at a time. 1. Tcl can't find encodings (they are in \Python21\tcl\tcl8.3\encoding\). Without them it is impossible to enter cyrillic and other kinds of letters in Text and Entry widgets under Windows. Tkinter tries to help Tcl by means of FixTk.py: import sys, os, _tkinter ver = str(_tkinter.TCL_VERSION) for t in "tcl", "tk": v = os.path.join(sys.prefix, "tcl", t+ver) if os.path.exists(os.path.join(v, "tclIndex")): os.environ[t.upper() + "_LIBRARY"] = v This sets env. variables TCL_LIBRARY and TK_LIBRARY to "C:\Python21\tcl\tcl8.3". The problem is that it imports _tkinter which initialises and calls Tcl_FindExecutable before TCL_LIBRARY is set. It is easy to fix this error in FixTk.py: import sys, os if not os.environ.has_key('TCL_LIBRARY'): tcl_library = os.path.join(sys.prefix, "tcl", "tclX.Y") os.environ['TCL_LIBRARY'] = tcl_library Tcl is smart enough to look into "C:\Python21\tcl\tclX.Y\..\tcl8.3" as well. 2. Now we are able to print in IDLE: >>> print "??????" and we will see russian letter... before we press Enter, after which: UnicodeError: ASCII decoding error: ordinal not in range(128) appears. Tcl recoded "??????" into Unicode. Python tries to recode it back into usual string, assuming usual strings have sys.getdefaultencoding(). Now we need to set default encoding. Lets look into site.py: # Set the string encoding used by the Unicode implementation. The # default is 'ascii', but if you're willing to experiment, you can # change this. encoding = "ascii" # Default value set by _PyUnicode_Init() if 0: # Enable to support locale aware default string encodings. import locale loc = locale.getdefaultlocale() if loc[1]: encoding = loc[1] if 0: # Enable to switch off string to Unicode coercion and implicit # Unicode to string conversion. encoding = "undefined" if encoding != "ascii": sys.setdefaultencoding(encoding) The code for setting default encoding is commented (maybe, to allow faster startup?) Then goes: # # Run custom site specific code, if available. # try: import sitecustomize except ImportError: pass # # Remove sys.setdefaultencoding() so that users cannot change the # encoding after initialization. The test for presence is needed when # this module is run as a script, because this code is executed twice. # if hasattr(sys, "setdefaultencoding"): del sys.setdefaultencoding So, sys.setdefaultencoding is deleted after we used it in sitecustomize.py. Its too bad, because the program can't set default encoding and implicit string<->unicode conversions are very common in Python and IDLE. The solution could be as follows. Lets put sitecustomize.py in C:\Python21\ with the following: import locale, sys encoding = locale.getdefaultlocale()[1] if encoding: sys.setdefaultencoding(encoding) * It would be wonderful if IDLE itself could setup encoding based on locale or issued warnings and pointed t o solution somehow. 3. Now we can try it again in IDLE: >>> print "??????" after hitting Enter we are getting... latin1. It's time to look at how _tkinter.c communicates with Tcl. The cheap&dirty solution for IDLE is as follows: --- Percolator.py.orig Sat Jul 14 19:38:16 2001 +++ Percolator.py Sat Jul 14 19:38:16 2001 @@ -22,6 +22,8 @@ def insert(self, index, chars, tags=None): # Could go away if inheriting from Delegator + if index != 'insert': + chars = unicode(chars) self.top.insert(index, chars, tags) def delete(self, index1, index2=None): --- PyShell.py.orig Sat Jul 14 19:38:37 2001 +++ PyShell.py Sat Jul 14 19:38:37 2001 @@ -469,6 +469,8 @@ finally: self.reading = save line = self.text.get("iomark", "end-1c") + if type(line) == type(u""): + line = line.encode() self.resetoutput() if self.canceled: self.canceled = 0 But alas these patches only mask the problem. What is really needed? Starting from version 8.1 Tcl is totally unicoded. It is very simple: tt wants us utf-8 strings and returns also utf-8 strings. (As an exception, Tcl could assume latin1 if it is unable to decode string). _tkinter.c just sends Python strings as is to Tcl. And does it correctly for Unicode strings. Receiving side is slightly more complicated: Tkapp_Call function (aka root.tk.call) handles most of the Tkinter Tcl/Tk commands. If the result is 7bit clean, Tkapp_Call returns usual string, if not -- it converts from utf-8 into unicode and returns Unicode string. Only Tkapp_Call does it. All others (Tkapp_Eval, GetVar, PythonCmd) return utf-8 string! IDLE extensively use Tkinter capabilities and all kinds of strings go back and forth between Python and Tcl. Of course, _tkinter.c works incorrectly. i) before sending a string to Tcl, it must recode it FROM default encoding TO utf-8 ii) upon receive of a string from Tcl, it must recode it from utf-8 to default encoding, if possible. [R.S.: Or return it as Unicode, if impossible] It is possible to optimize the conversions. Of course, this will have impact on the speed of Tkinter. But in our opinion correct work is more important than speed. Solution checked under Win98. >From R.S.: yes, IDLE is not ideal and there are better IDEs (Emacs, for example) and "serious" programmers rarely use it. Also Tkinter is critisized much, etc. But the problem indicated above is very bad for Python image as a user-friendly language. That is why it is very important to FIX the problem as soon, as possible. We can prepare patches for _tkinter.c as well. Before we proceed to submitting bug-reports and patches, we will be glad to hear if somebody has better solution to the indicated problem. (The big deal of the problem is the need to patch _tkinter.c and recompile it. Everything else even beginner could fix if supplied with clues and files with fixes. But of course, Python's IDLE must run correct out of the box). Author: Kirill Simonov Translator: Roman Suzi From aleaxit at yahoo.com Sun Jul 15 03:02:24 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 15 Jul 2001 09:02:24 +0200 Subject: Tkinter/Win32 Question: References: <9C847.6$ei.832667@newssvr15.news.prodigy.com> Message-ID: <9irfbb01jaq@enews1.newsguy.com> "Xione Wrent" wrote in message news:9C847.6$ei.832667 at newssvr15.news.prodigy.com... > Does anyone know how to add "System Tray Minimization" functionality to a > Tkinter GUI? I don't think Tkinter offers such an intrinsically non-cross-platform functionality. I suspect therefore that you'd need to work this part through the win32all add-ons, win32gui.Shell_NotifyIcon &tc. Alex From jkraska1 at san.rr.com Mon Jul 2 02:25:52 2001 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 02 Jul 2001 06:25:52 GMT Subject: New PEP: Quality Guidelines For Standard Modules References: Message-ID: Seems like a good start. I only have one objection: > 1. Standard Modules MUST not rely on global variables to keep > state information, except when it is absolutely required. When writing language requirements, one MUST not use the term "MUST" in conjunction with an "except". And in any case, I disagree. Emphatically. The use of a singleton pattern changes nothing unless every call to the module has the singleton as its first argument. And if you're envisioning storing the singleton as a global, nothing has been accomplished. There's a global. Perhaps you could make a better case for why you think this is even important. C// From paulp at ActiveState.com Sat Jul 14 18:04:47 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sat, 14 Jul 2001 15:04:47 -0700 Subject: PEP: Defining Unicode Literal Encodings (revision 1.1) References: Message-ID: <3B50C1FF.7E73739B@ActiveState.com> Tim Peters wrote: > >... > > That is, the module docstring is just the module's __doc__ attr, and that > can be bound explicitly (a trick I've sometimes use for *computed* module > docstrings). I must be missing something fundamental. Why wouldn't we just redefine the algorithm used to find the docstring to allow a directive and implement it in the interpreter? *What tools* in particular are we worried about breaking? -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From roy at panix.com Sun Jul 15 21:51:32 2001 From: roy at panix.com (Roy Smith) Date: Sun, 15 Jul 2001 21:51:32 -0400 Subject: re Challenge: More Compact? References: <3B51E6B1.47E25214@tundraware.com> <92ae279c.0107151429.398e6e9e@posting.google.com> Message-ID: tim at vegeta.ath.cx (Tim Hammerquist) wrote: > from 'Mastering Regular Expressions', p.124: > > '^([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.\ > ([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])$' Along those lines, but more compact: r'^([01]?\d\d?|2[0-4]\d|25[0-5])(\.([01]?\d\d?|2[0-4]\d|25[0-5])){3,3}$' From vnestr at netvision.net.il Sun Jul 8 16:49:51 2001 From: vnestr at netvision.net.il (Vladimir Nesterovsky) Date: Sun, 8 Jul 2001 22:49:51 +0200 Subject: anonymous variable References: <9i791n$3bh$1@macareux.ens-lyon.fr> <9i7tjq01b9o@enews3.newsguy.com> <9i88o3$hj41s$1@ID-91128.news.dfncis.de> <9i9fsn$enb$02$1@news.t-online.com> Message-ID: <9iadiq$ho0qu$1@ID-91128.news.dfncis.de> Georg Mischler wrote in message news:9i9fsn$enb$02$1 at news.t-online.com... > Vladimir Nesterovsky wrote: > > > ... I once did it to sort Lisp data by a > > Now look who found the way to Python land... > > Welcome to the club, Vladimir! > Thanks, George! :-) I'm just toying with the language, it looks nice and it has _lambda_ and _map_ .... :-) :-) From nospam at newsranger.com Wed Jul 18 16:13:16 2001 From: nospam at newsranger.com (Levente Sandor) Date: Wed, 18 Jul 2001 20:13:16 GMT Subject: sys.argv not found References: <3B55962C.63F7E2EF@mit.edu> <3B55B2C2.74A8FB3D@mit.edu> <3B55DBAB.EB900433@mit.edu> Message-ID: It seems that one of the imported modules deletes sys.argv. Suggestion: import sys at the top of your script, then make immediately the variable assignements. Levi In article <3B55DBAB.EB900433 at mit.edu>, Man Vehicle Laboratory says... > >Fiddling with the script some more, it seems like Vrut somehow runs the script >again when vrut.go() is called. I placed print statements all throughout the >code, which shows up in the interactive window until vrut.go() is called. Then >in the vrut window, it gives the Attribute Error. I'm going to have to muck >through the vrut code itself to see what's going on. > > Thanks for everyone's help! > Fen > > > >Steve Holden wrote: > >> "Man Vehicle Laboratory" wrote in message >> news:3B55B2C2.74A8FB3D at mit.edu... >> > >> > I've tried putting a print statement right after I import sys. I have the >> same >> > error as before: >> > >> > >> > >> **************************************************************************** >> ** >> > >> > * WINVRUT 2.4a Copyright 1995-2001 University of California, Santa >> > Barbara * >> > * Massachusetts Institute of >> > Technology * >> > >> **************************************************************************** >> ** >> > >> > VRUT 2.4a >> > voicekey Voicekey 0.9 >> > serialthrustmaster Serial thrustmaster 1.0 >> > avstu AvatarStudio 1.1 >> > Traceback (most recent call last): >> > File "", line 1, in ? >> > File "N:\FenZhao\E3_sid_data\e3_sid_data2.py", line 61, in ? >> > print sys.argv >> > AttributeError: argv >> > >> Well, this traceback looks very suspicious. I assume that the file you are >> taking about is indeed e3_sid_data2.py? Maybe not ... it is quite weird >> that sys appears to have no argv attribute. I can only conclude that perhaps >> some other portion of your code assigns to sys? But you say below this is >> NOT the case. Aaarrgghh... >> >> > The error I get from vrut is from my code looking at argv, not vrut (error >> > message w/out print statement: >> > >> > Traceback (most recent call last): >> > File "", line 1, in ? >> > File "N:\FenZhao\E3_sid_data\e3_sid_data2.py", line 62, in ? >> > mode=string.atoi(sys.argv[1]) >> > AttributeError: argv >> > >> The first line of the tracebacks implies that some code is being executed >> from a strng variable. If none of your code does anything like that (uses >> eval/exec, let's say) then the obvious suspect is the vrut module... >> >> Your module doesn't by any chance import itself, does it? >> >> > So whatever my first operation is dealing with sys.argv, there's an >> attribute >> > error with argv) >> > >> > What confuses me is that this error is displayed in the VRUT window; VRUT >> opens >> > two windows, a display window that shows the 3D VR scene, and a text >> window that >> > will display print statements and error messages from python. Logically, >> if >> > argv can't be found, an error message will end the program before vrut >> ever gets >> > started. >> > >> Oh. Is it possible that importing the vrut module modifies >> sys.stdout/sys.stderr, leaving something weird in place before the vrut.go() >> call creates the windows? >> >> > I've also tried importing vrut after looking at sys.argv in case vrut does >> > something funky in it's initialization/import. Same problem. Yet >> commenting >> > out the vrut.go() command, and the sys.argv is fine. >> >> OK, so what you are telling us is that the presence of a function call you >> have not yet executed is somehow affecting the sys module's namespace. That >> sounds pretty funky to me, and frankly I'm beginning to wonder whether you >> have programmed a time machine :-) >> >> > >> > --Fen >> > >> > PS. I hope this helps: all of my code up to the call to vrut (minus >> > comments)... there's not much there, can't figure out what's making it >> work >> > improperly. None of the modules that I wrote and imported do anything >> with sys >> > >> I can understand your confusion. I hope the rest of the list will feel free >> to dive in with suggestions about what's wrong! :-0 >> > >> >> Put "import sys; print sys.argv" here to make sure your program does indeed >> see the correct value for the argument list. >> >> > import vrut >> >> Put "import sys; print sys.argv" here too, to verify that the import >> statement makes no changes to sys. >> If you see output from the first print bu not the second then the module is >> indeed doing something funky. >> >> > import sid >> > >> > >> > import string >> > import math >> > import time >> > >> > >> > import speeds >> > import e3_dataAn >> > import sys >> > >> > mode=string.atoi(sys.argv[1]) >> > ARGFILE_stim=sys.argv[2] >> > ARGFILE_calib=sys.argv[3] >> > OUTFILE=sys.argv[4] >> > SUMFILE=sys.argv[5] >> > sidOutfile=sys.argv[6] >> > VECTION_DURATION=string.atoi(sys.argv[7]) >> > path=sys.argv[8] >> > >> > vrut.go(vrut.NICE) >> > >> > >> > >> > Steve Holden wrote: >> > [ various apparently irrelevant things ] >> >> I'm currently betting that a recursive import is somehow messing things up. >> Otherwise I'm a little stumped, and we'll have to proceed with debugging >> step by step. >> >> regards >> Steve >> -- >> http://www.holdenweb.com/ > From tjreedy at home.com Tue Jul 31 18:22:42 2001 From: tjreedy at home.com (Terry Reedy) Date: Tue, 31 Jul 2001 22:22:42 GMT Subject: Python Is Really Middleware References: <3B667EBA.DA6C298@tundraware.com> Message-ID: "Tim Daneliuk" wrote in message news:3B667EBA.DA6C298 at tundraware.com... an interesting essay with many things to think about. Thanks for sharing your experience-based thoughts with us. ... > - How do we write more correct, maintainable, code *faster*? If Python does not enable this, no special reason it should expand. If it actually does, for many programmers who give it a try, then it seems to this Darwinian that the resulting competitice advantage should lead to an almost inevitable growth -- or is Dilbert more true to life than I would like to believe? > (For those of you Neo-Marxists in the audience who think that "Information > Just Wants To Be FREE", I should mention that the survivability of > any technology has always been primarily a function of commercial adoption, > at least in the long run. How many people write in COBOL today? (Many!) > How many program in Eiffel? Snobol? ML? Oberon? Haskell? 'Nuff said. > Economic Reality trumps Bad Collectivist Theory every time. Thank-You, > Adam Smith.) As a Smithian hippie, I think the better adage is "Entertainment information want to be free", which is to say that people like to share non-critical information as part of their social interaction and play. On the other hand, several people have noted that Python being free is a barrier to commercial acceptance. As a free user, I would like to see more commercial exploitation without enclosure. (Software and information in general does *NOT* suffer from the tragedy of the commons.) One selling point 'should' be that the 100,000 (or whatever) 'free' users help research, develop, and test the polished versions bundled with paid-for support services. > But, there's a rub. When you buy Middleware, you are > (if you did your homework right) removing a large part of the > dependency the apps have on networking, OS, and so forth. > BUT, you are marrying the Middleware vendor until that > application goes away. So part of the pitch of Python-as-Middleware vendors 'should' be that because Python is open rather than proprietary, there can/are/will be multiple such vendors, and so clients will never be totally dependent on any one such vendor. > I worry about one thing and one thing only in the Python world. It > is something I have witnessed in *every* new technology I've > ever seen. Python is dangerously close to becoming a victim of > Feeping Creaturism - not so much In Fact, but rather in this community's > mindset of forever wanting to fiddle one more feature into the > language One thing I like about Python is that it, like C, is currently small enough to be kept in mind all at once, in a way that C++, for instance, is not. I would not like this to change, so I consider simplification vs. complexification to be one criterion for evaluation proposals. Of course, one proposal can do both, depending on viewpoint. > I, for one, would like to see a date picked for a permanent moratorium > on the language proper, All the changes in the last year have been discussed for years. So I expect/hope that in another year we will see something of a plateau again with Python2final. > after which, only bug fixes and new modules could be added. You are free to sponsor such releases, along the lines of 2.0.1 and 2.1.1 but with new modules, of any version *you* want to stabilize , for an many years as you think it useful. Unless someone offers to *pay* Guido enough to persuade him to do this, there is no reason *he* should. > After that date, language changes would have to be > part of some new language Consider Python3 to be a new language, if you want. Or even Python 2.2. I personally prefer to move,when I want, from one language I like to another that is only slightly different in ways I see as improvement, than to an unrelated language. I think it worth noting that 2.2 without 'import future' is arguably more compatible with 2.1 than most versions of, for instance, 'C' have been with each other. ['Version of C' = defacto language of particular compiler on particular platform with particular settings.] In this sense alone, you are correct: Python is middleware that has already successfully hidden some annoying variations in the underlying platforms it runs on. Terry J. Reedy From rupe at metro.yak.net Thu Jul 26 14:09:57 2001 From: rupe at metro.yak.net (Rupert Scammell) Date: 26 Jul 2001 11:09:57 -0700 Subject: HTML to formatted text conversion function References: <79179cf5.0107241216.7345d345@posting.google.com> Message-ID: <79179cf5.0107261009.56d708d3@posting.google.com> Duncan Booth wrote in message news:... > > Is this what you need? > > --- begin strip.py --- > --- end strip.py --- Thank you for your help, Duncan. This is a marvellous little snippet of code, and does exactly what I was looking for. --- Rupert Rupert Scammell rupe at metro.yak.net http://metro.yak.net From stephen_purcell at yahoo.com Wed Jul 4 04:15:13 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: 4 Jul 2001 01:15:13 -0700 Subject: I'd Like to Contribute to an Open Source Project References: <3b41d693$1_7@news5.uncensored-news.com> Message-ID: <309094c8.0107040015.37ef7087@posting.google.com> Doug Fort wrote in message news:<3b41d693$1_7 at news5.uncensored-news.com>... > I have some time on my hands. It seems like a good opportunity to do some > noncommercial Python programming. Like my hero TV's Frank on MST3K, I'm > more suited to be the lackey than the mad scientist. > > I've checked the 'Project Help Wanted' on SourceForge and don't see > anything that really fits. > > Anybody need some Python code on an Open Source project? > > You can see some of my work at http://pyagent.sourceforge.net and at > http://asynchttp.sourceforge.net. It might interest you to look at my fledgling WebUnit project (http://webunit.sourceforge.net/). I can see some possible connections with your async http work, and with your stressmy.com service because WebUnit simulates browser sessions with a web site. SSL support and optional use of async sockets would be interesting extensions for WebUnit. -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From phd at phd.fep.ru Thu Jul 5 10:07:44 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Thu, 5 Jul 2001 18:07:44 +0400 (MSD) Subject: FTP program works -- now how do I send the directory over? In-Reply-To: Message-ID: On Thu, 5 Jul 2001, Kemp Randy-W18971 wrote: > I seem to be getting the listing of what's on my d drive in windows, rather then the binary contents. Here is what I do (the server id changed to protect the innocent: > > for filename in glob.glob('d:\programsPython\*'): > ftp.storbinary("STOR " + filename, open(filename, 'rb')) > List the directory contents in Unix > > ee110:/usr2/ecadtesting/tarbackups> ls > d:\programsPython\CE H2-102000 Usage Mentor1.txt > Why do I get the text d:\programsPython\filename? Because glob() returns full path, so you end up running commands like ftp.storbinary("STOR " + 'd:\\programsPython\\CE H2-102000 Usage Mentor1.txt'... (please note double backslashes) If you want just filenames without path you can do one of two things: 1) cd d:\programsPython (os.chdir("d:\\programsPython")) and then use glob('*') - this will list just the curent directory 2) or cut off the file/path yourself: for filename in glob.glob('d:\programsPython\*'): name = string.split(filename, '\\')[-1] ftp.storbinary("STOR " + name, open(filename, 'rb')) > How should I change the program to get the actual files sent over? Why do you think those funny files are not real files? It is just UNIX didn't interpreted backslashes! :) I am sure they are your real files! Test it. 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 Jul 12 04:35:18 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 12 Jul 2001 10:35:18 +0200 Subject: LAMBDA IS IT USELESS? References: Message-ID: <9ijng5026ut@enews4.newsguy.com> "EricIDLE" wrote in message news:tO837.679712$166.14009323 at news1.rdc1.bc.home.com... > Ok well I dont quite grasp the Lambda concept heres an example. Oh, the _concept_ is not too deep or complicated: lambda lets you keep extremely-simple functions anonymous by defining them 'inline' where you use them (often, pass them as parameters). > def mult(x,y): > return x * y > f = reduce(lambda x,y: x*y,n) > print f > > *NOTE The varible N is defined in the code before this excerpt. > > Anyways back to the point the book says this is easier!?!? Easier than what? > But comon sense tells me this is easier. > > def mult(x,y): > return x * y > f = reduce(mult,n) > print f > > Isnt that easier?? Even 'easier' (and surely faster) would IMHO be: import operator f = reduce(operator.mul, n) print f Many 'appropriate' examples of lambda are things that module operator exposes in a faster and more usable way. When you go beyond that, things can easily get too complicated for a lambda to be well-readable. There ARE a few exceptions, but personally I'd rather have operator extended a little bit, and/or use some form of currying. So I hardly ever use lambda, personally, nor do I suggest it to newbies. > Or do I not get lambda? > > *NOTE ... I think its just a way to complicate things OR just a way to avoid > typing the function name beacuse.... I dont know they are scared of the > names they give them. People do like to keep things anonymous, and sometimes they have a point. A well-chosen name can help make code clearer, but if you care nothing about the name you're quite apt to choose one that will instead make code LESS readable. And naming something often means 'breaking up' an expression into a few statements -- that may well be beneficial to clarity when the expression is overly complicated, but for some expressions of middling complexity the breaking-up may instead diminish readability by spreading things out too much. I think you do "get lambda": it's nothing but a way to keep some extremely simple functions anonymous and in-line. I tend to agree that, in Python as it exists today, lambda does not add enough expressive power to "carry its weight" in terms of added language complication (when teaching Python to people without a background in other languages that include some 'lambda' construct -- and such 'other languages' tend to have fewer limitations on lambdas' power). A slightly richer module operator and a standardized way to curry any arbitrary callable would be vastly preferable (it's easy to cook up currying in Python today, but newbies having some problems with lambda are unlikely to think of that:-). Alex From hinsen at cnrs-orleans.fr Thu Jul 12 05:00:38 2001 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 12 Jul 2001 11:00:38 +0200 Subject: Language change and code breaks References: <6A%27.454703$eK2.93741234@news4.rdc1.on.home.com> Message-ID: David Bolen writes: > Of course, if a was complex then we wouldn't be worried about a/b > truncating anything either. But definitely something to keep in mind > if working on code that might receive either complex or integer > parameters. Whenever you know the type of your objects there is no problem. But often you want to write a mathematical expression which accepts any reasonable type, even Python classes with a number interface. An explicit cast to float() is very undesirable in such situations, and a hack such as (a+0.)/b is not obvious to the uninitiated. A special operator, // or whatever, with the meaning of "the best approximation to standard artihmetic division that is available" is the best way to express this, in my opinion. Perhaps some number-like classes could even reimplement it in some clever way. 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 kentabacchi at excite.com Thu Jul 26 10:03:38 2001 From: kentabacchi at excite.com (Ken Tabacchi) Date: 26 Jul 2001 07:03:38 -0700 Subject: Threads in Python version 1.5, thread doesn't start until calling process dies References: <3B5EE94B.1EBA28FF@Lugoj.Com> Message-ID: Sorry about the omission of key information. My system is Windows NT 4.0. The Python interpreter is version 1.5.1, and, if this means anything, it is the interpreter that came with a dSPACE Control Desk version 1.1 package. Something interesting I discovered this morning, my implementation of the thread module works as expected when run in Pythonwin (1.5.1), but gives the erroneous result (thread doesn't start until process that called it has died) when run in the Control Desk environment. I'm not sure about which interpreter Control Desk is using, although they site 1.1.2.8 in their Help, About menu, but I think that number means something only to dSPACE people. Both Pythonwin and Control Desk versions report the following when sys.version is called: '1.5.1 (#0, Jan 27 1999, 11:10:46) [MSC 32 bit (Intel)]' Same interpreter yet different result. It has been suggested to use the threading module for a more 'predictable' execution. Does anyone have any advice about simply starting a new thread, exiting a thread and possibly acquiring a lock using the threading module? Much appreciated. James Logajan wrote in message news:<3B5EE94B.1EBA28FF at Lugoj.Com>... > That does look odd. What operating system are you using? And when you say > 1.5, do you mean 1.5 or 1.5.2? > > Ken Tabacchi wrote: > > > > I am having some trouble with a threadded process in Python version > > 1.5. It seems that the thread does not start until the calling > > process has died. The thread starts immediately when the following > > program is run under Python version 2.1. > [ Elided. ] From XQ.Xia at ccsr.cam.ac.uk Fri Jul 13 05:13:09 2001 From: XQ.Xia at ccsr.cam.ac.uk (XiaoQin Xia) Date: Fri, 13 Jul 2001 10:13:09 +0100 Subject: Question on nested scope Message-ID: <3B4EBBA5.10745796@ccsr.cam.ac.uk> In Python 2.1: >>> b=10 >>> a="b=b+11" >>> def f(p): exec p print a print b >>> f(a) b=b+11 21 >>> b 10 >>> When exec "b=b+11", python can find the second b (10), why it generate another b? Cheers, Xiao-Qin Xia From peter at engcorp.com Mon Jul 16 23:38:33 2001 From: peter at engcorp.com (Peter Hansen) Date: Mon, 16 Jul 2001 23:38:33 -0400 Subject: OO misconceptions References: <9ir1l7$3ja$1@panix2.panix.com> <9irfbc11jaq@enews1.newsguy.com> <3B538E16.65394C9D@engcorp.com> Message-ID: <3B53B339.B6698858@engcorp.com> Tim Hammerquist wrote: > > > Nevertheless, I feel compelled to say that I believe there may be > > applications for which Perl is the better language, [...] > > Any other application, and I would probably say Python was a > > better choice... > > This is where our opinions (on both languages) differ, and where we > might as well agree to disagree? Well, I'm going to have to sit on the fence on that one. :) (Actually, when I started posting the other message, my intention was to admit that I had hardly even tried to learn and apply Perl. I consider myself fortunate to have discovered Python just when I was considering Perl for an application which required a scripting language. Perl, in this case (factory automation) would definitely *not* have been a better choice, even in your estimation. I've used a wide enough variety of languages, however, to know that it just wouldn't work for me. I _do_ have an open mind about it, but that doesn't stop me proselytizing about Python. :-) From emile at fenx.com Fri Jul 13 08:14:30 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 13 Jul 2001 05:14:30 -0700 Subject: PyZipFile References: <25b2e0d9.0107122104.50347e10@posting.google.com> <9imotd$jrp8f$1@ID-11957.news.dfncis.de> Message-ID: <9imovp$jdvue$1@ID-11957.news.dfncis.de> Whoops, where'd my response go? ;-) You're getting the error because you're not eval'ing source code, but the contents of a pyc file. If what you're trying to do is execute code stored in a zipfile python archive, this should work: exec(marshal.loads(p.read('pe/lang.pyc')[8:])) HTH, -- Emile van Sebille emile at fenx.com --------- "Emile van Sebille" wrote in message news:9imotd$jrp8f$1 at ID-11957.news.dfncis.de... > > > -- > > Emile van Sebille > emile at fenx.com > > --------- > "gods1child" wrote in message > news:25b2e0d9.0107122104.50347e10 at posting.google.com... > > Why wont the following code work? Thanx. > > > > import zipfile > > p = zipfile.PyZipFile("c:\\pe\\arc.zip","w",zipfile.ZIP_STORED) > > p.writepy("c:\\pe") > > p.close() > > p = zipfile.PyZipFile("c:\\pe\\arc.zip","r",zipfile.ZIP_STORED) > > eval(p.read("pe/lang.pyc")) > > p.close() > > > > ---------------------------------------------------- > > Traceback (most recent call last): > > File "C:/pe/nest.py", line 6, in ? > > eval(p.read("pe/lang.pyc")) > > TypeError: expected string without null bytes > From fdrake at acm.org Tue Jul 17 19:31:07 2001 From: fdrake at acm.org (Fred L. Drake) Date: Tue, 17 Jul 2001 19:31:07 -0400 (EDT) Subject: [development doc updates] Message-ID: <20010717233107.C0EAE2892B@beowolf.digicool.com> The development version of the documentation has been updated: http://python.sourceforge.net/devel-docs/ Final update of the 2.2a1 documentation. From christopherjmcmillan at eaton.com Tue Jul 10 10:34:35 2001 From: christopherjmcmillan at eaton.com (Chris McMillan) Date: Tue, 10 Jul 2001 10:34:35 -0400 Subject: File processing References: <9id5p9$8r62@interserv.etn.com> Message-ID: <9if3fv$8r65@interserv.etn.com> Thank you everyone for your imput!! On a side note: I would have loved to use bash, sed, etc, but unfortunately I'm forced to use a Windows NT machine. I just thought this might be an excellent python exercise since I'm in the process of learning it. Thanks again, Chris Chris McMillan wrote in message <9id5p9$8r62 at interserv.etn.com>... >Hello all! > >I'm trying to write a script that will open a file, delete the first line, >and then save the file with the same name. Can someone please point me in >the right direction? Thanks! > >Why am I doing this you may ask: I have tens of data files that I need to >strip the first line before I can process it in Matlab. So, I dream of a >script that opens every file in a directory, deletes the first line, ..... > >Thanks, > >Chris > > From gustafl at algonet.se Wed Jul 4 11:10:55 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 4 Jul 2001 15:10:55 GMT Subject: Two problems with backslashes References: Message-ID: Skip Montanaro wrote: > Your first statement should be either > > path = 'e:\\test\\test.txt' > > or > > path = r'e:\test\test.txt' Forgot to tell you one thing: I get these paths from user input (arguments to getopt.getopt()), so I have no control on this. Have looked for a function to convert a string to a raw string, but couldn't find any. I'll take a closer look on os.path now. Regards, Gustaf Liljegren From max at alcyone.com Sun Jul 22 13:55:10 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 22 Jul 2001 10:55:10 -0700 Subject: subclassing Exceptions References: <9ihklt8u0vvh1aa0mg6tadbmjo9mot47e0@4ax.com> Message-ID: <3B5B137E.3606B75D@alcyone.com> Sheila King wrote: > Thanks, Brian, but I've seen the docs many times. I need more info > than > that. Like example code, or source code. The library reference quoted states pretty clearly: The root class for exceptions. All built-in exceptions are derived from this class. All user-defined exceptions should also be derived from this class, but this is not (yet) enforced. The str() function, when applied to an instance of this class (or most derived classes) returns the string value of the argument or arguments, or an empty string if no arguments were given to the constructor. When used as a sequence, this accesses the arguments given to the constructor (handy for backward compatibility with old code). The arguments are also available on the instance's args attribute, as a tuple. This gives you a pretty effective specification for what a class derived from exceptions.Exception should do; it should return something meaningful in its __str__ method, support __len__ and __getitem__ for indexing, and have an `args' attribute that contains the arguments it was instantiated with as a tuple. The Exception class itself does this. If all you want is a different _type_ of exception that you can key off of, then deriving from the class and doing nothing with it (using `pass' as you did in your example) is perfectly satisfactory. If you want to do more, then you can add extra methods as you need that use the value gained through calling `str' or the `args' attribute. What more did you need to 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 / \ But since when can wounded eyes see / If we weren't who we were \__/ Joi Rules for Buh / http://www.alcyone.com/max/projects/cards/buh.html The official rules to the betting card game, Buh. From qrczak at knm.org.pl Sat Jul 28 15:40:43 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 28 Jul 2001 19:40:43 GMT Subject: PEP 238 (revised) References: Message-ID: Fri, 27 Jul 2001 15:43:24 -0400, Tim Peters pisze: > Multiplying by 1.0 preserves the sign of a 754 zero, but adding 0.0 > (of either sign) may not; Why adding a negative zero may not? If 0.0+(-0.0) is specified to be 0.0, then I don't see where it breaks. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From new_name at mit.edu Thu Jul 26 13:05:16 2001 From: new_name at mit.edu (Alex) Date: 26 Jul 2001 13:05:16 -0400 Subject: PYTHONPATH References: Message-ID: Use this, inside python: import sys p = '/path' if p not in sys.path: sys.path.append(p) HTH Alex. From jkraska1 at san.rr.com Mon Jul 2 02:15:10 2001 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 02 Jul 2001 06:15:10 GMT Subject: Augmented Assignement (was: Re: PEP scepticism) References: Message-ID: >> def f(x): >> x = x + (1,2,3) >> print x >A vast improvement: clear, unambiguous, and correct. I can safely pass a >list as an argument and not have it modified behind my back. Eek. I finally got what everyone is talking about. x += (1,2,3) ... is not the same as... x=x+(1,2,3) That's just plain wrong. C// From tjreedy at home.com Thu Jul 26 16:13:12 2001 From: tjreedy at home.com (Terry Reedy) Date: Thu, 26 Jul 2001 20:13:12 GMT Subject: indetation problem References: Message-ID: "Fuming Wang" wrote in message news:b0fd9226.0107261009.33a6b066 at posting.google.com... > I am experiencing indentation problems when mixing tabs and spaces in my code. Don't. > Question: is this something new, or it has always been there. Old, with long discussions, resulting in above advice and tabnanny.py in utility directory of distribution. >It is strange that I have been using Python for several years, but only > notice this behavior recently. Change editor? Terry J. Reedy From owen at astro.washington.edu Mon Jul 23 12:57:36 2001 From: owen at astro.washington.edu (Russell E. Owen) Date: Mon, 23 Jul 2001 09:57:36 -0700 Subject: Advice wanted: asynch I/O on unix Message-ID: I have a unix C library that reads some parallel port cards (asynchronously), processes the data and writes it files. I want to be able to call it from Python and would love some advice. My unix experience is somewhat limited, as is my experience writing C modules for Python. The present C program works as follows: - open the parallel port as a file-like device (and config with ioctl) - allocate some buffers - call aioread to start reading into one buffer - call aioread to queue a read into a 2nd buffer - repeatedly poll the aioreads; when one finishes, processes the data, deallocate the buffer, and allocate a new buffer and queue an aioread on it writing works similarly It would be nicest to end up with as little C code as possible (i.e. move most of this functionality into Python). Some of the processing would be better done in Python, and it's so much easier to debug and modify things in Python. I think I can rewrite most or all of this directly in Python, but surely I can do better than simply replicate this code? It looks awfully complex. Is there A Better Way? Ideally, I'd like to start a read into a big FIFO, then check every once in awhile and process the data that has arrived. In other words, somehow treat the parallel port card as a buffered stream. Is this practical, or should I just bite the bullet and code up all that fussy buffer manipulation? (By the way, the device does come with a library that allows setting up a circular set of buffers. This would save some of the fussing with buffers, though I have my doubts about aspects of the interface and it means using a custom C library.) Any advice would be appreciated. -- Russell From jwbaxter at spamcop.com Mon Jul 23 10:51:25 2001 From: jwbaxter at spamcop.com (John W. Baxter) Date: Mon, 23 Jul 2001 07:51:25 -0700 Subject: Future division patch available (PEP 238) References: Message-ID: <230720010751255977%jwbaxter@spamcop.com> In article , Stephen Horne wrote: > What the hell is a decimal float, and where did they come from! They > only exist, to my knowledge, in the sense of standard form/scientific > notation. Microsoft BASIC (at least for Macintosh) did them in 1985 (or 1984). There were two interpreters...one with a $ worked into the icon, for the decimal form; one with a pi in the $'s location for the faster binary floats. [I've never used MS Basic on the Intel side.] --John From wware at world.std.com Tue Jul 3 07:39:29 2001 From: wware at world.std.com (Will Ware) Date: Tue, 3 Jul 2001 11:39:29 GMT Subject: Python for air traffic control? References: Message-ID: Carlos Ribeiro (cribeiro at mail.inet.com.br) wrote: > ...the problem in air traffic > control is *not* how to map airplane positions using radar input; is how to > calculate paths and coordinate communications with dozens, or even > hundreds, of airplanes, while following *very* strict safety rules that > tell how to solve conflicts that arise all the time. You have to manage the > queues for takeoff and landing, keeping everything in sync to make the most > of precious time. ...there are several "lanes" in air > space, defined by the authorities. The use of the radio frequencies must > also be managed by the tower to make sure that there are not any undesired > interference between different airplanes... This is a wonderful statement of the magnitude of a tough problem. One more thing: In modern times it has become customary to maintain a geographical database that tracks turbulence, depending primarily on reports from pilots. Regions of turbulence move fairly slowly, so you end up with a gradually shifting 3D representation of where the turbulence is, which helps pilots avoid it. -- -----------------------------------+--------------------- 22nd century: Esperanto, geodesic | Will Ware domes, hovercrafts, metric system | wware at world.std.com From vincent_a_primavera at netzero.net Wed Jul 11 12:37:20 2001 From: vincent_a_primavera at netzero.net (Vincent A. Primavera) Date: Wed, 11 Jul 2001 16:37:20 +0000 Subject: More CGI ?'s... Message-ID: <3B45051300143CA3@mail.san.yahoo.com> (added by postmaster@mail.san.yahoo.com) Hello, Is there a way to access each row's data from this text area with python's cgi module(cgi.FieldStorage to be exact...)? Notes:
Thank you, Vincent A. Primavera From guido at python.org Thu Jul 19 16:30:15 2001 From: guido at python.org (Guido van Rossum) Date: Thu, 19 Jul 2001 20:30:15 GMT Subject: Case insensitivity References: Message-ID: "Arthur Siegel" writes: > Many of us feel, I believe, that case insensitivity is such > an affection. Guido seems to be saying that he views it > otherwise - that it is case sensitivity that is an affect. I apologize for my poor English -- I don't know what you mean by "an affection" or "an affect". Consulting a dictionary didn't help, but I'm guessing that you mean something that gets in your way when programming. > Which to me is the beginning of a real discussion. Fair enough. So let's begin the real discussion. > Not meaning to be nasty at all, but these issues have > been on the table for quite some time - and I do think > it a tactical error to try to trump deeper discussion > by pointing to selective anecdotal reports from > near random sources, taken out of any meaningful > context, that happen to support a predilection. Here we go again -- I had to use a dictionary to find out what "predilection" means (it's a "preference"). Anyway, I wasn't trying to do anything of the sort -- I was indicating I have a right to be torn over this issue, since strong arguments can be made for both cases. Several people whom I respect have strongly suggested that if Python wants to appeal to non-programmers, it should be case-insensitive. (Leaving apart details of how to implement that; I agree that it should be case-preserving.) Others, whome I respect just as much, feel that it should be case-sensitive. Unfortunately there isn't a lot of scientific evidence to help decide this. There may be old reports that case-sensitivity hurts beginners. I know that many other designers of programming languages aimed at non-programmers have consciously choses case-insensitivity (e.g. hypertalk, REXX). TeachScheme is an interesting case -- Scheme is a case-sensitive language, but in "beginner mode", TeachScheme is case-insensitive. I can't find it on the web, but I bet the TeachScheme folks have a rationale for this decision. My own intuition and experience tells me that there seem to be two kinds of people: some folks think case-sensitively, others think case-insensitively. Myself, I am a case-sensitive person, but I can easily learn to work with case-insensitive systems. It's possible that most programmers have case-sensitive minds, but I think that most non-programmers probably have case-insensitive minds. And non-programmers are quite the majority. *If* there is any hard scientific evidence that case-sensitivity is a hindrance to learning to program (for most people), that would confirm my hunch. It has been argued that making Python case-insensitive would be "dumbing it down". I find this a strange argument. It doesn't take any power away (as long as there's a way to link to external systems that require case-sensitivity). I see it as lowering the bar -- what's wrong with that? (If you really feel that being a programmer makes you part of an elite and you want to keep others out of that elite, I pity you.) It has been argued that case-sensitivity is a minor wart that's easily explained. I find that a weak argument. Lots of minor problems can be explained and gotten used to, but that doesn't mean we shouldn't try to get rid of them if we can. Historically, this argument has been used as an excuse for poor compilers or linkers. It's been argued that making string, String, STRING and StRiNg mean the same thing makes for less readable programs. I agree. A good programming environment should silently correct the case of identifiers as you type to conform to the definition. This also means that you can still use different case conventions to hint about what type of identifier it is, e.g. MACRO, Class, variable. It's been argued that it's convenient to be able to write c = C(), where C is a class and c is an instance of that class. Surely there are other conventions we can use. To me, the only real important question is, how can we introduce case-sensitivity for novices without breaking the millions of lines of existing Python code. One option could be: forget it, it's too late. Another: put the case-insensitivity in the tools. --Guido van Rossum (home page: http://www.python.org/~guido/) From tjreedy at home.com Mon Jul 9 14:55:34 2001 From: tjreedy at home.com (Terry Reedy) Date: Mon, 09 Jul 2001 18:55:34 GMT Subject: Comment on PEP-0238 References: <9icndo$loe$1@nntp6.u.washington.edu> Message-ID: "Donn Cave" wrote in message news:9icndo$loe$1 at nntp6.u.washington.edu... > Quoth Courageous : > ... > | [Snip: Guido's plan] > | > | This seems to me to be reasonable. While backward compatibility > | is important in computer languages, the real problem occurs when > | changes are abrupt. And in any case, we always have older versions > | of the interpreter around. > > Sure. For me, it looks like older versions is all we're going to > have around. Python is getting too complicated, has always been > too slow (mainly startup cost), and now it's going to start breaking > existing code in a serious way, for the sake of notions that are > very debatable. In my perhaps overly long-winded post Saterday evening ("2.2+==3000?"), I tried to make three points. 1. The proposed code-breaking change is unprecedented in several respects. > I'm not saying "play my way, or I'm taking my > ball and going" - I think I see the handwriting on the wall one > way or the other. The present offense is probably a blessing in > disguise, since 2.0/2.1 is probably a better place to stake it > down than a couple of versions farther down the curve. 2. We should recognize 2.1 (or perhaps 2.2, exactly which to be discussed) as the end of the decade-long series of no-code-break-except-in-extreme-circumstance releases and designate it as the stable (and possibly maintained) 'older' version that, it has been said several times, we would 'always have around' to run 'old' code (or new code written by 'old' pythoneers who choose not to follow all the changes). The release that intentionally breaks code should be given a new major number. > It's ironic, just recently my department has started to think about > supporting Zope on our web servers. Of course I have been pitching > Python as the greatest thing since sliced bread for 7 or 8 years, > but my colleague, our main web server expert, was interested for a > while but gave up on it fairly quickly, and one of the criticisms he > levelled against it was that a new release will break all your code. > Not my experience at all, but how he will laugh to hear about this one. 3. While no-code break has been the promise and actuality for the 1.X series of releases (which includes 2.0 and 2.1, which were bumped up for legal/political reasons), Guide also stated years ago that he would give himself more freedom to break code in a new major series, and that the first change might specifically be to change int/int semantics. > And now, if I'm obliged to bring in these new versions of Python after > all, it probably will be because of Zope. > > Donn Cave, donn at u.washington.edu Terry J. Reedy From mirko.liss at web.de Thu Jul 5 03:52:04 2001 From: mirko.liss at web.de (Mirko Liss) Date: Thu, 5 Jul 2001 09:52:04 +0200 Subject: Python for air traffic control? In-Reply-To: <9hv4c301ts3@enews1.newsguy.com> References: <9hlfbn$6ok$1@nereid.worldonline.nl> <9hrj3q$cj1@news1.gtech.com> <20010704013238.2DC8A00.NOFFLE@niccolo.ke4.de> <9hv4c301ts3@enews1.newsguy.com> Message-ID: <20010705075209.39021A0F.NOFFLE@niccolo.ke4.de> On Wed, 4 Jul 2001, Alex Martelli wrote: > "Mirko Liss" wrote in message > news:20010704013238.2DC8A00.NOFFLE at niccolo.ke4.de... > I was taught "shud" is a four-letter word, to be avoided > in mixed company. Once again, I've made a fool of myself. I do that on a regular basis, 13 times a year. Sorry to have bothered a newsgroup. > In that case, most programmers' hopes are going to be frustrated, > if most programmers are working in C. You're right. I have to use tools like LCLint to get support for abstract types. friendly regards, Mirko Liss From XQ.Xia at ccsr.cam.ac.uk Fri Jul 13 05:33:39 2001 From: XQ.Xia at ccsr.cam.ac.uk (XiaoQin Xia) Date: Fri, 13 Jul 2001 10:33:39 +0100 Subject: Question on nested scope Message-ID: <3B4EC073.6D97E840@ccsr.cam.ac.uk> In Python 2.1: >>> b=10 >>> a="b=b+11" >>> def f(p): exec p print a print b >>> f(a) b=b+11 21 >>> b 10 >>> When exec "b=b+11", python can find the second b (10), why it generate another b? Cheers, Xiao-Qin Xia From mal at lemburg.com Fri Jul 13 09:49:42 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 13 Jul 2001 15:49:42 +0200 Subject: [Python-Dev] PEP: Unicode Indexing Helper Module References: <3B4EE3C0.9875AB3D@lemburg.com> <072101c10b9d$a28068e0$0acc8490@neil> Message-ID: <3B4EFC76.606FBC83@lemburg.com> Neil Hodgson wrote: > > M.-A. Lemburg: > > next_(u, index) -> integer > > > > Returns the Unicode object index for the start of the next > > found after u[index] or -1 in case no next > > element of this type exists. > > > > prev_(u, index) -> integer > > ... > > Its not clear to me from the description whether the term "object index" > is used for a code unit index or an index. Code unit index seems > to make the most sense but this should be explicit. Good point. The "Unicode object index" refers to the index you use for slicing or indexing Unicode objects, i.e. like in "u[10]" or "u[12:15]". As such it refers to the Unicode code unit as implemented by the Unicode implementation (and is application specific). I'll add a note to the PEP. Thanks, -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From skip at pobox.com Wed Jul 11 17:38:22 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 11 Jul 2001 16:38:22 -0500 Subject: Pickle translation In-Reply-To: References: Message-ID: <15180.51022.393563.524245@beluga.mojam.com> William> When I start the daemon that does all the work with William> python1.5.2, it loads the pickle fine. When I try to start it William> with python2.1 I get this: William> Traceback (most recent call last): William> File "bin/momd", line 83, in ? William> kserv = load(f) William> ValueError: invalid \x escape Interpretation of \x escapes was tightened up in 2.0 I believe. In versions earlier than 2.0 '\xyy' is interpreted as the four-character sequence: \ x y y In 2.0 and 2.1 the ValueError you see is raised because "yy" can't be interpreted as a hex number. I'm not sure what the solution is. Someone with more pickle/string/ internals knowledge will probably have some ideas. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From db3l at fitlinxx.com Tue Jul 24 17:16:08 2001 From: db3l at fitlinxx.com (David Bolen) Date: 24 Jul 2001 17:16:08 -0400 Subject: re bad leadership References: <0+yM4IAgmKX7EwIQ@jessikat.fsnet.co.uk> <20010724171838.A21770@xs4all.nl> Message-ID: Robin Becker writes: > it doesn't matter what the leadership says is right. The popular vote is > against the stupid float '/' operator. > > MDFL you are wrong! Give up gracefully now! (and) > In message <20010724171838.A21770 at xs4all.nl>, Thomas Wouters > writes > .... > >Robin, sorry, but you are wrong . > > > that's almost always true, but I think not in this particular case. I > think the compatibility issue is of prime importance here. I think this thread suddenly veered the integer division discussion well off a reasonable track and in quite the wrong direction. It's worth pointing out that placing more weight on the compatibility argument (with which I happen to agree) does not imply either the desired float '/' operator is "stupid" nor that Guido must be "wrong". And name calling is never good form. If the "leadership" were really "M" (e.g., malevolent, which BTW, seems an awfully strong word to me), then stuff would just change and break and we'd be discussing/complaining about it after the fact rather than before the fact. This discussion may be over the top far too often, with far too much repetition, but there's still useful snippets of discourse if you pick your way through it. But let's not make the mistake of letting this get personal in any way. It's (or it should be) a technical debate. -- -- 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 eppstein at ics.uci.edu Wed Jul 25 02:43:48 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Tue, 24 Jul 2001 23:43:48 -0700 Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <9jlo4v$rhbl$1@sky.inp.nsk.su> Message-ID: In article <9jlo4v$rhbl$1 at sky.inp.nsk.su>, "Andy Salnikov" wrote: > > int < long < rational < float < complex > > > Just a comment: What bothers me is that floats in computers are not the > same as R continuum im math. This makes me think that rationals are "better" > than floats. Indeed, any float number can be exactly represented by > rational, but not vice virsa. So my tower would be like that: The ordering is not by what is a "better" representation, or even by information loss, but by what is the most appropriate direction for one-way coercions. Although one could convert float->rational without information loss, it would hardly ever be right to do so, because you are just making things slower without anything to gain in return: you've already lost your exactness and pretending you have it again won't make it so. On the other hand int->long and long->rational are necessary to avoid overflow or truncation, and any of these ->float are reasonable to speed up computations where it is ok to be approximate. So I completely agree with Guido's ordering. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From gbreed at cix.compulink.co.uk Fri Jul 6 10:52:31 2001 From: gbreed at cix.compulink.co.uk (gbreed at cix.compulink.co.uk) Date: 6 Jul 2001 14:52:31 GMT Subject: pb with xmlrpclib References: Message-ID: <9i4jbf$g0m$1@plutonium.compulink.co.uk> In article , alf at leo.logilab.fr (Alexandre Fayolle) wrote: > On 6 Jul 2001 14:35:47 GMT, gbreed at cix.compulink.co.uk wrote: > >Have you tried > > > > server.echo(unicode('\231','latin-1')) > > > >? Dunno about xmlrpc, but it works with SOAP. > > > I've just tried it and it doesn't work with xmlrpclib. :o( > Which implementation of SOAP are you using ? Maybe I'll switch to > SOAP, if it can solve my problem. SOAP.py, Graham From sylqme at nowhere.com Wed Jul 4 16:46:55 2001 From: sylqme at nowhere.com (sylqme at nowhere.com) Date: Wed, 04 Jul 2001 20:46:55 GMT Subject: ____ Jenny's Pics jenny.jpg (1/1) 8145 Message-ID: <3hL07.15904$t_5.82462@news.pacbell.net> Great amateur shots of girls getting naked at mardi gra!!! http://www.free-sexxx-hosting.com/Crazy_XXX_Pictures/ jstiboyyqiydyke From emile at fenx.com Tue Jul 10 08:10:39 2001 From: emile at fenx.com (Emile van Sebille) Date: Tue, 10 Jul 2001 05:10:39 -0700 Subject: PythonCOM and Office. Arrgh! References: <3B4A7C91.44680652@ihug.co.nz> Message-ID: <9ierk3$ig4st$1@ID-11957.news.dfncis.de> This worked for me. Win2ksp1, excel2k, Python 2.1 >>> import win32com.client >>> xl = win32com.client.Dispatch("Excel.Application") >>> xlc = win32com.client.constants >>> xl.Workbooks.Open('test',Password='fred') >>> xl.Visible=1 What do you get when you try this? -- Emile van Sebille emile at fenx.com --------- "Matthew" wrote in message news:3B4A7C91.44680652 at ihug.co.nz... > Hi everyone, > > A few more hours and my mind will be gone; burnt to a frazzle by this > most annoying, frustarting problem. > > No matter what I try, I CAN NEVER get named keyword arguments to do > anything via PythonCOM Excel automation. > > xlapp.Workbooks.Open("D:\\Fred.xls", Password='fred') > profers no error. The xcel window opens with Password Dialog opem. Type > in 'fred' and s/s loads up. Named arg passed in call apparently ignored. > > xlapp.Workbooks.Open("D:\\Fred.xls", password='fred') > generates error - Open got unexpected keyword argument 'password', so it > seems to me that somethings going on with passed named args > > I've tried 10s of different xcel functions but with identical results. > Named args do zippo. Spell a keyword arg incorrectly and you get > reprimanded. > > I've tried under NT4/2000 with both ActiveState2.0 build 203 & > ActiveState21.- build 210. > > What am I overllooking/missing? Please help before it's too late... > > Thanks, matthew. > From guido at python.org Thu Jul 26 12:37:23 2001 From: guido at python.org (Guido van Rossum) Date: Thu, 26 Jul 2001 16:37:23 GMT Subject: The error of building Python on HP UX References: <9jobt0$nh7$1@mail.cn99.com> Message-ID: "Paolo Invernizzi" writes: > Is that the reason why, for a major costumer tied with HPUX, we managed to > use jython (since pre-alpha release!) instead? > Seriously, jython is a wonderful alternative for HP Thanks for the tip -- I'll keep that in mind. It makes sense! --Guido van Rossum (home page: http://www.python.org/~guido/) From thomas at xs4all.net Tue Jul 10 03:54:08 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 10 Jul 2001 09:54:08 +0200 Subject: module for CVS or RCS In-Reply-To: <87elrpfqq2.fsf@wombat.house-net> References: <87elrpfqq2.fsf@wombat.house-net> Message-ID: <20010710095408.U8098@xs4all.nl> On Tue, Jul 10, 2001 at 02:39:27AM +0000, Eric Holbrook wrote: > is there a module for handling CVS (or RCS)? if so, where do i find > it? In the 2.1 source distribution, under the 'Demo' directory, there is a directory called 'pdist' which contains some scripts and classes to work with RCS and CVS. They aren't very robust, though. You might also want to look at Greg Stein's ViewCVS, http://www.lyra.org/viewcvs, though I'm not sure if it can be used as a module. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From spboulet at speakeasy.net Tue Jul 3 22:51:06 2001 From: spboulet at speakeasy.net (Stephen Boulet) Date: Tue, 3 Jul 2001 22:51:06 -0400 Subject: Access all classes in a directory, put into an array, and print them out References: <9hsql302ghk@enews1.newsguy.com> Message-ID: Tim Hammerquist wrote: [snip] > People are just as capable of writing bad Perl code as they are of > writing bad Python code. You've heard of people writing this? > > for i in range(len(array)): > process(array[i]) > > Of course, once you know a little more it becomes: > > for item in array: > process(item) Ok, how would you write this if you actually needed the index of array in your for loop? My (ugly looking) solution; I hope there's something better: i = 0 for item in array: process(item) someFunction(i) i = i + 1 -- Stephen From gregj at pdxperts.com Thu Jul 19 22:50:31 2001 From: gregj at pdxperts.com (Greg Jorgensen) Date: Fri, 20 Jul 2001 02:50:31 GMT Subject: Python 2 times slower than Perl References: <8f41cfd.0107171238.6ff33b9b@posting.google.com> <9j3rvk$26bt$1@norfair.nerim.net> <3B559B30.61A90EA@jam.rr.com> <9j4af20d2o@enews4.newsguy.com> <87elrdtgps.fsf@ivory.localhost> Message-ID: "Patrick W." wrote: > To get a better understanding of which languages it benefits us to > learn and teach. Also to get a better understanding of which languages > are best used in the "real world", given a set of tradeoffs between > development time and program performance. > > Sounds reasonable enough to me. Discussion of languages and their applications in teaching or professional work is fine, I'm all for that. But how does comparing benchmarks of Perl vs. Python help in that regard? Serious programmers know that such discussions are often wrong, usually irrelevant, and about as useful as comparing the speed of a Toyota Camry vs. a Honda Accord. The less-than-serious programmers apparently find deep meaning in these comparisons; apparently they believe they must find the "best" language because they can learn and use only one. The increasing number of postings comparing Python to language X is I suppose a good thing: lots of people are kicking the tires and taking Python for a spin. I think we should encourage that, but not by comparing execution times of loops. We need to discourage the amateur programmer obsession with "performance" and "efficiency" as if those attributes are all that matter. Greg Jorgensen PDXperts LLC Portland, Oregon, USA From tony-clpy at lownds.com Wed Jul 18 22:28:02 2001 From: tony-clpy at lownds.com (Tony Lownds) Date: 18 Jul 2001 19:28:02 -0700 Subject: Python CGI speed on MacOS X References: Message-ID: Day-to-day use of Mac OS X can cause quite a load on your machine. What does uptime say? [localhost:~/Linux] tlownds% uptime 7:21PM up 1:17, 1 user, load averages: 0.91, 1.17, 1.22 With that status (pretty quiet since Classic is running), my pystone is: [localhost:Python-2.1/Lib/test] tlownds% python pystone.py Pystone(1.1) time for 10000 passes = 2.96 This machine benchmarks at 3378.38 pystones/second And the startup time is: [localhost:Python-2.1/Lib/test] tlownds% time python -c "pass" 0.240u 0.020s 0:00.60 43.3% 0+0k 0+2io 0pf+0w Finally try setenv PYTHONCASEOK 1 And see how it affects the numbers above. I think I saw a difference while my machine was under serious load, but not when it was quiet. -Tony (please cc: on replies) johnca at DIESPAMmac.com (John Abbe) wrote in message news:... > In article , > johann at leporello.berkeley.edu wrote: > > > John Abbe writes: > > > > > I'm running MacOS X on a PowerBook G3 400MHz, and have Python 2.1 > > > installed (from http://tony.lownds.com/macosx/). > > > > I've got the same computer, and I do notice Python being a bit more > > pokey than it should be. I suspect some weird intereaction between > > the Apple-patched gcc compiler and the Python source. > > Maybe the 10.1 release of OS X will help. > > Anyone else able to offer insights? From brian at sweetapp.com Thu Jul 12 03:58:18 2001 From: brian at sweetapp.com (Brian Quinlan) Date: Thu, 12 Jul 2001 00:58:18 -0700 Subject: Creating weak references from extension module Message-ID: <000501c10aa8$69ef52c0$445d4540@D1XYVL01> It seems like the weak reference module is less accessible from C than it should be. I've been trying to figure out a good way to create weak references from an extension module and it's not obvious. weakref_proxy and weakref_ref are static so they are no goes unless I call them through Python. Any reason not to add a nice function to _weakref.c that allows you to construct weak proxies and weak references? Cheers, Brian From peter at engcorp.com Fri Jul 27 21:30:42 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 27 Jul 2001 21:30:42 -0400 Subject: Operator symbol for "nb_intdivide" References: <01Jul26.192106pdt."3453"@watson.parc.xerox.com> <6q4rrytru4.fsf@abnoba.intevation.de> Message-ID: <3B6215C2.70B7CC36@engcorp.com> Bernhard Herzog wrote: > > Guido van Rossum writes: > > > ... Programmers coming from languages where only > > "|" existed were tempted to use that, but the priorities are so broken > > that a==b | c==d is parsed as (a == (b|c)) == d. > > Interesting that even a language designer with lots of C-experience can > get this wrong :) | has in fact almost the same precedence as || and > it's in fact lower than the comparison operators, so that a==b | c==d is > actually parsed as the user expected ( (a == b) | (c == d)) so it even > works as expected, although in cases where the operands are e.g. a > normal int and a comparison this is likely to break down. > > The problem with |'s and &'s precedence in C is that in an expressions > like 0x0f == a & 0x0f, which seems to test whether the 4 lower bits of a > are 1, is in fact parsed as (0x0f == a) & 0x0f. But good C programmers, whether language designers or not, would write both of the above with parentheses to show clearly what the desired precedence was. They would not rely on the assumption that the next programmer to read the code would know C precedence rules perfectly: (a == b) | (c == d) 0x0f == (a & 0x0f) Whether or not "|" or "==" are correct is not my point; that getting caught by precedence errors is just plain sloppy, is. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From zen at shangri-la.dropbear.id.au Mon Jul 2 19:50:41 2001 From: zen at shangri-la.dropbear.id.au (Zen) Date: 3 Jul 2001 10:50:41 +1100 Subject: Python and DB support (was: Re: Is Python Dead?) References: <9hqoe8019j5@enews4.newsguy.com> Message-ID: <3b4116e1$1@mercury.its.rmit.edu.au> "Alex Martelli" writes: >Yep, the recordset part of ADO is undoubtedly the most popular single >feature of it among us lazy programmers. You can even disconnect from >the DB and keep the recordset around, persist it to a file (maybe in XML), >depersist it later... it's fun!-) I'm preparing a PEP to address a few issues with the Python DB API and an initial draft has been presented to the DB-SIG. I'm unfamiliar with ADO. When you retrieve a recordset, are all relevant tuples retrieved from the database (like the Cursor.fetchall() method in the DB API)? Or is it a lazy object that only downloads the rows when they are accessed by the application (like the Cursor.fetch() or Cursor.fetchmany() methods in the DB API)? Can you provide examples of things you can do using the ADO interface (don't care what programming language) that are difficult to do using the Python DB API? Even if it is outside the scope of *this* PEP, I need to understand peoples wishlists to ensure they can be integrated in the future. >> From this and also from my own experience with PostgeSQL queries from >> Python, I could say that DB support in Python exists, but need enhancement >> and standartization. Probably, higher level more or less common >> object-oriented interfaces could help this. >It seems to me the (DB API 2) standard is fine (maybe a bit too >ambitious, so actual implementations may not have reached up >to it yet?-). The 2.0 driver implementations of the major databases seem fine to me. One problem I notice with database tools is extremly rare for someone to deal with more than three vendors RDBMS implementations, and generally people only develop with one or two. >> I must also say, that I myself am completely satisfied with Python DB >> support, but I do not use DB extentensively and routinely to judge. >> However, I think that including some more DB support, at least for open >> source databases like Postgresql and MySQL + ODBC/JDBC, could be a good >> idea and will give a standard. (Yes, I know about Python DB API). >And? What's wrong with it? What support would you get from ODBC, >portably between Postgres & MySQL, that the relevant DB API modules >don't supply? Maybe we could supply an ADO-recordset-workalike on >top of any DB API compliant implementation, that might be handy at >times I guess. But hardly a make-or-break thing, no? >If I had a vote, I'd rather seen _Gadfly_ tuned up (out with regex >and regsub, in favour of re; minimal-tolerance support of stuff it >does not implement, such as NULLs) and made a part of Python. It I agree that it would be a benefit and worth a PEP if the Gadfly author agrees and someone volunteers to do the required tweaking. I don't see a point in including drivers in the core for databases that follow a different development cycle. Last thing we want is obsolete PostgreSQL drivers out there when a new version of PostgreSQL is released. Although PHP manages to do this.... can any PHP users comment? From jkraska1 at san.rr.com Wed Jul 25 00:05:07 2001 From: jkraska1 at san.rr.com (Courageous) Date: Wed, 25 Jul 2001 04:05:07 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: Message-ID: <48hslt0se5agqnev0rt8d9nd632qmm3b8o@4ax.com> On 24 Jul 2001 08:35:51 -0400, com-nospam at ccraig.org (Christopher A. Craig) wrote: >any people have argued that they would like to see the behavior from >the PEP if Python were a new language. I disagree. I would prefer to >see '/' defined as "exact division" and '//' defined as "truncated >division" and have types that don't support either raise a TypeError >if the types don't support the operation in question. I think this >parallels existing operations better. I'd go further: '/' should be exact division, and "div" should be truncated division, analagous to the way divmod works, except without the mod. C// From eppstein at ics.uci.edu Thu Jul 26 22:16:37 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Thu, 26 Jul 2001 19:16:37 -0700 Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <9jnt9p$qhe$1@newsy.ifm.liu.se> Message-ID: In article , "Tim Hochberg" wrote: > * Addition of a rational literal (PEP 240)? This one you could easily > dislike a lot. But if your really super concerned about the evils of > inexatitude, you'll probably like this more than I do. Actually, I do dislike this. Much as I find floats generally useless, I think that 0.666667 should return a float, and that if I want to write a rational literal I should be able to write it as 2/3. Also it is odd that the abstract discusses modifying division to return rationals but that the rest of the PEP is entirely about what to do with decimal strings. -- 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 Tue Jul 3 11:30:11 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 3 Jul 2001 17:30:11 +0200 Subject: Fetching multiple items from a list References: <3B41B778.6BD422C1@nokia.com> Message-ID: <9hsoe402duc@enews1.newsguy.com> "Joonas Paalasmaa" wrote in message news:3B41B778.6BD422C1 at nokia.com... > Why doesn't Python support fetching and setting multiple items > at the same time for lists and tuples. I don't know. Too APL'ish?-) > For example in the example below multiple fetching would be > much better way than the ordinary way. > > >>> import string > >>> mylist = list(string.lowercase) > >>> mylist[18],mylist[15],mylist[0],mylist[12] > ('s', 'p', 'a', 'm') > >>> mylist[18,15,0,12] > Traceback (most recent call last): > File "", line 1, in ? > mylist[18,15,0,12] > TypeError: sequence index must be integer > >>> The ordinary way of course is [mylist[i] for i in 18,15,0,12] so it's not THAT bad, albeit SLIGHTLY more verbose than mylist[18,15,0,12] as you would like. But there is no "set-multiple" equivalent to the way the list comprehension provides a reasonably-handy get-multiple; it does have to be a for-statement: for i, v in zip((18,15,0,12),'blah')): mylist[i] = v or an auxiliary function: def setitems(cnt, idx, val): for i, v in zip(idx, val): cnt[i] = v to be called as: setitems(mylist, (18,15,0,12), 'blah'). Alex From 18k11tm001 at sneakemail.com Thu Jul 5 03:05:33 2001 From: 18k11tm001 at sneakemail.com (Russ) Date: 5 Jul 2001 00:05:33 -0700 Subject: Python for air traffic control? References: <134704696.994123281122.JavaMail.root@boots> Message-ID: grante at visi.com (Grant Edwards) wrote in message news:... > In article , Russ wrote: FYI, my only access to comp.lang.python is through Google groups, and they seem to update about once per day or so! > >Just for the record, Mr. Park is publicly posting my private > >replies to him. I guess I should have expected something like > >that from him. > > Ignore him. You're absolutely right. I should have never responded to him. Note, however, that he emailed his post directly to me. Then he edited and posted my private replies, which were none too polite. > >You must also understand, of course, that the safety-critical > >application I am referring will not actually be deployed in a > >critical mode for several years at least, during which time it > >will be thoroughly and completely tested. Believe me, I'm > >talking about more testing than you think. It will first be > >used for years as a non-critical back-up for (human) > >controllers before it is ever used as a primary means of > >assuring separation. > > My gut feeling is that if the system is done in C or C++ (for > example) it is going to have to use dynamic memory allocation. > Once you've taken that step, I don't think that Python is > inherently more likely to have memory problems, and I think > that Python is inherently _less_ likely to have many other > types of bugs. I have done real-time programming in C++, and I used static or start-up memory allocation almost exclusively to avoid memory management overhead. It really helps execution efficiency, but it really sucks up memory. Memory is cheap these days, however. I would probably take the same approach in Python, if possible. (As I said, I am a Python beginner.) > If this were a simple, hard-realtime system with response time > requirements in the milliseconds, I'd stay away from Python, > away from C++, and away from dynamic memory allocation. > However, with response time requirements in the hundreds of > milliseconds and a problem domain that probably requires > dynamic memory allocation I think Python would be suitable. The response time requirements are on the order of a few seconds or so, definitely not hard real time. > The introspection features could be very useful for automated > testing, as could some simple instrumentation of the memory > management functions. Thanks for your insights. Russ From aleaxit at yahoo.com Tue Jul 10 11:18:15 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 10 Jul 2001 17:18:15 +0200 Subject: Newbie asks: How to do this line of C in Py? References: Message-ID: <9if6bt011b9@enews3.newsguy.com> "Steve S.L. Wong" wrote in message news:tkm2bef90nsic1 at news.supernews.com... > if (sscanf(command, "%d", &num) != 1 ) { > } try: num = int(command) except ValueError: print "some error (or whatever)" Actually this depends on the exact semantics of sscanf -- the Python version will tolerate whitespace on either side of the sign and digits, but not other extraneous characters -- and it's been a while since I sscanf'd something, so I don't precisely recall what (if anything) it will tolerate in terms of 'extraneous chars'. But anyway, the general approach of try/except is how you try a string->whatever conversion, while ready to handle the case in which the conversion cannot be performed correctly. Alex From owen at astrono.junkwashington.emu Wed Jul 25 11:59:17 2001 From: owen at astrono.junkwashington.emu (Russell E. Owen) Date: Wed, 25 Jul 2001 08:59:17 -0700 Subject: question about handling pointers in C extensions References: <9jkhdv$r3o$1@nntp6.u.washington.edu> Message-ID: <9jmqcm$j5s$1@nntp4.u.washington.edu> In article , Harald Kirsch wrote: >> /* convert device pointer to a Python Long object */ >> py_dev_p = PyLong_FromVoidPtr ((void *) dev_p); > >This makes py_dev_p into a reference you own, therefore ... > >> if (py_dev_p == NULL) { >> return NULL; >> } >> >> /* increment reference and return the PyLong */ >> Py_INCREF (py_dev_p); >> return Py_BuildValue("O", py_dev_p); > >... neither INCREF nor BuildValue are needed. Thanks for the save!!! You and Chris Liechti both then go on to suggest creating a new Python type. I'm a bit confused here. This would create a Python class or an actual new Python data type? "Python Essential Reference" makes creating a new data type scary, but I haven't been able to figure out if that applies equally to creating a Python object. Anyway, I'd love to convert my C interface to one that produces Python objects. The code would be much cleaner to use in Python. I'll have another look at it. If anybody has a pointer to simple sample code or documentation beyond "Extending and Embedding" and "Python/C API", please let me know. I figure I'll start with straight function calls (and associated icky pointers), get that working, then see if I can create Python objects. -- Russell From ehoute at nospamzeelandnet.nl Tue Jul 17 18:26:30 2001 From: ehoute at nospamzeelandnet.nl (Ewald van Houte) Date: 17 Jul 2001 22:26:30 GMT Subject: Python 2 times slower than Perl References: <8f41cfd.0107171238.6ff33b9b@posting.google.com> Message-ID: xucs007 at yahoo.com (Xu, C.S.) wrote in news:8f41cfd.0107171238.6ff33b9b at posting.google.com: > I just compared the speed of Python, Perl, Java, C > to do simple numerical calculations. Python is the > slowest: took 150 times of time than C, Perl about > 60 times, Java is 4.5 times. > > The source code of Python is: (Other source are > similar, all use while loop): > > #!/usr/bin/env python > i = 2.5; > while i < 1e7: > j = 2.5 * 2.5 > i += 1 > print i, j > > The `time` results on my PII 450M is: > python script: 37.93u 0.03s 0:38.03 99.8% > perl script: 15.36u 0.03s 0:15.42 99.8% > java compiled: 1.07u 0.10s 0:01.20 97.5% > C compiled: 0.24u 0.01s 0:00.25 100.0% > > Can anybody explain why Python is always about 1 time > slower than Perl? > > Regards, Tried the same with for loop and while loop def f1(): i=2.5 while i<1e7: j=2.5*2.5 i+=1 print i,j def f2(): i=2.5 for i in range(2.5,1e7+1): j=2.5*2.5 print i,j def f3(): i=2.5 for i in xrange(2.5,1e7+1): j=2.5*2.5 print i,j Results f1() 34.5 seconds f2() 47.6 seconds f3() 18.8 seconds some improvement but f3() will still be slower than Perl version (~30%) From cgale1 at _remove_home.com Thu Jul 5 03:10:53 2001 From: cgale1 at _remove_home.com (Van Gale) Date: Thu, 05 Jul 2001 07:10:53 GMT Subject: Python for air traffic control? References: <87lmm5dqjq.fsf@litterbox.meowing.net> Message-ID: <1qU07.86470$%a.3839546@news1.rdc1.sdca.home.com> "Grant Edwards" wrote in message news:slrn9k7c2n.ip.grante at tuxtop.visi.com... > I find that extremely hard to believe: tools that read source > code and verify execution timing? Of multi-threaded apps with > unsyncrhonized inputs? > > That would be pretty amazing. The Software Productivity Consortium developed such a tool around 1989 or so, but I'm not sure how it panned out. I just went to their web site (www.software.org) and see no mention of it... even as part of their Test Automation Framework. This means the tool is only being used by the original Consortium members (almost all aerospace companies) who paid for the development, or the tool sucked and it was thrown away :) I have no clue, and can only say it had a lot of PhD types working on it for years, it did read source code, and it used "stochastic petri nets" in some way for the simulation. Sorry I can't explain it any more than that... I was only working on lowly tools for network management and administation :) Van From tim at vegeta.ath.cx Wed Jul 25 00:22:04 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Wed, 25 Jul 2001 04:22:04 GMT Subject: no traceback?? References: <6BL67.17641$EP6.4530210@news1.rdc2.pa.home.com> Message-ID: Me parece que Rainy dijo: > On Mon, 23 Jul 2001 07:49:12 GMT, Tim Hammerquist wrote: > > Me parece que Rainy dijo: > >> Well, I'm asking in a general way, i.e. why could there be no traceback or > >> error? This is not right. I mean, if a program runs into a problem, it should > >> print some sort of feedback, at worst, a segfault? I haven't run into cases > >> like this before when *NOTHING* is printed. In general, what sort of errors > >> just quit silently? > > > > I would guess that it _is_ raising an exception, but it's caught at some > > point up in the call chain by an 'except: pass' clause. What happens > > Nope, I looked for that.. > > > right before the invisible error? What is it doing at that point? > > I believe it was caused by termios.SOMETHING access which is good for > 2.1 but in 2.0 it should be TERMIOS.SOMETHING. I still don't understand > why it didn't give any error but I fixed that.. Does termios in Py2.1 automatically import the constants in TERMIOS? No, hold on. Let me check... Ah yes. TERMIOS is not deprecated. -- Destinations are often a surprise to the destined. -- Thessaly, The Sandman From chrishbarker at home.net Wed Jul 25 19:59:18 2001 From: chrishbarker at home.net (Chris Barker) Date: Wed, 25 Jul 2001 16:59:18 -0700 Subject: Proposal for .py2, py3, etc. extensions. Was: A way to accommodate laguage changes References: <3B5CB83B.F3B7D51@home.net> <5E877.23798$EP6.5677355@news1.rdc2.pa.home.com> <23891c90.0107240128.4715d705@posting.google.com> <3B5DC56F.3B84E77D@alcyone.com> <3B5DE39C.543DA6@home.net> <3B5DE7F3.EB5EC5F1@Lugoj.Com> <3B5E1075.94167ECD@home.net> <3B5E45B7.2C4AE40@Lugoj.Com> <3B5EFAEB.1EB156B3@home.net> <3B5F098A.18E8B17A@Lugoj.Com> Message-ID: <3B5F5D56.CA77E656@home.net> James Logajan wrote: > Neither scheme is 100% perfect. Surely true > How about using several schemes, with the following precedence: > > 1) The module contains a "UsesVersion" statement to indicate the operative > version. > 2) The python interpreter is started with a flag to indicate the version to > compile with. > 3) The module name contains a suffix to indicate the operative version. This seems to violate the "only one way to do it" principle, but maybe it's neccesary > P.S. When feeding eval() a string, I'm pretty sure it only takes an > expression; not a series of statements. You can't imbed a version statement. > So if, as you claim, there is indeed a lot of people who have string > snippets buried in databases or elsewhere that are evaled on the fly, then I > think that a lot of conversion pain is inevitable. You're right about eval(). exec() and execfile() do allow a series of statements however, but you could certainly be evaling a expression with a "/" in it. Anyway, none of the "powers that be" seem to be paying any attention to this thread, so this is my last post. Guido(in another thread) did express some interest in the *.py3 idea, however. We'll see. -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 Thu Jul 5 15:20:11 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 5 Jul 2001 15:20:11 -0400 Subject: There's got to be an easy way to do this References: <9i27i8$gd9bq$1@ID-11957.news.dfncis.de> <3B44B031.819C93E@stroeder.com> Message-ID: But "if x.isdigit()" might help speed it up (assuming 2.0 or later). regards Ste e -- http://www.holdenweb.com/ "Michael Str?der" wrote in message news:3B44B031.819C93E at stroeder.com... > Emile van Sebille wrote: > > Or (without re): > > print "".join([x for x in '(123)/456-7890' if x in '0123456789']) > > I guess this one will be significantly slower for larger > data sets than the re solution because of > > if x in '0123456789' > > Ciao, Michael. From BPettersen at NAREX.com Fri Jul 20 18:11:45 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Fri, 20 Jul 2001 16:11:45 -0600 Subject: Case insensitivity Message-ID: <6957F6A694B49A4096F7CFD0D900042F27D56C@admin56.narex.com> > From: Fran?ois Pinard [mailto:pinard at iro.umontreal.ca] > > [Guido van Rossum] > > > TeachScheme is an interesting case -- Scheme is a case-sensitive > > language, but in "beginner mode", TeachScheme is > case-insensitive. I > > Did it change recently? I thought Scheme was > case-insensitive. An idiom I > saw a few times in Scheme code, written by other people, is > writing `lambda' > or `cdr' when you mean what it means, and `LAMBDA' and `CDR' > when you are > quoting the same, for example when you write code which produces code. You're correct: "Upper and lower case forms of a letter are never distinguished except within character and string constants. For example, Foo is the same identifier as FOO, and #x1AB is the same number as #X1ab." http://www.cs.indiana.edu/scheme-repository/R4RS/r4rs_4.html -- bjorn From thomas at xs4all.net Sat Jul 7 15:45:47 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Sat, 7 Jul 2001 21:45:47 +0200 Subject: PEP scepticism In-Reply-To: References: Message-ID: <20010707214547.L8098@xs4all.nl> On Sat, Jul 07, 2001 at 01:56:02PM -0400, Tim Peters wrote: > BTW, in case newcomers are wondering, Guido didn't become BDFL by > assassinating his predecessor, nor does he maintain Absolute Power by force > of arms. Although he's been thinking about it . What, Eric finally got his hands on the time machine and transplanted Guido's grandparents to the gun-lovin' Wild West ?! ;P Dodging-the-laser-dot-ly y'rs, -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From glenfant.nospam at bigfoot.com Tue Jul 10 17:42:01 2001 From: glenfant.nospam at bigfoot.com (Gilles Lenfant) Date: Tue, 10 Jul 2001 23:42:01 +0200 Subject: Adding timeouts to Internet sockets References: Message-ID: <9ifshm$19fi$1@norfair.nerim.net> I did not have any problem with the latest versions I use for QOS oriented python agents. "John Copella" a ?crit dans le message news: RBF27.212379$WB1.31341412 at typhoon.tampabay.rr.com... > How have developers added timeout behavior to Internet sockets in Python? I > am developing an application that uses ftplib, and I need to timeout if the > server is unavailable, etc. I note that Tim O'Malley has a package out > (http://www.vex.net/parnassus/apyllo.py?i=87800233) that very cleverly and > transparently does this (or seems to). Has anyone used it? My application > will be mission-critical, and I would prefer to use whatever is considered > the current best practice. > > Please reply via email, as my access to newsgroups is limited. Any help on > this matter is greatly appreciated! > > John Copella > Aerologic Inc. > > > From qrczak at knm.org.pl Tue Jul 10 02:22:28 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 10 Jul 2001 06:22:28 GMT Subject: Help with reduce(). References: <3ur27.663627$166.13698874@news1.rdc1.bc.home.com> Message-ID: 10 Jul 2001 00:39:02 GMT, Quinn Dunkan pisze: > You can fold from the right or left, but don't worry about that now > (in an eager language like python it doesn't make any difference > anyway). It makes a difference if the function is not associative. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From ykingma at accessforall.nl Fri Jul 13 17:29:08 2001 From: ykingma at accessforall.nl (Ype Kingma) Date: Fri, 13 Jul 2001 22:29:08 +0100 Subject: dictionary speed References: <41899b99.0107121100.7b2c2cdc@posting.google.com> Message-ID: <3B4F6821.E1BF40E0@accessforall.nl> "doug s." wrote: > > hi all, > > is there any speed differential to be aware or with nested > dictionaries? that is, does the position of data matter. for example, > if i need to access certain data quickly and often, is it best to > structure things so that it is all near the top level? > What precisely do you mean with 'nested dictionaries' and 'top level'? The kind of speed up you can get by restructuring data structures to access often needed data quickly is not normally needed in a scripting language. The easiest way to do that in Python would be to use separate dictionary for faster access, ako. cache. Regards, Ype From skip at pobox.com Fri Jul 6 16:40:15 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 6 Jul 2001 15:40:15 -0500 Subject: Comment on PEP-0238 In-Reply-To: References: <3dd77drkea.fsf@ute.cnri.reston.va.us> Message-ID: <15174.8751.465954.910371@beluga.mojam.com> Guido> Picking div() means that we can still turn that into a keyword Guido> later (the keyword would be both a unary and a binary operator). What would a unary "div" operator mean? Skip From guido at python.org Fri Jul 27 10:54:56 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 27 Jul 2001 14:54:56 GMT Subject: Language change and code breaks References: <3B5D88B1.774A4D70@Bibliothek.Uni-Augsburg.de> <3B601CBE.627D3D22@Bibliothek.Uni-Augsburg.de> <9jpbi8$32v$1@samos.cs.uu.nl> <9jpj4j$182a$1@nntp4.u.washington.edu> <3B60A0ED.BAAFE3A9@Lugoj.Com> Message-ID: piet at cs.uu.nl writes: > I wrote several parts of the CDC Cyber Algol 68 compiler (and later also an > Algol 60 compiler) and we just moved the address of the following > instruction to the stack (`manually') and then jumped to the procedure > address. And of course we used 12 bit characters and the language was > case-sensitive. Our lives touched! I used that Algol 68 compiler. It also (very indirectly) affected Python: that compiler had a very strong worldview of its own that often didn't match that of other languages and tools on the system, and that made it hard to mix tools. I found this a nuisance (ABC had the same nuisance even stronger), and when I designed Python, one of my requirements was that it blend in with its environment. This explains why Python extensions are so useful. --Guido van Rossum (home page: http://www.python.org/~guido/) From morneault at hanirc.net Sat Jul 28 10:50:39 2001 From: morneault at hanirc.net (morneault) Date: Sat, 28 Jul 2001 23:50:39 +0900 Subject: request mailling list Message-ID: request mailling list From gtcopeland at earthlink.net Tue Jul 3 12:09:47 2001 From: gtcopeland at earthlink.net (Greg Copeland) Date: 03 Jul 2001 11:09:47 -0500 Subject: py2exe & wxWin Message-ID: Is it possible to use py2exe to package up a wxPython application? Thanks, Greg -- 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 stevewilliams at wwc.com Mon Jul 30 11:36:31 2001 From: stevewilliams at wwc.com (Steve Williams) Date: Mon, 30 Jul 2001 15:36:31 GMT Subject: Tangent on wireless hysteria (was: Language Niches (long)) References: <8beb91f5.0107280407.5a30341d@posting.google.com> <8beb91f5.0107282158.4785ae5e@posting.google.com> Message-ID: <3B657FA9.8A60D135@wwc.com> Cameron Laird wrote: > In article , > Paul Prescod wrote: > . > [stuff] > . > I've lost count--is WAP essentially > dead now, or on the verge of utter > world domination? According to the Register, that would be 'dead': http://www.theregister.co.uk/content/6/20717.html From caeshmer at yahoo.com Thu Jul 19 15:48:59 2001 From: caeshmer at yahoo.com (caeshmer at yahoo.com) Date: Thu, 19 Jul 2001 19:48:59 -0000 Subject: Question about compiled moduls and dlopen Message-ID: <9j7djb+bd5l@eGroups.com> I'm running Red Hat Linux 7.0, and I installed the RPMs for Python 2.1 from python.org. I downloaded pygtk from Ximian (pygtk-0.6.8-ximian.1) which uses python 1.5.2 as shipped by Red Hat, and patched it to compile with /usr/bin/python2, put stuff in the python2.1 directory, etc. So I have both versions of python installed, and two compilations of pygtk. Everything works fine except gdkpixbuf, which is a compiled module. This is my test program: import gdkpixbuf p = gdkpixbuf.new_from_file("/tmp/spicy.gif") print p Under python 1.5.2, it works fine, just loads the file, displays , and exits. But when I run it under python 2.1, I get this error: python2: error while loading shared libraries: /usr/lib/gdk-pixbuf/loaders/libpixbufloader-gif.so: undefined symbol: g_malloc0 What seems to be happening is that the libgdk_pixbuf library (which the module calls into) loads .so modules of its own to handle different kinds of image files. I've used ldd on these /usr/lib/gdk-pixbuf/loaders/libpixbufloader-????.so files, and it shows that they aren't linked with libglib, even though they make calls like g_malloc. Any program that links directly with libgdk_pixbuf would generally have to link with libglib, and I'm assuming dlopen() could resolve g_malloc that way, but I don't know what happens when you link a python module with libgdk_pixbuf. I'm assuming something changed in python from version 1.5.2 to 2.1 that caused this problem, I just don't know what. I noticed that there are new functions sys.getdlopenflags() and sys.setdlopenflags() in 2.2, and I'm wondering if they might help solve this problem somehow. Did the flags used to open a compiled module change between 1.5.2 and 2.1? This is a problem that will have to be addressed at some point, and I figure we may as well discuss it before 2.2 is finally released. From grayson-wilson at home.com Sun Jul 8 17:38:42 2001 From: grayson-wilson at home.com (EricIDLE) Date: Sun, 08 Jul 2001 21:38:42 GMT Subject: Good Newbie Books Message-ID: Hello, Does anybody know of some good newbie books for me to read? I have already read Ian Van Laningham's "Teach yourself Python in 24 Hours" are there any good books that kind of step me up (from the book mentioned before). Thanks. From tim at vegeta.ath.cx Tue Jul 17 16:07:10 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Tue, 17 Jul 2001 20:07:10 GMT Subject: OO misconceptions References: <9ir1l7$3ja$1@panix2.panix.com> <9irfbc11jaq@enews1.newsguy.com> <3B538E16.65394C9D@engcorp.com> <3B53B339.B6698858@engcorp.com> <3B543B6D.A97F2843@engcorp.com> Message-ID: Me parece que Peter Hansen dijo: > Tim Hammerquist wrote: > In this case, more than anything else, the driving factor was > the easy ability to wrap third-party DLLs (e.g. for a GPIB > interface card) with calldll and make a beautiful object-oriented > wrapper to talk to instruments on the bus. I knew I would > be able to make a maintainable and flexible system which > newcomers (new developers that is) could learn to use easily > and continue growing. At the time, putting a Tkinter > interface on it quickly was an attractive option, although > I've since halted work on that development path until we > have time to retool around the web paradigm instead... On this matter, we'd have both been reaching for Python. I've done (makeshift) OO in Perl and it was both shoddy and slow. Python makes OO wrappers elegant and simple. -- You're quite free to convert your strings to byte arrays and do the entire pattern tree by hand in pure logic code if you'd like. By the time you finish most of the rest of us will be doing contract work on Mars. -- Zenin on comp.lang.perl.misc From richard at stockcontrol.net Tue Jul 24 09:50:09 2001 From: richard at stockcontrol.net (Richard Walkington) Date: Tue, 24 Jul 2001 14:50:09 +0100 Subject: Debuger for python 2.x References: <3B5D6C56.A951BDAE@sci.pam.szczecin.pl> Message-ID: <995982609.10820.0.nnrp-13.3e31cb7a@news.demon.co.uk> Piotr Legiecki wrote: > Hi > > I'm new to python and I'm writing my first python program. I'd like to > use some nice debugger (like ddd, xgdb etc) but I can't find any for > python 2.x. DDD has pydb but only for python 1.5.2. IDLE is not very > helpful curently. Aby other choices? > > I'm using debian/sid. What about pdb? I'v read that this is the python's > standard debugger, but on my system there is no such a program. > Hello, I'm using Debian testing and Python2 from Debian packages and I have the pdb module. Its part of the standard distribution so you should have it. Regards Richard Walkington From grante at visi.com Thu Jul 26 13:50:32 2001 From: grante at visi.com (Grant Edwards) Date: Thu, 26 Jul 2001 17:50:32 GMT Subject: Language change and code breaks References: <9j7gv8$9mg@dispatch.concentric.net> <3B5DF101.9B2E4631@earthlink.net> <08k0mtc2lftoon7eii2jo43qj1tt76256c@4ax.com> Message-ID: In article <08k0mtc2lftoon7eii2jo43qj1tt76256c at 4ax.com>, maxx at easynews.com wrote: >Because writing code is a completely different function than >"normal every day writing." Learning to write code means >beginners must learn to structure their thoughts, and organize >tasks, so that their code is not a potential jumble of ideas, >as normal every day writing can be. I don't there's that much difference between writing code and _decent_ "normal every day writing." If the person you're teaching to program can't write a coherent paragraph, then yes, programming is going to be different than their "normal every day writing." -- Grant Edwards grante Yow! .. My vaseline is at RUNNING... visi.com From slash at dotnetslash.net Wed Jul 11 17:01:12 2001 From: slash at dotnetslash.net (Mark W. Alexander) Date: Wed, 11 Jul 2001 17:01:12 -0400 (EDT) Subject: [Distutils] Package DB: strawman PEP In-Reply-To: <5.1.0.14.1.20010710220537.027b3f08@laplaza.org> Message-ID: On Tue, 10 Jul 2001, Mats Wichmann wrote: > At 02:33 PM 7/9/2001 -0400, Mark W. Alexander wrote: > >On Sun, 8 Jul 2001, Andrew Kuchling wrote: > > > >> It seems time to bite the bullet and actually begin designing and > >> implementing a database of installed packages. As a strawman to get a > >> focused discussion started, here's a draft of a PEP, with lots of > >> XXX's in it. Followups to the Distutils SIG, please. > > > >I'm confused. Why? What does this give us that native package managers > >don't. How is it going to keep synchronized with package manager? > > One problem is that native package managers don't make sense for > everything. I can't imagine wanting to even deal with many of > the package managers out there for a smaller Python package. I'm > not even convinced that one of the major entrants out there - the > Windows one - does a reasonable job with dependencies, but I'm > pretty ignorant there. And even small packages - a few Python source > files - might want to check for prereqs. Uhm, ok, I'll admit in my (non)Windows-bias that I didn't consider _that_ one. Although in my ignorant defense, I have to ask: Does Windows have what we've come to think of as a package manager? I know there's information in the registry, and that an installer can check to see if required dependencies are installed, but is there native support to prevent the removal of those dependencies once the dependent package is safely installed. In my experience, if there is, it doesn't work. The issue that I have is that when you go to manage software on a machine, any time there is more than one place software information may be stored you never know what's there unless you look in both. Once you've got multiple places, automation goes out the window. Building a python-specific module-manager is fine from a single-system viewpoint, but in an enterprise with large numbers of heterogenous systems, managing another repository on every machine is a nightmare. Mark From graham at coms.com Sun Jul 8 18:31:53 2001 From: graham at coms.com (Graham Ashton) Date: Sun, 08 Jul 2001 23:31:53 +0100 Subject: time.strftime BUG? References: Message-ID: In article , "Roman Suzi" wrote: > >>> time.strftime("%Z", time.localtime(time.time())) > 'MSD' > >>> time.strftime("%z", time.localtime(time.time())) > '+0000' > While I believe the later should be: > '+0400' I'm a bit confused by this too. ratchet% python Python 2.1 (#7, Jun 24 2001, 18:32:35) [GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2 Type "copyright", "credits" or "license" for more information. >>> import time >>> time.strftime("%z") '+0100' >>> time.strftime("%z", time.localtime(time.time())) '+0000' What gets me is that (according to the way I read them) the docs say the two satements above should return the same thing. strftime(format[, tuple]) -> string Convert a time tuple to a string according to a format specification. See the library reference manual for formatting codes. When the time tuple is not present, current time as returned by localtime() is used. -- Graham From colin at meeks.ca Thu Jul 26 08:42:52 2001 From: colin at meeks.ca (Colin Meeks) Date: Thu, 26 Jul 2001 12:42:52 GMT Subject: Sorting Lists References: Message-ID: Thanks all, that's given me all the info I need. Colin "Colin Meeks" wrote in message news:lSh77.64029$2V.13507417 at news3.rdc1.on.home.com... > I have a list that comprises of First Name, Surname, Age > The list looks something like > > [["Mickey","Mouse","50"],["Stan","Mantz","3"],["Junior","Wilst","40"],["Kim" > ,"Bean","15"]] > > How can I sort the list to rearrange it by either First Name, Surname, Age > > I believe I'd have to use a cmpfunc in the sort, but not too sure how to > achieve the above. > > Thanks > > Colin > > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.265 / Virus Database: 137 - Release Date: 18/07/2001 > > --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.265 / Virus Database: 137 - Release Date: 18/07/2001 From teyc at bigfoot.com Tue Jul 31 19:06:28 2001 From: teyc at bigfoot.com (Chui Tey) Date: Wed, 1 Aug 2001 09:06:28 +1000 Subject: Python releases [was Long: Python Is Really Middleware] References: <3B667EBA.DA6C298@tundraware.com> Message-ID: <9k7dho$19f$1@bunyip.cc.uq.edu.au> Truely insightful, especially the warning on creeping featurism. There is so much 'new' technology abound nowadays that I would be very happy if something remained invariant for a little bit longer. The rapid cycle of python releases, some backwards incompatible means people have to be very careful about upgrading lest it breaks their existing libraries, some which they might not have written themselves. How often should releases be? There probably could be two kinds of releases: a) Petrified: Locked in stone. (1.52 is a classic example) Both language and library are stable. Libraries (official or third party) can be released against these in the expectation that all python users would probably want to have a copy of each petrified release installed. I say this coming from the win32 perspective that a lot of extensions are already precompiled, and that is a definite plus since it is a real time-saver. There is no reason why more third party precompiled extensions can't be supplied for the more common platforms as well. It's the m x n problem of the many platforms and the many versions of python around. This also helps people making RPMs or Debian distributions to decide what versions to make available in their general releases. People working on libraries can supply patches against these kind of releases as a matter of priority, since they know that this is a widely installed base. Petrified releases could be perhaps a year or more apart and may break backward compatibility. But they break compatibility only once a year. Programs written in these releases do not need to import from __future__. b) Stable Enhanced: These are the major releases that we have now - 1.6, 2.0, 2.1 and could break backward compatibility, but libraries using the new backwards incompatible functions ought to import from __future__. From sholden at holdenweb.com Thu Jul 5 00:54:54 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 5 Jul 2001 00:54:54 -0400 Subject: pickling and methods References: <25b2e0d9.0107041354.161f2cd3@posting.google.com> Message-ID: "gods1child" wrote in message news:25b2e0d9.0107041354.161f2cd3 at posting.google.com... > Hi, > > When an object instance is pickled, is the byte-code associated with > the object's methods stored with it? Or does Python pickle only the > object type and state information ? for example if i have: > class Class: > def function(): > self.stateinfo = 'mystate' > pass # large amount of code here > > a = Class() > b = Class() > > If i pickled a and b, would they both have the byte-code for the > method 'function' or would they only have the class (Class) and the > state information (stateinfo)? > > The reason for asking this is because I have a class which has a large > amount of code in its __init__ method. Once the object is created, > most of that code is pretty much useless. Many instances of this > object will be pickled during program execution. If Python does store > the function byte code with each instance of the object, I wanted to > consider the space saving i might achieve by moving most of the > processing code to a object-factory class instead which would return a > light weight class which i can pickle. > > Even from a good programming perspective, i wanted to know your > opinions of moving the __init__ code to a factory method in cases > where the processing code is huge and is never used (not even while > unpickling) once the object is instantiated. > When you unpickle an instance, it imports the class from the original module in which it was defined. This is why you can't successfully pickle instances of objects whose class is in the __main__ module: Python doesn't know where to go to get their definitions. You can therefore assume it keeps only the state information in the pickle. Of course, if that includes references to other objects your pickle can anyway end up larger than you think. regards Steve -- http://www.holdenweb.com/ From skip at pobox.com Mon Jul 16 17:33:35 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 16 Jul 2001 16:33:35 -0500 Subject: memory leak with dynamically defined functions? In-Reply-To: References: Message-ID: <15187.23983.562368.858629@beluga.mojam.com> zooko> In searching for the source of the leakge today, I encountered a zooko> surprising behaviour of Python which I think may be a bug. If I zooko> allocate a bunch of memory with a function like this: >>> blarg = {} >>> for i in range(2**13): ... blarg[i] = [0] * (2**10) zooko> and then remove the references to this memory, like this: >>> del blarg zooko> then all the memory is freed up. zooko> But if I allocate memory and store a reference to it in a default zooko> argument to an inner function, like this: >>> def silliest_func(): >>> x = [0] * (2**10) >>> def inner_silliest_func(x=x): >>> pass >>> return inner_silliest_func >>> >>> blarg = {} >>> for i in range(2**13): >>> blarg[i] = silliest_func() zooko> and then remove the references to this memory, like this: >>> del blarg zooko> none of the memory is freed up! zooko> Even stimulating the garbage collector, with: >>> import gc >>> gc.collect() 0 zooko> just returns "0" and the memory is still in use. The garbage collector only considers containers (lists, tuples, dicts, and a couple other types perhaps) as potential sources of circularity. I don't think functions are considered. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From claird at starbase.neosoft.com Thu Jul 5 09:20:02 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 5 Jul 2001 08:20:02 -0500 Subject: Most important text processing examples References: Message-ID: <73BAB27563390BFF.A4E251244196609E.C75D14D5EC085CDD@lp.airnews.net> In article , A.T.Hofkamp wrote: . . . >Although not really happy about providing clues to some one that aims to make >money from my suggestions, well, here it goes. If it helps any, be confident that Dr. Mertz will not be *making* money on this book; it might cover a few expenses, though. . . . >- Perform interaction with other programs (either existing other programs, in a > PyExpect-like way (there is not a PyExpect yet, is there?) > For new programs, I will use XML techniques to exchange data. Actually, there is; see It's not in good shape, I believe. Tcl-ers have offered to help make a new and better Expect that'll be easy to integrate with Python. It doesn't seem imminent, though; Pythoneers seem to have other things on their minds. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From wheelege at tsn.cc Sat Jul 28 02:12:43 2001 From: wheelege at tsn.cc (Glen Wheeler) Date: Sat, 28 Jul 2001 16:12:43 +1000 Subject: Deposing Dictators References: <9jmjne$q54$1@wisteria.csv.warwick.ac.uk> <3b61a98d$0$11917@wodc7nh0.news.uu.net> <3B61B01F.6C6B2B5D@Lugoj.Com> <6c8b7eb9.0107271358.4783d9c1@posting.google.com> <9jstsl$6qlmd$1@fido.engr.sgi.com> Message-ID: <037701c1172c$510a1660$0200a8c0@ACE> > > Dirck wrote: > |> I just wanted to add a thank-you to Guido, for a terrific language. > |> It really is a joy to write Python code. > > Yes, I agree. As do I! Python is a magnificent language, and Guido still actively developing the language is Good. From pinard at iro.umontreal.ca Mon Jul 2 10:51:28 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 02 Jul 2001 10:51:28 -0400 Subject: `traiter' [was: Re: Is Python Dead?] In-Reply-To: References: Message-ID: [Gerhard H?ring] > PHP is IMHO even worse a programming language than Perl [...] When I needed dynamic Web pages, I took a few days to see things available in Python, and many things I found indeed. From simple things (sometimes quite clever) to the ambitious ZOPE. I also looked at SSI, and various other avenues. Despite PHP has many good ideas, I was rather rebuked by the aspect of the language. I merely decided to make an ad hoc tool for my Web designers, inspired from Python for the overall flow of preprocessing conditional and loops, but also allowing tight Python for more serious tasks, database access, and such. I called my tool `traiter', short of a better name; I wrote the first draft in half a day. I polished it afterwards as needed, probably a few weeks overall. It has been very satisfying to us so far. Since the tool was essentially simple, I did not thought about publishing it, as I presumed others could also do similar things as fast as I did this one. In fact, I acquired the opinion at the time that Python is just the proper tool for implementing dynamic Web pages simply, and that it was probably not worth debating the virtues of similar tools, nor harassing potential users with such debates. (I keep ZOPE aside as a notable special case, as it is a whole framework, not just a quickly made tool like mine and others'.) Yet, sometimes, I wonder if I should not document `traiter' and make it available, just as a kind of reply to those who seem do consider Python bad if they have to write a few lines of it to get their Web job done! :-) Documenting `traiter' does not attract me much, as my actual users do not read English. I should at least write French documentation. Currently, my users just walk in my office when they have a question or a need... Documenting `traiter' would be more about its setup, and the good tricks that make it so useful, as these are usually not apparent solely from its code. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From guido at digicool.com Sun Jul 15 13:29:24 2001 From: guido at digicool.com (Guido van Rossum) Date: Sun, 15 Jul 2001 13:29:24 -0400 Subject: [Python-Dev] Re: PEP: Defining Unicode Literal Encodings (revision 1.1) In-Reply-To: Your message of "Sun, 15 Jul 2001 10:15:28 PDT." <3B51CFB0.ACE9070D@ActiveState.com> References: <3B50C1FF.7E73739B@ActiveState.com> <200107150126.VAA23781@cj20424-a.reston1.va.home.com> <3B51CFB0.ACE9070D@ActiveState.com> Message-ID: <200107151729.NAA00455@cj20424-a.reston1.va.home.com> > > Explain again why a directive is better than a specially marked > > comment, when your main goal seems to be to make it easy for > > non-parsing tools like editors to find it? > >... > > Parsing tools do need it. The directive changes the file's semantics. > Both parsing and non-parsing tools need it. I understand that. > I could live with a comment but I think that that is actually harder to > implement so I don't understand the benefit...I'm still trying to > understand what tools we are protecting. compiler.py can be easily > fixed. The real parser/compiler can be easily fixed. The other tools > mostly take their cue from one of these two modules, right? I disagree with the first sentence -- I believe a comment is easier to implement. The directive statement is still problematic. Martin's hack falls short of doing the right thing in all cases: you can't have the first statement of your program be "directive = ..." or "directive(...)". Another argument for a comment: I expect there could be situations where you want to declare an encoding that doesn't affect the Python parser, but that does affect the editor (e.g. when you use the encoding only in comments and/or 8-bit strings). A comment would back-port to older Python versions; a directive statement wouldn't. I don't know how important this is though. --Guido van Rossum (home page: http://www.python.org/~guido/) From aleaxit at yahoo.com Tue Jul 17 10:19:47 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 17 Jul 2001 16:19:47 +0200 Subject: Calling C++ objects References: <3B542819.955186A2@ccsr.cam.ac.uk> Message-ID: <9j1hi502tmu@enews3.newsguy.com> "Sven ?string" wrote in message news:3B542819.955186A2 at ccsr.cam.ac.uk... > Is there an interface for calling C++ classes in Python, with access to > class members and methods? http://www.boost.org/libs/python/doc/index.html Alex From new_name at mit.edu Wed Jul 4 18:28:36 2001 From: new_name at mit.edu (Alex) Date: 04 Jul 2001 18:28:36 -0400 Subject: python-mode and py-python-command References: Message-ID: I think you're doing the right thing, but you have to try the new setting out with a new emacs. python-mode.el doesn't use the value in py-python-command directly, but passes it into some other variables, so just changing it will have no immediate effect. Alex. From chrishbarker at home.net Fri Jul 20 17:27:34 2001 From: chrishbarker at home.net (Chris Barker) Date: Fri, 20 Jul 2001 14:27:34 -0700 Subject: string random generator (Sorry if too stupid, but i am a beginner) References: Message-ID: <3B58A246.E3FFD805@home.net> Bjorn Pettersen wrote: > import random, string > > def randomWord(length): > res = '' > for i in range(length): > res += random.choice(string.letters) > return res This will work, if you only want letters, which I think is not the case. Also, strings are immutable, so the += is creating a new string each time you add a letter, so it will be a little slow. The short answer is: chr(), which converts an ascii code to a string character, so you can what you did above: import random def strrnd(n = 24) : result = [] while n : n = n - 1 result.append(chr(random.randrange(1,255,1))) return "".join(result) You can change the range, if you only want letters. Using a list means that the list is added to rather than re-generated, which I think is more efficent. The "".join means that you want to join the individual strings together, putting an empty string between them. A "for i in range(n):" loop might make more sense, and A niftier (and probably faster) way to do it is with list comprehensions: def strrnd(n = 24): return "".join([chr(random.randrange(1,255,1)) for x in range(n)]) > > From: Gustavo Vieira Goncalves Coelho Rios > > Another problem: This function will be called thousands of > > time a minute, so performance is a definitive requirement. If the strings you are generating are long, performance may be an issue, in which case, you can check out the Numeric package: http://sourceforge.net/projects/numpy then you could do: import RandomArray def strrnd3(n = 24): RandomArray.randint(1,255,(n,)).astype('c').tostring() RandomArray is a module that provied functions for generating arrays of random numbers, randint generates an array of random integers, astype('c') converts the integers to Characters, and tostring() converts the array to a Python string. Presto. I did a little time test with various methods. Here it is: import random, RandomArray def strrnd0(n = 24): res = '' for i in range(n): res += chr(random.randrange(1,255,1)) return res def strrnd1(n = 24): result = [] while n : n = n - 1 result.append(chr(random.randrange(1,255,1))) return "".join(result) def strrnd2(n = 24): return "".join([chr(random.randrange(1,255,1)) for x in range(n)]) def strrnd3(n = 24): RandomArray.randint(1,255,(n,)).astype('b').tostring() # now a time test import time start = time.time() functions = [strrnd0,strrnd1,strrnd2,strrnd3] N = [5, 25, 100, 1000] for n in N: print "n = %i"% n for func, i in zip(functions,range(len(functions))): start = time.time() for j in range(1000): str = func(n) print "The %ith function took %f seconds"%(i,(time.time() - start)) Running it on my machine I get: n = 5 The 0th function took 0.340676 seconds The 1th function took 0.369182 seconds The 2th function took 0.365142 seconds The 3th function took 0.375739 seconds n = 25 The 0th function took 1.570712 seconds The 1th function took 1.721119 seconds The 2th function took 1.732749 seconds The 3th function took 0.403911 seconds n = 100 The 0th function took 6.188933 seconds The 1th function took 6.752507 seconds The 2th function took 6.349224 seconds The 3th function took 0.579671 seconds n = 1000 The 0th function took 64.490783 seconds The 1th function took 66.025794 seconds The 2th function took 63.856450 seconds The 3th function took 1.352100 seconds So: 1) using strings is in fact a little bit faster than using a list (but only a tiny bit), this surprised me. 2) using list comprehensions is no faster than looping, in this case. 3) Numeric is about the same for very short strings, and MUCH faster for long strings. Numeric is a wonderful package...oh when will it be included in the standard library! -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 rnd at onego.ru Tue Jul 10 01:15:06 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 10 Jul 2001 09:15:06 +0400 (MSD) Subject: Newbie asks: How to translate this line of C to Py In-Reply-To: Message-ID: On Tue, 10 Jul 2001, Steve S.L. Wong wrote: >while (command = strtok(line_ptr,";"),line_ptr=0,command) { >} Pribably: import string # ... for command in string.split(line, ";"): # ... Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Tuesday, July 10, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "-- is the key to success" _/ From kirschh at lionbioscience.com Thu Jul 12 02:26:52 2001 From: kirschh at lionbioscience.com (Harald Kirsch) Date: 12 Jul 2001 08:26:52 +0200 Subject: shortest match regexp operator anyone? References: <3B4C96E8.668FB82A@kst.siemens.de> Message-ID: "Richard.Suchenwirth" writes: > Harald Kirsch wrote: > ... > > 2) TASK: Find the first '
' and match, if it is followed by a 'B' > > SOLUTION: ??? > > > > An approximation for (2) is '^[^<>A]+B', but it does not match > > 'AB', which it should. > > > > With non-greedy matching, another approximation is '^.*?B', however > > this matches 'xxyB', although it should not. > > Maybe I don't understand the exact problem, but wouldn't > > regexp {()B} fooCbarB -> matched > > fulfill task 2? Ooops, yes. Sorry, I stripped the example down too much. The typical application is of course that you want something resembling (.*) being part of a larger regexp except that the parenthesized expression shall be the shortest match found, i.e. '.*' may contain every string but "". I insist in `part of a larger regexp' since otherwise a step by step approach would still be easy to perform. (Yes, I *have* an application for that :-<). Harald Kirsch -- ----------------+------------------------------------------------------ Harald Kirsch | kirschh at lionbioscience.com | "How old is the epsilon?" LION bioscience | +49 6221 4038 172 | -- Paul Erd?s *** Please do not send me copies of your posts. *** From bokr at accessone.com Wed Jul 18 14:23:31 2001 From: bokr at accessone.com (Bengt Richter) Date: Wed, 18 Jul 2001 18:23:31 GMT Subject: PEP: Defining Python Source Code Encodings References: Message-ID: <3b55d56a.2252257755@wa.news.verio.net> On Tue, 17 Jul 2001 14:47:32 -0600 (MDT), Bruce Sass wrote: >Hi, > >regarding... > >> >Generally: # [] > >or as I should have written it... > ># [] > ><...> >> I withdraw my #!pragma (or #!pythma ;-) suggestion and propose >> r'^\s*#pragma\s' as the magic line prefix regular expression. > >Why is "pragma" better than " ## ", or some other sequence of >non-word characters? > >I would think that using any *word* as the is just asking for >trouble; someone is bound to have done (or normally does) a >block of comments where there is no space between the "#" and the >first word of the comment (iirc, emacs handles comments in such a way >that "#comments" is the right thing to do in some cases)... is the >word "pragma" now illegal as the first word in such a comment, what >does this do to any tools that automatically turn arbitrary text into >comments? > # ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## # # Ok, I'm not married to pragma. But the should be less # likely than " ## " and unique enough to grep well ;-) # # ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## If there are tools (not to mention the interpreter itself) dependent on current syntax, perhaps the file should not be modified at all? I.e., keep the unicode and other special file attributes or processing directives separate, but associated, as brought up by David Eppstein. See my other recent post in this thread for a couple alternative ideas along those lines. There could be some real benefits to separation. Separation would factor pre-processing out of the internal file context, and open the door for other kinds of per-file pre-processing like decompression etc., which have nothing to do with the python language definition itself, yet which could be controlled as files are accessed by the interpreter for its processing. From t-weh at online.no Fri Jul 27 13:15:04 2001 From: t-weh at online.no (Thomas Weholt) Date: Fri, 27 Jul 2001 19:15:04 +0200 Subject: Distributed computing using SOAP. What about speed ? References: <15199.8639.732833.516879@beluga.mojam.com> <200107260721.JAA18607@pandora.informatik.hu-berlin.de> <9js13u$c80$1@dahlia.singnet.com.sg> Message-ID: <4Jh87.1292$e%4.30029@news3.oke.nextra.no> > - a Medusa-based soap_handler that does HTTP/1.1 server-side A quickie: Doesn't medusa provide far better performance than BaseHTTPServer? Does anybody know? Benchmarks would be nice, testing with several concurrent clients etc. How capable is BaseHTTPServer and the other standard python libs. for this kind of thing? How capable are they in general? Just for testing or do they work "under pressure" too? It would be great cuz they're really simple to use. ( Ng Pheng Siong, you're a life-saver. This is exactly what I need. Thanks!! :-)) Thomas From db3l at fitlinxx.com Tue Jul 24 16:37:14 2001 From: db3l at fitlinxx.com (David Bolen) Date: 24 Jul 2001 16:37:14 -0400 Subject: Evolving Python and PEP238 References: <3B5B37B9.4D7A80CD@Lugoj.Com> Message-ID: Paul Prescod writes: > I notice that people keep mentioning Python 1.5.2. That was a > particularly popular release of Python and people seem not to care much > about releases before that. I don't think that's it. I think that due to the length of time that 1.5.x was available that it simply became the prevalent installed base version. 1.5.2 in particular seems to have hit the sweet spot in terms of remaining unchanged for a significant period of time during which Python usage was ramping up quickly - thus it became the version most commonly in use. Since most of the references to 1.5.2 are in relation to backwards compatibility, it makes sense that the most deployed version would be used. > Now consider if Guido says: "I'm going to be changing a behaviour that > was deprecated in 1.4 and has issued a warning since then. Any > complaints?" Would anyone here complain? I doubt it. The offending > feature would have been expunged from the collective consciousness so > long ago that people would not even remember it. And so? That's not apples to apples, since here we're talking about changing a feature in a commonly in use release today, not a release that was already replaced many years ago. And we're talking about just introducing the warning for a short period (relative to the longevity of 1.5.2) and not a warning that already existed. And BTW, sure, if I was using 1.4 in my deployed base I'd be complaining about the above hypothetical case just as much and for the same reasons. > So the backwards compatibility question is a function both of how severe > the change is and *how quickly it is made*. Add on "and how big a deployed base is impacted", and I'd agree. > Python is around 11 years old. If Guido had embarked on this PEP238 path > 7 years ago, the backwards compatibility problem would also have been > severe for the code created in the first 4 years but by now most people > would not know or care about the fact that there was 3 or 4 year period > where divisions had to be migrated over slowly. Today, the period of > transition would be merely a mythical historical event like the Great > Usenet Reorganization. Maybe - or maybe these same arguments would have been held at the time, albeit with a much smaller user population, which might have had an easier time adapting. This is no different than changing any other deployed system. I have a much easier time making changes in my system when it's still in development on my desktop, to when I have one customer, to 10 customers, and so on. By the time I have hundreds or thousands of locations, changes by necessity have to take that into account. Does that mean that the threshold for making a change (even if good on its own merits) needs to take into account my deployed base. You betcha. Does that mean there's a higher hurdle for justifying the same change later in the development cycle than at the beginning. Yes. Does that mean you'd never make a backwards incompatible change? No, but it's far harder to justify when you've got a lot of systems out there. > It is one thing to argue that this change is not the right one. I > disagree but we can cover that in another discussion. And which, as I mentioned earlier, in the abstract I might agree, and certainly wouldn't have minded if this was how division was defined initially. > It is another > thing to say that Python is a language that can only accumulate warts > and never remove them. I think that that is an unnecessarily defeatist > attitude. The mechanism for making "big" changes is well-defined and > entirely workable. It merely requires patience and a sense that Python's > future is important enough to have a long-term plan. I'm not saying that it's impossible to make changes or fix warts. I do however feel that the justification for making such a change needs to be stronger the more impact to an installed base such a change has, and as you pointed out above, dependent on the scale/impact of the change, and the time factor. Much of this debate is how various people weigh these factors in the overall equation. As a person who has to maintain a large distributed system, I will naturally weigh backwards compatibility (particularly for a change like this that will eventually just break old code - it's not a forward evolution but a retroactive one) heavily. When I compare that against the benefit of fixing this wart, I don't see as overall beneficial enough. That may not match what others think - thus the rather extensive "discussion" :-) -- -- 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 flognat at flognat.myip.org Mon Jul 30 15:55:13 2001 From: flognat at flognat.myip.org (Andrew Markebo) Date: 30 Jul 2001 21:55:13 +0200 Subject: Debug your python code in emacs.. Message-ID: How is the status on debugging python from within GNU-Emacs?? Wolfgang Weitz created a pdb-mode for xemacs (can be found at www.python.org), and I modified it a while ago to work with GNU-Emacs.. Am I the only one who have been missing it for GNU-Emacs?? Maybe something to try to squeeze into the python-mode.el?? /Andy p.s. you can find it at http://flognat.myip.org/hacks if you want to try it out. p.s.2 Did some more digging, hey I did this 1997, old stuff.. was it Python 1.3 then or? :-) From brendano at stanford.edu Wed Jul 25 02:46:32 2001 From: brendano at stanford.edu (Brendan O'Connor) Date: Wed, 25 Jul 2001 06:46:32 GMT Subject: HOWTO: exit References: Message-ID: Vonlia wrote: > Hi, > Sorry, I know this will be easy and I'm making alot of noise, but > how do I exit from a script? I was hoping for something like sh's > `exit' command...Once again, sorry, I just got into the python thing > (long time Monty Python liker, though C-:) > import sys sys.exit() Enjoy. --Brendan From nperkins7 at home.com Fri Jul 13 20:15:32 2001 From: nperkins7 at home.com (Nick Perkins) Date: Sat, 14 Jul 2001 00:15:32 GMT Subject: Comparison of different types does not throw exception References: Message-ID: "Gordon Williams" wrote in message news:mailman.994953783.6278.python-list at python.org... > I would like to know why python does not produce an exception when a > comparison of objects of different types is made. For example: > > >>> 1 < "aaa" > 1 > > I cant see why anyone would like to have comparisons of different types as > it has no meaning. It is a programming error and an exception should be > produced. > > This one tripped me up in an assert statement for a couple of hours. The > assert statement was returning true when it should have been false to give > me a warning that there was a problem. It was something like: > > lengthA= 3 > lengthB= "2" > > assert lengthA <= lengthB > > and was returning true > > > It would have been *much* more helpful if it told be that I was comparing > objects of different types. > > Regards, > > Gordon Williams > > I agreed with you completely,...until I thought of a good use for the 'consistent but arbitrary' result of such comparisons. Suppose you want to use a list to represent a heterogenous set. You don't care about the order of things, but you want to know if two such sets are the same. You can sort a list of heterogenous types, and although the resulting order may be 'arbitrary', at least it will be 'consistent'. That is, two lists that have the same elements in a different order can be sorted, and then compared element-wise: def equal(a,b): return a==b def both(a,b): return (a and b) def samelist (L1, L2): return reduce( both, map(equal,L1,L2), 1 ) def show_compare(a,b): print 'a=', a, 'b=', b if samelist(a,b): print 'ARE the same' else: print 'are NOT the same' a = [ 1, 'one', 2, 'two' ] b = [ 1, 2, 'one', 'two' ] show_compare(a,b) a.sort(); b.sort() show_compare(a,b) OUTPUT: a= [1, 'one', 2, 'two'] b= [1, 2, 'one', 'two'] are NOT the same a= [1, 2, 'one', 'two'] b= [1, 2, 'one', 'two'] ARE the same Without the ability to compare, and therefore sort, a heterogenous list, it would be much harder, (or at least slower?) to do this. From aahz at panix.com Tue Jul 3 13:05:24 2001 From: aahz at panix.com (Aahz Maruch) Date: 3 Jul 2001 10:05:24 -0700 Subject: Is Python Dead? References: Message-ID: <9hsu0k$smr$1@panix3.panix.com> In article , Kemp Randy-W18971 wrote: >From: Steve Holden [mailto:sholden at holdenweb.com] >>"Kemp Randy-W18971" wrote in message >>news:mailman.994164845.2688.python-list at python.org... >>> >>> Roses are red, >>> and violets are blue, >>> I program in Python, >>> and so can you. >> >>Roses are red >>Violets are blue >>Everyone knows >>Four into nine gives two > >You forgot the fraction, >A quarter infraction (in fraction, get it), >This error in Python, >Would deserve drastic action. Burma Shave -- --- 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'm not tense, i'm just terribly, terribly alert" --unknown From fluxent at yahoo.com Thu Jul 5 11:41:20 2001 From: fluxent at yahoo.com (Bill Seitz) Date: 5 Jul 2001 08:41:20 -0700 Subject: SQL-SELECT against View via ODBC? References: <2l%Z6.22470$g4.740189@e420r-atl2.usenetserver.com> Message-ID: I installed mxODBC, and confirmed that it does not have this bug, so my problem is solved. I just have to pay for mxODBC now... fluxent at yahoo.com (Bill Seitz) wrote in message news:... > I established that the "cause" of the problem is that one of the > tables in my view has a Text field. It's the last field in the base > table, so those queries always worked fine. When I built the view, it > was no longer the last field, so the error reared it's ugly head. > > Does anyone know whether mxODBC has this bug? The person who led me on > this discovery thought so, but wasn't too sure... From guido at python.org Wed Jul 11 10:19:39 2001 From: guido at python.org (Guido van Rossum) Date: Wed, 11 Jul 2001 14:19:39 GMT Subject: Comment on PEP-0238 References: <9ichdv$rik$1@tomm.stsci.edu> Message-ID: Marcin 'Qrczak' Kowalczyk writes: > Mon, 09 Jul 2001 18:19:10 GMT, Terry Reedy pisze: > > > I thought the desire was/is to have an operator which just preserved int / > > int -> int. But I have never seen it specified whether float div whatever > > would be an error or have the current meaning (in which case confirmation > > would not be necessary). > > I would prefer it to mean integer division of fractional numbers, e.g. > 1.3 div 0.3 == 4 > 1.3 mod 0.3 == 0.1 > > The question whether div should return int or long (or even fractional > with integral value) becomes irrelevant when ints and longs are unified > (even if "unified" means that operations on ints return longs instead > of raising overflow, keeping types distinct). Indeed, x div y (or x//y, or div(x, y)) will be defined as divmod(x, y)[0]. This is already defined for floats and returns an integer value with a float type. By the way (this is for Terry :-), int/int in Python does not do the same as it does in C for negative operands. --Guido van Rossum (home page: http://www.python.org/~guido/) From anapraxis at yahoo.com.au Fri Jul 20 01:57:04 2001 From: anapraxis at yahoo.com.au (Patrick W.) Date: 20 Jul 2001 15:57:04 +1000 Subject: Python 2 times slower than Perl References: <8f41cfd.0107171238.6ff33b9b@posting.google.com> <9j3rvk$26bt$1@norfair.nerim.net> <3B559B30.61A90EA@jam.rr.com> <9j4af20d2o@enews4.newsguy.com> <87elrdtgps.fsf@ivory.localhost> Message-ID: <87ofqgdtxr.fsf@ivory.localhost> "Greg Jorgensen" writes: > "Patrick W." wrote: > > > To get a better understanding of which languages it benefits us to > > learn and teach. Also to get a better understanding of which languages > > are best used in the "real world", given a set of tradeoffs between > > development time and program performance. > > > > Sounds reasonable enough to me. > > Discussion of languages and their applications in teaching or professional > work is fine, I'm all for that. But how does comparing benchmarks of Perl > vs. Python help in that regard? OK, crossed purposes here. I thought you were dismissing the potential usefulness of quantitative language-comparative studies in general. You weren't. > Serious programmers know that such discussions are often wrong, > usually irrelevant, and about as useful as comparing the speed of a > Toyota Camry vs. a Honda Accord. Sure. If you're talking about the merits of comparing the speed of a loop that doesn't do anything useful in any language, I agree totally. I think there's a bigger issue though. (I know you don't disagree, I'm just explaining what I had in mind). We (the industry as a whole) are bogged down by the choices we've made in the past. We used languages that may or may not have been the best ones available at the time, and now we have huge systems that we can't afford to abandon or rewrite. So you're right. Most programmers don't get to choose the language they work with. Going forward, the main value I see in comparative language studies is that we have a chance of making smarter decisions for NEW projects. Instead of rushing headlong into the next Java-like novelty, we could take stock of what we know, put a few assumptions to the test, and start improving what we already have and/or use it in better ways. To do that properly, it would be useful to have some *real* benchmarks. Not timed loops, but real tasks performed by equivalently experienced programmers in different languages, to see which ones (if any) consistently lead to the most robust, timely and cost-efficient solutions - in practice. The results may not be consistent or repeatable (which is the whole point of experimenting). But if they are, it will be a *major* discovery. Personally, I'd be very curious to find out whether my intuitions are quantitatively verifiable. (As yet, I only have gut feeling to judge by). The way I see it, only three languages (or families of languages) are really necessary : 1. A simple low level language, capable of generating code that extracts maximum efficiency from the CPU, suitable for space and memory constrained architectures, etc. C has stood the test of time. It works. 2. A Lisp-like language for higher level logic. Able to clearly and concisely represent any kind of data structure or algorithm. Extensible through the mechanisms of its own semantics. Able to generate code that generates code. Able to read its own code as data, and output data as code. Able to assimilate any programming paradigm without torturing its simple syntax. 3. Another language, similar to #2 in its expressive power, but with infix notation for convenience. (Hard to go past Python or Dylan). A programmer who has these tools in his arsenal is capable of anything his brain can handle. No single programmer is ever going to be able to cover all the intellectual ground in terms of domain-specific knowledge or specialist skill, but it should be possible for any person to master the *means* to do so. So, to me, these studies are potentially *very* valuable. (Value measured in life-years, dollars and brain cells). > The less-than-serious programmers apparently find deep meaning in > these comparisons; apparently they believe they must find the "best" > language because they can learn and use only one. To be honest, I can empathise with that. I certainly wouldn't think ONE language can solve all problems, but I think the industry is fragmenting into too many special-purpose hacks instead of trying to identify the core linguistic / conceptual factors that enhance productivity the most, without costing too much in hardware power. > The increasing number of postings comparing Python to language X is I > suppose a good thing: lots of people are kicking the tires and taking Python > for a spin. I think we should encourage that, but not by comparing execution > times of loops. We need to discourage the amateur programmer obsession with > "performance" and "efficiency" as if those attributes are all that matter. Totally agree. But Alex's article (the one you responded to) was about the tradeoff between machine efficiency and programmer efficiency. (Actually, Erann Gatt's followup re Lisp showed it to be a correlation rather than a tradeoff). I don't think advocates of higher level languages have any reason to shy away from benchmarks on *that* level. Regards, P. From grante at visi.com Sun Jul 29 19:27:15 2001 From: grante at visi.com (Grant Edwards) Date: Sun, 29 Jul 2001 23:27:15 GMT Subject: Language Niches (long) References: <8beb91f5.0107280407.5a30341d@posting.google.com> <3B62FAFF.BB987077@Lugoj.Com> <8beb91f5.0107282158.4785ae5e@posting.google.com> Message-ID: On Sun, 29 Jul 2001 21:44:37 +0100, Robin Becker wrote: >In article , Paul >Prescod writes >>Robin Becker wrote: >>> >>> ... >>> I believe that well designed languages define their own niche. >> >>I can give you many examples of beautiful languages that fell into >>disuse. Sather, Modula-X and Objective-C jump to mind. The eternally >>minor languages like Common Lisp, Scheme, Eiffel and Smalltalk are also >>worth consideration. >> >>Now let's examine some of the other languages out there: >> >> * For a long time, C was the only way to do system programming for Unix > >what language does one use nowadays. AFAIK, all Unix system programming is still done in C. (At least that's true for the Unices I'm familiar with (SCO, Solaris, BSD, Linux). -- Grant Edwards grante Yow! Do you have exactly at what I want in a plaid visi.com poindexter bar bat?? From skilchen at swissonline.ch Wed Jul 25 10:10:17 2001 From: skilchen at swissonline.ch (Samuel Kilchenmann) Date: Wed, 25 Jul 2001 16:10:17 +0200 Subject: PEP0238 lament References: <5sdnlt072hm6hp17nluu6f0fqq4bvr6mj8@4ax.com> <916olt0p3kciv0evmotdg6jev9bl29l57i@4ax.com> Message-ID: <9jmkpt$5fh4$1@ID-13368.news.dfncis.de> "Steve Horne" wrote in news:916olt0p3kciv0evmotdg6jev9bl29l57i at 4ax.com... > On Mon, 23 Jul 2001 03:26:52 -0400, "Tim Peters" > wrote: > > >[]Stephen Horne] > >> ... > >> And what about the languages web developers are used to, such as > >> VBScript and JavaScript. > > > >Good thing you stopped before mentioning Perl (yes, 1/2 is 0.5 there) -- > >I'm afraid the "mimic other languages" approach requires picking > >languages very carefully if you want the illusion of consistency. > >By the way, 1/2 is also 0.5 in standard JavaScript: > > My mistake. However, the overwhelming majority of code is written to a > pattern where 1/2=0 - the simple fact Visual BASIC does it almost sets > the standard itself Neither VBScript nor Visual BASIC nor VBA do integer division by default, all use the '\' operator to force integer division. Per default: 1/2 == 0.5 in VBScript, VBA and Visual Basic. From JamesL at Lugoj.Com Sat Jul 14 12:40:57 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Sat, 14 Jul 2001 09:40:57 -0700 Subject: converting from perl: variable sized unpack References: <3B505B3F.C2851242@student.gu.edu.au> Message-ID: <3B507619.C1002AE@Lugoj.Com> Joal Heagney wrote: > I've noticed that everyone is using string.split. Is there a reason why > we aren't using the .split() function of strings? They work the same way > in all these examples, so I was wondering was this because they aren't > supported in python 1.5? You hit the nail squarely: I have 1.5.2 on my machine and recently wrote a Python program that had users whose own machines had 1.5.2 and they couldn't or didn't want to upgrade. From sholden at holdenweb.com Mon Jul 9 10:31:27 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 9 Jul 2001 10:31:27 -0400 Subject: overriding of methods and variables in a class. References: Message-ID: wrote in message news:mailman.994686374.24889.python-list at python.org... > I dont seem to understand why a method name and a variable name is > allowed to be same in a class. what is the use. Most importantly, > Assuming that we have a class as follows: > > class abc > # I am going to define a variable here. > var_x = 1 > # now the function with the same name as the variable with say some > #parameter > def var_x(abc) > return abc+1 > > Now the question is how do i access the variable as well as the > function (with the same name as the variable) say from another > function. thanx in advance. Just because you're allowed to do something doesn't mean it's a good thing to do. Python won't raise any errors, because it doesn't fundamentally differentiate between binding to a name using assignment and binding to a name using def. If you define two methods with the same name in a class you'll find that only the second one (the definition executed second) will be available. You still don't see any errors. The shortest and simplest answer is: "don't do that!". regards Steve -- http://www.holdenweb.com/ From tchur at optushome.com.au Fri Jul 13 21:06:38 2001 From: tchur at optushome.com.au (Tim Churches) Date: Sat, 14 Jul 2001 11:06:38 +1000 Subject: Statistics tool box. References: Message-ID: <3B4F9B1E.B4493A1@optushome.com.au> Prem Rachakonda wrote: > > Hi, > I am trying to convert my matlab scripts into Python. But I see that > there are no equivalent stat. tools in Python. If there are any, could you > please let me know. I am looking for the functions similar to: > > normrnd() > unifrnd() > hist() First of all, install Numerical Python (Numpy) - see http://numpy.sourceforge.net Numpy includes a set of MATLAB-compatible functions. Then look at Gary Strangman's stats.py module: http://www.nmr.mgh.harvard.edu/Neural_Systems_Group/gary/python.html Tim C Sydney, Asutralia From leenutter at australia.edu Wed Jul 25 09:30:22 2001 From: leenutter at australia.edu (Lee Nutter) Date: Wed, 25 Jul 2001 23:30:22 +1000 Subject: A few things :) Message-ID: <3B5EC9EE.108@australia.edu> Hello, Im a beginner, and although (i think) I know the base language all right, I haven't really made anything. Can anyone recommend anything for a first project? Also, I was just wondering, Why do you use python? To me its a hobby. Why do some of you use it over other languages? I love the language, don't get me wrong, I was just curious :) Thanks, From grante at visi.com Thu Jul 26 17:44:51 2001 From: grante at visi.com (Grant Edwards) Date: Thu, 26 Jul 2001 21:44:51 GMT Subject: proposed language change to int/int==float (was: PEP0238 lament) References: <9jnt9p$qhe$1@newsy.ifm.liu.se> Message-ID: In article , Guido van Rossum wrote: >> >>> 1+2 >> 3 >> >>> 1.0+2.0 >> 3.0 >> >>> >> >> ... unless 3 and 3.0 are "the same value". In which case my >> definition of that phrase is merely different than yours. > >[Guido] >Well, they have the same *mathemtical* value, and Python does its >darndest to treat them as equal everywhere. I've been thinking in assembly language too long. :) In my mind, floats and ints are only distantly related. >For example, a dict with int keys can be indexed with >corresponding float or complex values. That's interesting -- I didn't know that. >Exceptions are operations that intrinsically require ints, e.g. list >indexing. (This would change under a unified numeric system though, I >expect, unless inexact numbers are excluded from being used as >sequence indices.) If the numerical types all get unified, then I think one would expect an inexact number to get "converted" to an exact one if used in that context. -- Grant Edwards grante Yow! I guess it was all a at DREAM... or an episode of visi.com HAWAII FIVE-O... From guido at python.org Wed Jul 11 10:45:20 2001 From: guido at python.org (Guido van Rossum) Date: Wed, 11 Jul 2001 14:45:20 GMT Subject: getpass() problems.. References: Message-ID: Andrew Todd writes: > getpass() seems to be crashing my WinNT system. Is there > some way I can manually change the echo to aterisks or > something? I'm writing a _really_ simple program that just > encrypts text files past in on the command line using the > rotor module. I'm using getpass to get the key... is this a > bad idea? Is there a better way? Strange. You *should* be able to use the routines in the msvcrt module to write your own getpass()-like routine. Are you running Norton Antivirus 2000? Are you *sure* the problem is in getpass()? --Guido van Rossum (home page: http://www.python.org/~guido/) From aahz at panix.com Thu Jul 5 09:33:01 2001 From: aahz at panix.com (Aahz Maruch) Date: 5 Jul 2001 06:33:01 -0700 Subject: Python for air traffic control? References: <9htgsb$ck3@news1.gtech.com> Message-ID: <9i1qad$h56$1@panix2.panix.com> In article , Russ <18k11tm001 at sneakemail.com> wrote: > >Let's cut right to the chase here. I like strong typing almost as much >as you do, but I don't understand why I can't get it in Python, >perhaps by specialized code-analysis tools. Is the problem just that >the development tools are underdeveloped, or is there a fundamental >technical reason that type-checking cannot be done? If it's the >former, then I suggest that the tools be given a very high priority. >If it's the latter, then perhaps type checking can be done under >certain reasonable restrictions. Whatever the case, I want to have my >cake and eat it too. :-) Python simply has no direct mechanisms for enforcing type control *except* for the fact that performing an incorrect operation on an object will raise an exception. That is, if you attempt foo.append(bar) and foo does not have an append method, you'll get an exception. That is the entire basis of Python's built-in type control. Now, you can use Python's introspective capabilities to pre-test for this, but there's rarely any reason to do so. What you want to do is fail gracefully -- the tricky part is defining what is "graceful" within your application. -- --- 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 So much Astroglide. So little time. From mwh at python.net Wed Jul 4 06:18:29 2001 From: mwh at python.net (Michael Hudson) Date: 04 Jul 2001 11:18:29 +0100 Subject: Redirecting input? References: Message-ID: philh at comuno.freeserve.co.uk (phil hunt) writes: [getpass, getuser] > > Now that Mac OS X is based on Unix, will this work for Macs too? I'd have thought so; AIUI Python sees MacOS X as some kind of bizarre FreeBSD. Cheers, M. -- MARVIN: What a depressingly stupid machine. -- The Hitch-Hikers Guide to the Galaxy, Episode 7 From dgoodger at bigfoot.com Wed Jul 4 23:32:56 2001 From: dgoodger at bigfoot.com (David Goodger) Date: Wed, 04 Jul 2001 23:32:56 -0400 Subject: PEP: Procedure for Adding New Modules (please comment) In-Reply-To: <9hvqhr$gj2$1@newshost.accu.uu.nl> References: <9hvqhr$gj2$1@newshost.accu.uu.nl> Message-ID: Martijn: Good PEP. Comments: > The library PEP > differs from a normal standard track PEP in that the reference > implementation should in this case always already have been > written before the PEP is to be reviewed; the reference > implementation _is_ the proposed contribution. By "to be reviewed" do you mean "to be decided upon by the Integrators"? Or "to be released to the Python community for comment"? I hope the former. Please clarify. > In the case where no head maintainer can be found (possibly > because there are no maintainers left), the integrators will issue > a call to the community at large asking for new maintainers to > step forward. If no one does, the integrators can decide to > declare the contribution deprecated as described in PEP 4. I agree with Roman that this needs some explanation. When, why, under what conditions, would the Integrators deprecate a contribution? I think "maintainerless" is a useful category; after all, most modules do *not* require much if any maintenance between releases. > Should there be a list of what criteria integrators use for > evaluating contributions? It would be useful. I think it would have to come from the PythonLabs crew themselves. I think it would be useful to them as well. > A related question is integration with the Python documentation > process. Contributions should come with good documentation that > can be integrated with the Standard Library documentation. Should > we detail this more in this PEP? Say exactly that, with a pointer to the "Documenting Python" section of the Python reference. -- 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 thomas.heller at ion-tof.com Fri Jul 27 08:16:02 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Fri, 27 Jul 2001 14:16:02 +0200 Subject: Colors in Windows text mode? References: Message-ID: <9jrm23$1a9d6$1@ID-59885.news.dfncis.de> > I was wondering, is it possible to output colored text in Python while in > Windows text/console mode? You could call it "in a DOS box", but I'm talking > about Windows Python, not a DOS version. I vaguely recall that I have seen an > example of this a long time ago, but I haven't been able to find it. > > TIA, Well, there is Fredrik Lundh's windows console module, but this takes over the whole console. Here is another extension module, which makes a setColor() function available and the 16 possible colors under their names. It allows to change the console text color in the low byte, and the backgound color in the high byte. Python style license, Thomas --- file _color.c --- #include "Python.h" #include static char setColor__doc__[] = "Set the console color, return previous console color."; static char module_doc[] = ""; static PyObject *setColor(PyObject *self, PyObject *args) { int color; CONSOLE_SCREEN_BUFFER_INFO csbi; HANDLE handle; if (!PyArg_ParseTuple(args, "i", &color)) return NULL; handle = GetStdHandle(STD_OUTPUT_HANDLE); if (handle == INVALID_HANDLE_VALUE || !GetConsoleScreenBufferInfo(handle, &csbi)) { PyErr_SetString(PyExc_RuntimeError, "Cannot get console screen buffer info"); return NULL; } if (!SetConsoleTextAttribute(handle, color)) { PyErr_SetString(PyExc_RuntimeError, "Cannot set console text attribute"); return NULL; } return PyInt_FromLong(csbi.wAttributes); } static PyMethodDef methods[] = { { "setColor", setColor, METH_VARARGS, setColor__doc__ }, { NULL, NULL }, /* Sentinel */ }; DL_EXPORT(void) init_color(void) { PyObject *m, *d; m = Py_InitModule3("_color", methods, module_doc); d = PyModule_GetDict(m); PyDict_SetItemString(d, "BLACK", PyInt_FromLong(0x00)); PyDict_SetItemString(d, "BLUE", PyInt_FromLong(0x01)); PyDict_SetItemString(d, "GREEN", PyInt_FromLong(0x02)); PyDict_SetItemString(d, "CYAN", PyInt_FromLong(0x03)); PyDict_SetItemString(d, "RED", PyInt_FromLong(0x04)); PyDict_SetItemString(d, "MAGENTA", PyInt_FromLong(0x05)); PyDict_SetItemString(d, "BROWN", PyInt_FromLong(0x06)); PyDict_SetItemString(d, "WHITE", PyInt_FromLong(0x07)); PyDict_SetItemString(d, "GRAY", PyInt_FromLong(0x08)); PyDict_SetItemString(d, "LIGHT_BLUE", PyInt_FromLong(0x09)); PyDict_SetItemString(d, "LIGHT_GREEN", PyInt_FromLong(0x0A)); PyDict_SetItemString(d, "LIGHT_CYAN", PyInt_FromLong(0x0B)); PyDict_SetItemString(d, "LIGHT_RED", PyInt_FromLong(0x0C)); PyDict_SetItemString(d, "LIGHT_MAGENTA", PyInt_FromLong(0x0D)); PyDict_SetItemString(d, "YELLOW", PyInt_FromLong(0x0E)); PyDict_SetItemString(d, "BRIGHT_WHITE", PyInt_FromLong(0x0F)); } --- EOF --- --- setup.py --- from distutils.core import setup, Extension import py2exe setup(name="_color", version="0.1", description="", license="Python", author="Thomas Heller", author_email = "theller at python.net", ext_modules = [Extension("_color", sources=["extensions/_color.c"]), ], ) --- EOF --- From guido at python.org Fri Jul 27 13:51:50 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 27 Jul 2001 17:51:50 GMT Subject: PEP 238 (revised) References: Message-ID: "Terry Reedy" writes: > To Guido: Version 1.10, which you indicated would not be the last, has > gotten many cogent comments. I recommend that at some point you > pre-announce a time limit for discussion, at which time you will > gather up existing comments, declare 1.10 and further comments thereon > obsolete, retire to your desk or study, write version 1.11, and > thereafter restart discussion with a new thread entitled 'PEP 238 > v1.11' . > > To everyone else: such a declaration would in no way stop anyone from > discussing anything they want. It would help people not waste their > own time by making obsolete comments of no effect. An author of a > work in progress has a right and usually a need to stop listening to > return to writing a new draft. One he releases the new draft, he has > a right to only listen to comments that reference that new draft, so > the discussion can move forward, (as it already has with 1.10). This > standard procedure is probably most valuable when the work is > contentious. Thanks for the suggestion. I am almost ready to post 1.11. But at some point I will have to withdraw from the newsgroup again -- then we will need a different mechanism to comment on the PEP (at least if you want me to hear you). --Guido van Rossum (home page: http://www.python.org/~guido/) From yeah at right.net Fri Jul 6 17:03:15 2001 From: yeah at right.net (baronsamedi) Date: Fri, 06 Jul 2001 21:03:15 GMT Subject: Time for a Python distribution? take two. References: Message-ID: <3B46278F.1000308@right.net> Sorry about posting pretty much the same information, but my news server's a tad on the poor side, this message didn't show until I refreshed to see if my message had been posted :( ========================= baronsamedi/icarus ========================= From wyatts at onr.com Fri Jul 13 12:33:10 2001 From: wyatts at onr.com (wyatt stafford) Date: Fri, 13 Jul 2001 16:33:10 GMT Subject: greenbeen seeks advice Message-ID: <9pF37.22474$g96.625691@news.easynews.com> Preamble: I am a computer/network support person who has decided to start programming for a vocation (no previous experience beyond minor scripting, etc). After some research I selected Python as a good place to start. I bought "Learn to Program using Python" (Gauld) and "Quick Python" (Harms/McDonald). Also checking out the tutorial, and other good info at www.python.org. I have a leaping, intuitive learning style given to missing the obvious, so I am concerned about having fatal gaps in my learning via home schooling plan. Questions: Beyond those mentioned above, may I have any recommendations for self study resources (books, etc) or techniques that will help me be a good programmer, in general? Do I need to know what is taught in CompSci 101/102/etc, to be great? thanks and happy weekend to all, wyatt "Oh, that's not what I call bingeing" From tanzer at swing.co.at Fri Jul 27 12:38:15 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Fri, 27 Jul 2001 18:38:15 +0200 Subject: PEP 238 (revised) In-Reply-To: Your message of "Fri, 27 Jul 2001 15:44:22 GMT." Message-ID: "Terry Reedy" wrote: > "> PEP: 238 > > Title: Non-integer Division > > Now that I look at it, the title seems rather odd, given that at least > half of the PEP and the discussion is/has been about integer division. > How about Revising Division or even better Splitting the Division > Operator. Dividing the Division Operator ??? -- 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 steve at lurking.demon.co.uk Tue Jul 24 03:42:26 2001 From: steve at lurking.demon.co.uk (Stephen Horne) Date: Tue, 24 Jul 2001 08:42:26 +0100 Subject: proposed language change to int/int==float (was: PEP0238 lament) References: Message-ID: On Mon, 23 Jul 2001 23:48:33 -0500, "Chris Gonnerman" wrote: >Stephen seems not to want to have to admit to his boss that Python has >changed >the basic rules for division of integers. I can grasp this... a proposal >like >mine, which allows for other numeric types to be dynamically added to the >language, would be an easier sell: > > Boss: I heard Python was changing the rules for division of integers. > Are you sure we should be using such a stupid language? > SH: No, boss, you've got it all wrong. We have a new method for adding > numeric types, like rationals, fixedpoint, decimals, etcetera, and > is just happens that the default division mode changed as a > consequence. I can easily add a single line of code to any old >module > and Python will run it under the old rule. No fault, no foul. > Boss: Oh. Well, carry on. And *this* storyline would leave me 98% of the way to seeing the change as no different to the (IMO) less scary case insensitivity change - I've already expressed my reservations on the religious aspects ad nauseum, but in the practical sense this would leave only one minor problem. The minor problem is finding the code - the only way I can trace all these programs written over the last three years which have been passed from person to person, and which have been modified by others or which I just plain forgot I wrote etc is by sending out an email to the whole company. If the change is as simple as above, I can find a way to do this that saves face - there is no chance of an avalanche of bugs, only that some people won't want to do the change themselves giving me an excuse for an occasional half hours wandering about, getting coffee, doing a no-brainer task and having a chat ;-) Still not happy with the principle, and I still forsee problems for people who's code is no longer neatly located in their actual company , but in the case of my personal pratical issues - well, my blood pressures down a bit anyway ;-) From Randy.L.Kemp at MOTOROLA.COM Fri Jul 13 12:00:41 2001 From: Randy.L.Kemp at MOTOROLA.COM (Kemp Randy-W18971) Date: Fri, 13 Jul 2001 11:00:41 -0500 Subject: Book count test Message-ID: While I was waiting for some software to be FTPed from one server to another, I could either count the books or play the movies review clips at www.badmovies.org. -----Original Message----- From: Garry Steedman [mailto:gs at styrax.com] Sent: Friday, July 13, 2001 12:52 PM To: Kemp Randy-W18971 Cc: python-list at python.org Subject: Re: Book count test Randy, are you trying to prove to us that quantity = quality? the fact that python emits less CO2 than java means we dont have to kill the trees! ;-) garry On 13 Jul 2001, at 11:22, Kemp Randy-W18971 wrote: From: Kemp Randy-W18971 To: "'python-list at python.org'" Subject: Book count test Date sent: Fri, 13 Jul 2001 11:22:16 -0400 > I went to www.amazon.com and counted the number of books in these > categories > Python - 136 (including snake books) > Java - 1621 > Perl - 430 > C++ - 1341 > PHP - 38 > ASP - 172 > Oracle - 682 > > > -- > 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 prem at engr.uky.edu Fri Jul 13 18:29:19 2001 From: prem at engr.uky.edu (Prem Rachakonda) Date: Fri, 13 Jul 2001 18:29:19 -0400 Subject: Statistics tool box. Message-ID: Hi, I am trying to convert my matlab scripts into Python. But I see that there are no equivalent stat. tools in Python. If there are any, could you please let me know. I am looking for the functions similar to: normrnd() unifrnd() hist() Thanks, 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 From tom-list at home.com Fri Jul 6 14:18:53 2001 From: tom-list at home.com (Tom) Date: Fri, 06 Jul 2001 18:18:53 GMT Subject: ANN: the C++ Standard Library for Python Message-ID: The core of the C++ Standard Library is now available for Python. This includes 4 sequence containers, 8 mapping containers, and approximately 60 algorithms. The algorithms can be applied to any of these containers, or to any of the Python built-in sequences. This is an actual C++ standard library, exposed to Python, not a Python implementation of it - so it is all native code. It is being release under a standard Python style license. Please note that this is a beta release. http://www.malcolmson.com/pystl I'll watch this thread for comments and feedback (thanks in advance). From chris.gonnerman at newcenturycomputers.net Mon Jul 2 09:06:02 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Mon, 2 Jul 2001 08:06:02 -0500 Subject: Is Python Dead? References: <9hp1f002dp6@enews4.newsguy.com> Message-ID: <001d01c102f7$c3677700$0101010a@local> ----- Original Message ----- From: "Alex Martelli" > "Chris Gonnerman" wrote in message > news:mailman.994049882.30354.python-list at python.org... > ... > > When am I forced? Sadly it seems that integrating any other language > > directly into MS Access is out of the question. (Am I wrong? Someone > > please tell me if I am!) > > Depends what you mean by "directly". With COM and ActiveScripting, > it's generally not a problem to use Python or other AS-compliant languages > with any Office or other Automation-enabled app, albeit with a simple > passage through VBA or VBScript. Define "simple"... what I want is to drop in Python in place of VBA. I'm still not sure it's possible. > > The only other time is when I must work with dBase tables... but I would > > hardly typify that as not being "good database support". > > http://www.stud.ifi.uio.no/~larsga/download/python/ I can't get this URL to work... I am getting Forbidden errors. From vAbazarov at dAnai.com Fri Jul 20 23:29:06 2001 From: vAbazarov at dAnai.com (Victor Bazarov) Date: Sat, 21 Jul 2001 03:29:06 GMT Subject: Unusual minidom behaviour References: Message-ID: <6G667.233321$%i7.131478396@news1.rdc1.sfba.home.com> "Bill Bell" wrote... > > "Victor Bazarov" wrote, in part: > > ... My colleagues called the situation "maybe there's a race > > condition". Could it be minidom has problems multi-tasking? > > I know nothing about 'minidom'. FWIW, it sounds like it might be a > race condition to me too. Is there any way to put it in a thread by > itself, protected by a lock or within a critical section? Probably. I'll try. > (And, forgive > me, does the code use CoInitialize/CoUninitialize?) Not that I know of. > > > I would be grateful for any, no matter how crazy, suggestion. > > As you read my response just remember that you included this > final sentence. :o) > > Good luck! Thanks. I'll need it... Victor -- Please remove capital A's from my address when replying by mail From tundra at tundraware.com Sun Jul 15 15:00:02 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 15 Jul 2001 19:00:02 GMT Subject: re Challenge: More Compact? Message-ID: <3B51E6B1.47E25214@tundraware.com> The following re is (I think) the description of a legitimate IP addess in "quad" format (IPV4). My question is, can it be made even shorter? ipquad = r"^((\d\d?\d?\.){3}(\d\d?\d?))$" -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From weage98 at yahoo.com Fri Jul 13 10:16:44 2001 From: weage98 at yahoo.com (Joshua Weage) Date: 13 Jul 2001 07:16:44 -0700 Subject: Tkinter: Frames in nested classes? Message-ID: <9053f4e3.0107130616.79fd6378@posting.google.com> I'm trying to nest frames inside of other frames, hiding the detatils inside of a class - the purpose is to be able to change a child frame, depending on the options selected in the parent. When I don't use classes the frames nest as expected - but the program wouldn't be as clean. When I attempt to use classes, the frames are packed individually into root. The labels correctly use 'self' as the master, and are placed inside of the frames, but the child frames appear to use 'root' instead of 'self' as the master. Here is a simple example: from Tkinter import * class Frame1(Frame): def __init__(self,master=None,cnf={},**kw): Frame.__init__(self,master=None,cnf={},**kw) Label(self,text="frame1").pack() self.frame = Frame2(self,borderwidth=5,relief="groove") self.frame.pack() class Frame2(Frame): def __init__(self,master=None,cnf={},**kw): Frame.__init__(self,master=None,cnf={},**kw) Label(self,text="frame2").pack() self.frame = Frame3(self,borderwidth=5,relief="groove") self.frame.pack() class Frame3(Frame): def __init__(self,master=None,cnf={},**kw): Frame.__init__(self,master=None,cnf={},**kw) Label(self,text="testing").pack() root = Tk() root.title("Temp testing") root.config(height=200,width=300) frame1 = Frame1(root,borderwidth=5,relief="groove") frame1.pack() root.mainloop() From alankarmisra at hotmail.com Wed Jul 4 17:54:44 2001 From: alankarmisra at hotmail.com (gods1child) Date: 4 Jul 2001 14:54:44 -0700 Subject: pickling and methods Message-ID: <25b2e0d9.0107041354.161f2cd3@posting.google.com> Hi, When an object instance is pickled, is the byte-code associated with the object's methods stored with it? Or does Python pickle only the object type and state information ? for example if i have: class Class: def function(): self.stateinfo = 'mystate' pass # large amount of code here a = Class() b = Class() If i pickled a and b, would they both have the byte-code for the method 'function' or would they only have the class (Class) and the state information (stateinfo)? The reason for asking this is because I have a class which has a large amount of code in its __init__ method. Once the object is created, most of that code is pretty much useless. Many instances of this object will be pickled during program execution. If Python does store the function byte code with each instance of the object, I wanted to consider the space saving i might achieve by moving most of the processing code to a object-factory class instead which would return a light weight class which i can pickle. Even from a good programming perspective, i wanted to know your opinions of moving the __init__ code to a factory method in cases where the processing code is huge and is never used (not even while unpickling) once the object is instantiated. Thanx! From aahz at panix.com Tue Jul 3 00:20:06 2001 From: aahz at panix.com (Aahz Maruch) Date: 2 Jul 2001 21:20:06 -0700 Subject: Python for air traffic control? References: Message-ID: <9hrh5m$mm9$1@panix2.panix.com> In article , Russ <18k11tm001 at sneakemail.com> wrote: > > [...] Please just ignore bozos like William Park. This is a public newsgroup, so we can't keep him out, but ignoring him makes this a much more pleasant environment. -- --- 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'm not tense, i'm just terribly, terribly alert" --unknown From jim at publishingresources.com Fri Jul 20 18:23:55 2001 From: jim at publishingresources.com (Jim Abrams) Date: Fri, 20 Jul 2001 22:23:55 -0000 Subject: Problem with win32, ActivePython2.1, ASP Message-ID: Help? PythonWin 2.1 (#15, Apr 19 2001, 10:28:27) [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 win32com.client >>> pptc = win32com.client.Dispatch("Powerpoint.Application") >>> ppt = pptc.Presentations.Add(WithWindow=0) >>> slide = ppt.Slides.Add(1, 12) >>> shapes = slide.Shapes >>> shapes.AddOLEObject(ClassName=u'ShockwaveFlash.ShockwaveFlash.1') >>> pptc >>> ppt >>> slide >>> shapes >>> shapes.AddOLEObject >>> All is cool. But, try this same thing inside an ASP page... <%@LANGUAGE="Python"%> <% def w(o): Response.Write(Server.HTMLencode(repr(o)) + "
") import win32com.client pptc = win32com.client.Dispatch("Powerpoint.Application") w(pptc) ppt = pptc.Presentations.Add(WithWindow=0) w(ppt) slide = ppt.Slides.Add(1, 12) w(slide) shapes = slide.Shapes w(shapes) w(shapes.AddOLEObject) shapes.AddOLEObject(ClassName=u'ShockwaveFlash.ShockwaveFlash.1') w(shape) %> gets me: Python ActiveX Scripting Engine error '80020009' Traceback (innermost last): File "